— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet391/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   387   388   389   390   391   392   393   394   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

 
chapter 13
public void buildTrackAndStart() {
int[] trackList = null;

sequence.deleteTrack(track);
track = sequence.createTrack();
for (int i = 0; i < 16; i++) {
trackList = new int[16];
 
int key = instruments[i];
for (int j = 0; j < 16; j++ ) {

JCheckBox jc = (JCheckBox) checkboxList.get(j + (16*i));
if ( jc.isSelected()) {
trackList[j] = key;
} else {
trackList[j] = 0;
}
} // close inner loop


makeTracks(trackList);
track.add(makeEvent(176,1,127,0,16));
} // close outer
track.add(makeEvent(192,9,1,0,15));
try {
 
sequencer.setSequence(sequence); 
 
sequencer.setLoopCount(sequencer.LOOP_CONTINUOUSLY);
sequencer.start();
sequencer.setTempoInBPM(120);
} catch(Exception e) {e.printStackTrace();}
} // close buildTrackAndStart method


public class MyStartListener implements ActionListener {
public void actionPerformed(ActionEvent a) {
buildTrackAndStart();
}
} // close inner class
We’ll make a 16-element array to hold the values for 
one instrument, across all 16 beats. If the instrument is 
supposed to play on that beat, the value at that element 
will be the key. If that instrument is NOT supposed to 
play on that beat, put in a zero.
Is the checkbox at this beat selected? If yes, put 
the key value in this slot in the array (the slot that 
represents this beat). Otherwise, the instrument is 
NOT supposed to play at this beat, so set it to zero.
do this for each of the 16 ROWS (i.e. Bass, Congo, etc.)
Set the ‘key’. that represents which instrument this 
is (Bass, Hi-Hat, etc. The instruments array holds the 
actual MIDI numbers for each instrument.)
NOW PLAY THE THING!!
First of the inner classes, 
listeners for the buttons. 
Nothing special here.
This is where it all happens! Where we 
turn checkbox state into MIDI events, 
and add them to the Track.

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   387   388   389   390   391   392   393   394   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish