Audio synthesis problem in the fft tutorial

i try to do this tutorial to learn fft:

problem is my laptop’s mic doesn’t work so i created a little oscillator that is supposed to create frequencies for me to test the fft stuff on:

this is how i modified the code from the init fft-turorial to play my oscillator:

as you can see i created that label which is supposed to display the current freq- and wave-values of the oscillator that i want to feed to the fft later. the lfo-osc is meant to make the normal osc’s freq walk up and down between 0 and 420 slowly, so i have something to play with.

however when i run this programm it only shows some values moving (that look correct as far as i can tell btw) in the beginning (for some secounds) but then just stops, as if the programm decided that there is no new audio buffer to process from now on. what could be the problem?

As far as I can see, nothing in your code calls your paint() method. (No repaint() call for example in the timer callback.) You probably just got lucky and the operating system made a few repaints anyway for a little while. You shouldn’t really do stuff like set the texts of labels in the paint(), though. (Actually, the repaints could be the result of that. That could lead the message queue of the system to fill up and after some time it just stops.)

1 Like

thanks! that fixed the problem. so… what’s the best place to add a text that has information of the audio data into a label?

The timer callback would be the appropriate place to update your label texts. (And also make the repaint() call so that your custom drawing code also gets executed.) The setBounds call on the label is also in the wrong place, don’t do it inside paint(). You can override the resized() method of Component to do stuff like that.

i didn’t start with the actual tutorial yet since it would be kinda pointless without audio to test it on. that’s why the code there is still empty :slight_smile: wow thanks btw. i was asking myself all the time already how to share information from the audio “place” with the gui one… sorta. now i know the place and it’s actually easy. cool!