Hi!
I need to use my computer speaker /no sound card/. Like PLAY or SOUND in QBasic, sending wav files to it too. I think it can be done trough OUT commands, but I don't know how.
------------------
Thanks,
John, 14 years old
Printable View
Hi!
I need to use my computer speaker /no sound card/. Like PLAY or SOUND in QBasic, sending wav files to it too. I think it can be done trough OUT commands, but I don't know how.
------------------
Thanks,
John, 14 years old
Your correct! You can access the speaker of your PC through an address and play various frequency notes. In fact, I believe its address is 61H, but I could be wrong.
Problem: VB does not ship with any direct Out commands.
You can download an I/O port library from www.lvr.com/parport.htm. There are many free utilities there that will allow you to use in and out.
------------------
HTH,
Philip
[email protected]
Better yet, here's some code :)
In the module, put this:
Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer
note: you need to get this file from the address PhilipG gave you.
In the form, put a two command buttons and a horizontal scroll bar. Command1 is Stop, and command two is Go. The scroll bar changes the frequency, and is limited to >37. The code:
Private Sub Sounds(Freq)
Dim LoByte As Integer
Dim HiByte As Integer
Dim Clicks As Integer
Dim SpkrOn As Integer
Clicks = CInt(1193280 / Freq)
LoByte = Clicks And &HFF
HiByte = Clicks \ 256
vbOut 67, 182
vbOut 66, LoByte
vbOut 66, HiByte
SpkrOn = vbInp(97) Or &H3
vbOut 97, SpkrOn
End Sub
Private Sub Command1_Click()
vbOut 97, 0
End Sub
Private Sub Command2_Click()
Freq = HScroll1.Value
Sounds Freq
End Sub
Private Sub HScroll1_Change()
Freq = HScroll1.Value
Sounds Freq
End Sub
Private Sub HScroll1_Scroll()
Freq = HScroll1.Value
Sounds Freq
End Sub
I believe that should do it for you. If it doesn't work, post.
bob
Hey!
Thank you very much, it works perfect. Now, is possible to send a wave file to the speaker? [Square signal isn't the best way to reproduce the sound].
PS: Note, .txt wave files (from GoldWave) are good way to start, aren't?
------------------
Thanks,
John, 14 years old