Timeline for Computing and plotting a spectrogram in Mathematica
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 16, 2020 at 9:23 | history | edited | CommunityBot |
Commonmark migration
|
|
Mar 11, 2016 at 17:37 | comment | added | rm -rf♦ | @TylerDurden This is not a library to support every codec on earth. I was using example data which has a specific format. | |
Mar 11, 2016 at 17:17 | comment | added | Tyler Durden | How do you know things like "sndSampleRate = snd[[1, 2]];"? WAV have 10 different possible codecs, all with different conventions. How do you figure out imaginary components? | |
Apr 8, 2012 at 17:41 | comment | added | rm -rf♦ |
@Sjoerd Aha! I now get what you're saying. The frequencies in my output f are correct (2nd bin is about 21.5ish), but since I set the range from Min[f] to Max[f] , it stretches the labeling from the left end of the first bin (if you consider it a rectangle) to the right end of the last bin instead of the left end of the last bin. So while I don't think that starting from 20 (or whatever it is) will fix this (it'll have the same subtle misalignment), I agree that it needs to be fixed. I hadn't gotten around to implementing a custom plot of my own and just quickly used yours :)
|
|
Apr 8, 2012 at 16:26 | comment | added | Sjoerd C. de Vries | I'm not talking about bin centres. If you're examining your sound data in pieces of 1000 samples at a time and with a sample rate of 20 kHz the lowest representable frequency will be 20 Hz. That's what should be the lowest part of the plot (or the second lowest in your case). If you let it start at 0 every step in your spectrogram will be slightly mislabeled. | |
Apr 8, 2012 at 16:10 | comment | added | rm -rf♦ | @Sjoerd That's a labeling convention — depends on whether you choose to place the tick mark at the bin center or at the ends. Bin center is also very common and in that case, it would start at half the bin width. I'm aware that Fourier doesn't need a list that's a power of 2, but you'd be hard pressed to find a signal processing application/paper that doesn't use a power of 2 — probably relics from the past, but is convention. Perhaps I could add another option that uses the actual length instead of padding. | |
Apr 8, 2012 at 16:04 | comment | added | Sjoerd C. de Vries |
BTW there's no need to provide Fourier with a data list whose length is a power of 2. DFT implementations are usually faster when this is the case (I haven't tested this on MMA), but speed doesn't seem to be an issue here.
|
|
Apr 8, 2012 at 15:51 | comment | added | Sjoerd C. de Vries | This is not about the first bin per se. It's about making your data range fit correctly. If your window length is short the lowest assignable frequency is not negligible and the frequency values for all the bins except the last one experience a shift wrt the values you assign them. The second bin the most of course. | |
Apr 8, 2012 at 15:01 | comment | added | rm -rf♦ | @SjoerdC.deVries The first DFT bin (and the frequencies it spans) contributes to the "mean". You chose to discard it, I didn't. AFAIK it's not customary to throw it out when plotting. | |
Apr 8, 2012 at 6:52 | comment | added | Sjoerd C. de Vries | You have the frequency start at 0 Hz, but that can't be true. The lowest frequency is determined by the length of your window. | |
Apr 7, 2012 at 22:33 | history | answered | rm -rf♦ | CC BY-SA 3.0 |