B9X Voice Client SDK For Windows

The B9X Voice Client Library For Windows works seamlessly with the Xojo development environment. Just load the provided example project and compile. The B9X Voice Client SDK For Windows includes a DLL and Xojo Module. These are both free of charge and distributable. There are no royalties when used with any purchased version of B9X Voice Server(TM).

To add to your own project you simply include the provided dll next to the xojo project file in the project directory. You add the modVoice module Xojo module to your project by using copy and paste on this module. The below methods can then be called. You can right click the Windows icon in your project and add a ‘Build Setting|Build Step|Copy Files’ and drag the dllvoip.dll file to this window. Click again on the Windows icon and be sure to set the destination to AppParent folder. This way the dll will be copied to the build exe folder when you build your app. The Windows archetitecture should additionally be set to ‘x86 32-bit’. Be sure to additionally set the IP, of the PC running the B9X Voice Server(TM), in the example project.

You can load the sample application, that is a fully functional client, that can be executed on your Windows PC. With 2 PCs and/ or Phones connected to our server, the 2 devices can communicate with each other. If more devices are connected, they can additionally communicate with the group.

The description of the DLL library’s methods and subs are described below:

xSetkey(ByVal key As CString) as Integer – This method sets the key for encryption of the connection to the server.
Parameters:

  • key – This key is required, must be exactly 32 bytes long, and must be identical to the key set at the server.

Returns: none

xClearKey as Integer – This method clears the key. The DLL will not be able to connect to the server if the key is cleared.
Parameters:
None.

Returns: none

xConnect(ByVal hst as CString, ByVal port as integer, ByVal srcPort as integer, ByVal pw as CString) As Integer- This method connects to the B9X Voice Server(TM). Once connected to the server, real time audio chat with other clients can take place.
Parameters:

  • hst – the the host or ip address of the Windows machine running B9X Voice Server(TM)
  • port – the port number of the instance of B9X Voice Server(TM)
  • srcPort – the port number this app is listening on.
  • pw – The password is required. The server has two passwords to set. The Admin Password, at the server, allows for both voice chat and broadcast messages. The Password, at the server, allows only voice chat.

Returns: “[CONNECT_OK]” – a successful connection was established with the server. This value is returned by calling xGetMsg.

xClose As Integer – This method closes the previous xConnect to the B9X Voice Server(TM). Once vClose is called, real time audio chat with other stops.
Parameters: none

Returns: “[CLOSE_OK]” – a current connection, with the server, is now closed. This value is returned by calling xGetMsg.

xBroadcast(ByVal msg as CString) As Integer – This method will send text to the server and any of its connected clients. You must have previously connected to the server with the Admin Password that was set at the server.
Parameters:

  • msg – this method will send text to the server and any of its connected clients. You must have previously connected to the server with the Admin Password that was set at the server.

Returns: “[BCAST_OK]” – the text provided in msg was successfully sent to server and broadcasted to server connected clients. This value is returned by calling xGetMsg.

xStartListening(listenPort as integer, deviceID as integer, samplesPerSecond as integer, channels as integer, bitsPerSample as integer) As Integer – This method sets the port number that your app will listen on. This port will receive the audio and broadcast messages from the server.
Parameters:

  • listenPort – The port number this client will listen on and sets the audio format of sent audio and received audio. This port number must be unique and cannot be a reserved or well established UDP ports. This port cannot be the same as the port set at the server.
  • deviceID – the soundcard’s device number.Set to zero for the default sound card
  • samplesPerSecond – at this time, 11025 samples per second is the only supported sample rate available.
  • channels – at this time, 2 channels is the only supported channels available.
  • bitsPerSample – at this time, 16 bits is the only supported sample size available.

Returns:

When audio arrives:

“[VOICE_RECEIVE_ON][ip][port]” – voice audio was received from the server, at the server’s ip and port(from any of the connected clients at the server).
“[VOICE_RECEIVE_OFF]” – receiving voice audio stopped.
These values are returned by calling xGetMsg.

xStopListening As Integer – This method will stop your app from listening for audio and status messages.
Parameters: none

Returns: none.

xStartSending As Integer – This method will stop sending audio to the server and any connected clients at the server.
Parameters: none

Returns: “[START_SENDING]” – the xStartSending method was invoked. This value is returned by calling xGetMsg.

xStopSending As Integer – This method will stop sending audio to the server and any connected clients at the server. At some point, xStopSending must be called otherwise audio from the PC’s mic audio will continue to be sent to the server and its connected clients.
Parameters: none

Returns: “[STOP_SENDING]” – the xStopSending method was invoked. This value is returned by calling xGetMsg.

xGetNthField(findex as integer, evtData as string) As String – This method will return the nth field of a string with square bracketed delimited data.
Parameters:
fIndex – the field number. Starts at 1.
evtData – the string to search.

Returns:

Example: A string such as s=[VOICE_RECEIVE_ON][192.168.1.1][20000]
a=xGetNthField(2, s) will return a string value for ‘a’ of “192.168.1.1”

xMsgReady As Integer – returns 1 if a message is waiting or 0 if there are no messages waiting.

xGetMsg(msg As Ptr) As Integer – this method will retrieve the oldest pending message. The message received will have square bracketed delimited data or less than/greater than brackets.
Example(this method can be called in a timer’s action event where Action event occurs about every 100ms or more):

Var msg as new memoryblock(256)
Var s as string

If xIsMsgReady() = 1 Then
  Call xGetMsg(msg)
  s=msg.CString(0)
  lstevents.AddRow(s)
End If


Parameters:
msg – a memory block to fill with the retrieved message.
Additional messages not defined above are:

“[VOX_TRIGGER_ON]” – the voice from the mic was triggered.
“[VOX_TRIGGER_OFF]” – the voice from the mic stopped.
“[PING]” – this string is sent periodically by the server to this client indicating an active connection to the server.

References And Disclaimer

B9X Electronics

Website: https://b9xelectronics.com

B9X Voice Server™ and B9X Voice Client™ are trademarks of B9X Electronics.

Windows™ is a trademark of Microsoft Corporation.

Xojo™ is a trademark of Xojo Corporation.

B4A™ is a trademark of Anywhere Software.

Android™ and Google™ are trademarks of Google.

Yaesu™ and products mentioned are trademarks of Yaesu/Vertex Standard.

Icom™ and products mentioned are trademarks of Icom.

All other references are trademarks and copyrights of their respective holders.

The specifications in this document are only given to provide information, without any guarantee in regards to either mistakes or omissions. B9X Electronics reserves the right to make changes to the products contained in this publication for any reason.

IN NO EVENT WILL B9X ELECTRONICS BE LIABLE TO YOU OR ANYONE FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO INJURY TO PERSON OR PRODUCT, LOST PROFITS, LEGAL COSTS, LOST SAVINGS, OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS AND ANY OF OUR PRODUCTS.