Тема: Ahk: Мелодии на стандартном динамике
Интересно, если нет слуха и знаний по нотам, можно что-нибудь состряпать на стандартном динамике ?
было бы здорово, если бы рингтоны можно было перегонять в циферки и играть их на системном динамике вставляя в скрипты...
Следующий скрипт позволяет записывать простейшую музыку для AutoHotkey, а также извлекать её из кодов Nokia для последующего воспроизведения встроенным динамиком компьютера.
timer := 80 ; задаётся длительность [1/3]
const := (2**(1/12))
Menu, Tray, Icon, %SystemRoot%\system32\shell32.dll, 117 ;169
#NoTrayIcon
Gui, Add, Tab, x5 y10 w400 h400 buttons, Recorder|Nokia-->Ahk
Gui, Add, Button, xp40 yp30 w30 h50 , C#
Gui, Add, Button, xp+40 yp+0 w30 h50 , D#
Gui, Add, Button, xp+80 yp+0 w30 h50 , F#
Gui, Add, Button, xp+40 yp+0 w30 h50 , G#
Gui, Add, Button, xp+40 yp+0 w30 h50 , A#
Gui, Add, Button, xp-225 yp+50 w40 h75, C
Gui, Add, Button, xp+40 yp+0 w40 h75 , D
Gui, Add, Button, xp+40 yp+0 w40 h75 , E
Gui, Add, Button, xp+40 yp+0 w40 h75 , F
Gui, Add, Button, xp+40 yp+0 w40 h75 , G
Gui, Add, Button, xp+40 yp+0 w40 h75 , A
Gui, Add, Button, xp+40 yp+0 w40 h75 , B
Gui, Add, Button, xp+75 yp+0 w40 h75 , Пауза
Gui, Add, Text, x276 y170, Октава
Gui, Add, ListBox, r9 x276 y185 w100 voct gsubm, 0.0625|0.125|0.25|0.5||1||2|4|8|16
Gui, Add, Text, x276 y315, Длительность
Gui, Add, ListBox, r4 x276 y330 w100 vdlit gsubm, 0.125|0.25||0.5|1|
Gui, Add, Edit, w220 h210 x16 y175 vMyEdit1
Gui, Tab, 2
Gui, Add, GroupBox, x10 y40 w370 h110 , Введите код в формате Nokia
Gui, Add, Edit, x20 y60 w350 h80 vmyedit2,
Gui, Add, Edit, x16 y175 w220 h210 vitog ,
Gui, Add, Text, x276 y170, Октава
Gui, Add, Slider, x276 y185 w100 h30 vslideroctmod Range-2-2, 0
Gui, Add, Text, x276 y220, Длительность
Gui, Add, Slider, x276 y235 w100 h30 vsliderdlitmod Range10-50 , 30
Gui, Add, Button, x276 y275 w100 h30 , Прослушать
Gui, Add, Button, x276 y315 w100 h30 , Преобразовать
Gui, Add, Button, x276 y355 w100 h30 gbuferizovat, Скопировать`nв буфер
Gui, Show, x530 y509 h400 w400, Мелодии на стандартном динамике
return
subm:
Gui, Submit, nohide
return
buttonC:
ton := 0
Goto, presbut
return
buttonC#:
ton := 1
Goto, presbut
return
buttonD:
ton := 2
Goto, presbut
return
buttonD#:
ton := 3
Goto, presbut
return
buttonE:
ton := 4
Goto, presbut
return
buttonF:
ton := 5
Goto, presbut
return
buttonF#:
ton := 6
Goto, presbut
return
buttonG:
ton := 7
Goto, presbut
return
buttonG#:
ton := 8
Goto, presbut
return
buttonA:
ton := 9
Goto, presbut
return
buttonA#:
ton := 10
Goto, presbut
return
buttonB:
ton := 11
Goto, presbut
return
buttonПауза:
Gui, Submit, nohide
dlitmod:=ceil(10*timer*dlit)
GuiControl, ,MyEdit1, %MyEdit1% Sleep, %dlitmod% `n
return
presbut:
Gui, Submit, nohide
freq := Ceil(oct * 261.63 * (const ** ton ))
dlitmod:=ceil(10*timer*dlit)
SoundBeep, %freq%, %dlitmod%
GuiControl, ,MyEdit1, %MyEdit1% SoundBeep %freq%, %dlitmod% `n
;msgbox oct %oct%, const %const%, ton %ton%, freq %freq%
return
buttonПрослушать:
write:=0
sound:=1
goto transf
Return
buttonПреобразовать:
sound:=0
write:=1
GuiControl, ,itog,
goto transf
return
buferizovat:
Gui, Submit, nohide
clipboard:=itog
clipboard = %clipboard%
Return
transf:
Gui, Submit, nohide
Loop, parse, myedit2,%a_space%,
{
last:=StrLen(A_LoopField)
IF StrLen(A_LoopField) <>0
{
dlitmod := 0
ton := 0
nota := 0
octmod := 0
pausemod:= 0
loop, parse, A_LoopField
{
IF InStr("123468",A_LoopField) and (dlitmod=0) and (A_Index=1)
{
tempvar := A_LoopField
dlitmod := ceil((timer*sliderdlitmod*(1/A_LoopField)))
}
IF InStr("123468" ,A_LoopField) and (dlitmod<>0) and (A_Index=2)
dlitmod := ceil(timer*sliderdlitmod*(1/(10*tempvar+A_LoopField)))
IF A_LoopField = #
ton := 1
IF InStr("abcdefg" ,A_LoopField)
nota := A_LoopField
IF (InStr("1234" ,A_LoopField) and (nota<>0) and (A_Index=last))
octmod := 2**(A_LoopField+slideroctmod)
IF A_LoopField= `-
pausemod:= 1
}
IF (pausemod = 1) and (write=1)
{
Gui, Submit, nohide
GuiControl, ,itog, %itog% sleep, %dlitmod% `n
}
IF (pausemod = 1) and (sound=1)
sleep, %dlitmod%
IF pausemod <> 1
{
If nota = c
nota := 0
If nota = d
nota := 2
If nota = e
nota := 4
If nota = f
nota := 5
If nota = g
nota := 7
If nota = a
nota := 9
If nota = b
nota := 11
freq := Ceil(0.5*octmod * 261.63 * (const ** (nota+ton) ))
Gui, Submit, nohide
If write=1
GuiControl, ,itog, %itog% SoundBeep %freq%, %dlitmod%`n
If sound=1
SOUNDBEEP %freq%, %dlitmod%
}
}
}
return
GuiClose:
ExitApp