Skip to content

Commit

Permalink
RingBufferFile
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Apr 30, 2023
1 parent bf6995d commit 805cb27
Show file tree
Hide file tree
Showing 16 changed files with 599 additions and 644 deletions.
15 changes: 7 additions & 8 deletions examples/build-examples-log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@
../examples/examples-audiokit/streams-audiokit-sd-audiokit -> rc=0
../examples/examples-audiokit/streams-audiokit-serial -> rc=0
../examples/examples-audiokit/streams-audiokit-tf -> rc=0
../examples/examples-audiokit/streams-audiokit-webserver_aac -> rc=0
../examples/examples-audiokit/streams-audiokit-webserver_mp3 -> rc=0
../examples/examples-audiokit/streams-audiokit-webserver_wav -> rc=0
../examples/examples-audiokit/streams-file_loop-audiokit -> rc=0
../examples/examples-audiokit/streams-generator-audiokit -> rc=0
Expand Down Expand Up @@ -134,7 +132,7 @@
../examples/examples-maximilian/18-DrumMachine -> rc=0
../examples/examples-maximilian/19-Enveloping2 -> rc=0
../examples/examples-maximilian/20-FFT -> rc=0
../examples/examples-tts/streams-azure_tts-i2s.ino -> rc=1
../examples/examples-tts/streams-azure_tts-i2s -> rc=0
../examples/examples-tts/streams-espeak-audiokit -> rc=0
../examples/examples-tts/streams-espeak-i2s -> rc=0
../examples/examples-tts/streams-flite-audiokit -> rc=0
Expand All @@ -147,11 +145,9 @@
../examples/examples-faust/streams-faust_noise-i2s -> rc=0
../examples/examples-faust/streams-generator-faust-i2s -> rc=0
../examples/examples-faust/streams-i2s-faust_guitarix-i2s -> rc=0
../examples/examples-communication/esp-now/communication-espnow-receive -> rc=0
../examples/examples-communication/esp-now/communication-espnow-receive_csv -> rc=0
../examples/examples-communication/esp-now/communication-espnow-receive_measure -> rc=0
../examples/examples-communication/esp-now/communication-espnow-send -> rc=0
../examples/examples-communication/esp-now-codec/* -> rc=1
../examples/examples-communication/esp-now/codec -> rc=1/0
../examples/examples-communication/esp-now/pcm -> rc=1/0
../examples/examples-communication/esp-now/speed-test -> rc=1/0
../examples/examples-communication/ip/communication-ip-receive -> rc=0
../examples/examples-communication/ip/communication-ip-receive_measure -> rc=0
../examples/examples-communication/ip/communication-ip-send -> rc=0
Expand Down Expand Up @@ -182,10 +178,13 @@
../examples/tests/codecs/test-codec-gsm -> rc=0
../examples/tests/codecs/test-codec-iLBC -> rc=0
../examples/tests/codecs/test-codec-lc3 -> rc=0
../examples/tests/codecs/test-codec-ogg -> rc=0
../examples/tests/codecs/test-codec-opus -> rc=0
../examples/tests/codecs/test-codec-opusogg -> rc=0
../examples/tests/codecs/test-codec-sbc -> rc=0
../examples/tests/codecs/test-container-binary -> rc=0
../examples/tests/codecs/test-mp3-helix -> rc=0
../examples/tests/codecs/test-mp3-helix-reading -> rc=0
../examples/tests/codecs/test-mp3-mad -> rc=0
../examples/tests/concurrency/NBuffer -> rc=0
../examples/tests/concurrency/synchBufferRTOS -> rc=0
Expand Down
6 changes: 3 additions & 3 deletions examples/build-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ compile_example "esp32:esp32:esp32" "../examples/examples-audiokit/*"
compile_example "esp32:esp32:esp32" "../examples/examples-maximilian/*"
compile_example "esp32:esp32:esp32" "../examples/examples-tts/streams*"
compile_example "esp32:esp32:esp32" "../examples/examples-faust/streams*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/codec"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/pcm"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/speed-test"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/codec/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/pcm/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/esp-now/speed-test/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/ip/*"
compile_example "esp32:esp32:esp32" "../examples/examples-communication/rtsp/*"
compile_example "esp32:esp32:esp32" "../examples/tests/test*"
Expand Down
3 changes: 2 additions & 1 deletion examples/sandbox/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

These folder contains some work in progress, experiments and tests, so do not expect them to work.
These folder contains some work in progress, experiments and tests, so do not expect them to work!

But it might still serve as a source of inspiration...
89 changes: 89 additions & 0 deletions examples/tests/buffers/test-ringbufferfile/test-ringbufferfile.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @file test-ringbufferfile.ino
* @author Phil Schatzmann
* @brief genTest for the file backed ringbuffer
* @version 0.1
* @date 2023-04-30
*
* @copyright Copyright (c) 2022
*
*/
/**
* Test for the file backed ringbuffer
*/
#include "AudioTools.h"
#include <SdFat.h>
// SD pins
#define PIN_SD_CARD_CS 13
#define PIN_SD_CARD_MISO 2
#define PIN_SD_CARD_MOSI 15
#define PIN_SD_CARD_CLK 14

const char* file_name = "/tmp.bin";
SdFs SD;
FsFile file;
RingBufferFile<FsFile, int16_t> buffer(file);


void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);

// setup SD
SPI.begin(PIN_SD_CARD_CLK, PIN_SD_CARD_MISO, PIN_SD_CARD_MOSI, PIN_SD_CARD_CS);
while (!SD.begin(PIN_SD_CARD_CS, SPI_HALF_SPEED)) {
Serial.println("Card Mount Failed");
delay(500);
}

// create file and setup buffer
file = SD.open(file_name, O_RDWR | O_CREAT );
if (!file) {
Serial.println("Failed to open file for writing");
return;
}

// test write
for (int j = 0; j < 10; j++) {
buffer.write(j);
}

// test write array
int16_t tmp[10];
for (int j = 0; j < 10; j++) {
tmp[j] = j;
}
buffer.writeArray(tmp, 10);

// test read
Serial.println("read");
for (int j = 0; j < 10; j++) {
int16_t result = buffer.read();
Serial.print(result);
Serial.print(" ");
assert(result == j);
}
Serial.println();

// test read array
Serial.print("readArray");
Serial.print(" ");
Serial.println(buffer.available());
memset(tmp, 0, 10 * sizeof(int16_t));

int max = buffer.readArray(tmp, buffer.available());
for (int j = 0; j < max; j++) {
Serial.print(tmp[j]);
Serial.print(" ");
assert(j == tmp[j]);
}
Serial.println();

file.close();
Serial.println("Test success!");

// cleanup
SD.remove(file_name);
}

void loop() {}
27 changes: 0 additions & 27 deletions examples/tests/codecs/test-ogg-write/test-write-ogg.ino

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void setup(){
AudioLogger::instance().begin(Serial, AudioLogger::Info);

sine_wave.begin(info, N_B4);
conv.begin(from, to_channels);
conv.begin(info, to_channels);
in_stream.begin();

out.begin();
Expand Down
1 change: 1 addition & 0 deletions src/AudioFilter/Equilizer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <math.h>
#include "AudioTools/AudioStreams.h"
#include "AudioTools/AudioOutput.h"
#include "AudioBasic/Int24.h"

Expand Down
1 change: 1 addition & 0 deletions src/AudioTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "AudioTools/AudioStreamsConverter.h"
#include "AudioTools/AudioOutput.h"
#include "AudioTools/VolumeStream.h"
#include "AudioTools/AudioIO.h"
#include "AudioTools/ResampleStream.h"
#include "AudioTools/StreamCopy.h"
#include "AudioCodecs/AudioEncoded.h"
Expand Down
Loading

0 comments on commit 805cb27

Please sign in to comment.