Android Question Audio Library - Beeper - Duration

Discussion in 'Android Questions' started by Horst Leistner, Apr 22, 2017.

  1. Horst Leistner

    Horst Leistner Member Licensed User


    I want to create short pulses of 19kHz and with a duration shorter than 1ms.
    Currently I do that by making a wav-file, save it and play it by MP3.
    Is there a possibility to modify the Beeper function to generate pulses shorter than 1ms?
    Maybe it would be helpfull for me to get the source code of the Audio Library.

    Best regards
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should use AudioStreamer for that.

    Put this code in the Starter service:
    Sub Process_Globals
    Private streamer As AudioStreamer
    End Sub

    Sub Service_Create
    "streamer"8000True16, streamer.VOLUME_MUSIC)
    End Sub

    Public Sub Beep (DurationMs As Double, Frequency As Int)
    Dim sampleRate As Int = 8000
    Dim numSamples As Int = sampleRate * DurationMs / 1000
    Dim gsnd(2 * numSamples) As Byte
    For i = 0 To numSamples - 1
    Dim d As Double = Sin(2 * cPI * i / (sampleRate / Frequency))
    Dim val As Short = d * 32767
    2 * i) = Bit.And(val, 0x00ff)
    2 * i + 1) = Bit.UnsignedShiftRight(Bit.And(val, 0xff00), 8)
    End Sub
    You can then call it with:
    CallSub3(Starter, "Beep"1000400)
  3. Horst Leistner

    Horst Leistner Member Licensed User

    Thank you very much, Erel. Each time I use it I am exited with this development tool! Due to my Seagrave book I am sure to understand your piece of code within the next hours.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice