Trying to gather data from a sound file without listening to it, but I’m having trouble getting there. I thought I might be able to do it by playing the file in draw(), gathering the FFT spectrum data, then pausing at the end.
I tried the reverse order first to make sure the sound is working properly, but the results were strange. I thought that draw() would only render the final state of the file, so if I put play last, it would just play it, but it seems every draw() frame it pauses and plays, chopping up and slowing down the sample in half. Below is an example of the code I’m using with sin440.wav as a stand-in for whatever sound file you want to use.
Could you elaborate on how I might solve this problem with the use of mapping input/output devices?
With regards to FFT.input, it seems like it only analyzes when .play() is active. Is that a correct observation? That’s what I’ve tried to work with in the sound library. Play the sound, get the FFT spectrum, Pause, next draw frame, repeat. However, all combinations and methods I tried with that library so far have either resulted in Play being called again and again, overloading the soundcard, or a stuttery/clicky pause-play-pause-play, etc. that halves the speed of the source. Can’t get one draw frame to Play and Pause smoothly in one go.
My guess right now is that .play() executes at the end of a draw frame no matter where it’s placed in the code. Also that each draw frame creates its own instance of .play/pause/stop() and the next instance can’t interact with the previous. Do you know if I got any of that right? haha.
and you do that 60 times per second!
what you will get?
divorce
actually what you try to do should not involve SOUND stream at all,
what you need would be to read the data from file
( and that i do not know how to do from today sound files )
in 512 array batches and run your own FFT on that array.
and on keyPressed read the next 512 lines.
Haha, nice. Yeah, if I knew how to just read it from the file I would, unfortunately I’m an amateur who struggles with things I assume pros could do in a couple seconds.
For now my solution was just to lower the amp to an inaudible amount and just use the map function when I need to use the data.
I honestly don’t know – it might be possible, which is why I suggested it as a starting point, but I can only recall seeing minim actually used for this, which is why I recommended that instead.