Help with I2S to A2DP #1410
-
Hey, first thanks for this awesome resource. I am lost in how to utilize different streams together and was hoping for some help. I have a ESP32 with I2S mic input, and I have a working sketch to transmit I2s input to A2DP. The targeted sounds I am attempting to auscultate are bettween 200 Hz to 2000 Hz, which aren't picked up well by a mems microphone. So I wanted to incorporate volume stream to allow boost to increase volume of I2S source as well as apply a low pass filter to filter frequencies >5kHz. I have tried incorporating a Volume Stream and a FilteredStream seperately at first, both of which aren't working as expected. First the volume stream, I get appropriate sounds through A2DP but altering volume value has no effect. bool allow_boost = true; int32_t get_sound_data(Frame* data, int32_t frameCount) { // Arduino Setup // setup conversion // start i2s input with default configuration
volume.begin(cfg); // we need to provide the bits_per_sample and channels // start the bluetooth Serial.println("A2DP started"); a2dp_source.set_volume(255); // Arduino loop - repeated processing Then the filtered stream, which does not produce any audio through A2DP, although it complies correctly and I can connect to bluetooth, I don't get any audio when connected. #include "AudioTools.h" AudioInfo info32(44100, 1, 32); FormatConverterStream conv(out); int32_t get_sound_data(Frame* data, int32_t frameCount) { FilteredStream<int32_t, float> filtered(in, info32.channels); // Assuming your filter has 64 coefficients // define FIR filter parameters // Arduino Setup // setup filters for all available channels // setup conversion // start i2s input with default configuration // start the bluetooth Serial.println("A2DP started"); a2dp_source.set_volume(255); // Arduino loop - repeated processing |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
No, it's not working like this. You need to build a chain: e.g. I2SStream -> FormatConverterStream -> ConverterStream -> VolumeStream -> FilteredStream. In each constructor you indicate the source. No copy is needed/allowed in this chain. The good thing is that you can build and test this step by step |
Beta Was this translation helpful? Give feedback.
-
Double check the bit sizes at each step: You define volume to be 32 bits, but after the conversion it's 16 |
Beta Was this translation helpful? Give feedback.
No, it's not working like this. You need to build a chain: e.g. I2SStream -> FormatConverterStream -> ConverterStream -> VolumeStream -> FilteredStream. In each constructor you indicate the source.
And the callback will then just read from the FilteredStream object.
No copy is needed/allowed in this chain.
The good thing is that you can build and test this step by step