Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to the documentation, <code>SIZE</code> looks like it should be the number of samples in <code>signal</code>. If it's truly a 1 s signal at 44.1 kHz, then you should use <code>SIZE = 44100</code>. Since you're using complex data, <code>signal</code> should be an array twice this size (real/imaginary in sequence). </p> <p>If you don't use <code>SIZE = 44100</code>, your results will not match what Matlab gives you. This is because of the way Matlab (and probably JTransforms) scales the <code>fft</code> and <code>ifft</code> functions based on the length of the input - don't worry that the amplitudes don't match. By default, Matlab calculates the FFT using the full signal. You can provide a second argument to <code>fft</code> (in Matlab) to calculate the N-point FFT and it should match your JTransforms result.</p> <hr> <p>From your comments, it sounds like you're trying to create a <a href="http://en.wikipedia.org/wiki/Spectrogram" rel="nofollow noreferrer">spectrogram</a>. For this, you will have to figure out your tradeoff between: spectral resolution, temporal resolution, and computation time. Here is my (Matlab) code for a 1-second spectrogram, calculated for each 512-sample chunk of a 1s signal.</p> <pre><code>fs = 44100; % Hz w = 1; % s t = linspace(0, w, w*fs); k = linspace(-fs/2, fs/2, w*fs); % simulate the signal - time-dependent frequency f = 10000*t; % Hz x = cos(2*pi*f.*t); m = 512; % SIZE S = zeros(m, floor(w*fs/m)); for i = 0:(w*fs/m)-1 s = x((i*m+1):((i+1)*m)); S(:,i+1) = fftshift(fft(s)); end </code></pre> <p><img src="https://i.stack.imgur.com/eJzIC.png" alt="Spectrogram created with 512-sample chunks"><br> For this image we have 512 samples along the frequency axis (y-axis), ranging from [-22050 Hz 22050 Hz]. There are 86 samples along the time axis (x-axis) covering about 1 second. <img src="https://i.stack.imgur.com/EX8lZ.png" alt="Spectrogram created with 4096-sample chunks"><br> For this image we now have 4096 samples along the frequency axis (y-axis), ranging from [-22050 Hz 22050 Hz]. The time axis (x-axis) again covers about 1 second, but this time with only 10 chunks.</p> <p>Whether it's more important to have fast time resolution (512-sample chunks) or high spectral resolution (4096-sample chunks) will depend on what kind of signal you're working with. You have to make a decision about what you want in terms of temporal/spectral resolution, and what you can achieve in reasonable computation time. If you use <code>SIZE = 4096</code>, for example, you will be able to calculate the spectrum ~10x/s (based on your sampling rate) but the FFT may not be fast enough to keep up. If you use <code>SIZE = 512</code> you will have poorer spectral resolution, but the FFT will calculate much faster and you can calculate the spectrun ~86x/s. If the FFT is still not fast enough, you could then start skipping chunks (e.g. use <code>SIZE=512</code> but only calculate for every other chunk, giving ~43 spectrums per 1s signal). Hopefully this makes sense.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload