Start/Stop FFT between copying... #776
-
Ref: #755 I noticed this is very close to what I'm trying to do. I'm attempting to FFT audio from a bee hive to detect swarming. But each grouping of audio requires a new window. In other words, I don't need to continuously stream the audio, but periodically sample the audio every x-minutes apart. As I understand it, in my loop (pseudo code) I simply need to do: This safely works? Should I worry of heap fragmentation? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes that should work! Fragmentation might only be an issue if you allocate/deallocate memory by some other processes after stopping and the system can't allocate the same memory again. However I would also expect that it might just be good enough to stop and start calling copy() maybe by using a flag. Also note that one copy() is not good enough! You will need to call copy() for some short period, until you get a stable result. I guess 5 to 15 seconds might be reasonable. |
Beta Was this translation helpful? Give feedback.
-
Just FYI, doing this does ultimately result in an assert failure and stack dump. It appears to trigger when there is buffer remainders. I do not believe this a viable approach. I did not spend time to investigate further. I simply reverted to the old logic, which keeps potential stale data within the window. I may investigate further in the future. Regardless, wanted to make a note for others who may attempt this. |
Beta Was this translation helpful? Give feedback.
Yes that should work!
Fragmentation might only be an issue if you allocate/deallocate memory by some other processes after stopping and the system can't allocate the same memory again.
However I would also expect that it might just be good enough to stop and start calling copy() maybe by using a flag.
Also note that one copy() is not good enough! You will need to call copy() for some short period, until you get a stable result. I guess 5 to 15 seconds might be reasonable.