— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet362/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   358   359   360   361   362   363   364   365   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

first.setMessage(192, 1, instrument, 0)
3
Make a MidiEvent instance for the message
MidiEvent noteOn = new MidiEvent(first, 1);
4
Add the event to the track
track.add(noteOn);
public static MidiEvent makeEvent(int comd, int chan, int one, int two, int tick) {
MidiEvent event = null;
try {
ShortMessage a = new ShortMessage();
a.setMessage(comd, chan, one, two);
event = new MidiEvent(a, tick);

}catch(Exception e) { }
return event;
}
Let’s build a static utility method that 
makes a message and returns a MidiEvent
the four arguments 
for the message
The event ‘tick’ for 
WHEN this message 
should happen
make the message and the event, using 
the method parameters
whoo! A method with five parameters.
return the event (a MidiEvent all 
loaded up with the message) 
utility method for 
events


getting 
gui
you are here
4
389
import javax.sound.midi.*;
public class MiniMusicPlayer1 {

public static void main(String[] args) {
try {
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();


Sequence seq = new Sequence(Sequence.PPQ, 4);
Track track = seq.createTrack();

for (int i = 5; i < 61; i+= 4) {

track.add(makeEvent(144,1,i,100,i));
track.add(makeEvent(128,1,i,100,i + 2));

// end loop

sequencer.setSequence(seq);
sequencer.setTempoInBPM(220);
sequencer.start();
} catch (Exception ex) {ex.printStackTrace();}

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   358   359   360   361   362   363   364   365   ...   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