Simple Midi Message to Play a note Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
A_Perry_1984
Posts: 71
Joined: 07 Dec 2018, 12:08

Simple Midi Message to Play a note

10 Nov 2019, 09:58

I am very new to using AHK with midi. I just want an ultra simple send midi message to play one or more notes to the internal synth. I believe it requires DLL's to do so, but this far exceeds my knowledge and experience. I don't even know what to look for. Any help is appreciated.

Here is an example of what I mean:

Code: Select all

Play_These_Notes = C3.C4
;Send a midi message to play C3 and C4 at the same time.
;Use the basic internal piano
;Velocity, volume, instrument type etc. not important right now.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Simple Midi Message to Play a note  Topic is solved

21 Nov 2019, 22:32

Here are some basic examples:

Code: Select all

;q:: ;MIDI play notes
hModule := DllCall("kernel32\LoadLibrary", "Str","winmm", "Ptr")

vDeviceID := 0, hMIDIOutputDevice := 0
if DllCall("winmm\midiOutOpen", "Ptr*",hMIDIOutputDevice, "UInt",vDeviceID, "UPtr",0, "UPtr",0, "UInt",0, "UInt")
	return

hDev := hMIDIOutputDevice
vChan := 0

;==============================

;C3 and C4 at the same time:
MidiNoteOn(hDev, vChan, 48, 100)
MidiNoteOn(hDev, vChan, 60, 100)
Sleep, 2000
MidiNoteOff(hDev, vChan, 48, 0)
MidiNoteOff(hDev, vChan, 60, 0)
Sleep, 2000

;==============================

;note: 60 ;middle C
MidiNoteOn(hDev, vChan, 60, 100)
Sleep, 2000
MidiNoteOff(hDev, vChan, 60, 0)
Sleep, 2000

;==============================

vVel := 100
vDur := 500
vOffset := 0

oArray := [60, 64, 67, 72]
vOutput := ""
for vKey, vValue in oArray
{
	MidiNoteOn(hDev, vChan, vValue+vOffset, 100)
	Sleep, % vDur
}
Sleep, % vDur*3
for vKey, vValue in oArray
	MidiNoteOff(hDev, vChan, vValue+vOffset, 0)

Sleep, 1000

;==============================

vVel := 100
vDur := 200
vOffset := 8

MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 64+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*2)

MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 59+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur*2)

Sleep, 1000

;==============================

DllCall("winmm\midiOutClose", "Ptr",hMIDIOutputDevice, "UInt")
DllCall("kernel32\FreeLibrary", "Ptr",hModule)
return

;==================================================

MidiNotePlay(hMIDIOutputDevice, vChannel, vNote, vVelocity, vDuration)
{
	MidiNoteOn(hMIDIOutputDevice, vChannel, vNote, vVelocity)
	Sleep, % vDuration
	MidiNoteOff(hMIDIOutputDevice, vChannel, vNote, 0)
}

MidiNoteOn(hMIDIOutputDevice, vChannel, vNote, vVelocity)
{
	DllCall("winmm\midiOutShortMsg", "Ptr",hMIDIOutputDevice, "UInt",0x90 | vChannel | (vNote << 8) | (vVelocity << 16), "UInt")
}

MidiNoteOff(hMIDIOutputDevice, vChannel, vNote, vVelocity)
{
	DllCall("winmm\midiOutShortMsg", "Ptr",hMIDIOutputDevice, "UInt",0x80 | vChannel | (vNote << 8) | (vVelocity << 16), "UInt")
}

;==================================================

;frequency to MIDI note number:
;f = 440*(2^((d-69)/12))
;f/440 = 2^((d-69)/12)
;log_2(f/440) = (d-69)/12
;12*log_2(f/440) = (d-69)
;12*log_2(f/440) + 69 = d
;since we can't calculate log_2(x) directly
;and since log_2(x) = log(x) / log(2)
;d = 12*(log(f/440)/log(2)) + 69

;see also:
;MIDI tuning standard - Wikipedia
;https://en.wikipedia.org/wiki/MIDI_tuning_standard
;Piano key frequencies - Wikipedia
;https://en.wikipedia.org/wiki/Piano_key_frequencies

;SoundBeep range: 37-32767
;C0 (16.352 Hz) (MIDI note 12)
;A0 (27.5 Hz) (MIDI note 21)
;D1 (36.708 Hz) (MIDI note 26) (start of SoundBeep range)
;C4 (261.626 Hz) (MIDI note 60) (middle C)
;A4 (440 Hz) (MIDI note 69)
;C9 (8372.018 Hz) (MIDI note 120)
;A9 (14080 Hz) (MIDI note 129)
;C10 (16744.036 Hz) (MIDI note 132)
;A10 (28160 Hz) (MIDI note 141)
;B10 (31608.531 Hz) (MIDI note 143) (end of SoundBeep range)
;C11 (33488.072 Hz) (MIDI note 144)
;A11 (56320 Hz) (MIDI note 153)

;==================================================

;0	8.175799	C-1
;1	8.661957	C#-1
;2	9.177024	D-1
;3	9.722718	D#-1
;4	10.300861	E-1
;5	10.913382	F-1
;6	11.562326	F#-1
;7	12.249857	G-1
;8	12.978272	G#-1
;9	13.750000	A-1
;10	14.567618	A#-1
;11	15.433853	B-1
;12	16.351598	C0
;13	17.323914	C#0
;14	18.354048	D0
;15	19.445436	D#0
;16	20.601722	E0
;17	21.826764	F0
;18	23.124651	F#0
;19	24.499715	G0
;20	25.956544	G#0
;21	27.500000	A0
;22	29.135235	A#0
;23	30.867706	B0
;24	32.703196	C1
;25	34.647829	C#1
;26	36.708096	D1
;27	38.890873	D#1
;28	41.203445	E1
;29	43.653529	F1
;30	46.249303	F#1
;31	48.999429	G1
;32	51.913087	G#1
;33	55.000000	A1
;34	58.270470	A#1
;35	61.735413	B1
;36	65.406391	C2
;37	69.295658	C#2
;38	73.416192	D2
;39	77.781746	D#2
;40	82.406889	E2
;41	87.307058	F2
;42	92.498606	F#2
;43	97.998859	G2
;44	103.826174	G#2
;45	110.000000	A2
;46	116.540940	A#2
;47	123.470825	B2
;48	130.812783	C3
;49	138.591315	C#3
;50	146.832384	D3
;51	155.563492	D#3
;52	164.813778	E3
;53	174.614116	F3
;54	184.997211	F#3
;55	195.997718	G3
;56	207.652349	G#3
;57	220.000000	A3
;58	233.081881	A#3
;59	246.941651	B3
;60	261.625565	C4
;61	277.182631	C#4
;62	293.664768	D4
;63	311.126984	D#4
;64	329.627557	E4
;65	349.228231	F4
;66	369.994423	F#4
;67	391.995436	G4
;68	415.304698	G#4
;69	440.000000	A4
;70	466.163762	A#4
;71	493.883301	B4
;72	523.251131	C5
;73	554.365262	C#5
;74	587.329536	D5
;75	622.253967	D#5
;76	659.255114	E5
;77	698.456463	F5
;78	739.988845	F#5
;79	783.990872	G5
;80	830.609395	G#5
;81	880.000000	A5
;82	932.327523	A#5
;83	987.766603	B5
;84	1046.502261	C6
;85	1108.730524	C#6
;86	1174.659072	D6
;87	1244.507935	D#6
;88	1318.510228	E6
;89	1396.912926	F6
;90	1479.977691	F#6
;91	1567.981744	G6
;92	1661.218790	G#6
;93	1760.000000	A6
;94	1864.655046	A#6
;95	1975.533205	B6
;96	2093.004522	C7
;97	2217.461048	C#7
;98	2349.318143	D7
;99	2489.015870	D#7
;100	2637.020455	E7
;101	2793.825851	F7
;102	2959.955382	F#7
;103	3135.963488	G7
;104	3322.437581	G#7
;105	3520.000000	A7
;106	3729.310092	A#7
;107	3951.066410	B7
;108	4186.009045	C8
;109	4434.922096	C#8
;110	4698.636287	D8

;==================================================
While the MidiNotePlay/MidiNoteOn/MidiNoteOff functions, above, might be fine for simple scripts, I would recommend the MIDIOutputDevice class, which has more functionality, including a method called SynchroSleep, which is more precise than using Sleep.

These example MIDI scripts by rommmcek, use a class called MIDIOutputDevice (based on work by Uberi):
Bottles of beer on the wall... [4 lines or less challenge] - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=39754&p=184556#p184556
one-loop sorting of strings by their length - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=38630&p=184012#p184012

Cheers.

Links (MIDI):
The MIDI File Format
https://www.csie.ntu.edu.tw/~r92092/ref/midi/
Standard MIDI file format, updated
http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html
dyci2-multi/midifile.h at master · DYCI2/dyci2-multi · GitHub
https://github.com/DYCI2/dyci2-multi/blob/master/reinforcement/detection_fausse_note/extract_melody/midicsv-1.1/midifile.h

Links (MIDI) (concepts):
[running status]
MIDI tutorial for programmers
http://www.music-software-development.com/midi-tutorial.html
[VLQ]
Variable-length quantity - Wikipedia
https://en.wikipedia.org/wiki/Variable-length_quantity
Variable Length Values
http://www.ccarh.org/courses/253/handout/vlv/
[14-bit pitch bend value (0-16383)]
MIDI File Format - The Sonic Spot
https://web.archive.org/web/20141227205754/http://www.sonicspot.com/guide/midifiles.html
[PPQN]
Pulses per quarter note - Wikipedia
https://en.wikipedia.org/wiki/Pulses_per_quarter_note
[SMPTE: Society of Motion Picture and Television Engineers]
SMPTE timecode - Wikipedia
https://en.wikipedia.org/wiki/SMPTE_timecode
MIDI timecode - Wikipedia
https://en.wikipedia.org/wiki/MIDI_timecode

Links (MIDI) (further):
Dave's J.S. Bach Page - MIDI Files
http://www.jsbach.net/midi/
MIDI & Digital Music Making - Computerphile - YouTube
https://www.youtube.com/watch?v=imY4EpxjyMY
Music 253 Assignment 7
http://www.ccarh.org/courses/253/assignment/midifile/
Specifications - The Sonic Spot
https://web.archive.org/web/20141227105025/http://www.sonicspot.com/guide/fileformatspecs.html
Last edited by jeeswg on 22 Nov 2019, 23:41, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
AHKStudent
Posts: 653
Joined: 05 May 2018, 12:23

Re: Simple Midi Message to Play a note

22 Nov 2019, 01:32

@jeeswg the sample you posted works well, why do you suggest not to use it?
rommmcek
Posts: 730
Joined: 15 Aug 2014, 15:18

Re: Simple Midi Message to Play a note

22 Nov 2019, 21:42

MIDIOutputDevice is based on work by Anthony Zhang, which indeed is part of Uberi's game.

@A_Perry_1984 & @AHKStudent: You're welcome to ask any further questions!
bye!

P.s.: SynchroSleep() is my function (now already a bit obsolete) written of course through experiences acquired on the forum!
A_Perry_1984
Posts: 71
Joined: 07 Dec 2018, 12:08

Re: Simple Midi Message to Play a note

22 Nov 2019, 22:07

This is great! I have been working on a ear training and sight reading script. This is just what I needed.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Simple Midi Message to Play a note

22 Nov 2019, 23:40

@AHKStudent: I've clarified the post (and added some links). The script above is fine, however, MIDIOutputDevice has more functionality.

@rommmcek: Nice, I like the name, SynchroSleep.

@A_Perry_1984: Interesting usage. It might come in handy that the MIDI note system makes it quite easy to shift the pitch, just add/subtract an integer.

Thanks all.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
teadrinker
Posts: 1072
Joined: 29 Mar 2015, 09:41
Contact:

Re: Simple Midi Message to Play a note

23 Nov 2019, 07:44

jeeswg wrote:

Code: Select all

MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 64+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*2)

MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur*2)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 59+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur*2)
@jeeswg, it's a pain! Let me make corrections:

Code: Select all

MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*3)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*3)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 64+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*4)

MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur*3)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur*3)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 65+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 59+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 62+vOffset, vVel, vDur)
MidiNotePlay(hDev, vChan, 55+vOffset, vVel, vDur*4)
:lol:
Thanks for sharing!
Helgef
Posts: 4031
Joined: 17 Jul 2016, 01:02
Contact:

Re: Simple Midi Message to Play a note

23 Nov 2019, 08:40

@teadrinker, it's a pain! Let me make corrections:

Code: Select all

for k, idk in [ [60, 3]						
			  , [55, 1]
			  , [60, 3]
			  , [55, 1]
			  , [60, 1]
			  , [55, 1]
			  , [60, 1]
			  , [64, 1]
			  , [67, 4]
			  , [65, 3]
			  , [62, 1]
			  , [65, 3]
			  , [62, 1]
			  , [65, 1]
			  , [62, 1]
			  , [59, 1]
			  , [62, 1]
			  , [55, 4] ]
	
	MidiNotePlay(hDev, Chan, idk[1]+Offset, Vel, Dur*idk[2])
:lol:
Thanks for sharing!
teadrinker
Posts: 1072
Joined: 29 Mar 2015, 09:41
Contact:

Re: Simple Midi Message to Play a note

23 Nov 2019, 09:00

@Helgef Ok :) Also I'd replace numbers with note names.
rommmcek
Posts: 730
Joined: 15 Aug 2014, 15:18

Re: Simple Midi Message to Play a note

24 Nov 2019, 17:03

teadrinker wrote:it's a pain!
Yes, if you do by hand one note at a time. That's why we have AutoHotkey! O.k. coding takes some time too, but it's fun by itself, not to mention the outcome (sometimes)!

Code: Select all

;q:: ;MIDI play notes
hModule := DllCall("kernel32\LoadLibrary", "Str","winmm", "Ptr")

vDeviceID := 0, hMIDIOutputDevice := 0
if DllCall("winmm\midiOutOpen", "Ptr*",hMIDIOutputDevice, "UInt",vDeviceID, "UPtr",0, "UPtr",0, "UInt",0, "UInt")
	return

hDev := hMIDIOutputDevice
vChan := 0

vVel := 127
vDur := 1
vOffset := 4

MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 68+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*418)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*418)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*414)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*517)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*517)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*194)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 68+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*418)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*517)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 63+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 60+vOffset, vVel, vDur*517)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*194)
MidiNotePlay(hDev, vChan, 72+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*422)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*228)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*496)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*224)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*496)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*99)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*116)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*194)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*427)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*108)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*513)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 70+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 75+vOffset, vVel, vDur*224)
MidiNotePlay(hDev, vChan, 67+vOffset, vVel, vDur*517)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*116)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 82+vOffset, vVel, vDur*211)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*112)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 81+vOffset, vVel, vDur*220)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*95)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*198)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*207)
MidiNotePlay(hDev, vChan, 74+vOffset, vVel, vDur*103)
MidiNotePlay(hDev, vChan, 77+vOffset, vVel, vDur*203)
MidiNotePlay(hDev, vChan, 79+vOffset, vVel, vDur*422)

Sleep, 500
ExitApp
;==============================

DllCall("winmm\midiOutClose", "Ptr",hMIDIOutputDevice, "UInt")
DllCall("kernel32\FreeLibrary", "Ptr",hModule)
return

;==================================================

MidiNotePlay(hMIDIOutputDevice, vChannel, vNote, vVelocity, vDuration)
{
	MidiNoteOn(hMIDIOutputDevice, vChannel, vNote, vVelocity)
	Sleep, % vDuration
	MidiNoteOff(hMIDIOutputDevice, vChannel, vNote, 0)
}

MidiNoteOn(hMIDIOutputDevice, vChannel, vNote, vVelocity)
{
	DllCall("winmm\midiOutShortMsg", "Ptr",hMIDIOutputDevice, "UInt",0x90 | vChannel | (vNote << 8) | (vVelocity << 16), "UInt")
}

MidiNoteOff(hMIDIOutputDevice, vChannel, vNote, vVelocity)
{
	DllCall("winmm\midiOutShortMsg", "Ptr",hMIDIOutputDevice, "UInt",0x80 | vChannel | (vNote << 8) | (vVelocity << 16), "UInt")
}

esc:: ExitApp

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], swagfag, think and 276 guests