Jump to content

Another beep song UPDATED!


Paulie
 Share

Recommended Posts

Thank you.

I have been playing with this ever since I found it!

_52 (125)
_52 (125)
_52 (125)
_52 (500)
_47 (375)
_50 (375)
_52 (250)
_50 (125)

_52 (500)
_R (500)
_52 (375)
_50 (375)
_52(250)

_R (125)
_50 (250)
_55 (375)
_55 (250)
_54 (375)
_55 (250)
_54 (375)

_55 (250)
_52 (375)
_50 (375)
_49 (375)
_50 (250)
_47 (1000)
_R (375)

_52 (375)
_50 (375)
_52 (250)

_R (125)
_50 (250)
_55 (375)
_55 (250)
_54 (375)
_55 (250)
_54 (375)

_55 (250)
_52 (375)
_50 (375)
_49 (375)
_50 (250)
_57 (1000)
_R (375)

:)

Edited by jebus495
Link to comment
Share on other sites

I have made an adjustment to Paulie's UDF.

CODE
#cs

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

Beep Songs

by Paulie

Parameters:

_*Key*($duration)

*Key* - # of keyboard key

Duration - How long to hold it

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

#ce

Global $list[100], $tempo = 1

$list = StringSplit("4186.01|3951.07|"& _

"3729.31|3520.00|3322.44|"& _

"3135.96|2959.96|2793.83|"& _

"2637.02|2489.02|2349.32|"& _

"2217.46|2093.00|1975.53|"& _

"1864.66|1760.00|1661.22|"& _

"1567.98|1479.98|1396.91|"& _

"1318.51|1244.51|1174.66|"& _

"1108.73|1046.50|987.767|"& _

"932.328|880.000|830.609|"& _

"783.991|739.989|698.456|"& _

"659.255|622.254|587.330|"& _

"554.365|523.251|493.883|"& _

"466.164|440.000|415.305|"& _

"391.995|369.994|349.228|"& _

"329.628|311.127|293.665|"& _

"277.183|261.626|246.942|"& _

"233.082|220.000|207.652|"& _

"195.998|184.997|174.614|"& _

"164.814|155.563|146.832|"& _

"138.591|130.813|123.471|"& _

"116.541|110.000|103.826|"& _

"97.9989|92.4986|87.3071|"& _

"82.4069|77.7817|73.4162|"& _

"69.2957|65.4064|61.7354|"& _

"58.2705|55.0000|51.9130|"& _

"48.9995|46.2493|43.6536|"& _

"41.2035|38.8909|36.7081|"& _

"34.6479|32.7032|30.8677|"& _

"29.1353|27.5000|", "|")

;Notes Go Here

;Format - Number of key on the piano (1 lowest-88 highest), Duration to hold

;-------------------

Func _R($dura)

Sleep($dura*$tempo)

EndFunc

Func _88($dura)

Beep($list[1], $dura*$tempo)

EndFunc

Func _87($dura)

Beep($list[2],$dura*$tempo)

EndFunc

Func _86($dura)

Beep($list[3],$dura*$tempo)

EndFunc

Func _85($dura)

Beep($list[4],$dura*$tempo)

EndFunc

Func _84($dura)

Beep($list[5],$dura*$tempo)

EndFunc

Func _83($dura)

Beep($list[6],$dura*$tempo)

EndFunc

Func _82($dura)

Beep($list[7],$dura*$tempo)

EndFunc

Func _81($dura)

Beep($list[8],$dura*$tempo)

EndFunc

Func _80($dura)

Beep($list[9],$dura*$tempo)

EndFunc

Func _79($dura)

Beep($list[10],$dura*$tempo)

EndFunc

Func _78($dura)

Beep($list[11],$dura*$tempo)

EndFunc

Func _77($dura)

Beep($list[12],$dura*$tempo)

EndFunc

Func _76($dura)

Beep($list[13],$dura*$tempo)

EndFunc

Func _75($dura)

Beep($list[14],$dura*$tempo)

EndFunc

Func _74($dura)

Beep($list[15],$dura*$tempo)

EndFunc

Func _73($dura)

Beep($list[16],$dura*$tempo)

EndFunc

Func _72($dura)

Beep($list[17],$dura*$tempo)

EndFunc

Func _71($dura)

Beep($list[18],$dura*$tempo)

EndFunc

Func _70($dura)

Beep($list[19],$dura*$tempo)

EndFunc

Func _69($dura)

Beep($list[20],$dura*$tempo)

EndFunc

Func _68($dura)

Beep($list[21],$dura*$tempo)

EndFunc

Func _67($dura)

Beep($list[22],$dura*$tempo)

EndFunc

Func _66($dura)

Beep($list[23],$dura*$tempo)

EndFunc

Func _65($dura)

Beep($list[24],$dura*$tempo)

EndFunc

Func _64($dura)

Beep($list[25],$dura*$tempo)

EndFunc

Func _63($dura)

Beep($list[26],$dura*$tempo)

EndFunc

Func _62($dura)

Beep($list[27],$dura*$tempo)

EndFunc

Func _61($dura)

Beep($list[28],$dura*$tempo)

EndFunc

Func _60($dura)

Beep($list[29],$dura*$tempo)

EndFunc

Func _59($dura)

Beep($list[30],$dura*$tempo)

EndFunc

Func _58($dura)

Beep($list[31],$dura*$tempo)

EndFunc

Func _57($dura)

Beep($list[32],$dura*$tempo)

EndFunc

Func _56($dura)

Beep($list[33],$dura*$tempo)

EndFunc

Func _55($dura)

Beep($list[34],$dura*$tempo)

EndFunc

Func _54($dura)

Beep($list[35],$dura*$tempo)

EndFunc

Func _53($dura)

Beep($list[36],$dura*$tempo)

EndFunc

Func _52($dura)

Beep($list[37],$dura*$tempo)

EndFunc

Func _51($dura)

Beep($list[38],$dura*$tempo)

EndFunc

Func _50($dura)

Beep($list[39],$dura*$tempo)

EndFunc

Func _49($dura)

Beep($list[40],$dura*$tempo)

EndFunc

Func _48($dura)

Beep($list[41],$dura*$tempo)

EndFunc

Func _47($dura)

Beep($list[42],$dura*$tempo)

EndFunc

Func _46($dura)

Beep($list[43],$dura*$tempo)

EndFunc

Func _45($dura)

Beep($list[44],$dura*$tempo)

EndFunc

Func _44($dura)

Beep($list[45],$dura*$tempo)

EndFunc

Func _43($dura)

Beep($list[46],$dura*$tempo)

EndFunc

Func _42($dura)

Beep($list[47],$dura*$tempo)

EndFunc

Func _41($dura)

Beep($list[48],$dura*$tempo)

EndFunc

Func _40($dura)

Beep($list[49],$dura*$tempo)

EndFunc

Func _39($dura)

Beep($list[50],$dura*$tempo)

EndFunc

Func _38($dura)

Beep($list[51],$dura*$tempo)

EndFunc

Func _37($dura)

Beep($list[52],$dura*$tempo)

EndFunc

Func _36($dura)

Beep($list[53],$dura*$tempo)

EndFunc

Func _35($dura)

Beep($list[54],$dura*$tempo)

EndFunc

Func _34($dura)

Beep($list[55],$dura*$tempo)

EndFunc

Func _33($dura)

Beep($list[56],$dura*$tempo)

EndFunc

Func _32($dura)

Beep($list[57],$dura*$tempo)

EndFunc

Func _31($dura)

Beep($list[58],$dura*$tempo)

EndFunc

Func _30($dura)

Beep($list[59],$dura*$tempo)

EndFunc

Func _29($dura)

Beep($list[60],$dura*$tempo)

EndFunc

Func _28($dura)

Beep($list[61],$dura*$tempo)

EndFunc

Func _27($dura)

Beep($list[62],$dura*$tempo)

EndFunc

Func _26($dura)

Beep($list[63],$dura*$tempo)

EndFunc

Func _25($dura)

Beep($list[64],$dura*$tempo)

EndFunc

Func _24($dura)

Beep($list[65],$dura*$tempo)

EndFunc

Func _23($dura)

Beep($list[66],$dura*$tempo)

EndFunc

Func _22($dura)

Beep($list[67],$dura*$tempo)

EndFunc

Func _21($dura)

Beep($list[68],$dura*$tempo)

EndFunc

Func _20($dura)

Beep($list[69],$dura*$tempo)

EndFunc

Func _19($dura)

Beep($list[70],$dura*$tempo)

EndFunc

Func _18($dura)

Beep($list[71],$dura*$tempo)

EndFunc

Func _17($dura)

Beep($list[72],$dura*$tempo)

EndFunc

Func _16($dura)

Beep($list[73],$dura*$tempo)

EndFunc

Func _15($dura)

Beep($list[74],$dura*$tempo)

EndFunc

Func _14($dura)

Beep($list[75],$dura*$tempo)

EndFunc

Func _13($dura)

Beep($list[76],$dura*$tempo)

EndFunc

Func _12($dura)

Beep($list[77],$dura*$tempo)

EndFunc

Func _11($dura)

Beep($list[78],$dura*$tempo)

EndFunc

Func _10($dura)

Beep($list[79],$dura*$tempo)

EndFunc

Func _9($dura)

Beep($list[80],$dura*$tempo)

EndFunc

Func _8($dura)

Beep($list[81],$dura*$tempo)

EndFunc

Func _7($dura)

Beep($list[82],$dura*$tempo)

EndFunc

Func _6($dura)

Beep($list[83],$dura*$tempo)

EndFunc

Func _5($dura)

Beep($list[84],$dura*$tempo)

EndFunc

Func _4($dura)

Beep($list[85],$dura*$tempo)

EndFunc

Func _3($dura)

Beep($list[86],$dura*$tempo)

EndFunc

Func _2($dura)

Beep($list[87],$dura*$tempo)

EndFunc

Func _1($dura)

Beep($list[88],$dura*$tempo)

EndFunc

This allows you to change the speed at any time without changing any of the numbers. :)

Here's an example.

CODE
#include <Piano.au3>

$tempo = 1

_52 (125)

_52 (125)

_52 (125)

_52 (500)

_47 (375)

_50 (375)

_52 (250)

_50 (125)

_52 (500)

_R (500)

_52 (375)

_50 (375)

_52(250)

$tempo = 1.5

_R (125)

_50 (250)

_55 (375)

_55 (250)

_54 (375)

_55 (250)

_54 (375)

_55 (250)

_52 (375)

_50 (375)

_49 (375)

_50 (250)

_47 (1000)

_R (375)

$tempo = 0.5

_52 (375)

_50 (375)

_52 (250)

_R (125)

_50 (250)

_55 (375)

_55 (250)

_54 (375)

_55 (250)

_54 (375)

_55 (250)

_52 (375)

_50 (375)

_49 (375)

_50 (250)

_57 (1000)

_R (375)

Edited by jebus495
Link to comment
Share on other sites

  • 1 month later...

Short version:

#cs
§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
Beep Songs
by Paulie

Parameters:

Play($KEY,$DURATION)

$KEY - # of keyboard key
$DURATION - How long to hold it
§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
#ce

Global $LIST[100]

$LIST = StringSplit("4186.01|3951.07|"& _
"3729.31|3520.00|3322.44|"& _
"3135.96|2959.96|2793.83|"& _
"2637.02|2489.02|2349.32|"& _
"2217.46|2093.00|1975.53|"& _
"1864.66|1760.00|1661.22|"& _
"1567.98|1479.98|1396.91|"& _
"1318.51|1244.51|1174.66|"& _
"1108.73|1046.50|987.767|"& _
"932.328|880.000|830.609|"& _
"783.991|739.989|698.456|"& _
"659.255|622.254|587.330|"& _
"554.365|523.251|493.883|"& _
"466.164|440.000|415.305|"& _
"391.995|369.994|349.228|"& _
"329.628|311.127|293.665|"& _
"277.183|261.626|246.942|"& _
"233.082|220.000|207.652|"& _
"195.998|184.997|174.614|"& _
"164.814|155.563|146.832|"& _
"138.591|130.813|123.471|"& _
"116.541|110.000|103.826|"& _
"97.9989|92.4986|87.3071|"& _
"82.4069|77.7817|73.4162|"& _
"69.2957|65.4064|61.7354|"& _
"58.2705|55.0000|51.9130|"& _
"48.9995|46.2493|43.6536|"& _
"41.2035|38.8909|36.7081|"& _
"34.6479|32.7032|30.8677|"& _
"29.1353|27.5000|", "|")

Func Play($KEY,$DURATION)
    Beep($LIST[89-$KEY],$DURATION)
EndFunc

Func Rest($DURATION)
    Sleep($DURATION)
EndFunc

When the words fail... music speaks.

Link to comment
Share on other sites

  • 2 months later...

Just thought i share some of my physics :)

it seems you are use an array for storing the tones, but it is quite easy to calculate them

the only thing you need is a base tone to start from, lets for example take A which is 440Hz. then the next note's Hz will be defined by this function.

Y=440*12thRoot(2)^X

which can be written as:

Y=(440*2^(1/12)^X

Where X is the number of notes from A(440)

And Y= the Hz of that note.

AutoIt Demo:

Global $N

For $X=0 to 12 step 1
Beep (_GetNote(440,$X),200)
Next

_Chord (440,True)

Func _Chord ($Base,$Flag)
dim $note[3]
$note[0] = _GetNote($Base,$N)
Switch $Flag
    Case True
        $note[1] = _GetNote($Base,4)
    Case False
        $note[1] = _GetNote($Base,3)
EndSwitch
$note[2] = _GetNote($Base,7)
For $y=0 to 2
    Beep ($note[$y],200)
Next
EndFunc

Func _GetNote($StartHz,$N)
Return $StartHz*2^(1/12)^$N
EndFunc

I don't know if you already knew this, but choose to use an array for simplicity or speed, but I thought; knowledge is meant to be shared :party:

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

  • 2 years later...

Hi all,

I just can't get my head round how this works, can someone please help.

I have saved the original script as piano.au3. Then used the samples and added #Include <C:\piano.au3>

When running the sample i get errors:

C:\piano.au3 (93) : ==> Variable used without being declared.:

$Octave = GUICtrlCreateInput("1", 368, 123, 35, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))

$Octave = GUICtrlCreateInput("1", 368, 123, 35, 21, BitOR(^ ERROR

Any ideas, I would love to get this working with the mario tune via the internal pc speaker.

Thanks,

Link to comment
Share on other sites

Hi all,

I just can't get my head round how this works, can someone please help.

I have saved the original script as piano.au3. Then used the samples and added #Include <C:\piano.au3>

When running the sample i get errors:

C:\piano.au3 (93) : ==> Variable used without being declared.:

$Octave = GUICtrlCreateInput("1", 368, 123, 35, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY,$ES_NUMBER))

$Octave = GUICtrlCreateInput("1", 368, 123, 35, 21, BitOR(^ ERROR

Any ideas, I would love to get this working with the mario tune via the internal pc speaker.

Thanks,

Managed to figure out that you have to put the tune within the code to work.

However, the tune only plays through my Soundcard speakers and not the internal PC speaker.

Can anyone tell me how to get it to work through the internal speaker please?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...