BeatBox
code
Do this for each of the BEATS for this row
For this instrument, and for all 16 beats,
make events and add them to the track.
We always want to make sure that there IS an event at
beat 16 (it goes 0 to 15). Otherwise, the BeatBox might
not go the full 16 beats before it starts over.
get rid of the old track, make a fresh one.
Let’s you specify the number
of loop iterations, or in this
case, continuous looping.
using
swing
you are here
4
423
public class MyStopListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
sequencer.stop();
}
} // close inner class
public class MyUpTempoListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
float tempoFactor = sequencer.getTempoFactor();
sequencer.setTempoFactor((float)(tempoFactor * 1.03));
}
} // close inner class
public class MyDownTempoListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
float tempoFactor = sequencer.getTempoFactor();
sequencer.setTempoFactor((float)(tempoFactor * .97));
}
} // close inner class
public void makeTracks(int[] list) {
for (int i = 0; i < 16; i++) {
int key = list[i];
if (key != 0) {
track.add(makeEvent(144,9,key, 100, i));
track.add(makeEvent(128,9,key, 100, i+1));
}
}
}
public MidiEvent makeEvent(int comd, int chan, int one, int two, int tick) {
Do'stlaringiz bilan baham: |