Beep function real time tone adjustment

geo77

New Member
Joined
May 26, 2009
Messages
30
Hi guys,

I am trying to create simple tunes using the tone genarator. I use:

Sub Beep_1()
DoEvents
Beep a, b
End Sub

I can change a or b only after the sound finishes.
I also used:

Sub Beep_steps()
For i = 1 To 30
DoEvents
[B27] = 200 * i
Beep 200 * i, 400
DoEvents
Next i
End Sub

It sounds crappy (with fairly long irregular gaps between notes). I was wondering if there are some arguments of flags I can use that allow to change frequency while the beep function is playing.

Thanks, George
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,786
No, BEEP is, as you say, 'crappy'. Microsoft chapter & verse on BEEP: http://msdn.microsoft.com/en-us/library/ms679277(v=vs.85).aspx.

One alternative is to play a WAV file:-
Code:
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
  (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
 
Const SND_SYNC = &H0
Const SND_ASYNC = &H1

Sub Noisy()
  sndPlaySound32 "c:\windows\media\windows xp startup.wav", 0&  
End Sub
 

Forum statistics

Threads
1,141,728
Messages
5,708,134
Members
421,548
Latest member
douae

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top