<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; Ahk: Мелодии на стандартном динамике]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=2644</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=2644&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Ahk: Мелодии на стандартном динамике».]]></description>
		<lastBuildDate>Fri, 02 Jan 2009 17:42:10 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Ahk: Мелодии на стандартном динамике]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=17791#p17791</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Интересно, если нет слуха и знаний по нотам, можно что-нибудь состряпать на стандартном динамике <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />?</p></blockquote></div><div class="quotebox"><blockquote><p>было бы здорово, если бы рингтоны можно было перегонять в циферки и играть их на системном динамике вставляя в скрипты...</p></blockquote></div><p>Следующий скрипт позволяет записывать простейшую музыку для AutoHotkey, а также извлекать её из кодов Nokia для последующего воспроизведения встроенным динамиком компьютера.<br /></p><div class="codebox"><pre><code>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--&gt;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) &lt;&gt;0
    {
    dlitmod    := 0
    ton     := 0
    nota     := 0
    octmod     := 0
    pausemod:= 0
        loop, parse, A_LoopField
        {
        IF InStr(&quot;123468&quot;,A_LoopField) and (dlitmod=0) and (A_Index=1)
            {        
            tempvar := A_LoopField
            dlitmod := ceil((timer*sliderdlitmod*(1/A_LoopField)))
            }
        IF InStr(&quot;123468&quot; ,A_LoopField) and (dlitmod&lt;&gt;0) and (A_Index=2)
            dlitmod := ceil(timer*sliderdlitmod*(1/(10*tempvar+A_LoopField)))
        IF A_LoopField = #
            ton := 1
        IF InStr(&quot;abcdefg&quot; ,A_LoopField)
            nota := A_LoopField
        IF (InStr(&quot;1234&quot; ,A_LoopField) and (nota&lt;&gt;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 &lt;&gt; 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</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Fri, 02 Jan 2009 17:42:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=17791#p17791</guid>
		</item>
	</channel>
</rss>
