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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,795
Office Version
  1. 365
Platform
  1. Windows
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,175,985
Messages
5,900,734
Members
434,848
Latest member
kubersood321

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