AutoIt: до 3.3.0.0
Версия: 2006-2009г
Категория: Разное
Описание: Использование миди-инструментов, воспроизведение мелодии используя миди-устройство.
Код/Пример:
Лучший пример от sandin, вернее готовая программа-синтезатор
Пример от Uriziel01
Файл: Midiudf.au3
Источник: autoitscript.com
Автор(ы): Eynstyne
Версия: 2006-2009г
Категория: Разное
Описание: Использование миди-инструментов, воспроизведение мелодии используя миди-устройство.
Код/Пример:
Код:
#include <Midiudf.au3>
$open = _midiOutOpen ()
Global $instrument_String="Grand Piano|Bright Piano|Electric Grand Piano|Honky-Tonk Piano|Electric piano|Electric Piano|" & _
"Harpsichord|Clavinet|Celesta|Glockenspiel|Music Box|Vibraphone|Marimba|Xylophone|Tubular bells|Dulcimer|Drawbar Organ|" & _
"Percussive Organ|Rock Organ|Church Organ|Reed Organ|Accordion|Harmonica|Tango Accordion|Nylon String Guitar|Steel String Guitar|" & _
"Jazz Guitar|Clean Electric Guitar|Muted Electric Guitar|Overdrive Guitar|Distortion Guitar|Guitar Harmonics|Accoustic Bass|" & _
"Fingered Bass|Picked Bass|Fretless Bass|Slap Bass 1|Slap Bass 2|Synth Bass 1|Synth Bass 2|Violin|Viola|Cello|Contrabass|" & _
"Tremolo Strings|Pizzicato Strings|Orchestral Harp|Timpani|String Ensemble 1|String Ensemble 2|Synth Strings 1|" & _
"Synth Strings 2|Choir ahh|Choir oohh|Synth Voice|Orchestral Hit|Trumpet|Trombone|Tuba|Muted Trumpet|French Horn|" & _
"Brass Section|Synth Brass 1|Synth Brass 2|Soprano Sax|Alto Sax|Tenor Sax|Baritone Sax|Oboe|English Horn|Bassoon|" & _
"Clarinet|Piccolo|Flute|Recorder|Pan flute|Blown Bottle|Shakuhachi|Whistle|Ocarina|Square Wave|Sawtooth Wave|Caliope|" & _
"Chiff|Charang|Voice|Fifths|Bass & Lead|New Age|Warm|PolySynth|Choir|Bowed|Metallic|Halo|Sweep|FX: Rain|FX: Soundtrack|" & _
"FX: Crystal|FX: Atmosphere|FX: Brightness|FX: Goblins|FX: Echo Drops|FX: Star Theme|Sitar|Banjo|Shamisen|Koto|Kalimba|" & _
"Bagpipe|Fiddle|Shanai|Tinkle bell|Agogo|Steel Drums|Woodblock|Taiko Drum|Melodic Tom|Synth Drum|Reverse Cymbal|" & _
"Guitar Fret Noise|Breath Noise|Seashore|Bird Tweet|Telephone Ring|Helicopter|Applause|Gunshot"
Global $instrument_Array= StringSplit($instrument_String,"|")
$inct=1
$gui=GUICreate("Генератор мелодий",270,430) ; размер окна
$Menu=GUICtrlCreateMenu("Инструмент")
for $i = 1 to $instrument_Array[0]
Assign('menuinst' & $i, GUICtrlCreateMenuItem($instrument_Array[$i],$Menu))
Next
For $d = 1 To 8
For $i = 1 To 12
If $d=8 And $i>=5 Then ExitLoop 2
Assign('nota' & $i+12*$d-12, GUICtrlCreateButton ($i, $i*20-15,$d*20,20,20))
Next
Next
$check = GUICtrlCreateCheckbox ("Добавлять", 10, 180, 120, 20)
$Edit1 = GUICtrlCreateEdit('', 5, 210, 260, 170)
$play=GUICtrlCreateButton ("Воспроизвести", 82,383,100,22)
$Clear=GUICtrlCreateButton ("Очистить", 192,383,60,22)
$Cancel=GUICtrlCreateButton ("Отмена", 10,383,60,22)
$text='#include <Midiudf.au3>'&@CRLF&'$open = _midiOutOpen ()'&@CRLF
GUISetState (@SW_SHOW)
While 1
$msg = GUIGetMsg()
For $i = 1 To 88
If $msg = Eval('nota' & $i) Then _nota($i,$inct)
Next
For $i = 1 To $instrument_Array[0]
If $msg = Eval('menuinst' & $i) Then $inct=$i-1
Next
Select
Case $msg = $Cancel
$text=StringRegExpReplace($text, '(?s)(^.*)\r\n(.*)\r\n$', '\1')&@CRLF
If @Extended=0 Then $text='#include <Midiudf.au3>'&@CRLF&'$open = _midiOutOpen ()'&@CRLF
GUICtrlSetData($Edit1, $text)
Case $msg = $Clear
$text=''
GUICtrlSetData($Edit1, '')
Case $msg = $play
If $text<>'' Then
$file = FileOpen(@TempDir&'\Beepfile.au3',2)
FileWrite($file, $text&@CRLF&'_MidiOutClose ($open)')
FileClose($file)
_MidiOutClose ($open)
$sAutoIt_Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
If @error Then ContinueLoop
RunWait('"'&$sAutoIt_Path&'\AutoIt3.exe" "'&@TempDir&'\Beepfile.au3"', '', @SW_HIDE)
$open = _midiOutOpen ()
EndIf
Case $msg = -3
ExitLoop
EndSelect
Wend
Func _nota($i,$inct=127)
SetInstrument($open, $inct)
_MidiOutShortMsg($open, 0x90 + ($i * 256) + (127 * 0x10000)) ; воспроизведение ноты ($i - тон)
Sleep(300)
_MidiOutShortMsg($open, 0x90 + ($i * 256) + (0 * 0x10000)) ; остановка ноты выключением звука ноты в ноль
If GUICtrlRead ($check)=1 Then
$text&='_MidiOutShortMsg($open, 0x90 + ('&$i&' * 256) + (127 * 0x10000))'&@CRLF&'Sleep(300)'&@CRLF&'_MidiOutShortMsg($open, 0x90 + ('&$i&' * 256) + (0 * 0x10000))'&@CRLF
GUICtrlSetData($Edit1, $text)
EndIf
EndFunc
Func SetInstrument($open, $inct) ; установка инструмента
_MidiOutShortMsg($open,256 * $inct + 192)
EndFunc
Лучший пример от sandin, вернее готовая программа-синтезатор
Пример от Uriziel01
Файл: Midiudf.au3
Источник: autoitscript.com
Автор(ы): Eynstyne