Skip to content

Commit

Permalink
int24_t and scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed May 1, 2021
1 parent addfed4 commit bcef45b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Some basic C++ classes that can be used for Audio Processing privided as Arduino
- NBuffer (Multi buffer for writing and reading of (audio) data)
- TimerAlarmRepeating (e.g. for sampling audio data using exact times) [ESP32 only]
- A Wav Encoder and Decoder
- AudioOutputWithCallback class to provide callback integration with ESP8266Audio

This functionality provides the glue which makes different audio processing components and libraries work together.
We also provide plenty of examples that demonstrate how to implement the different scenarios.
Expand Down Expand Up @@ -62,5 +63,5 @@ This is currently work in progress:
| Streams | open |
| WAV encoding/deconding | open |
| AAC encoding/deconding | open |
| int24_t | open |
| int24_t | tested |

21 changes: 21 additions & 0 deletions sandbox/test_int24/test_int24.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "AudioTools.h"

using namespace audio_tools;

void setup(){
int24_t value;
Serial.begin(115200);

for (int32_t j=8388607;j>-8388606;j++){
value = j;
Serial.print(j);
Serial.print(", ");
Serial.print((int32_t)value);
Serial.println((int32_t)value == j ? ", OK" : ", ERROR");
}

}

void loop(){

}
2 changes: 1 addition & 1 deletion src/AudioTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @copyright GPLv3
*
*/
#include "AudioTools/SoundTypes.h"
#include "AudioTools/AudioTypes.h"
#include "AudioTools/Buffers.h"
#include "AudioTools/Converter.h"
#include "AudioTools/MusicalNotes.h"
Expand Down
8 changes: 6 additions & 2 deletions src/AudioTools/SoundTypes.h → src/AudioTools/AudioTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class int24_t {
value[2]=0;
}

int24_t(void *ptr){
int24_t(static_cast<uint8_t*>(ptr));
}

int24_t(uint8_t *ptr){
value[0]=ptr[0];
value[1]=ptr[1];
Expand Down Expand Up @@ -58,8 +62,8 @@ class int24_t {
}

/// provides value between -2,147,483,647 and 2,147,483,647
int16_t scale32() {
return static_cast<float>(*this) * INT32_MAX / INT24_MAX;
int32_t scale32() {
return static_cast<float>(*this) / static_cast<float>(INT24_MAX) * static_cast<float>(INT32_MAX) ;
}

/// provides value between -1.0 and 1.0
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/Converter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "SoundTypes.h"
#include "AudioTypes.h"
#include "BluetoothA2DPSource.h"

namespace audio_tools {
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/I2S.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "esp_a2dp_api.h"
#include "driver/i2s.h"
#include "freertos/queue.h"
#include "SoundTypes.h"
#include "AudioTypes.h"

namespace audio_tools {

Expand Down

0 comments on commit bcef45b

Please sign in to comment.