Filling pipeline with software generate sine wave

colinives
Posts: 37
Joined: Tue Mar 03, 2020 2:53 pm

Filling pipeline with software generate sine wave

Postby colinives » Thu Mar 05, 2020 3:37 pm

Hi there,

I'm looking at as many examples I can but can't find the trick. My application needs to provide users with alternating tones in each ear via bluetooth. I think I've sorted the A2DP part with audio files but need to create tones 'on the fly' with varying frequencies which I plan to create with is DDS sine wave generator. I expect to feed a ring buffer with generated stereo samples assuming downstream decoding at 44100 16bits/sample but don't know how to feed the input stream.

Any pointers gratefully received.

Thanks

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Filling pipeline with software generate sine wave

Postby ESP_Sprite » Fri Mar 06, 2020 8:44 am

You could modify this example: https://github.com/espressif/esp-idf/tr ... 2dp_source

The audio is generated in this function, so you could just replace that by a read from a queue or ring buffer. Have another task push the sine wave data into this queue/ringbuffer and you're done.

colinives
Posts: 37
Joined: Tue Mar 03, 2020 2:53 pm

Re: Filling pipeline with software generate sine wave

Postby colinives » Sat Mar 07, 2020 8:19 pm

Thank you so much for your reply,

I guess I missed it as it doesn’t use a pipeline/stream.

Can I assume that the format is:

Sample Rate: 44100
Data size: 16 bits
Format: L-R. 16 bit little-endian?

Thank you again.

Colin

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Filling pipeline with software generate sine wave

Postby ESP_Sprite » Mon Mar 09, 2020 9:56 am

From the existing function, it seems the samples are 16-bit little endian, but I'm not familiar enough with that code to tell you more about the other parameters, sorry.

colinives
Posts: 37
Joined: Tue Mar 03, 2020 2:53 pm

Re: Filling pipeline with software generate sine wave

Postby colinives » Tue Mar 10, 2020 10:33 am

Thank you.

I can confirm that I have success delivering various tones to standard A2Dp headset at a sample rate of 44100.

The big problem now is that the after 110 seconds from connecting the A2DP disconnects - then reconnects for another 110 seconds and repeats. I have looked around the code and cannot find any built-in time limit lined to the a2dp source example. Is there a limit built in somewhere for the example code?

Thank you.

julienD
Posts: 32
Joined: Fri Sep 13, 2019 12:38 pm

Re: Filling pipeline with software generate sine wave

Postby julienD » Sun Feb 05, 2023 5:08 pm

Hello,

Did you find some solution to this timeout?

Thanks
Julien

Who is online

Users browsing this forum: No registered users and 36 guests