minim sound chopping with code
in
Core Library Questions
•
1 year ago
hi all!
i have tried all i know, didn´t get the final idea.
my problem: the soundsample is 3 sec long, if i get an "on" message (true, button pressed) sound starts playing until i get an off (false, button not pressed) message. everything is fine until i start trying fading sounds out and pressing the button again while the sound is "playing" (muted in the background or whatever cage)... i´d like to know how could i: fade out the sound on button off, and be able to start the sound again from the beginning without chopping/whispering etc?
i could: load 5times every sound, and count them through, but, i have 8 buttons, every button has 3 sounds, played in a row, and this 5 times... makes a lot of bufferusage..... thogh there are some more 4 songs to play on other events.
here is my code, i really don´t get it.
also tried soundSample soundSnippet
should i change to beads? is it just my mistakes, or probably not working in minim/processing?
thx so much
polklemme
i have tried all i know, didn´t get the final idea.
my problem: the soundsample is 3 sec long, if i get an "on" message (true, button pressed) sound starts playing until i get an off (false, button not pressed) message. everything is fine until i start trying fading sounds out and pressing the button again while the sound is "playing" (muted in the background or whatever cage)... i´d like to know how could i: fade out the sound on button off, and be able to start the sound again from the beginning without chopping/whispering etc?
i could: load 5times every sound, and count them through, but, i have 8 buttons, every button has 3 sounds, played in a row, and this 5 times... makes a lot of bufferusage..... thogh there are some more 4 songs to play on other events.
here is my code, i really don´t get it.
also tried soundSample soundSnippet
should i change to beads? is it just my mistakes, or probably not working in minim/processing?
thx so much
polklemme
- import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer note0a, note0b, note0c;
int note0Counter = 0;
float note0Gain;
int keyboardLength = 8;
float[] inputarray = new float [keyboardLength];
boolean[] ptPressedarray = new boolean [keyboardLength];
boolean[] tPressedarray = new boolean [keyboardLength];
float input;
boolean ptPressed;
boolean tPressed;
void setup() {
size(500, 200);
background(0);
frameRate(25);
minim = new Minim(this);
// for audioPlayer
note0a = minim.loadFile("B1-Da.wav");
note0b = minim.loadFile("B2-Da.wav");
note0c = minim.loadFile("B3-Da.wav");
}
void draw() {
fill(0, 255, 0);
rect(width/2, 0, width, height);
tPressed = false;
input = mouseX;
if (input > width/2) {
tPressed = true;
}
if (tPressed != ptPressed) {
if (note0Counter > 5) {
note0Counter = 0;
}
note0Counter ++;
println("note Counter " + note0Counter);
println(tPressed);
if (tPressed == true && note0Counter == 1) {
note0a.setGain(0);
note0a.play(0);
println("note 0a playing " + note0a.isPlaying());
}
if (tPressed == true && note0Counter == 3) {
note0b.setGain(0);
note0b.play(0);
println("note 0b playing " + note0b.isPlaying());
}
if (tPressed == true && note0Counter == 5) {
note0c.setGain(0);
note0c.play(0);
println("note 0c playing " + note0c.isPlaying());
}
else {
println("just a note : single event after every playstart");
//note0a.stop();
//note0a.shiftGain(0, -80, 800);
// note0a.rewind();
// minim.stop();
}
if (tPressed == false){
println("just a note :single event after every switch off");
//note0a.shiftGain(0,-50,1000);
}
ptPressed = tPressed;
}
}
void stop() {
minim.stop();
super.stop();
}
1