本帖最后由 kisyan 于 2010-8-28 14:16 编辑 Func frequency($scale,$melody="C")
If $scale="0" Then Return 0
If $melody="C" Then
Switch $scale
Case "1"
Return 264
Case "2"
Return 297
Case "3"
Return 330
Case "4"
Return 352
Case "5"
Return 396
Case "6"
Return 440
Case "7"
Return 495
EndSwitch
ElseIf $melody="D" Then
Switch $scale
Case "1"
Return 297
Case "2"
Return 334
Case "3"
Return 371
Case "4"
Return 396
Case "5"
Return 446
Case "6"
Return 495
Case "7"
Return 557
EndSwitch
EndIf
SetError(1)
EndFunc
Func book($book,$speed=500,$melody="c")
For $s=1 To StringLen($book)
$frequency=frequency(StringMid($book,$s,1),$melody)
If @error Then ContinueLoop
$Duration=$speed
Switch StringMid($book,$s+1,1)
Case "H"
$frequency=frequency(StringMid($book,$s,1),$melody)*2
Case "L"
$frequency=frequency(StringMid($book,$s,1),$melody)/2
Case "Q"
$Duration=$speed/2
Case "S"
$Duration=$speed*2
EndSwitch
If $frequency=0 Then
Sleep($speed)
Else
Beep($frequency,$Duration)
EndIf
Next
EndFunc
book("12311231345034505Q6Q5Q4Q315Q6Q5Q4Q3126L1026L1",300,"D")
|