Skip to content

Commit 4a69eef

Browse files
committed
AudioMozzi
1 parent 4108bbf commit 4a69eef

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

.DS_Store

0 Bytes
Binary file not shown.

src/AudioMozzi.h

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,41 @@ class MozziGenerator : public SoundGenerator<AudioOutputStorage_t> {
6666

6767
/// Provides a single sample
6868
virtual AudioOutputStorage_t readSample() {
69+
if (info.updateAudio==nullptr){
70+
LOGE("The updateAudio method has not been defined!");
71+
end();
72+
return 0;
73+
}
74+
75+
// return prior right value from buffer
6976
if (is_read_buffer_filled){
7077
// for stereo output we might have the value already
7178
is_read_buffer_filled = false;
7279
return read_buffer;
7380
}
7481

82+
// control update
7583
if (--control_counter<0){
7684
control_counter = control_counter_max;
77-
info.updateControl();
85+
if (info.updateControl!=nullptr){
86+
info.updateControl();
87+
}
7888
}
79-
89+
90+
// return left value
91+
AudioOutputStorage_t result = updateSample();
92+
return result;
93+
}
94+
95+
protected:
96+
MozziConfig info;
97+
int control_counter_max;
98+
int control_counter;
99+
int read_buffer;
100+
bool is_read_buffer_filled = false;
101+
102+
103+
AudioOutputStorage_t updateSample(){
80104
AudioOutput out = info.updateAudio();
81105
// requested mono
82106
AudioOutputStorage_t result = 0;
@@ -105,12 +129,6 @@ class MozziGenerator : public SoundGenerator<AudioOutputStorage_t> {
105129
return result;
106130
}
107131

108-
protected:
109-
MozziConfig info;
110-
int control_counter_max;
111-
int control_counter;
112-
int read_buffer;
113-
bool is_read_buffer_filled = false;
114132

115133
};
116134

0 commit comments

Comments
 (0)