Skip to content

Commit 0956f94

Browse files
committed
RTTTLOutput: fix title, move to core
1 parent 60c8f1f commit 0956f94

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/AudioTools/CoreAudio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
#include "AudioTools/CoreAudio/AudioMetaData.h"
2626
#include "AudioTools/CoreAudio/FrequencyDetector.h"
2727
#include "AudioTools/CoreAudio/GoerzelStream.h"
28+
#include "AudioTools/CoreAudio/RTTTLOutput.h"

src/AudioTools/Sandbox/RTTTLOutput.h renamed to src/AudioTools/CoreAudio/RTTTLOutput.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class RTTTLOutput : public AudioOutput {
207207
bool is_start = true;
208208
char m_actual = 0;
209209
char m_prec = 0;
210-
Str m_title;
210+
Str m_title{100};
211211
int m_octave{4};
212212
int m_duration{4};
213213
int m_bpm{120};
@@ -245,19 +245,20 @@ class RTTTLOutput : public AudioOutput {
245245
}
246246
}
247247

248-
char next_char() {
248+
char next_char(bool convertToLower = true) {
249249
uint8_t c;
250250
if (!ring_buffer.read(c)) {
251251
c = 0;
252252
}
253253
m_prec = m_actual;
254-
m_actual = tolower(c);
254+
m_actual = convertToLower ? tolower(c) : c;
255255
return m_actual;
256256
}
257257

258258
void parse_title() {
259-
next_char();
260-
for (; m_actual != ':' && m_actual != '\0'; next_char()) {
259+
next_char(false);
260+
m_title = "";
261+
for (; m_actual != ':' && m_actual != '\0'; next_char(false)) {
261262
m_title += m_actual;
262263
}
263264
if (!m_title.isEmpty()) LOGI("title: %s", m_title.c_str());
@@ -282,12 +283,15 @@ class RTTTLOutput : public AudioOutput {
282283
switch (id) {
283284
case 'o':
284285
m_octave = parse_num();
286+
LOGI("default octave: %d", m_octave);
285287
break;
286288
case 'd':
287289
m_duration = parse_num();
290+
LOGI("default duration: %d", m_duration);
288291
break;
289292
case 'b':
290293
m_bpm = parse_num();
294+
LOGI("default bpm: %d", m_bpm);
291295
break;
292296
}
293297
continue;
@@ -301,6 +305,8 @@ class RTTTLOutput : public AudioOutput {
301305
m_msec_semi = 240000.0 / m_bpm;
302306
else
303307
m_msec_semi = 750.0;
308+
309+
LOGI("msec per semi: %.2f", m_msec_semi);
304310
}
305311

306312
void parse_notes() {

0 commit comments

Comments
 (0)