打开控制台
MIDI嗨起来
——以上纯属扯淡,by 扣钉骑士
Well forget it, let's play something here.
Let's say we're trying to generat something like it shown below:
01001101 01010100 01101000 01100100 // MThd
00000000 00000000 00000000 00000110 // header lentgh: 6 bytes
00000000 00000001 // Midi Type: 1
00000000 00000001 // Track count: 1
00000000 00011000 // Division: 48 ticks / second
01001101 01010100 01110010 01101011 // MTrk
00000000 00000000 00000111 10111011 // Track Length: 955 bytes - length-fixable data
00000000 11111111 00000010 00011100 // tick 0, 0xFF 0x02 0x1C - CopyRight, length: 28 bytes
00101000 01100011 00101001 00110010 // CopyRight Contents in 28 bytes.
00110000 00110001 00110011 00100000
01100010 01111001 00100000 01111001
01100001 01110010 01101101 01111001
01100001 01110010 01100011 01101000
01000000 01101100 01101001 01110110
01100101 00101110 01100011 01101110
00000000 11000000 00001011 // Program Change
00000000 10010000 00111100 01111111 // Note On
00000001 10110000 00001011 01111111 // 0xB0 0x11 0x7F
00000000 11100000 00000000 01000000 // 0xE0 0x00 0x40
00000001 10110000 00001011 01111111
00000000 11100000 00000000 01000000
00000001 10110000 00001011 01111110
00000000 11100000 00000000 01000001 // 0xE0 0x00 0x41
// 117 No.11 Controller
00000001 10110000 00000001 01111111 // 0xB0 0x01 0x7F
// 120 No.11 Controller
00000001 10110000 00001011 00000000 // 0xB0 0x11 0x00
00000000 11100000 00000000 01111111 // 0xE0 0x00 0x7F
00000000 10000000 00111100 00111111 // Note Off
00000000 11111111 00101111 00000000 // tick 0, 0xFF 0x2F 0x00 - End of Track Chunk
And here comes the scirpt for that, play it in the console:
var seq = new Midi.Sequence(1, 24),
track = seq.getTrack(0);
track.addEvent(0, new Midi.Message(0xc0, 0x11)); // Program Change to No.17
track.addEvent(0, new Midi.Message(0xB0, [124,0])); // omni on
track.addEvent(0, new Midi.Message(0xB0, [126,1])); // mono on & omni on
track.addEvent(0, new Midi.Message(0x90, [60,127])); // Note On Key 0x3C
track.addEvent(120, new Midi.Message(0xB0, [1,127])); // Vibrato Controller
track.addEvent(240, new Midi.Message(0x80, [60,127])); // Note Off
// Apply Voice Change and Pitch Wheel Change
for (var i = 1; i <= 240; ++i) {
track.addEvent(i, new Midi.Message(0xB0, [11, 127 - ~~((127 / 240) * i)]));
track.addEvent(i, new Midi.Message(0xE0, [0, 64 + ~~((63 / 240) * i)]));
}
// Click & Download
var blob = new Blob([seq.toByteArray(1)], {type:"audio/midi"});
var url = URL.createObjectURL(blob);
document.body.onclick = function() {
window.open(url);
document.body.onclick = "";
}
Or you may want to
select from an instrument here
0-Acoustic Grand Piano
1-Bright Acoustic Piano
2-Electric Grand Piano
3-Honky-tonk Piano
4-Rhodes Piano
5-Chorused Piano
6-Harpsichord
7-Clavichord
8-Celesta
9-Glockenspiel
10-Music box
11-Vibraphone
12-Marimba
13-Xylophone
14-Tubular Bells
15-Dulcimer
16-Hammond Organ
17-Percussive Organ
18-Rock Organ
19-Church Organ
20-Reed Organ
21-Accordian
22-Harmonica
23-Tango Accordian
24-Acoustic Guitar (nylon)
25-Acoustic Guitar (steel)
26-Electric Guitar (jazz)
27-Electric Guitar (clean)
28-Electric Guitar (muted)
29-Overdriven Guitar
30-Distortion Guitar
31-Guitar Harmonics
32-Acoustic Bass
33-Electric Bass(finger)
34-Electric Bass (pick)
35-Fretless Bass
36-Slap Bass 1
37-Slap Bass 2
38-Synth Bass 1
39-Synth Bass 2
40-Violin
41-Viola
42-Cello
43-Contrabass
44-Tremolo Strings
45-Pizzicato Strings
46-Orchestral Harp
47-Timpani
48-String Ensemble 1
49-String Ensemble 2
50-Synth Strings 1
51-Synth Strings 2
52-Choir Aahs
53-Voice Oohs
54-Synth Voice
55-Orchestra Hit
56-Trumpet
57-Trombone
58-Tuba
59-Muted Trumpet
60-French Horn
61-Brass Section
62-Synth Brass 1
63-Synth Brass 2
64-Soprano Sax
65-Alto Sax
66-Tenor Sax
67-Baritone Sax
68-Oboe
69-English Horn
70-Bassoon
71-Clarinet
72-Piccolo
73-Flute
74-Recorder
75-Pan Flute
76-Bottle Blow
77-Shakuhachi
78-Whistle
79-Ocarina
80-Lead 1 (square)
81-Lead 2 (sawtooth)
82-Lead 3 (caliope lead)
83-Lead 4 (chiff lead)
84-Lead 5 (charang)
85-Lead 6 (voice)
86-Lead 7 (fifths)
87-Lead 8 (bass+lead)
88-Pad 1 (new age)
89-Pad 2 (warm)
90-Pad 3 (polysynth)
91-Pad 4 (choir)
92-Pad 5 (bowed)
93-Pad 6 (metallic)
94-Pad 7 (halo)
95-Pad 8 (sweep)
96-FX 1 (rain)
97-FX 2 (soundtrack)
98-FX 3 (crystal)
99-FX 4 (atmosphere)
100-FX 5 (brightness)
101-FX 6 (goblins)
102-FX 7 (echoes)
103-FX 8 (sci-fi)
104-Sitar
105-Banjo
106-Shamisen
107-Koto
108-Kalimba
109-Bagpipe
110-Fiddle
111-Shanai
112-Tinkle Bell
113-Agogo
114-Steel Drums
115-Woodblock
116-Taiko Drum
117-Melodic Tom
118-Synth Drum
119-Reverse Cymbal
120-Guitar Fret Noise
121-Breath Noise
122-Seashore
123-Bird Tweet
124-Telephone Ring
125-Helicopter
126-Applause
127-Gunshot
and
, then it here.