File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,11 @@ class SAM {
204
204
}
205
205
}
206
206
207
+ // / Enableds/disables the scaling to 16 bits - by default this is on
208
+ void setTrue16Bits (bool active){
209
+ true16Bins = active;
210
+ }
211
+
207
212
// / Provides the sample rate (22050)
208
213
static int sampleRate () {
209
214
return SAMOutputBase::sampleRate ();
@@ -213,6 +218,7 @@ class SAM {
213
218
SAMOutputBase *arduino_output=nullptr ;
214
219
int bits_per_sample = 8 ;
215
220
int channel_count = 1 ;
221
+ bool true16Bins = true ;
216
222
217
223
// / Used to feed the audio result back to this class
218
224
static void outputByteCallback (void *cbdata, unsigned char b) {
@@ -253,10 +259,12 @@ class SAM {
253
259
arduino_output->write ((byte*)sample, channel_count);
254
260
} else if (bits_per_sample==16 ) {
255
261
int16_t s16 = b;
256
- // convert to signed
257
- s16 -= 128 ;
258
- // convert to int16
259
- s16 *= 128 ;
262
+ if (true16Bins) {
263
+ // convert to signed
264
+ s16 -= 128 ;
265
+ // convert to int16
266
+ s16 *= 128 ;
267
+ }
260
268
int16_t sample[channel_count];
261
269
for (int j=0 ;j<channel_count; j++){
262
270
sample[j] = s16;
You can’t perform that action at this time.
0 commit comments