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 › sample triggering MINIM
Pages: 1 2 
sample triggering MINIM (Read 2727 times)
sample triggering MINIM
Jan 5th, 2008, 1:40am
 
i think this is probably very simple but i'm not sure where to even start. i want to have an array of samples that can be triggered by different keys on the keyboard. i'm trying to use the AudioSample method followed by .trigger when the key is pressed.

I can't even get this working with one sample! says:

=== Minim Error ===
=== Unable to return a SourceDataLine: unsupported format.

=== Minim Error ===
=== Minim.loadSample: Couldn't acquire a SourceDataLine.

but even if i get minim working how do i put a lot of samples into an array that can all be separately triggered later?

any help is much appreciated. Smiley
Re: sample triggering MINIM
Reply #1 - Jan 5th, 2008, 7:09pm
 
Looks like you are trying to load an audio file that Minim doesn't know how to open. What kind of file is it? Probably I should make that error a little more verbose.

If you want an array of samples you'd do something like:

Code:

AudioSample[] sampleArray = new AudioSample[10];
for(int i = 0; i < sampleArray.length; i++)
{
sampleArray[i] = Minim.loadSample("samp" + i + ".wav");
}
Re: sample triggering MINIM
Reply #2 - Jan 6th, 2008, 8:49pm
 
thanks for that. i presume then my samples would all have to be called samp1, samp2, samp3.wav etc for your example to work.

i'm under the impression that if the sample is in the 'data' folder of the sketch folder, you don't have to put the whole file path. is that right.
the samples are all .wav and are stored in the data folder. i'm calling it at the moment using:

AudioSample samp;
samp = Minim.loadSample("samp.wav");

and i've tried it with the 512 sample rate too, i.e. ("samp.wav", 512)
Re: sample triggering MINIM
Reply #3 - Jan 7th, 2008, 3:42am
 
Yes, that's correct about the file location.  

Looks like I got confused about what a SourceDataLine is for. Checking the source, that error gets spit out when the AudioSample tries to get a line to *output* audio. It seems odd to me that Java would be able to read the file in but not play it out...
Re: sample triggering MINIM
Reply #4 - Jan 7th, 2008, 4:50pm
 
so maybe processing's having trouble finding my soundcard output?
would there be a way of specifying a particular output line?


incidentally, when i try and trigger the sample anyway during the program it throws out a 'null'.

also, this only seems to be a problem with the loadSample method. If i try making an AudioPlayer, using loadFile and playing a song this seems to work fine. i can pause and play ok.
Re: sample triggering MINIM
Reply #5 - Jan 8th, 2008, 5:38am
 
Oh, wow, that's really strange. Did you try creating a player with the exact same file that you tried creating a sample with?
Re: sample triggering MINIM
Reply #6 - Jan 8th, 2008, 10:11pm
 
until now, i hadn't tried that.
it seems to bring up the same error. well half of it. just the bit that says:

=== Minim Error ===
=== Unable to return a SourceDataLine: unsupported format.

still the nullpointer expection when the key's pressed.
i know the sample is fine, it plays in many different media players fine.
it is short though, is there a limit to how short a sample can be in Minim? maybe i have to specify if it's stereo or mono?
thanks for all your assistance with this ddf.
Re: sample triggering MINIM
Reply #7 - Jan 9th, 2008, 2:18am
 
If you would, put the line:

Code:

Minim.debugOn();


before you call to Minim.start and post back all the output you get.
Re: sample triggering MINIM
Reply #8 - Jan 9th, 2008, 4:38am
 
If you're on the experimental-new-Java 1.6, the developers totally broke javasound's wav support Tongue

I had to downgrade to 1.5 last week because in 1.6, you get the following bug:

AudioSystem.getAudioInputStream() throws "Resetting to Invalid Mark" exception when passed ANY .wav file (but, mp3's and ogg'2 work fine, but that really didn't cut it for my application).

Though, I assume this is NOT your issue, but it could be.
Re: sample triggering MINIM
Reply #9 - Jan 9th, 2008, 11:23pm
 
don't really know bout the Java 1.6. I'm running Processing 0132 Beta.


i ran the Minim.debugOn();

but still the same error. all it gives me is:

=== Minim Error ===
=== Unable to return a SourceDataLine: unsupported format.


in case it helps, here's all my code:

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;

AudioPlayer kick;


void setup() {
 
 Minim.debugOn();
 Minim.start(this);
 kick = Minim.loadFile("kick.wav", 512);

 
}

void draw() {
}

void keyPressed()

{
 if ( key == 'k' ) {kick.play();}
}

void stop() {
 
 kick.close();
 Minim.stop();
 
 super.stop();
}
Re: sample triggering MINIM
Reply #10 - Jan 10th, 2008, 12:15am
 
host one of the media files on http://www.mediafire.com please
Re: sample triggering MINIM
Reply #11 - Jan 10th, 2008, 3:50am
 
Really? There were no =====Minim Debug====== lines?
Re: sample triggering MINIM
Reply #12 - Jan 17th, 2008, 1:35am
 
hi, sorry i haven't replied, and thanks for all the help. i've been away from processing for the last few days, but it occurred to me that it must be the files themselves since the minim examples played fine.

turns out minim only likes 16bit, sampled at 44100Hz. Just had to change the recordings, and it all works fine.
Re: sample triggering MINIM
Reply #13 - Jan 17th, 2008, 3:42am
 
Ah, good to hear.
Re: sample triggering MINIM
Reply #14 - Jan 17th, 2008, 3:02pm
 
Im also having trouble with minim, the file plays when i click on the button, but only plays once?? All my files are .aiff's

thanks alot




if(mousePressed){                                          
   if(circleOver){                                  //If the mouse if pressed on the circle , it will load image "b" in the window at full screen
     song.play();

   }
   if(circle1Over){             //If the mouse if pressed on circle 1, the first movie will load where the mouse is    
     song1.play();        
   }
   if(circle2Over){                               //If the mouse if pressed on circle 2, the first movie will load at the given axis    
     song2.play();
Pages: 1 2