# play generated voice stream in a call

**URL:** <https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225>\
**Category:** Legacy FX/FXT series\
**Created:** [May 12, 2009, 9:46am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225 "2009-05-12T09:46:36Z")\
**Posts on this page:** 10\
**Page:** 3

<div class="post-metadata">

**Author:** ![diste](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@diste](https://forum.sierrawireless.com/u/diste)\
**Post date:** [February 3, 2010, 8:43am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/41 "2010-02-03T08:43:45Z")

</div>

> [@](#):
>
> I wonder if there is any common experience about this issue,

yes I have this problem too, when I stream a large amount of data through the serial cable and at the same time play the stream, then the problem occurs continuosly.

> [@](#):
>
> any idea about disabling this behaviour: “sending an empty frame when an Interrupt is missed”?

I suspect that is not possible… ☹

> [@](#):
>
> even an answer to this question: “why a LowIRQLevel Interrupt is missed? or how can I prevent this occurance?”

normally hardware irq’s cannot be ignored, maybe they are multiplexed or they have different priorities? No idea.  
If you have too much IO load the problem occours, I tried to use the cpu boost switch but nothing changes.

Anyway thanks for the question, I am interested too 😉

---

<div class="post-metadata">

**Author:** ![bandali](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bandali](https://forum.sierrawireless.com/u/bandali)\
**Post date:** [February 3, 2010, 7:17pm UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/42 "2010-02-03T19:17:06Z")

</div>

> [@](#):
>
> the problem occurs continuously.

Do you remember how often it occurs?

In my application, it usually occurs in about 5 seconds periods, although not exactly 5 sec! I don’t know if there is a specific cause or not! but I checked it by a toggle pin in IRQ handler and before that, I noticed this issue by monitoring received data in another GSM module.

> [@](#):
>
> normally hardware irq’s cannot be ignored, maybe they are multiplexed or they have different priorities? No idea.

as I checked, low IRQ has the highest priority, even more than wavecom firmware, and actually I tested out different ways to get rid of those lost frames, but nothing achieved yet ☹

> [@](#):
>
> If you have too much IO load the problem occurs

you know, I inactivated all the unnecessary sections in my code and it just remained call\_subscribe() and audio handler for Play audio stream, but the problem still persists!

---

<div class="post-metadata">

**Author:** ![diste](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@diste](https://forum.sierrawireless.com/u/diste)\
**Post date:** [February 15, 2010, 8:06am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/43 "2010-02-15T08:06:08Z")

</div>

> [@bandali](#):
>
> Do you remember how often it occurs?

I cannot give a period yet (never checked), I can only say it happens more often than 5s.

> [@bandali](#):
>
> I inactivated all the unnecessary sections in my code and it just remained call\_subscribe() and audio handler for Play audio stream, but the problem still persists!

mmmhh… it seems we have a different problem… If I preload the audiostream in wavecom memory, then the problem not occours.

---

<div class="post-metadata">

**Author:** ![bandali](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bandali](https://forum.sierrawireless.com/u/bandali)\
**Post date:** [February 16, 2010, 6:48am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/44 "2010-02-16T06:48:51Z")

</div>

unfortunately, I found out that in the sample code (Pcm\_Speak\_and\_Play), if I change the buffer size to save 15 seconds and use a toggle pin as below in LowIRQHandler (audio play stream), there is the same problem about missing frames (in fact, missing toggled signals in interrupt routine) ☹

```auto
// Recorded sound duration in seconds
#define DURATION 15
#define BUFFER_SIZE DURATION * 2 * 8000

s32 OFGpioOut_Handle;
adl_ioDefs_t Gpio_OF_Config = ADL_IO_GPIO | 23 | ADL_IO_DIR_OUT | ADL_IO_LEV_LOW;

bool appPlayLowIrqHandler( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t *Data )
{

	if (adl_ioReadSingle(OFGpioOut_Handle,&Gpio_OF_Config)) {
		adl_ioWriteSingle ( OFGpioOut_Handle, &Gpio_OF_Config, FALSE );
	} else {
		adl_ioWriteSingle ( OFGpioOut_Handle, &Gpio_OF_Config, TRUE );
	}

    // Copy samples from common buffer
    if (!pcm_buf_read(&listen_play_buffer, BufferSizePlay, StreamBufferPlay))
    {
        TRACE (( 1, "appListenLowIrqHandler: buffer underrun"));
        // Call High level handler
        return 1;
    }
    else
    {
        // Set BufferReady flag to TRUE
        *( ( adl_audioStream_t * )Data->SourceData )->BufferReady = TRUE;

        // Do NOT call the high level handler
        return 0;
    }
}
```

any common experience, any idea?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [May 31, 2010, 7:07pm UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/45 "2010-05-31T19:07:15Z")

</div>

> [@diste](#):
>
> For who is interested I opened my small project and now is public on sourceforge at [sourceforge.net/projects/fastrack-voice/](https://sourceforge.net/projects/fastrack-voice/)  
> So other beginner developers like me can look a complex example. I hope can help.

The ‘Files’ area for that project appears to be empty:

 ![](https://us1.discourse-cdn.com/flex025/uploads/sierrawireless/original/2X/6/6906c41708df499f6023f3513dbc98833dc2144e.gif)

---

<div class="post-metadata">

**Author:** ![diste](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@diste](https://forum.sierrawireless.com/u/diste)\
**Post date:** [May 31, 2010, 7:59pm UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/46 "2010-05-31T19:59:33Z")

</div>

Hi,  
yes the file area is empty because I don’t have uploaded any binary package.  
you can still get or browse the sources following the guide at [sourceforge.net/projects/fastrack-voice/develop](http://sourceforge.net/projects/fastrack-voice/develop)

```auto
svn co https://fastrack-voice.svn.sourceforge.net/svnroot/fastrack-voice fastrack-voice
```

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [June 1, 2010, 12:08pm UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/47 "2010-06-01T12:08:24Z")

</div>

> [@davidc](#):
>
> You essentially have to record the audio you want to play as 8kHz or 16kHz, 16bit, signed, Mono PCM, then find a method of loading the raw data onto the Q26xx.

(my emphasis)

But the example in the ADL User guide is un-signed

> [@ADL User Guide for Open AT® OS v6.21](#):
>
> // PCM samples  
> u16 PCM\_Samples[160] = { … , … , … , … , … , … , 0 };

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [June 2, 2010, 1:34am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/48 "2010-06-02T01:34:39Z")

</div>

Hiya,

> [@awneil](#):
>
> 8kHz or 16kHz, 16bit, signed, Mono PCM,

My Bad.

I was referring to the method of recording the audio - i.e. in Audacity I selected 16bit, signed, Mono PCM.

Yes, and when I convert the recorded data to the fixed arrays that I feed to the Audio Stream Play function, I store them as u8 (i.e. unsigned bytes) as it appears that the audio functions reassemble the PCM output correctly and output it to the voice call or speaker.

Sorry about the confusion.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [June 2, 2010, 6:35am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/49 "2010-06-02T06:35:16Z")

</div>

> [@davidc](#):
>
> in Audacity I selected 16bit, signed, Mono PCM.

I use CoolEdit-200 (now Adobe Audition, I beleive).  
It doesn’t have a signed/unsigned option - so I just get whatever it gives me.  
It has the option to save the PCM data to a text file, looking like this:

> [@](#):
>
> SAMPLES: 6000  
> BITSPERSAMPLE: 16  
> CHANNELS: 1  
> SAMPLERATE: 8000  
> NORMALIZED: FALSE  
> -57  
> -83  
> -1  
> -25  
> -36  
> 9  
> -40  
> -5  
> -23  
> -27  
> -45  
> -23  
> 29  
> -27  
> -6  
> 10  
> 4  
> etc…

So its 16-bit data is signed.

> [@](#):
>
> when I convert the recorded data to the fixed arrays that I feed to the Audio Stream Play function, I store them as u8 (i.e. unsigned bytes) as it appears that the audio functions reassemble the PCM output correctly and output it to the voice call or speaker.

I’ve made the above format into s16 arrays, and the PCM output seems to reproduce that faithfully in a voice call!

The sample code seems to be just using u8\* in the old idiom (ie, before void\* was invented) to indicate a “generic” pointer?

> [@davidc also](#):
>
> As it turns out, the PCM format is the same as a mono WAV file, with all the headers stripped off.

My understanding is that 16-bit WAV files do indeed use signed data; eg,

> [@In his blog](#):
>
> For the sample data, it’s important to note that each element of the data array is a signed value – it can be negative, positive or zero.
> 
> [blogs.msdn.com/b/dawate/archive/ … ormat.aspx](http://blogs.msdn.com/b/dawate/archive/2009/06/23/intro-to-audio-programming-part-2-demystifying-the-wav-format.aspx)

see also:  
[wotsit.org/list.asp?al=W](http://www.wotsit.org/list.asp?al=W)  
[support.microsoft.com/kb/89879](http://support.microsoft.com/kb/89879)

> [@](#):
>
> Sorry about the confusion.

None of this messing about would be necessary if Sierra Wireless would just document stuff properly in the first place! 😠😒

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [June 2, 2010, 6:53am UTC](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225/50 "2010-06-02T06:53:11Z")

</div>

Hiya,

> [@awneil](#):
>
> I’ve made the above format into s16 arrays, and the PCM output seems to reproduce that faithfully in a voice call!

I’ve had another look at my code (it was written a while ago!), and I am also feeding \*s16 data to the audioStream() functions. I’m using compression on my raw input PCM, which is why I’m storing the compressed audio data as u8 arrays in program space. I decompress the appropriate amount of raw data in the audio clip event handler. Works fine for me.

> [@awneil](#):
>
> None of this messing about would be necessary if Sierra Wireless would just document stuff properly in the first place! 😠 😒

Absolutely.

ciao, Dave

[Previous page](https://forum.sierrawireless.com/t/play-generated-voice-stream-in-a-call/3225.md?page=2)
