Beep function real time tone adjustment

geo77

New Member
Joined
May 26, 2009
Messages
31
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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

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
Back
Top