Skip to content

Commit 6a98cc1

Browse files
committed
Concurrency for RP2040
1 parent 65b5b20 commit 6a98cc1

File tree

32 files changed

+774
-345
lines changed

32 files changed

+774
-345
lines changed

examples/examples-communication/a2dp/basic-player-a2dp/basic-player-a2dp.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const char* ext="mp3";
2323
AudioSourceSDFAT source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS);
2424
MP3DecoderHelix decoder;
2525
//Setup of synchronized buffer
26-
SynchronizedNBuffer<uint8_t> buffer(buffer_size,buffer_count, portMAX_DELAY, 10);
26+
SynchronizedNBuffer buffer(buffer_size,buffer_count, portMAX_DELAY, 10);
2727
QueueStream<uint8_t> out(buffer); // convert Buffer to Stream
2828
AudioPlayer player(source, out, decoder);
2929
BluetoothA2DPSource a2dp;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @file streams-url_mp3-out.ino
3+
* @author Phil Schatzmann
4+
* @brief decode MP3 stream from url and output it with the help of PWM
5+
* @version 0.1
6+
* @date 2021-96-25
7+
*
8+
* @copyright Copyright (c) 2021
9+
*/
10+
11+
// install https://github.com/pschatzmann/arduino-libhelix.git
12+
13+
#include "AudioTools.h"
14+
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
15+
16+
17+
URLStream url("ssid","password");
18+
PWMAudioOutput out; // final output of decoded stream
19+
EncodedAudioStream dec(&out, new MP3DecoderHelix()); // Decoding stream
20+
StreamCopy copier(dec, url); // copy url to decoder
21+
22+
23+
void setup(){
24+
Serial.begin(115200);
25+
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
26+
27+
// setup out
28+
auto config = out.defaultConfig(TX_MODE);
29+
//config.resolution = 8; // must be between 8 and 11 -> drives pwm frequency (8 is default)
30+
// alternative 1
31+
//config.start_pin = 3;
32+
// alternative 2
33+
int pins[] = {22, 23};
34+
// alternative 3
35+
//Pins pins = {3};
36+
//config.setPins(pins);
37+
out.begin(config);
38+
39+
// setup I2S based on sampling rate provided by decoder
40+
dec.begin();
41+
42+
// mp3 radio
43+
url.begin("http://stream.srg-ssr.ch/m/rsj/mp3_128","audio/mp3");
44+
45+
}
46+
47+
void loop(){
48+
copier.copy();
49+
}

examples/tests/basic/test-queue/test-queue.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "AudioTools.h"
22
#include "AudioTools/Concurrency/QueueLockFree.h"
3-
#include "AudioTools/Concurrency/QueueRTOS.h"
3+
#include "AudioTools/Concurrency/RTOS/QueueRTOS.h"
44

55
// test different queue implementations:
66

examples/tests/concurrency/BufferRTOS/BufferRTOS.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*/
1111
#include "AudioTools.h"
12-
#include "AudioTools/AudioLibs/Concurrency.h"
12+
#include "AudioTools/Concurrency/RTOS.h"
1313

1414
BufferRTOS<int16_t> buffer(512 * 10);
1515

examples/tests/concurrency/NBuffer/NBuffer.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*
1010
*/
1111
#include "AudioTools.h"
12-
#include "AudioTools/AudioLibs/Concurrency.h"
1312

1413
NBuffer<int16_t> buffer(512, 4);
1514

examples/tests/concurrency/SynchronizedNBuffer/SynchronizedNBuffer.ino

Lines changed: 0 additions & 67 deletions
This file was deleted.

examples/tests/concurrency/audio-test/audio-test.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

22
#include "AudioTools.h"
33
#include "AudioTools/AudioLibs/AudioBoardStream.h"
4-
#include "AudioTools/AudioLibs/Concurrency.h"
4+
#include "AudioTools/Concurrency/RTOS.h"
55

66
AudioInfo info(44100, 2, 16);
77
// source and sink
88
SineWaveGenerator<int16_t> sineWave(32000);
99
GeneratedSoundStream<int16_t> sound(sineWave);
1010
AudioBoardStream out(AudioKitEs8388V1);
1111
// queue
12-
// SynchronizedNBuffer<uint8_t> buffer(1024, 10);
12+
// SynchronizedNBuffer buffer(1024, 10);
1313
BufferRTOS<uint8_t> buffer(1024 * 10);
1414
QueueStream<uint8_t> queue(buffer);
1515
// copy

examples/tests/concurrency/synchNBuffer/synchNBuffer.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*
1010
*/
1111
#include "AudioTools.h"
12-
#include "AudioTools/AudioLibs/Concurrency.h"
12+
#include "AudioTools/Concurrency/RTOS.h"
1313

14-
audio_tools::Mutex mutex;
14+
MutexRTOS mutex;
1515
NBuffer<int16_t> nbuffer(512, 10);
1616
SynchronizedBuffer<int16_t> buffer(nbuffer, mutex);
1717

examples/tests/concurrency/synchRingBuffer/synchRingBuffer.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*
1010
*/
1111
#include "AudioTools.h"
12-
#include "AudioTools/AudioLibs/Concurrency.h"
12+
#include "AudioTools/Concurrency/RTOS.h"
1313

14-
audio_tools::Mutex mutex;
14+
MutexRTOS mutex;
1515
RingBuffer<int16_t> nbuffer(512 * 4);
1616
SynchronizedBuffer<int16_t> buffer(nbuffer, mutex);
1717

examples/tests/performance/mp3-SynchronizedNBuffer/mp3-SynchronizedNBuffer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const char *startFilePath = "/";
2121
const char *ext = "mp3";
2222
AudioSourceSDFAT source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS);
2323
MP3DecoderHelix decoder;
24-
SynchronizedNBuffer<uint8_t> buffer(buffer_size, buffer_count, portMAX_DELAY,
24+
SynchronizedNBuffer buffer(buffer_size, buffer_count, portMAX_DELAY,
2525
10);
2626
QueueStream<uint8_t> out(buffer); // convert Buffer to Stream
2727
AudioPlayer player(source, out, decoder);

0 commit comments

Comments
 (0)