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.
IndexProcessing DevelopmentLibraries,  Tool Development › Minim: new audio library for processing
Pages: 1 2 
Minim: new audio library for processing (Read 37220 times)
Minim: new audio library for processing
Mar 28th, 2007, 12:17am
 
After two full days of getting the documentation in order, I've just released the first version of my audio library for Processing.

It's called Minim.

It's built on JavaSound, so it doesn't require any extra plug-ins, it's released under the GPL, so the source is included with the full distribution, but probably what people will be the most excited about:

Support for stereo playback (including mp3), monitoring and recording.

Feedback is welcome and greatly appreciated!
Re: Minim: new audio library for processing
Reply #1 - Jun 4th, 2007, 4:06am
 
I've just released a new version of Minim. It fixes several problem with mp3 playback and also has many more examples of how to use it.

Re: Minim: new audio library for processing
Reply #2 - Jun 9th, 2007, 9:12pm
 
ddf, this is very very very cool... and i have to congratulate you on great documentation -- impressively thorough but straightforward.

(for those who haven't checked it out, i would love it if all libraries had introductions like this one:
http://code.compartmental.net/tools/minim/manual-introduction/ Smiley

so far so good with the library, thank you!

by the way, i don't know the technical differences of using jsyn (like sonia)  vs. javasound. would you care to elaborate? is one or other of them more processor intensive? or faster?

something i haven't quite understood is the exact difference between an audioFile, audioSample and an audioSnippet (formerly audioClip). is a clip less processor intensive just because it's not filling up an audioBuffer? are there any other performance trade-offs?

thanks for what is sure to be a very useful library....
Re: Minim: new audio library for processing
Reply #3 - Jun 9th, 2007, 9:42pm
 
I can answer one of those questions, JSyn is a plugin for java, JavaSound is a built in. You can write programs that use JavaSound stuff, and they'll work on anybody's computer (assuming they have a non-ancient version of Java).

With JSyn no one can use the program until they install the plugin, unfortunately there's no nice "oh, this needs JSyn" box that pops up or anything, people have to know in advance.
Re: Minim: new audio library for processing
Reply #4 - Jun 9th, 2007, 11:19pm
 
thanks for the reply; i guess that's why i had my question -- is there any particular advantage to using something based on jsyn rather than javasound, is there any trade-off in using javasound (in terms of performance, i.e. apart from the fact that one needs a plug-in when using jsyn)?
Re: Minim: new audio library for processing
Reply #5 - Jun 10th, 2007, 2:17pm
 
jsyn is far better in terms of performance (i.e. lower latency), and the implementation of javasound across platforms and versions of java is inconsistent.
Re: Minim: new audio library for processing
Reply #6 - Jun 11th, 2007, 5:28pm
 
ch wrote on Jun 9th, 2007, 9:12pm:
something i haven't quite understood is the exact difference between an audioFile, audioSample and an audioSnippet (formerly audioClip). is a clip less processor intensive just because it's not filling up an audioBuffer are there any other performance trade-offs


AudioPlayer (which used to be AudioFile) is used to play audio in a CD player kind of way. You can play, pause, skip forward and backward, set loop amounts and so forth. It gives you access to the samples so you draw waveforms and do FFT analysis on it. It "streams" the audio from the file as it reads it, I can't give many details about that because it is handled by classes that I did not write. I just have an AudioInputStream and I read a buffer of samples from it at a time. Although, I do know that for mp3 files the way it works is that the stream reads about 2k bytes from the file at a time, decoding in chunks like that.

AudioSample reads the entire file into an sample buffer when you create it. This means that there is no file streaming going on when you trigger() the sample. It is just building a buffer of samples for output based on how many triggers there are and where in the file each trigger is. This means you won't want to load a 2 minute song into an AudioSample because it will take up a lot of memory.

An AudioSnippet just wraps a JavaSound Clip, so there is no access to samples and I don't know the exact details of the underlying implementation (Clip is an interface). But from the JavaSound manual I gather that a Clip buffers the file in memory (like I do with AudioSample) so you don't want to use long files with an AudioSnippet. I'm not sure there is much of a performance increase from an AudioSnippet, but you may find that playback is a little more reliable, due to the fact that it is playing from an in-memory buffer and not streaming from a file.

Hope that clears it up.

Re: Minim: new audio library for processing
Reply #7 - Jun 11th, 2007, 8:20pm
 
great, thanks for the clarifications.

i use sonia quite a lot but i can see that minim is going to be very useful for specific aspects like access to stereo streams, etc. and making effects straighforward.

thanks again...
Re: Minim: new audio library for processing
Reply #8 - Oct 13th, 2008, 8:46pm
 
I've just released a new version of Minim.

Get it here: http://code.compartmental.net/tools/minim/
Re: Minim: new audio library for processing
Reply #9 - Nov 22nd, 2008, 4:58am
 
i have tried it, but i think there are still some rooms for optimization.
Re: Minim: new audio library for processing
Reply #10 - Nov 25th, 2008, 5:07am
 
Uh, I don't doubt that, but that is hardly the kind of feedback that will help me improve the library. Smiley
Re: Minim: new audio library for processing
Reply #11 - Dec 4th, 2008, 4:39pm
 
i was using your library, but i have some problems with the output, i can play audio file, i see their wavefoms moving but there is no sound.
do you know if there are problems with Mac intel computers?
thanks,

Rodrigo
Re: Minim: new audio library for processing
Reply #12 - Dec 6th, 2008, 6:00pm
 
I commend you.  I am working on a simple visualizer for mp3 playback and your documentation and (more importantly) simple example is making this easy and fun.

Please keep us posted on further progress, but thanks again for a great contribution!
Re: Minim: new audio library for processing
Reply #13 - Dec 14th, 2008, 6:26pm
 
Hello!

i'm using the minim library, i started with the "RecordandPlayback" sketch and i'm trying to do a FFT analysis to the file that i'm recording in real time but i have this error....


Minim Error ===
=== FFT.forward: The length of the passed sample buffer must be equal to timeSize().

Can someone help me?
thanks,

Rodrigo


here is the patch:

import ddf.minim.analysis.*;
import ddf.minim.*;

Minim minim;
AudioInput in;
AudioRecorder recorder;
AudioPlayer player;
FFT fft;

void setup()
{
 size(512, 200, P3D);
 textMode(SCREEN);  
 minim = new Minim(this);
 
 // get a stereo line-in: sample buffer length of 2048
 // default sample rate is 44100, default bit depth is 16
 in = minim.getLineIn(Minim.STEREO, 2048);
 // create an AudioRecorder that will record from in to the filename specified, using buffered recording
 // buffered recording means that all captured audio will be written into a sample buffer
 // then, when save() is called, the contents of the buffer will actually be written to a file
 // the file will be located in the sketch's data folder.
 recorder = minim.createRecorder(in, "myrecording.wav", true);
 player = minim.loadFile("myrecording.wav",2048);
 
 textFont(createFont("Arial", 12));
 
   fft = new FFT(player.bufferSize(), player.sampleRate());
   fft.logAverages(44, 1);
}

void draw()
{
  fft.forward(player.mix);
 

 float moyen = ((fft.getAvg(0) + fft.getAvg(1) + fft.getAvg(2) + fft.getAvg(3) + fft.getAvg(4) + fft.getAvg(5) + fft.getAvg(6) + fft.getAvg(7) + fft.getAvg(8)) / 9);
 println(moyen*10);
// println(player.left.level()*1000);

 background(0);
 stroke(255);
 // draw the waveforms
 // the values returned by left.get() and right.get() will be between -1 and 1,
 // so we need to scale them up to see the waveform
 for(int i = 0; i < in.left.size()-1; i++)
 {
   line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
   line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
 }
 
 if ( recorder.isRecording() )
 {
   text("Now recording...", 5, 15);
 }
 else
 {
   text("Not recording.", 5, 15);
 }
}

void keyReleased()
{
 if ( key == 'r' )
 {
   // to indicate that you want to start or stop capturing audio data, you must call
   // startRecording() and stopRecording() on the AudioFileOut object. You can start and stop
   // as many times as you like, the audio data will be appended to the end of the buffer
   // (in the case of buffered recording) or to the end of the file (in the case of streamed recording).
   if ( recorder.isRecording() )
   {
     recorder.endRecord();
   }
   else
   {
     recorder.beginRecord();
   }
 }
 if ( key == 's' )
 {
   // we've filled the file out buffer,
   // now write it to a file of the type we specified in setup
   // in the case of buffered recording,
   // this will appear to freeze the sketch for sometime, if the buffer is large
   // in the case of streamed recording,
   // it will not freeze as the data is already in the file and all that is being done
   // is closing the file.
   // save returns the recorded audio in an AudioRecording,
   // which we can then play with an AudioPlayer
   if ( player != null )
   {
       player.close();
   }
   player = recorder.save();
   player.play();
   
 }
 
 
}

void stop()
{
 // always close Minim audio classes when you are done with them
 in.close();
 if ( player != null )
 {
   player.close();
 }
 minim.stop();
 
 super.stop();
}
Re: Minim: new audio library for processing
Reply #14 - Mar 4th, 2009, 4:44pm
 
also been using the lib, found a stutter / glitch bug when retriggering lots of AudioSample in a very short period of time. only reveals itself when framerate drops low actually, so it's not replicatable in the examples unless you force frameRate(20) or something.

mailed the dev using the form earlier today (before realizing it was framerate dependant), but im posting in here aswell, in vague hope someone else has run into similar issue and figured out a smart way to hack out of the stutter/glitch b0rk. buffer clean up or something... couldnt find anything for that on the javadoc but then again im not a javasound guru :/
Pages: 1 2