uses minwin
uses minmidi
def MM midiOutShortMsg hMidi, 0X%1
def MT sleep
sys hMidi
int er=midiOutOpen(hMidi, 0, 0, 0, CALLBACK_NULL) ' 0=synth a 2=soft synth
MM 0xff 'reset
MM 0x79B0 'reset all controllers
'MM 0000C0 'PIANO
MM 000EC0 'PROG TUBULAR BELLS
int i
for i=1 to 3
MM 3007B0 'VOL
MM 7F0AB0 'PAN
MM 404590 'A4 ON
MT 300
next
for i=1 to 3
MM 3007B0 'VOL
MM 000AB0 'PAN
'MM 4001B0 'MODULATION WHEEL
MM 4C80E0 'PITCH WHEEL
MM 404590 'A4 ON
MT 300
next
for i=1 to 3
MM 3007B0 'VOL
MM 000AB0 'PAN
MM 4001B0 'MODULATION WHEEL
MM 4080E0 'PITCH WHEEL
MM 304590 'A4 ON
MT 300
next
int j=45 'A2
for i=1 to 12
MM 3007B0 'VOL
MM 400AB0 'PAN
MM 0001B0 'MODULATION WHEEL
MM 4080E0 'PITCH WHEEL
MM 250090+j*0x100 'SCALING NOTE ON
MT 200
j+=3
next
MT 3000
MM 004580 'A4 OFF
midiOutClose(hMidi)
$ filename "PlayMidiNotes.exe"
'uses rtl32
'uses rtl64
uses console
'uses minmidi
'octave 0..10
extern lib "Winmm.dll"
sys midiOutOpen(sys *phmo, uDeviceID,dwCallback, dwInstance,fdwOpen)
sys midiOutShortMsg(sys hmo, dwMsg)
sys midiOutClose(sys hmo)
sys midiOutReset(sys hmo)
% MIDIMAPPER = 0xFFFFFFFF
% MIDI_MAPPER = 0xFFFFFFFF
% CALLBACK_NULL = 0
% MMSYSERR_NOERROR = 0
function freq(int d) as double
return pow(2,(d-69)/12)*440
end function
function playNotes() as uint
int err
sys hMidiOut
uint PPQN_CLOCK = 5
err = midiOutOpen(hMidiOut, MIDIMAPPER, 0, 0, CALLBACK_NULL)
if (err != MMSYSERR_NOERROR) then
printl "Error opening MIDI Mapper, Error code: " err
end if
int Instrument = 72 'Piccolo, 0x48
err = midiOutShortMsg(hMidiOut, (0x100 * Instrument) + 0xc0)
'err = midiOutShortMsg(hMidiOut, 0x48c0)
dword noteOn
dword noteOff
int i = 20
printl "Midi"
printl "Num NoteOn NoteOff"
while i < 127
i+=1 : print i ") "
' velocity midi num cmd: on
noteOn = (0x7f * 0x10000) + (i * 0x100) + 0x90 : print "0x00" hex (noteOn) ", "
err = midiOutShortMsg(hMidiOut, noteOn)
if(err != MMSYSERR_NOERROR) then
printl "Error sending command, Error code: " err
end if
noteOff = (i * 0x100) + 0x80 : print "0x0000" hex(noteOff) ", "
print " Hertz: " str(freq(i),2) + cr
Sleep(100 * PPQN_CLOCK)
err = midiOutShortMsg(hMidiOut, noteOff)
if(err != MMSYSERR_NOERROR) then
printl "Error sending command, Error code: " err
end if
wend
midiOutReset(hMidiOut)
midiOutClose(hMidiOut)
return 0
end function
playNotes()
printl "Enter ..."
waitkey
Page created in 0.132 seconds with 14 queries.