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 playback faltering in sequencer
Page Index Toggle Pages: 1
Minim playback faltering in sequencer (Read 610 times)
Minim playback faltering in sequencer
Dec 2nd, 2009, 2:31am
 
Hi All
I have been hacking away at a step sequencer in Processing which is based on the excellent, simple and effective version created by Ian Bartholomew http://www.ianbartholomew.com
I have switched it to play directly rather than send a label via OSC to chuck, and have used the minim library.
So far, so good- but the sequencer will now skip playback on some sweeps of the tempo (play) line, and there is a lack of clarity to the notes (ie they pop and crackle a bit after playing).
Could folks help? To spot why I am getting sweeps of the notes without playback (this seems not to follow a pattern, it can play well for three or four loops and then go silent), and also if there's a cleaner way of playing the notes? Much appreciated - I am a fairly newbie and this is an exercise in learning for me!

calling the notes and sending them the label for id
Code:

public void play(int pos, float freq) {

if (!played[pos]) { // if the note hasn't been played already (this assures that the note is only played once)...
//myOSC.play(label, freq, slider.gain()); //.. send out the OSC info..

sounds.play(label);
played[pos] = true; // and set it to played

}


the tab that deals with playing the sounds
Code:

public class Sounds{

//String label;
//AudioPlayer kick;
//Audioplayer bassguitar;


public Sounds() {






app.registerDraw(this); // this registers the draw events
// app.registerMouseEvent(this); // this registers the mouse events

}

void draw(){

}

void play(String _label) { //going to add-- float _freq, float _gain



// myMessage.add(freq); // freqency
// myMessage.add(gain); // gain

String label = _label;
//float freq = _freq;
//float gain = _gain;

if (label == "Row 1"){

row1.trigger();
minim1.stop();

} else if (label == "Row 2"){
row2.trigger();
minim2.stop();

} else if (label == "Row 3"){
row3.trigger();
minim3.stop();

} else if (label == "Row 4"){
row4.trigger();
minim4.stop();

} else if (label == "Row 5"){
row5.trigger();
minim5.stop();

} else if (label == "Row 6"){
row6.trigger();
minim6.stop();

}


}

/* void stop(String _label){

String label = _label;
if (label == "Row 1"){

minim1.stop();


} else if (label == "Row 2"){
minim2.stop();

} else if (label == "Row 3"){
minim3.stop();

} else if (label == "Row 4"){
minim4.stop();

} else if (label == "Row 5"){
minim5.stop();

} else if (label == "Row 6"){
minim6.stop();

}
minim1.stop();
minim2.stop();
minim3.stop();
minim4.stop();
minim5.stop();
minim6.stop();


// super.stop();
}
*/
}


the other sequencer code that adds and remembers the notes, their position etc, that may be the source of the problem...
Code:

public void add(int _x, int _y) {

// this just adds points to the arrays.
theX[place] = _x;
theY[place] = _y;

played[place] = false; // this is for playing of the notes. Set it to false by default

place++; // this advances the place by one each time add() runs

if (place == theX.length-1) { // if place (and, by extention, the number of points) is the size of the array..

theX = expand(theX, theX.length+25); // ..expand the arrays by 25
theY = expand(theY, theY.length+25);
played = expand(played, played.length+25);

}

}

public boolean exists(int locX, int locY) { // Check to see if the points exist. Called when mouse is pressed

exist = false;

for (int i=0; i<theX.length; i++) {

if ((theX[i] > locX-4)&&(theX[i] < locX+4)&&(theY[i] > locY-4)&&(theY[i] < locY+4)) {
exist = true;
cue=i; // if the point does exist, set the point to the cue. used for removing
}
}
return exist;
}


public void notes(int marker) { // checks the placement of the tempo marker, and plays the notes that are there

if (marker == 100) reset(); // if the marker is at the end of the box, call the reset() method

for (int i=0; i<theY.length; i++) {
if ((theX[i]<marker+4)&&(theX[i]>marker-4)) { // if the marker is roughly (because the marker doesn't always land on the point) equal to a point
play(i, theY[i]); // play the note

}
}
}


many many thanks!
Page Index Toggle Pages: 1