Skip to content

Commit bcef45b

Browse files
committed
int24_t and scaling
1 parent addfed4 commit bcef45b

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Some basic C++ classes that can be used for Audio Processing privided as Arduino
1111
- NBuffer (Multi buffer for writing and reading of (audio) data)
1212
- TimerAlarmRepeating (e.g. for sampling audio data using exact times) [ESP32 only]
1313
- A Wav Encoder and Decoder
14+
- AudioOutputWithCallback class to provide callback integration with ESP8266Audio
1415

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

sandbox/test_int24/test_int24.ino

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "AudioTools.h"
2+
3+
using namespace audio_tools;
4+
5+
void setup(){
6+
int24_t value;
7+
Serial.begin(115200);
8+
9+
for (int32_t j=8388607;j>-8388606;j++){
10+
value = j;
11+
Serial.print(j);
12+
Serial.print(", ");
13+
Serial.print((int32_t)value);
14+
Serial.println((int32_t)value == j ? ", OK" : ", ERROR");
15+
}
16+
17+
}
18+
19+
void loop(){
20+
21+
}

src/AudioTools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @copyright GPLv3
88
*
99
*/
10-
#include "AudioTools/SoundTypes.h"
10+
#include "AudioTools/AudioTypes.h"
1111
#include "AudioTools/Buffers.h"
1212
#include "AudioTools/Converter.h"
1313
#include "AudioTools/MusicalNotes.h"

src/AudioTools/SoundTypes.h renamed to src/AudioTools/AudioTypes.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class int24_t {
2020
value[2]=0;
2121
}
2222

23+
int24_t(void *ptr){
24+
int24_t(static_cast<uint8_t*>(ptr));
25+
}
26+
2327
int24_t(uint8_t *ptr){
2428
value[0]=ptr[0];
2529
value[1]=ptr[1];
@@ -58,8 +62,8 @@ class int24_t {
5862
}
5963

6064
/// provides value between -2,147,483,647 and 2,147,483,647
61-
int16_t scale32() {
62-
return static_cast<float>(*this) * INT32_MAX / INT24_MAX;
65+
int32_t scale32() {
66+
return static_cast<float>(*this) / static_cast<float>(INT24_MAX) * static_cast<float>(INT32_MAX) ;
6367
}
6468

6569
/// provides value between -1.0 and 1.0

src/AudioTools/Converter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "SoundTypes.h"
2+
#include "AudioTypes.h"
33
#include "BluetoothA2DPSource.h"
44

55
namespace audio_tools {

src/AudioTools/I2S.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "esp_a2dp_api.h"
66
#include "driver/i2s.h"
77
#include "freertos/queue.h"
8-
#include "SoundTypes.h"
8+
#include "AudioTypes.h"
99

1010
namespace audio_tools {
1111

0 commit comments

Comments
 (0)