File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -66,17 +66,41 @@ class MozziGenerator : public SoundGenerator<AudioOutputStorage_t> {
66
66
67
67
// / Provides a single sample
68
68
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
69
76
if (is_read_buffer_filled){
70
77
// for stereo output we might have the value already
71
78
is_read_buffer_filled = false ;
72
79
return read_buffer;
73
80
}
74
81
82
+ // control update
75
83
if (--control_counter<0 ){
76
84
control_counter = control_counter_max;
77
- info.updateControl ();
85
+ if (info.updateControl !=nullptr ){
86
+ info.updateControl ();
87
+ }
78
88
}
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 (){
80
104
AudioOutput out = info.updateAudio ();
81
105
// requested mono
82
106
AudioOutputStorage_t result = 0 ;
@@ -105,12 +129,6 @@ class MozziGenerator : public SoundGenerator<AudioOutputStorage_t> {
105
129
return result;
106
130
}
107
131
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 ;
114
132
115
133
};
116
134
You can’t perform that action at this time.
0 commit comments