Use plain square wave, 8192 amplitude (25%) volume
An I2S bug in core ESP8266 Arduino was causing the square wave to fail, not an I2S DAC problem. Move back to the square wave and save some PROGMEM space and make it simpler and faster.
This commit is contained in:
1 parent
66d1f37810
commit
898e960319
1 file changed
+1
-12
@@ -51,16 +51,6 @@ bool AudioGeneratorRTTTL::isRunning()
|
||||
return running;
|
||||
}
|
||||
|
||||
// Can't do pure square wave, the I2S DACs don't like being fed them
|
||||
static int16_t period[64] PROGMEM = {
|
||||
250, 500, 1000, 2000, 4000, 8000, 16000, 32000, 32000, 31000, 32000, 31000,
|
||||
32000, 31000, 32000, 31000, 32000, 31000, 32000, 32100, 32000, 31000, 32000,
|
||||
31000, 32000, 32000, 16000, 8000, 4000, 2000, 1000, 500,
|
||||
-250, -500, -1000, -2000, -4000, -8000, -16000, -32000, -32000, -31000,
|
||||
-32000, -31000, -32000, -31000, -32000, -31000, -32000, -31000, -32000,
|
||||
-32100, -32000, -31000, -32000, -31000, -32000, -32000, -16000, -8000,
|
||||
-4000, -2000, -1000, -500 };
|
||||
|
||||
bool AudioGeneratorRTTTL::loop()
|
||||
{
|
||||
if (!running) goto done; // Nothing to do here!
|
||||
@@ -84,8 +74,7 @@ bool AudioGeneratorRTTTL::loop()
|
||||
while (samplesSent < ttlSamples) {
|
||||
int samplesSentFP10 = samplesSent << 10;
|
||||
int rem = samplesSentFP10 % ttlSamplesPerWaveFP10;
|
||||
rem = (64 * rem) / ttlSamplesPerWaveFP10;
|
||||
int16_t val = pgm_read_word(&period[rem]);
|
||||
int16_t val = (rem > ttlSamplesPerWaveFP10/2) ? 8192:-8192;
|
||||
int16_t s[2] = { val, val };
|
||||
if (!output->ConsumeSample(s)) goto done;
|
||||
samplesSent++;
|
||||
|
||||
Reference in new issue
Block a user