We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › minim non-realtime buffer access
Page Index Toggle Pages: 1
minim non-realtime buffer access (Read 1221 times)
minim non-realtime buffer access
Oct 31st, 2007, 4:17pm
 
My situation is kind of strange. I'm using the processing libraries and minim on Linux via JRuby. It works great, although I'm sure it's not as fast as native.

I'm using this as kind of a movie renderer, outputting huge frames as PNG and then encoding them all as a movie later. Like this thread: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Sound;action=display;num=1174169711

So, I want to loadFile and then instead of playing it, I want to manually advance it a certain number of milliseconds per frame. This is possible with the ESS FFT by doing

   fft.getSpectrum(channel.samples(), x);

where x is the offset. However, ESS dies on one of the machines I'm using.

Minim runs great in realtime if I just .play the audio and pass the AudioPlayer.mix to the FFT (except I'm overloading my CPU with all the crap I'm drawing.)

But, I can't figure out how to request a certain part of the buffer for this "rendering" mode. AudioPlayer.cue doesn't seem to do what I want; do I need to implement AudioListener and take in all the data like a firehose, and THEN run it through FFT selectively?

I'm a bit lost when it comes to this stuff - my apologies if this is somewhere obvious in the javadocs for Minim, but I'm just not seeing it.
Re: minim non-realtime buffer access
Reply #1 - Nov 16th, 2007, 2:06am
 
Ah, yes, I see what you mean. When you play an audio file the reading of the data from the file and subsequent sending of that data to the audio system is done in its own Thread. The handing of samples to the user is just a courtesy, if you like. What you really want is to be able to control the read speed and not even send it out to the system, right? I don't give access to the AudioInputStream that is being used to read from the file, so it's not currently possible to do exactly what you want. However, as you suggest, you could write an AudioListener that buffers audio as it receives it and then lets you bite off chunks at your pace. The problem is that you will probably wind up buffering a whole lot of audio due to the fact that you'll be asking for samples a lot more slowly than you are receiving them. You might run out memory. Worth a try, though.
Re: minim non-realtime buffer access
Reply #2 - Nov 24th, 2007, 6:33am
 
wow, you're doing exactly what I'm doing (using processing as a cool effect maker w/ large frames and such, I"m doing music videos)

and... I think I might be missing the question because my answer's too easy, but why not just make a second program that plays the audio, and every frame takes the fft's and writes them to a file, and then you can use the scanner class in the memory intensive program to read the ffts without playing the audio... just make each line in the data file a new frame

once again, just my input. (I use spectrum laboratory to export my fft's to a .txt file and then use them in processing though, haven't played with ESS much... speclab is giving me not so good stuff these days though, might try it out)
Re: minim non-realtime buffer access
Reply #3 - Dec 3rd, 2007, 12:47am
 
^ Proof of above method:

http://youtube.com/watch?v=YsSFdoFHGJg

: just make a linkedList of float[] 's and serialize that to some file, and then make a class that implements some of FFT class' method and replace all instances of FFT class in your code with it. "Foward(song.mix)" will just advance the listiterator.
Re: minim non-realtime buffer access
Reply #4 - Dec 3rd, 2007, 4:21am
 
sweet.
Re: minim non-realtime buffer access
Reply #5 - Dec 3rd, 2007, 2:50pm
 
taifunbrowser wrote on Dec 3rd, 2007, 12:47am:
^ Proof of above method:

http://youtube.com/watch?v=YsSFdoFHGJg

: just make a linkedList of float[] 's and serialize that to some file, and then make a class that implements some of FFT class' method and replace all instances of FFT class in your code with it. "Foward(song.mix)" will just advance the listiterator.

Dang.
That's very neat !

How did you get it to react that great to the music playing
That's one of the obstacles I'm currently struggling with.
Did you do some sort of timing to the music manually
Page Index Toggle Pages: 1