Code: Select all
;
; by Danilo, 25.12.2002
;
Global hMidiOut
#Church_organ = 19
#Orchestral_harp = 46
#Channel1 = 1
#Channel2 = 2
Procedure MidiOutMessage(hMidi,iStatus,iChannel,iData1,iData2)
dwMessage = iStatus | iChannel | (iData1 << 8) | (iData2 << 16)
ProcedureReturn midiOutShortMsg_(hMidi, dwMessage) ;
EndProcedure
Procedure SetInstrument(channel,instrument)
MidiOutMessage(hMidiOut, $C0, channel, instrument, 0)
EndProcedure
Procedure PlayNote(channel,Note)
MidiOutMessage(hMidiOut, $90, channel, Note , 127)
EndProcedure
Procedure StopNote(channel,Note)
MidiOutMessage(hMidiOut, $90, channel, Note , 0)
EndProcedure
; open MIDI out
If midiOutOpen_(@hMidiOut,0, 0, 0, 0) = #MMSYSERR_NOERROR
; set harp as instrument
SetInstrument(#Channel1,#Orchestral_harp)
SetInstrument(#Channel2,#Orchestral_harp)
; play notes from c2 to c4
For a = $2C To $4C Step 2
PlayNote(#Channel1,a) : PlayNote(#Channel2,a)
Delay(125)
StopNote(#Channel1,a) : StopNote(#Channel2,a)
Next a
; play notes from c4 to c1 (backwards)
For a = $4C To $1C Step -2
PlayNote(#Channel1,a) : PlayNote(#Channel2,a)
Delay(125)
StopNote(#Channel1,a) : StopNote(#Channel2,a)
Next a
; small pause
Delay(300)
; set church organ as instrument
SetInstrument(#Channel1, #Church_organ)
SetInstrument(#Channel2, #Church_organ)
; play J.S.Bach notes
Restore Bach_Toccata_in_D_Minor
For a = 1 To 60
Read note
PlayNote(#Channel1,note) : PlayNote(#Channel2,note)
Delay(110)
StopNote(#Channel1,note) : StopNote(#Channel2,note)
Next a
; end: reset instruments to 0 (default)
SetInstrument(#Channel1,0)
SetInstrument(#Channel2,0)
; end: close MIDI output
midiOutClose_(hMidiOut)
EndIf
End
DataSection
Bach_Toccata_in_D_Minor:
Data.l 110, 69, 81, 110, 67, 79, 990, 69, 81, 220, -1, -1
Data.l 110, 67, 79, 110, 65, 77, 110, 64, 76, 110, 62, 74
Data.l 220, 61, 73, 440, 62, 74, 1980, -1, -1, 110, 57, 69
Data.l 110, 55, 67, 990, 57, 69, 220, -1, -1, 220, 52, 64
Data.l 220, 53, 65, 220, 49, 61, 440, 50, 62, 1980, -1, -1
EndDataSection
Note 'c1' is $1C and note 'c2' is $2C and so on...
...hope it helps.