Skip to content

Commit 1e06daf

Browse files
committed
Deactivate Logging
1 parent f25b69b commit 1e06daf

File tree

4 files changed

+141
-132
lines changed

4 files changed

+141
-132
lines changed

src/AudioConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
*/
7979

8080
#ifndef USE_AUDIO_LOGGING
81-
#define USE_AUDIO_LOGGING true
81+
#define USE_AUDIO_LOGGING false
8282
#endif
8383

8484
// Logging Implementation

src/AudioTools/AudioLogger.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#pragma once
22

3+
#include "AudioConfig.h"
4+
5+
#if USE_AUDIO_LOGGING
6+
7+
38
#include "Stream.h"
49
#include <cstdarg>
510

611
#ifndef PRINTF_BUFFER_SIZE
712
#define PRINTF_BUFFER_SIZE 160
813
#endif
914

10-
#define LOG_LEVEL AudioLogger::Warning
15+
#define LOG_LEVEL AudioLogger::Warning
1116
#define LOG_STREAM Serial
1217

1318

@@ -156,3 +161,5 @@ class AudioLogger {
156161
};
157162

158163
}
164+
165+
#endif

src/AudioTools/MusicalNotes.h

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -4,114 +4,114 @@
44

55
#pragma once
66

7-
#define C0 16
8-
#define CS0 17
9-
#define D0 18
10-
#define DS0 19
11-
#define E0 21
12-
#define F0 22
13-
#define FS0 23
14-
#define G0 25
15-
#define GS0 26
16-
#define A0 28
17-
#define AS0 29
18-
#define B0 31
19-
#define C1 33
20-
#define CS1 35
21-
#define D1 37
22-
#define DS1 39
23-
#define E1 41
24-
#define F1 44
25-
#define FS1 46
26-
#define G1 49
27-
#define GS1 52
28-
#define A1 55
29-
#define AS1 58
30-
#define B1 62
31-
#define C2 65
32-
#define CS2 69
33-
#define D2 73
34-
#define DS2 78
35-
#define E2 82
36-
#define F2 87
37-
#define FS2 93
38-
#define G2 98
39-
#define GS2 104
40-
#define A2 110
41-
#define AS2 117
42-
#define B2 123
43-
#define C3 131
44-
#define CS3 139
45-
#define D3 147
46-
#define DS3 156
47-
#define E3 165
48-
#define F3 175
49-
#define FS3 185
50-
#define G3 196
51-
#define GS3 208
52-
#define A3 220
53-
#define AS3 233
54-
#define B3 247
55-
#define C4 262
56-
#define CS4 277
57-
#define D4 294
58-
#define DS4 311
59-
#define E4 330
60-
#define F4 349
61-
#define FS4 370
62-
#define G4 392
63-
#define GS4 415
64-
#define A4 440
65-
#define AS4 466
66-
#define B4 494
67-
#define C5 523
68-
#define CS5 554
69-
#define D5 587
70-
#define DS5 622
71-
#define E5 659
72-
#define F5 698
73-
#define FS5 740
74-
#define G5 784
75-
#define GS5 831
76-
#define A5 880
77-
#define AS5 932
78-
#define B5 988
79-
#define C6 1047
80-
#define CS6 1109
81-
#define D6 1175
82-
#define DS6 1245
83-
#define E6 1319
84-
#define F6 1397
85-
#define FS6 1480
86-
#define G6 1568
87-
#define GS6 1661
88-
#define A6 1760
89-
#define AS6 1865
90-
#define B6 1976
91-
#define C7 2093
92-
#define CS7 2217
93-
#define D7 2349
94-
#define DS7 2489
95-
#define E7 2637
96-
#define F7 2794
97-
#define FS7 2960
98-
#define G7 3136
99-
#define GS7 3322
100-
#define A7 3520
101-
#define AS7 3729
102-
#define B7 3951
103-
#define C8 4186
104-
#define CS8 4435
105-
#define D8 4699
106-
#define DS8 4978
107-
#define E8 5274
108-
#define F8 5588
109-
#define FS8 5920
110-
#define G8 6272
111-
#define GS8 6645
112-
#define A8 7040
113-
#define AS8 7459
114-
#define B8 7902
7+
#define N_C0 16
8+
#define N_CS0 17
9+
#define N_D0 18
10+
#define N_DS0 19
11+
#define N_E0 21
12+
#define N_F0 22
13+
#define N_FS0 23
14+
#define N_G0 25
15+
#define N_GS0 26
16+
#define N_A0 28
17+
#define N_AS0 29
18+
#define N_B0 31
19+
#define N_C1 33
20+
#define N_CS1 35
21+
#define N_D1 37
22+
#define N_DS1 39
23+
#define N_E1 41
24+
#define N_F1 44
25+
#define N_FS1 46
26+
#define N_G1 49
27+
#define N_GS1 52
28+
#define N_A1 55
29+
#define N_AS1 58
30+
#define N_B1 62
31+
#define N_C2 65
32+
#define N_CS2 69
33+
#define N_D2 73
34+
#define N_DS2 78
35+
#define N_E2 82
36+
#define N_F2 87
37+
#define N_FS2 93
38+
#define N_G2 98
39+
#define N_GS2 104
40+
#define N_A2 110
41+
#define N_AS2 117
42+
#define N_B2 123
43+
#define N_C3 131
44+
#define N_CS3 139
45+
#define N_D3 147
46+
#define N_DS3 156
47+
#define N_E3 165
48+
#define N_F3 175
49+
#define N_FS3 185
50+
#define N_G3 196
51+
#define N_GS3 208
52+
#define N_A3 220
53+
#define N_AS3 233
54+
#define N_B3 247
55+
#define N_C4 262
56+
#define N_CS4 277
57+
#define N_D4 294
58+
#define N_DS4 311
59+
#define N_E4 330
60+
#define N_F4 349
61+
#define N_FS4 370
62+
#define N_G4 392
63+
#define N_GS4 415
64+
#define N_A4 440
65+
#define N_AS4 466
66+
#define N_B4 494
67+
#define N_C5 523
68+
#define N_CS5 554
69+
#define N_D5 587
70+
#define N_DS5 622
71+
#define N_E5 659
72+
#define N_F5 698
73+
#define N_FS5 740
74+
#define N_G5 784
75+
#define N_GS5 831
76+
#define N_A5 880
77+
#define N_AS5 932
78+
#define N_B5 988
79+
#define N_C6 1047
80+
#define N_CS6 1109
81+
#define N_D6 1175
82+
#define N_DS6 1245
83+
#define N_E6 1319
84+
#define N_F6 1397
85+
#define N_FS6 1480
86+
#define N_G6 1568
87+
#define N_GS6 1661
88+
#define N_A6 1760
89+
#define N_AS6 1865
90+
#define N_B6 1976
91+
#define N_C7 2093
92+
#define N_CS7 2217
93+
#define N_D7 2349
94+
#define N_DS7 2489
95+
#define N_E7 2637
96+
#define N_F7 2794
97+
#define N_FS7 2960
98+
#define N_G7 3136
99+
#define N_GS7 3322
100+
#define N_A7 3520
101+
#define N_AS7 3729
102+
#define N_B7 3951
103+
#define N_C8 4186
104+
#define N_CS8 4435
105+
#define N_D8 4699
106+
#define N_DS8 4978
107+
#define N_E8 5274
108+
#define N_F8 5588
109+
#define N_FS8 5920
110+
#define N_G8 6272
111+
#define N_GS8 6645
112+
#define N_A8 7040
113+
#define N_AS8 7459
114+
#define N_B8 7902
115115

116116
namespace audio_tools {
117117

@@ -157,15 +157,15 @@ class MusicalNotes {
157157
protected:
158158

159159
uint16_t notes[9][12] = {
160-
{C0, CS0, D0, DS0, E0, F0, FS0, G0, GS0, A0, AS0, B0},
161-
{C1, CS1, D1, DS1, E1, F1, FS1, G1, GS1, A1, AS1, B1},
162-
{C2, CS2, D2, DS2, E2, F2, FS2, G2, GS2, A2, AS2, B2},
163-
{C3, CS3, D3, DS3, E3, F3, FS3, G3, GS3, A3, AS3, B3},
164-
{C4, CS4, D4, DS4, E4, F4, FS4, G4, GS4, A4, AS4, B4},
165-
{C5, CS5, D5, DS5, E5, F5, FS5, G5, GS5, A5, AS5, B5},
166-
{C6, CS6, D6, DS6, E6, F6, FS6, G6, GS6, A6, AS6, B6},
167-
{C7, CS7, D7, DS7, E7, F7, FS7, G7, GS7, A7, AS7, B7},
168-
{C8, CS8, D8, DS8, E8, F8, FS8, G8, GS8, A8, AS8, B8}
160+
{N_C0, N_CS0, N_D0, N_DS0, N_E0, N_F0, N_FS0, N_G0, N_GS0, N_A0, N_AS0, N_B0},
161+
{N_C1, N_CS1, N_D1, N_DS1, N_E1, N_F1, N_FS1, N_G1, N_GS1, N_A1, N_AS1, N_B1},
162+
{N_C2, N_CS2, N_D2, N_DS2, N_E2, N_F2, N_FS2, N_G2, N_GS2, N_A2, N_AS2, N_B2},
163+
{N_C3, N_CS3, N_D3, N_DS3, N_E3, N_F3, N_FS3, N_G3, N_GS3, N_A3, N_AS3, N_B3},
164+
{N_C4, N_CS4, N_D4, N_DS4, N_E4, N_F4, N_FS4, N_G4, N_GS4, N_A4, N_AS4, N_B4},
165+
{N_C5, N_CS5, N_D5, N_DS5, N_E5, N_F5, N_FS5, N_G5, N_GS5, N_A5, N_AS5, N_B5},
166+
{N_C6, N_CS6, N_D6, N_DS6, N_E6, N_F6, N_FS6, N_G6, N_GS6, N_A6, N_AS6, N_B6},
167+
{N_C7, N_CS7, N_D7, N_DS7, N_E7, N_F7, N_FS7, N_G7, N_GS7, N_A7, N_AS7, N_B7},
168+
{N_C8, N_CS8, N_D8, N_DS8, N_E8, N_F8, N_FS8, N_G8, N_GS8, N_A8, N_AS8, N_B8}
169169
};
170170

171171

src/AudioWAVServer.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class AudioWAVServer {
2828
* @param password
2929
*/
3030
AudioWAVServer(const char* network, const char *password) {
31-
this->network = network;
32-
this->password = password;
31+
this->network = (char*)network;
32+
this->password = (char*)password;
3333
}
3434

3535
/**
@@ -39,10 +39,11 @@ class AudioWAVServer {
3939
* @param sample_rate
4040
* @param channels
4141
*/
42-
void begin(Stream &in, int sample_rate, int channels) {
42+
void begin(Stream &in, int sample_rate, int channels, int bits_per_sample=16) {
4343
this->in = &in;
4444
this->sample_rate = sample_rate;
4545
this->channels = channels;
46+
this->bits_per_sample = bits_per_sample;
4647

4748
connectWiFi();
4849

@@ -57,11 +58,12 @@ class AudioWAVServer {
5758
* @param sample_rate
5859
* @param channels
5960
*/
60-
void begin(AudioWAVServerDataCallback cb, int sample_rate, int channels) {
61+
void begin(AudioWAVServerDataCallback cb, int sample_rate, int channels, int bits_per_sample=16) {
6162
this->in =nullptr;
6263
this->callback = cb;
6364
this->sample_rate = sample_rate;
6465
this->channels = channels;
66+
this->bits_per_sample = bits_per_sample;
6567

6668
connectWiFi();
6769

@@ -115,12 +117,13 @@ class AudioWAVServer {
115117
// WIFI
116118
WiFiServer server = WiFiServer(80);
117119
WiFiClient client;
118-
const char *password = nullptr;
119-
const char *network = nullptr;
120+
char *password = nullptr;
121+
char *network = nullptr;
120122

121123
// Sound Generation
122124
int sample_rate;
123125
int channels;
126+
int bits_per_sample;
124127

125128
AudioWAVServerDataCallback callback = nullptr;
126129
Stream *in = nullptr;
@@ -132,17 +135,15 @@ class AudioWAVServer {
132135
LOGD("connectWiFi");
133136
if (WiFi.status() != WL_CONNECTED && network!=nullptr && password != nullptr){
134137
WiFi.begin(network, password);
135-
WiFi.setSleep(false);
138+
//WiFi.setSleep(false);
136139
while (WiFi.status() != WL_CONNECTED){
137140
Serial.print(".");
138141
delay(500);
139142
}
140143
Serial.println();
141144
}
142-
char msg[80];
143-
sprintf(msg, "IP address: %s",WiFi.localIP().toString().c_str());
144-
LOGI(msg);
145-
Serial.println(msg);
145+
Serial.print("IP address: ");
146+
Serial.println(WiFi.localIP());
146147
}
147148

148149
void sendReply(){
@@ -158,16 +159,17 @@ class AudioWAVServer {
158159
config.channels = channels;
159160
config.sample_rate = sample_rate;
160161
//config.data_length = data_length;
162+
config.bits_per_sample = bits_per_sample;
161163
config.is_streamed = true;
162164
encoder.begin(client, config);
163165

164-
// copy only for stream
165166
if (callback!=nullptr){
166-
LOGI("sendReply - calling callback");
167167
// provide data via Callback
168+
LOGI("sendReply - calling callback");
168169
callback(wav_stream);
169170
client.stop();
170171
} else {
172+
// provide data for stream
171173
LOGI("sendReply - Returning WAV stream...");
172174
copier.begin(wav_stream, *in);
173175
}

0 commit comments

Comments
 (0)