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 › Some fundamental sound questions
Page Index Toggle Pages: 1
Some fundamental sound questions (Read 2903 times)
Some fundamental sound questions
Jun 15th, 2009, 5:53am
 
Hi,

i created sound files with the minim sound library.

example:
import ddf.minim.*;
Minim minim;
AudioSample kick;

kick = minim.loadSample("boing2.wav", 20048);

With kick.trigger(); i started the sound.

my problem is now, that i dont know how to avoid it, that 2 sounds can appear at the same time.

1: i always want to have only 1 sound at a time that plays from his beginning to his end.

2: i found no command to stop a sound manually when a reason is filled. I want to be able to play the sound again later.


it would be very nice if someone could help me
Re: Some fundamental sound questions
Reply #1 - Jun 15th, 2009, 9:25am
 
there's also an isPlaying() method that'll tell you whether the sound is still playing. a simple loop (with a delay() in it) and you can stop a second note being triggered until the first one has finished.

you have to rewind() the sample before you can play it again. (oh, that's for AudioSnippets which are a smaller footprint version of audio samples useful when you just want to play a sound, not examine it)

(Snippets appear to use play rather than trigger so you might need to change that if you use Snippets)

Re: Some fundamental sound questions
Reply #2 - Jun 15th, 2009, 2:11pm
 
Ok thanks, i will try it with audio snippets, but my problem is, that i dont know how to play a file again if i choose close(); before.

what is the command to make a file playable again???
Re: Some fundamental sound questions
Reply #3 - Jun 16th, 2009, 3:19am
 
you don't really want to close a snippet until you've completely finished with it. you'll need to load it again otherwise and that (i recently found) isn't something you can do in realtime.

look at the stop() method in the examples - it gets called at the end and closes all the samples.
Re: Some fundamental sound questions
Reply #4 - Jun 16th, 2009, 3:42am
 
Ok, i want it an other way, i explain it:

i have a song. this song is abount 3 minutes.

I created a game with 3 different screens, a start screen with no sound ,a play screen with only noises and the last screen where you can hear the song.

Now its planned, that you can hear the song only when the last screen is showed. If a user clicks in this screen the retry button, the song should stop and the screen goes back to the play screen.

After the next game is finished, the song should start again and plays from the beginning.

You see now the problem:

i want to interrrupt the sound file manually but be able to play it again later from the beginning.
Re: Some fundamental sound questions
Reply #5 - Jun 16th, 2009, 9:46am
 
http://code.compartmental.net/minim/javadoc/ddf/minim/Playable.html

play()
         Starts playback from the current position.

pause()
         Pauses playback.

rewind()
         Rewinds to the beginning. <- do this before playing it again

there is no stop() which is odd. but pause() will do.
Re: Some fundamental sound questions
Reply #6 - Jun 16th, 2009, 11:43am
 
Ok thats nice, thank you Smiley
Re: Some fundamental sound questions
Reply #7 - Jun 16th, 2009, 2:22pm
 
Hmm strange:

when i use


AudioSnippet kick7;
kick7 = minim.loadSnippet("spielmusik.mp3");

kick7.loop(5);

i didnt get any loop.

if i tried it with play(); it  works but i havent a loop.

for the main theme of the game i want i loop, what have i to add for this?

Re: Some fundamental sound questions
Reply #8 - Jun 23rd, 2009, 7:20am
 
try using AudioPlayer instead of AudioSnippet
Page Index Toggle Pages: 1