Added USE_A2DP to examples

This commit is contained in:
Phil Schatzmann 2021-10-20 10:17:59 +02:00
parent 4b4a8b73d2
commit b1f3037842
20 changed files with 57 additions and 18 deletions

View File

@ -7,6 +7,9 @@
* @copyright GPLv3
*
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "BluetoothA2DPSource.h"
#include "AudioTools.h"

View File

@ -7,6 +7,9 @@
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "BluetoothA2DPSource.h"
#include "AudioTools.h"

View File

@ -7,6 +7,9 @@
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include <SPI.h>
#include <SD.h>
#include "AudioFileSourceSD.h"

View File

@ -7,6 +7,9 @@
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "BluetoothA2DPSource.h"
#include <SPI.h>
#include <SD.h>

View File

@ -7,6 +7,8 @@
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "AudioTools.h"

View File

@ -9,12 +9,11 @@
#include "Arduino.h"
#include "AudioTools.h"
#include "BluetoothA2DPSource.h"
using namespace audio_tools;
/**
* @brief We use I2S as input and send the data to A2DP
* @brief We use I2S as input
* To test we use a INMP441 microphone.
*/

View File

@ -1,3 +1,6 @@
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include <SPI.h>
#include <SD.h>

View File

@ -7,6 +7,9 @@
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include <AudioFileSourcePROGMEM.h>
#include "AudioGeneratorMIDI.h"
#include "ESP8266AudioSupport.h"

View File

@ -24,7 +24,7 @@ typedef int16_t sound_t; // sound will be repre
uint8_t channels = 2; // The stream will have 2 channels
MozziGenerator mozzi(CONTROL_RATE); // subclass of SoundGenerator
GeneratedSoundStream<sound_t> in(mozzi); // Stream generated with mozzi
UDPStream out; // UDP Output - A2DPStream is a singleton!
UDPStream out; // UDP Output
StreamCopy copier(out, in); // copy in to out
/// Copied from AMsynth.ino

View File

@ -1,5 +1,6 @@
// set this in AudioConfig.h or here after installing https://github.com/pschatzmann/arduino-libhelix.git
#define USE_HELIX
#define USE_A2DP
#include "AudioTools.h"
#include "AudioCodecs/CodecMP3Helix.h"

View File

@ -6,6 +6,9 @@
* @author Phil Schatzmann
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "AudioTools.h"
#include "AudioA2DP.h"

View File

@ -6,6 +6,10 @@
* @author Phil Schatzmann
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "AudioTools.h"
#include "AudioA2DP.h"

View File

@ -7,6 +7,9 @@
* @copyright GPLv3
*
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "AudioTools.h"
#include "AudioA2DP.h"

View File

@ -8,6 +8,9 @@
* @copyright GPLv3
*
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "AudioTools.h"
#include "AudioA2DP.h"

View File

@ -7,16 +7,8 @@
* @copyright GPLv3
*/
/**
* @file streams-i2s-a2dp.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/i2s-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "AudioTools.h"

View File

@ -7,6 +7,10 @@
* @copyright GPLv3
*
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "AudioTools.h"
#include "AudioA2DP.h"
#include "audio.h"

View File

@ -7,6 +7,10 @@
* @copyright GPLv3
*
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#define USE_MOZZI
#include "AudioTools.h"
#include "AudioA2DP.h"
#include "AudioMozzi.h"

View File

@ -7,6 +7,10 @@
* @copyright GPLv3
*
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "AudioTools.h"
#include "AudioA2DP.h"

View File

@ -7,6 +7,8 @@
* @copyright GPLv3
*/
// Add this in your sketch or change the setting in AudioConfig.h
#define USE_A2DP
#include "Arduino.h"
#include "AudioTools.h"

View File

@ -19,7 +19,7 @@
namespace audio_tools {
/**
* @brief Covnerts the data from T src[][2] to a Channels array
* @brief Covnerts the data from T src[][2] to a Frame array
* @author Phil Schatzmann
* @copyright GPLv3
*
@ -34,7 +34,7 @@ class ChannelConverter {
}
// The data is provided as int24_t tgt[][2] but returned as int24_t
void convert(T src[][2], Channels* channels, size_t size) {
void convert(T src[][2], Frame* channels, size_t size) {
for (int i=size; i>0; i--) {
channels[i].channel1 = (*convert_ptr)(src[i][0]);
channels[i].channel2 = (*convert_ptr)(src[i][1]);
@ -53,7 +53,7 @@ RingBuffer<uint8_t> a2dp_buffer(A2DP_BUFFER_SIZE*A2DP_BUFFER_COUNT);
volatile bool is_a2dp_active = false;
// callback used by A2DP to provide the a2dp_source sound data
int32_t a2dp_stream_source_sound_data(Channels* data, int32_t len) {
int32_t a2dp_stream_source_sound_data(Frame* data, int32_t len) {
LOGD("a2dp_stream_source_sound_data: %d", len);
size_t result_len = 0;
// at first call we start with some empty data
@ -66,10 +66,10 @@ int32_t a2dp_stream_source_sound_data(Channels* data, int32_t len) {
is_a2dp_active = true;
}
// the data in the file must be in int16 with 2 channels
size_t result_len_bytes = a2dp_buffer.readArray((uint8_t*)data, len*sizeof(Channels));
size_t result_len_bytes = a2dp_buffer.readArray((uint8_t*)data, len*sizeof(Frame));
// result is in number of frames
result_len = result_len_bytes / sizeof(Channels);
result_len = result_len_bytes / sizeof(Frame);
// Log result
if (AudioLogger::instance().level()==AudioLogger::Debug){