Audio data streaming in SDK

If you want to process incoming audio data using the SDK there are basically three options: 

  1. Using DivaRecordVoiceFile() you can automatically record data to an audio file in the background. This function allows you to set a maximum record time, and also can do data conversion for you. In ISDN the line data is coded into 8-bit samples of A-Law or mu-Law data, arriving at a rate of 8000 per second. Generally, mu-Law is used by the US and Japan, where A-Law is used in the rest of the world. This can be converted on-the-fly to 8 or 16-bit PCM format, and can be written either raw (samples only) or as a standard Microsoft WAV files.

  2. If you just want to receive the raw stream of A-Law (or mu-Law) samples off the line, then this can be done using the call DivaReceiveData(). To use this method, you need to process the event DivaEventDataAvailable, which tells you when there is data to read, and how many bytes are available. On receiving this event, make a call to DivaReceiveData() to transfer the data to your buffer. 

  3. Similarly, using DivaReceiveAudio() you can capture the audio stream directly into a memory buffer. The advantage over DivaReceiveData() is that (as with DivaRecordVoiceFile()) the format can be changed on-the-fly to PCM and/or WAV. To use this technique, process the DivaEventDataAvailable event, and use this to trigger the call to DivaReceiveAudio() to copy (and optionally translate) the available data into your buffer.

 

Return to Documentation Home I Return to Sangoma Support