Need help with sounds (beeps)

VITMan

Member
Licensed User
Longtime User
I need to make some beeping type sounds.

I tried doing somthing this.

Dim b1 As Beeper
Dim b2 As Beeper
Dim b3 As Beeper
Dim b4 As Beeper


b1.Initialize(300, 200) 'freq is 200 too low to hear - used as a delay
b2.Initialize(300, 700) 'low note
b3.Initialize(300, 1000) 'med note
b4.Initialize(300, 1200) 'high note


b2.Beep 'low note
b1.Beep 'delay
b3.Beep 'medium note
b1.Beep 'delay
b4.Beep 'high note
b1.Beep 'delay


When run, I only hear one beep and suspect the three notes are being played
simultaneously.

Any ideas ?

Thanks,

VitMan
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Process_Globals
   Dim beepers(3) As Beeper
   Dim currentBeeper As Int
   Dim tmrBeeper As Timer
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      beepers(0).Initialize(300, 700) 'low note
      beepers(1).Initialize(300, 1000) 'med note
      beepers(2).Initialize(300, 1200) 'high note
      tmrBeeper.Initialize("tmrBeeper", 300)
   End If
   Beep
End Sub
Sub Activity_Click
   Beep
End Sub

Sub Beep
   currentBeeper = 0
   tmrBeeper.Enabled = True
End Sub
Sub tmrBeeper_Tick
   If currentBeeper >= beepers.Length Then
      tmrBeeper.Enabled = False
      Return
   End If
   beepers(currentBeeper).Beep
   currentBeeper = currentBeeper + 1
End Sub

Sub Activity_Pause(UserClosed As Boolean)
   
End Sub
 
Upvote 0

VITMan

Member
Licensed User
Longtime User
Thanks Erel

Thanks Erel !

I will try something similar to what you've posted this evening.

VitMan
 
Upvote 0

VITMan

Member
Licensed User
Longtime User
Still doesn't work

Sorry I haven't responded back sooner.

The sound thing still doesn't work the way intended.

I want to generate beeps in a similar fashion as Morse code.

The problem is that they sounds being generated are generated
via interrupt and the beep routine exits immediately even though the
sound continues to sound for a period of time.

This is messing up the timing.

I want to generate a beep for 600ms then silence for 200ms then beep
again for 200ms and then silent for 200ms.

I've tried a lot of different ways to may this work but the beep still exits
immediately.

Are there other beep type sound routines I could use to do this that
I have missed ?

Any help would be most appreciated.

VitMan
 
Upvote 0

VITMan

Member
Licensed User
Longtime User
will try

Sounds kludgy and a long way to go to get a simple beep of a certain length
and delay after but will try anything at this point... lol !

Thanks, Erel.
 
Upvote 0
Top