|
Post by honkytonk on Jun 17, 2022 9:35:19 GMT
Hello all, In the message "Midi" (dwMsg=channel+144+note*256+volume*65536 calldll #winmm,"midiOutShortMsg",hMidiOut as ulong,dwMsg as ulong,ret as ulong) I spotted the pitch and the volume. But can we adjust the duration, and if so, how? Thanks to the experts. Note: I'm posting here because I can't connect to: "Liberty".
|
|
|
Post by tsh73 on Jun 17, 2022 10:07:42 GMT
Never tried myself but Google makes me think that you send a message to turn note ON and another one to turn it OFF Like this (foom another language, consider to be pseudocode)
'instrument select midiOutShortMsg(MidiOut, StrToInt('$0000' + 'instrument number. 0..79' + 'C0'));
'Note ON Note := StrToInt('$007F' + 'note code' + '90'); midiOutShortMsg(MidiOut, Note);
'..wait some time..
'Note OFF Note := StrToInt('$007F' + 'note code' + '80'); MidiOutShortMsg(MidiOut, Note);
)
Incidentally 0x90 is hex(144) So try to change it to 0x80...
|
|
|
Post by honkytonk on Jun 17, 2022 10:29:48 GMT
The messages: StrToInt('$007F' + 'note code' + '90'); midiOutShortMsg(MidiOut, Note);
AND: StrToInt('$007F' + 'note code' + '80'); MidiOutShortMsg(MidiOut, Note);
Are to be inserted before, after, or inside: dwMsg=channel+144+nota*256+127*65536 calldll #winmm,"midiOutShortMsg",hMidiOut as ulong,dwMsg as ulong,ret as ulong ? ? ?
|
|
|
Post by Rod on Jun 17, 2022 10:48:20 GMT
See if this helps, its code from Liberty forum which I did not have any issues accessing.
'Based on Alyce Watson's excellent midi mapper demo from LBPE 'here we tease out the multi channel capability
hmidi=midiopen(hmidi) 'open the midi device if it is not already open vol=midivol(255,255,hmidi) 'set and remember the left and right volumes
'event 128 is stop note on channel 0-15 'event 144 is start note on channel 0-15 'event 192 is change instrument on channel 0-15
ret=message(192,1,44,0,hmidi) 'load whatever instrument 44 is to channel 2
'simply play a note five times on channel 1 and channel 2 using different instruments timer 500,[play] wait
[play] ret=message(128,0,60,0,hmidi) 'note off ch1 ret=message(144,0,60,127,hmidi) 'note on ch1 middle C ret=message(128,1,48,0,hmidi) 'note off ch2 ret=message(144,1,48,127,hmidi) 'note on ch2 count=count+1 if count >5 then [stop] wait
[stop] timer 0 nul=silence(hmidi) 'stop / silence all notes playing 0=success nul=midiclose(hmidi) 'close midi 0=sucess end
function message(event,channel,pitch,velocity,hmidi) status=event+channel low=(pitch*256)+status hi=velocity*256*256 dwMsg=low+hi CallDLL #winmm, "midiOutShortMsg",_ hmidi as ulong,_ 'handle to opened device dwMsg as ulong,_ 'message ret as ulong end function
function silence(hmidi) CallDLL #winmm, "midiOutShortMsg",_ hmidi as ulong,_ 'handle to opened device 128 as ulong,_ 'message ret as ulong silence=ret end function
function midivol(left,right,hmidi) '0 to 65535 or 0 to FFFF so FF=middle vol vol = (right * 256) + left calldll #winmm, "midiOutSetVolume",_ hmidi as ulong,_ vol as ulong,_ ret as ulong midivol=vol end function
function midiopen(hmidi) struct m, a$ As ptr if hmidi=0 then CallDLL #winmm, "midiOutOpen",_ m As struct,_ 'address of midiOut handle -1 As ulong,_ 'ID of MIDI output device 0 As ulong,_ 'callback, not used 0 As ulong,_ 'callback instance, not used 0 As ulong,_ 'callback event flag, not used ret As ulong '0=success (MMSYSERR_NOERROR = 0) if ret=0 then midiopen = m.a$.struct 'handle to midi device else midiopen = 0 end if end if end function
function midiclose(hmidi) if hmidi<>0 then CallDLL #winmm, "midiOutClose",_ hmidi as ulong,_ 'handle to opened device midiclose as ulong '0=success (MMSYSERR_NOERROR = 0) end if end function
|
|
|
Post by honkytonk on Jun 17, 2022 12:21:18 GMT
Thank you very much, I will think about all this.
|
|