Hi people !
I want to create a morse code aplication , but I don't no how generate a sound . The Beep function it's not good .
Thanks for any sugestion.
Mike
Try the beep API...
[tt]
Public Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
[/tt]
This allows you to set the tone and the duration of the beep of which in your case the duration of the beep is what you are looking for. May I also suggest the Sleep API...
[tt]
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
[/tt]
that you can use to keep the time between beeps pretty constant.
here is some code that demonstrates the beep API:-
its also a useful tool im your a musician
(PS i am not jolyon bloomfield)
you will need 3 combos(cmboDec,cmboNote,cmboOct) 1 textbox(text1) 2 labels (label1, label5) 2 buttons(command1, command2)
Option Explicit
'
' Written By Jolyon Bloomfield January 2001
' Frequency Calculator - Used to calculate frequencies for notes of a set pitch
' If you find this useful, thank somebody, long ago, for telling me the formula.
'
' Use this as you wish, just don't claim it as yours, which it is not.
'
' I hopy you enjoy it.
' Jolyon Bloomfield
' ICQ UIN: 11084041 E-mail: Jolyon_B@Hotmail.Com
'
Private Declare Function Beep Lib "kernel32" ( _
ByVal dwFreq As Long, _
ByVal dwDuration As Long _
) As Long
Private Const A1 = 55
Private Sub cmboDec_Click()
Calculate
End Sub
Private Sub cmboNote_Click()
Calculate
End Sub
Private Sub cmboOct_Click()
Calculate
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Calculate
End Sub
Private Sub Form_Load()
Dim I As Integer
For I = 1 To 8
cmboOct.AddItem I
Next I
cmboOct.ListIndex = 3
For I = 0 To 10
cmboDec.AddItem I
Next I
cmboDec.ListIndex = 3
With cmboNote
.AddItem "A"
.AddItem "Bb"
.AddItem "B"
.AddItem "C"
.AddItem "Db"
.AddItem "D"
.AddItem "Eb"
.AddItem "E"
.AddItem "F"
.AddItem "F#"
.AddItem "G"
.AddItem "Ab"
.ListIndex = 3
End With
End Sub
Private Sub Calculate()
If cmboOct.ListIndex = -1 Or cmboNote.ListIndex = -1 Or cmboDec.ListIndex = -1 Then Exit Sub
Dim Temp As Double
Dim Temp2 As String
Dim returned
Temp = A1 * (2 ^ (cmboOct.ListIndex))
Temp = Temp * (2 ^ ((cmboNote.ListIndex) / 12))
Temp2 = Format(Temp, "#." & String(cmboDec.ListIndex, "#")
If Right(Temp2, 1) = "." Then Temp2 = Left(Temp2, Len(Temp2) - 1)
Text1.Text = Temp2 & " Hertz"
returned = Beep(CDbl(Temp2), 500)
End Sub
good luck
If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.