Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

Desktop Recorder

Reply
 
LinkBack Thread Tools Display Modes
  #41 (permalink)  
Old 03-16-2010, 11:58 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Quote:
EDIT : - ToRealAmplitude is not a good name because of "Real." I thought I might call it ToAmplitudes, note the plural, but is that too close to the existing ToAmplitude method name? I will also add the complementary ToPhases method.
Perhaps:
ToAmplitudePhase
ToAmplitude
ToPhase

Best regads.
__________________
Klaus
Switzerland
Reply With Quote
  #42 (permalink)  
Old 03-16-2010, 12:03 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by klaus View Post
- send, in the data() array to the FFT object, only the real values- the imaginary 0 samples are generated inernally in the FFT dll
That would waste some time. After you DIM an array .NET fills it with zeros so on a new array it is only necessary to fill in the Real values.
Quote:
- get back only the first half of the real and imaginary samples, only the useful ones
I've already suggested that in the post above but I need a better name or to rename some existing methods, any suggestions?
Quote:
or eventually use a 'FFT algorithm specialized for real and/or symmetric data' with the same inputs and outputs.
I'll leave that to someone who is more confident with the maths than I am.
Quote:
I will make some improvements.
I'll wait till you have done that
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #43 (permalink)  
Old 03-16-2010, 12:12 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by klaus View Post
Perhaps:
ToAmplitudePhase
ToAmplitude
ToPhase
I've already got ToAmplitude and ToPhase. How about GetAmplitute and GetPhase or shall I do a complete rename of the existing methods? What did you intend ToAmplitudePhase to do?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #44 (permalink)  
Old 03-16-2010, 12:45 PM
Junior Member
 
Join Date: Jan 2009
Posts: 23
Default

Allow me to summarize what I understood from these detailled posts, related to my example:

Filling the array only with 4096 real bytes from my sound sample will work mathematically, giving 100% correct results, but could take more time. Is that correct to assume ?

I understand the .NET mechanism that fills an array at declaration time with zeros, and see the benefits. I also understand now how the fft library is able to handle an input with only real values anyway, as it seems to generate the zero (imag) values itself internally.

BTW, I tried both methods, and besides the probable speed difference, the results looked good every time.

In my real life app, I only look for frequencies between 33 and 166 Hertz, being 1000 to 5000 RPM "headspeed" for a 2 bladed R/C helicopter. Simply 33*60/2 and 166*60/2. And until now, in this small, lower part of the spektrum, i only encountered this 1 frequency, together with 1 harmonic with exactly half the frequency, but less than half in amplitude. So my code can easily make the difference between those two, leaving no room for error.
I visualised this by means of a graph indeed, to be able to control this.
The user is of course responsible of making a recording with no other sound sources present. All the other frequencies generated by a R/C heli are much higher, being the 2-3 times faster turning tail blades, or the even higher RPMs of the electric motor, and all harmonics I found until now.

Last edited by redbird : 03-16-2010 at 12:48 PM.
Reply With Quote
  #45 (permalink)  
Old 03-16-2010, 02:18 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Andrew,

I'm coming back on my suggestion 1) transfering in the Fft.Transform function only the real data.

I had a look at your library with SharpDevelop and saw that the real and imag samples could relatively easy be treated separately.
- real data in the input, half the length than before
- so, n = data.length and no more n = data.length/2
- generate an internal array for the imag data samples
- everywhere you have data(i) or data(j) is the real input data array realdata(i)
- everywhere you have data(i+1) or data(j+1) is the internal imag data array imagdata(i)
- for the return copy the first half of the imag samples into the second half of the data array.

Just to illustrate
Code:
<font size="2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font></font></font></font><font size="2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j </font><font size="2"><font color="#006400"><font size="2"><font color="#006400">+ </font></font></font></font><font size="2"><font color="#00008b"><font size="2"><font color="#00008b">1</font></font></font></font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font></font></font></font><font size="2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i </font><font size="2"><font color="#006400"><font size="2"><font color="#006400">+ </font></font></font></font><font size="2"><font color="#00008b"><font size="2"><font color="#00008b">1</font></font></font></font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i </font><font size="2"><font color="#006400"><font size="2"><font color="#006400">+ </font></font></font></font><font size="2"><font color="#00008b"><font size="2"><font color="#00008b">1</font></font></font></font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font></font></font>
would become
Code:
real<font size="2">data</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font><font color="black">real</font></font></font></font><font size="2"><font color="black">da</font>ta</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imagdata</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font><font color="black">imag</font></font></font></font><font size="2"><font color="black">d</font>ata</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">realdata</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imagdata</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font></font></font>
Could you please have a look at this.

If this is could be done, then we do no more need two methods for Amplitude and Phase.

With ToAmplitudePhase I was thinking of a single method for getting both arrays, but two seperate functions are OK for me.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #46 (permalink)  
Old 03-16-2010, 02:34 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

It's not quite that simple as the loop arithmetic needs altering together with some other indexing stuff but I'll have a think about restructuring the library as it has grown a bit like Topsy.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #47 (permalink)  
Old 03-16-2010, 03:05 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Try this, it's probably buggy as I haven't played with it. To keep things simple and retain the full inverse transform capability I didn't generate imaginary internal values. Dimming a new array initialised to zeroes is just as cheap in Basic4pc code as in C#.

void Transform(double[] real, double[]imag)

void Inverse(double[] real, double[] imag)

double[] CopyArray(double[] array)

double[] ToAmplitude(double[] real, double[] imag, double scale)

double[] ToPhase(double[] real, double[] imag)

ToAmpAndPhase(double[] real, double[] imag, double scale) ' half and half

double[] ToReal(double[] amplitude, double[] phase, double scale)

double[] ToImaginary(double[] amplitude, double[] phase, double scale)


EDIT :- It doesn't work. I don't understand the indexing (k) in the bitreverse method so can't get it right for separate Real and Image arrays and theres a similar problem (b) in the actual transform. I'm going back to the original algorithm but will make it accept and return separate arrays.
Attached Files
File Type: zip FFT1.2.zip (4.5 KB, 5 views)
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.

Last edited by agraham : 03-16-2010 at 05:42 PM.
Reply With Quote
  #48 (permalink)  
Old 03-16-2010, 06:47 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I'm beginning to wish I hadn't started this separate array stuff Try this version with the same methods listed above.
Attached Files
File Type: zip FFT1.3.zip (4.8 KB, 7 views)
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #49 (permalink)  
Old 03-16-2010, 06:51 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Andrew,

I just cam back home, and looked at the library.
What version is FFTV1.2 ?
The one before your edit ?

I had a look at the FFT.cs file and found that in lines 65-68
Code:
<font size="2">real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font></font></font></font><font size="2">real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font></font></font></font><font size="2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font></font></font>
should be
Code:
<font size="2">real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font></font></font></font><font size="2">real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">j</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] = </font></font></font></font><font size="2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] - </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2"><font color="red">real</font></font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_real</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font>
</font></font><font size=
"2">imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">[</font></font></font></font><font size="2">i</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">] += </font></font></font></font><font size="2">wd_imag</font><font size="2"><font color="#006400"><font size="2"><font color="#006400">;</font></font></font></font>
This evening I won't be at home.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #50 (permalink)  
Old 03-16-2010, 06:59 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by klaus View Post
What version is FFTV1.2 ?
V1.1 takes a single data() array
V1.2 attempted modified algorithm to take real() and imag() arrays - FAILURE for at least two reasons.
V1.3 original alogorithm wrapped to look like V1.2
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
player-recorder derez Share Your Creations 5 11-23-2009 08:59 PM
Recorder That Emails the File craigisaacs Open Source Projects 9 07-15-2009 07:22 PM
Question about Desktop Recorder for Erel Pachuquin Questions (Windows Mobile) 3 07-10-2009 08:37 AM
Recorder Erel Additional Libraries 11 12-23-2008 05:36 PM
Calendar Recorder Rioven Share Your Creations 5 10-21-2007 07:55 AM


All times are GMT. The time now is 01:18 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0