B4A Library Audio library v1.2 - Beeper

Status
Not open for further replies.
Audio library was updated and it now supports generating "beep" sounds.

B4X:
Dim b As Beeper
b.Initialize(300, 500) '300 milliseconds, 500 hz
b.Beep
Once the object is initialized you can reuse it and play it multiple times.
Documentation: http://www.b4x.com/android/help/audio.html

Installation instructions:
- Download the attached file.
- Copy both files to the internal libraries folder: C:\Program Files\Anywhere Software\Basic4android\Libraries
 

Attachments

  • Audio.zip
    16.8 KB · Views: 1,936

Ottilein

New Member
Thanks Erel,

works really fine...

I wonder if there is a workaround if you want to play the tone continously without predifined duration, e.g. the tone starts while the user holds the thouch screen and tone stops when the touch screen is released...?

Regards,

Otti
 

Gigatron

Member
Licensed User
Longtime User
Thank EREL

Like said Ottilein it's possible like this:

B As Beeper
b.Initialize

x,duration as int
if x>300 then
b.Beep(duration, x) '300 millisecondes, 500 Hz
end if

Thanks
 
Last edited:

jota

Active Member
Licensed User
Longtime User
What is the maximum frequency at which the sound can be issued?
------------------------------------------------------------------
¿cual es la frecuencia maxima a la que se puede emitir el sonido?
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Is there any chance of getting a Volume parameter added to the Beeper class? Either in the Beep function call as in:
Dim b as Beeper
b.Initialize(500, 440)
b.Beep(.5)

or in another initialization, as in:
Dim b as Beeper
b.Initialize3(500, 440, .5)
b.Beep

This would allow us to construct arbitrary waveforms by creating an array of Beeper objects with the appropriate relative amplitudes as specified by the waveform's Fourier coefficients. Playing the waveform would then be a simple matter of calling the Beep member function for each element of the array in rapid succession.

I would even be happy to write and upload a Waveform class that allows the programmer to create and play square waves, saw tooth waves, sharktooth waves, and arbitrary programmer-specified waveforms. All I need is a Volume parameter in the Beeper object.

Thanks,
Royce
 

Roycefer

Well-Known Member
Licensed User
Longtime User
That sets the overall volume, not the volume of an individual Beeper object. I can't, for example, play two simultaneous Beeper objects at two different volumes.
 

stevel05

Expert
Licensed User
Longtime User
a simple matter of calling the Beep member function for each element of the array in rapid succession.

You may be better using the SoundPool Library, or manipulating the sounds directly using the Audiotrack library. There is a limit to the number of beeper objects that can be created at once, about 20 if I remember correctly.
 

DrWave

Member
Licensed User
Longtime User
making audio tones

I followed this thread and while I can make a tone on a Samsung S3 using beep it is not clear how to make a sound that it sustained until changed. I want to generate sounds of different frequency depending on the tilt of the phone (using the internal gyro's etc).

Thanks as always. B4A 1.8 audio library 1.3
 

DrWave

Member
Licensed User
Longtime User
Ah. but say you start a beep with a 1000 ms duration and 500Hz. Now 200ms later you start the same beep again with a duration of 1000ms at say 800Hz. Will the first beep stop at 200ms and start the next one ? This way you could have a timer updating every 200ms starting the beep with different frequencies depending on the tilt angle.

Alternatively you could have an array of beeper each of duration 200ms and different frequencies corresponding to increasing tilt angle. Then again using a 200mS timer trigger the appropriate one.


Think this is possible ? Which idea is a better choice ?

Thanks.
 

MikeH

Well-Known Member
Licensed User
Longtime User
Hello, my first post, thanks for a great program.

If I run:

B4X:
Dim b As Beeper
b.Initialize(300, 440)
b.Beep

This should produce a note of 440hz. However, on my ViewPad7 it produces 444.3hz. I have tried other frequencies and find it is (nearly) always high/sharp.

For example:
500 = 500hz, 480 = 500hz, 470 = 470hz, 410 = 421hz, 280 = 285hz, 220 = 222hz.

I could adjust if it were consistent but sadly, it isnt.

I wrote a little test app to play a user selected frequency - BeepFreq.

Is this something I am doing wrong?
 

Attachments

  • BeepFreq.zip
    7.2 KB · Views: 444
Status
Not open for further replies.
Top