|
Author |
Topic: Sonia LiveInput Event? (Read 413 times) |
|
skloopy
|
Sonia LiveInput Event?
« on: Apr 27th, 2004, 10:14pm » |
|
Hi this is a Q for Amit or anybody who's used sonia a lot.. I'm trying to build a sketch around LiveInput connected from an AIFF file, and i'm havin trouble with the differences in framerates. If I do some stuff with the FFT data at 60fps it's totally different than with 30fps, which is normal because it's sampling less frequently. But is there some sort of LiveInputEvent() that can be called every time a new piece of the audio data is grabbed from the source, say like every 1024 frames? That way the audio could update seperately from the visuals which would be at a slower framerate.. I'm trying to do this with a custom Thread right now, but it's getting very complicated for something that simple, and also it'll never line up with the audio coming in exactly.. Is there a method like that or would it be easy to make one? ryan
|
« Last Edit: Apr 27th, 2004, 10:15pm by skloopy » |
|
|
|
|
pitaru
|
Re: Sonia LiveInput Event?
« Reply #1 on: May 5th, 2004, 12:48am » |
|
hey ryan, you can use the undocumented command: mySample.getSpectrum(int fftNum, int startFrameNum); this function enables you to analize any sample without the liveInput(), in non realtime. The sample returns a float array, with the same length you specify in the fftNum parameter. Parameters: int fftNum -- number of FFT frequencies you'd like to get from the analysis. for example - 128, 256, 512 etc. int startFrameNum -- the location in the sample that you'd like to analize. For example use 11000 to analize the 11000th frame of the sample. If the sample's rate is 22000kHz, you will be analizing the sample at half a second into its playtime. for example: float[] fftData[512]; fftData = mySample.getSpectrum(512, mySample.getCurrentFrame()); hmm.. i hope i got it right, let me know, and remember this is still an untested feature. -amit Update -- important note-- one of the reasons i did not release this yet is the following problem: if the sample has 1000 frames, than mySample.getSpectrum(512, 500); will return an error as it will try to analize frames 500 to 1012 (or maybe 1512 - i need to check!). In other words, you will be atempting to analize sample data that does not exist. So use with caution. i'll make this function more friendly soon!
|
« Last Edit: May 5th, 2004, 1:00am by pitaru » |
|
|
|
|
skloopy
|
Re: Sonia LiveInput Event?
« Reply #2 on: May 6th, 2004, 10:04pm » |
|
Thanks Amit! Okay I think that'll help. The synching is still a problem, though, because I'm anylizing the audio in real-time, so the audio is happening at a constant rate, but the visuals could be updated at any time, depending on the actual framerate. When Sonia plays a sound, i'm guessing the actual playing is happening inside JSyn so you don't have access to the thread that's feeding the audio chunks to the line out.. Hmm I could have that all wrong because I'm really new to audio Okay thanks for the useful command. I'm gonna keep trying things and see if I can get it to work.
|
|
|
|
|