-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
something not quite right... #82
Comments
(1) You may want to look at changing the settings on NOTE_FINAL_AMP as this will likely have the impact you want. (2a) I believe the embedded system wants smaller values for the ADC in... I recommend looking at https://github.com/cnlohr/colorchord/blob/master/embedded8266/user/user_main.c#L100 what does your entry look like? (2/3) Hmm... I don't know if I ever tested any other sizes for the # of fixbins, there may be some other constant hidden somewhere awful. (4) Would you mind posting the output of your embeddedbins32? |
(1) don't really get where the 12 comes from... #define NOTE_FINAL_AMP 12 //Number from 0...255 (2a) to be clear I am using an ESP32 but I have used snippets of your code in my Arduino project... my feeding of the samples is more like colorchord/embeddedstm32f303/main.c Line 83 in 8e628ab
I looked at the embeddedstm32f303 it looked simpler to follow without all the tasks :-) The example you sent shows the sounddata[] as unsigned 8 bits, in my example I used it was signed 16 bits and the function prototype used was void PushSample32( int16_t dat ); (2/3) was thinking it might be a rollover issue somewhere when a uint8 was used and now needs to be uint16 due to the extra octaves.... that said, I watched a youtube video of your friend playing on the keyboard and my leds would not react at all to the video.... (ColorChord 2: Fugue In D Minor) weird, played lots of music tracks and got some action, but zero with that keyboard (4) I will post this when I have access to the hardware again |
also, why does this call HandleInt twice with same data??? void PushSample32(int16_t dat) { |
(2a) what filter is that just before the PushSample32() my system has a high pass at 50Hz, removed it at one point to see if I could see a difference and there was none.... |
re: calling twice, IIRC, this was because the way the algorithm works it updates the top? octave every frame, and all the other octaves 1/2^their octave down frames. I believe it just offers slightly better stability. I believe 2A is the filter which removes the DC offset. I don't know if it's actually needed with the current algorithm, but I think it is. |
I have no DC offset on my data stream from microphone, I had already been doing lots of FFT and DFT stuff with the stream so I am very aware of how its working, and there is no issue with that part I know. Will keep at it here, I had done plenty of troubleshooting before I posted... to better understand and discuss the problem more intelligently :-) |
If you don't have a significant DC offset, it shouldn't be an issue, so you can feel free to remove it! |
I played notes using a tone generator from A0 to A7, while the software was running it would output to the screen the contents of embeddedbins32[] which is the DFT bins for each frequency that corresponds to a note. This was done in the UpdateOutputBins32() function. The tones played were pure tone, so I expect to see peaks at certain locations in the array that correspond to the note played. I show also the location the peak was found for each note. I expected: Again setup for 7 octaves starting at A0 (27.5hz), after the note is the position of the max value, I am playing pure tones. HOWEVER the correct colors are shown... just stop being displayed around C5 A0 75th A1 67th A2 91th A3 124th A4 145th A5 167th A6 ?? A7 ?? |
OK set it up for 3 octaves... very interesting after A2,A3,A4 look good.... thats 3, but the first 2 are wacked! A0 0 A1 0 A2 0 A3 24 A4 48 A5 72 |
also just tried to decrease the amplitude of the input (went from 13bit to 8 bit) got basically the same results with just smaller #'s in the array and the LEDS did not light as the #'s being small are not very bright... but the position where the notes appear on the array stayed constant. |
I'm sorry I don't understand exactly what the arrays are showing under what conditions, do you mind going back and editing the post to include additional information? |
Sorry, I editted #82 (comment) |
Hmm... So, first I encourage you to use the embeddedlinux tool and feed the data in procedurally... But I don't agree with your analysis of the data. Something may be wrong with the first one at higher frequencies but you seem to be exceeding the ranges frequency-wise. Though I do agree something is broken with the first data set. And am not exactly sure how this could happen, I wonder if the frequency selection for the bins is somehow damaged? Can you tell me the settings of the following preprocessor values? Also - for background - lower frequencies generally are rougher, or lumpier because the response time with them is artificially high compared to higher frequencies, so it is difficult to get a really good picture. This is expected behavior and generally does not have an adverse impact on the overall quality of the visualization. |
Understood about the low frequencies.... UpdateBinsForProgressiveIntegerSkippyInt() is not used and does not exists, it only uses UpdateBins32(); and fbins is precomputed (constant) values: |
Hey! So... I rewrote all the DFT functions and went away from the progressive method and went for the brute force, calculate all the bins at once approach.... now it all works 100%, it takes approx. 25% ESP32 CPU to run the effect. I was getting about the same with the non-working implementation also. My DFT function returns real numbers, I assumed the embeddedbins32[] array with its 2 entries was for real and complex.... so I filled in real and set the complex entry to zero. If this is somehow wrong, it still works :-) My DFT function looks like, and uses a table to select the frequency coefficient of each note. float DFT(int16_t *samples, int nSamples, int n) { while (nSamples--) { return Q2 * Q2 + Q1 * Q1 - coeff * Q1 * Q2; |
Hmm... Would you consider doing a PR for me so this could be an option for others, also I would really appreciate to see the code. I still find this quite perplexing, but, that is kind of ... insane ... that the ESP32 can handle the brute force approach. |
I will clean up my code and make it available. I have done even more complex things with the ESP32 and it always shines through, I have a 64x32 RGB panel (HUB75) pumping out 18 bit color at 100Hz while doing 64 channels of DFT for spectrum also at 100Hz and also maintaining about 5 layers of animation that are all updated in realtime. AND the kicker... all with floats! and it also has about 3 digital audio filters running on the 16Khz audio also done with floats, and an AGC :-) all this runs around 35% CPU |
Well... i found one of my routines was being redundantly called and only needed to be called 10X less... we are now at 4% CPU :-) and that's still using float DFT... I could half this with 32 bit ints... but its not worth it... so it will stay floats! |
Then I strongly would love it if we could add an ESP32 thing to ColorChord! |
I will work on the cleanup soon, and document the source code. The only question I have now is the assumption I made on the embeddedbins32[] being in the format of: embeddedbins32[0] = DFT0 real Is this correct? If not can you describe this data structure and why it has 2 entries per DFT bin? EDIT: int32_t * ipt = &Sdatspace32BOut[0]; So I think now embeddedbins32[] holds either one octave of 1/2 notes, or 2 octaves of notes.... Let me know. |
Sdatspace32BOut is the sin/cosine thing. You can see it here: https://github.com/cnlohr/colorchord/blob/master/embeddedcommon/DFT32.c#L212 Sdatspace32BOut should be 2*notes
Embeddedbins32 is the combined data, the scalar portion. Should be a vector of # of notes.
|
@themindfactory , it would be really handy if you could share your code. Don't worry if you haven't cleaned it up or added comments. Thank you |
Any code to share, @themindfactory ? |
I downloaded the code and added parts of it to an Arduino build (ESP32) I have done with a digital I2S microphone. The microphone interface is stable and giving the correct values.
What I notice is:
the brightness of the LEDS are only going to around 70 out of 255 when it calls the HSV(h,s,v) routines, so v is never larger than around 70
I configured it to do 7 octaves from 27.5Hz so that should get me to about 3300hz, however when using a tone generator it only gets to around 500hz and then no LEDS display no matter the volume.
I am running at 16000Hz sample rate, I make sure it feeds the "ADC" -4095 to +4095
I do get proper colors out at the correct notes for the first 3-4 octaves, So assume that I have correctly set up sample frequency.
When I take a look at the embeddedbins32[] array I expect if I play a 3200hz (upper end of the 7 octaves its set for) then the last few entries in the array should be larger than the rest.. they are not, I get to around 700Hz when this happens. FIXEDBINS is at 168 which makes sense also as this is 7 octaves * 12 notes/octave * 2 ... so I am a little stumped.
The text was updated successfully, but these errors were encountered: