B4i Library B4X GBEBeep

Hello,
This additional library may be used in B4A, B4J and B4i as well. It generates a beep sound.

Name: GBEBeep.b4xlib
Version: 1.0
(C) G. Becker
Licence: Royalty Free for all purpose

For All:
  • Copy library file GBEBeep.b4xlib to the additional files folder. Recommend to use a sub Folder B4X there.
  • Activate the library GBEBeep.
  • Place #IgnoreWarnings: 32 in the Main Module
  • Place Private Beeper as GBEBeep in the Globals Sub.
For B4A:
  • Activate internal Audio library
  • Place Beeper.Initialize(Duration,Frequency) in the Activity or B4XPage_Created Sub
    Duration in Milliseconds, Frequency in Hz

Usage: Beeper.Beep

Notice:
  • B4i Version is not tested due to have no Apple Environment.
  • B4A tested on Samsung S21 and Emulator
  • B4J tested on Windows Desktop
  • B4J and B4i needs not initialization

May I ask for your help to test it in the different Environments. Any comment is wellcommed expecially if it works in B4i. Thankyou.
 

Attachments

  • GBEBeep.b4xlib
    543 bytes · Views: 4

hatzisn

Expert
Licensed User
Longtime User
Hi... Thank you for your work.

I read in your post "For B4A Activate Audio Library"... You can add this functionality directly in your library by adding a manifext.txt file containing the following code mentioning the corresponding libraries needed, seperated with comas for each platform. If the needed libraries are b4xlibs then you add as it shows in the libraries tab with the extension also (MyLibrary.b4xlib). If no libraries are needed for a specific platform then write only f.e. "B4i.DependsOn=". F.e.:

manifest.txt incredients:
VERSION=1.00
B4A.DependsOn=JSON
B4i.DependsOn=iJSON
B4J.DependsOn=JSON
 
Last edited:

hatzisn

Expert
Licensed User
Longtime User
Hello,
This additional library may be used in B4A, B4J and B4i as well. It generates a beep sound.

Name: GBEBeep.b4xlib
Version: 1.0
(C) G. Becker
Licence: Royalty Free for all purpose

For All:
  • Copy library file GBEBeep.b4xlib to the additional files folder. Recommend to use a sub Folder B4X there.
  • Activate the library GBEBeep.
  • Place #IgnoreWarnings: 32 in the Main Module
  • Place Private Beeper as GBEBeep in the Globals Sub.
For B4A:
  • Activate internal Audio library
  • Place Beeper.Initialize(Duration,Frequency) in the Activity or B4XPage_Created Sub
    Duration in Milliseconds, Frequency in Hz

Usage: Beeper.Beep

Notice:
  • B4i Version is not tested due to have no Apple Environment.
  • B4A tested on Samsung S21 and Emulator
  • B4J tested on Windows Desktop
  • B4J and B4i needs not initialization

May I ask for your help to test it in the different Environments. Any comment is wellcommed expecially if it works in B4i. Thankyou.

Also change your code into this because the way it was there was not an initialize sub in B4J and B4i (your code works also in b4i this way) :

B4X:
Private Sub Class_Globals
    #if B4A
        Dim beeper As Beeper
    #End If
End Sub

Sub Initialize

End Sub

#if B4A
    Sub SetBeeper(Duration As Int, Frequency As Int)
        beeper.Initialize(300,300)
    End Sub

    Sub Beep
        beeper.beep
    End Sub
#else if B4J
    Sub Beep
        Dim jo As JavaObject = Me
        jo.RunMethod("beep", Null)
    End Sub

    #if Java
    public static void beep() {
        java.awt.Toolkit.getDefaultToolkit().beep();
    }
    #End If
#else if B4i
    Sub Beep
        Dim NativeMe As NativeObject = Me
        NativeMe.RunMethod("beep", Null)
    End Sub

    #If ObjC
    #import <AVFoundation/AVAudioPlayer.h>
    - (void) beep {
      AudioServicesPlaySystemSound(1302);
    }
    #End If
#end if
 
Last edited:
Top