h4yn0nnym0u5e
Well-known member
Hi folks
Been chasing this one for a while, and have got somewhere, though I don't understand the hardware interactions well enough to make a stab at fixing the code
Here's a sketch that reproduces the problem:
This mixes two slightly differing sine waves to get a helpful waveform, then outputs the result to I2S as a reference (green trace). After a while an AudioOutputSPDIF3 object is created and connected to the same source as the I2S (magenta trace). Here are the results:
You can see that the AudioOutputSPDIF3 is outputting incorrect waveform data for part of each update. Judging by the third image, it's actually what should have been emitted 2 audio engine update cycles previously.
Here are some 'scope traces using AudioOutputSPDIF2 in exactly the same way:
Apart from the rather dodgy start-up, you can see the correct waveform emerging. (EDIT: I realise I mucked up the SPDIF2 test a bit, as it was already in existence, which accounts for the "dodgy start-up".)
I hope someone can make sense of this and figure out a fix!
Been chasing this one for a while, and have got somewhere, though I don't understand the hardware interactions well enough to make a stab at fixing the code
Here's a sketch that reproduces the problem:
Code:
#include <Arduino.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// TestSPDIFout: begin automatically generated code
// Audio Processing Nodes
AudioSynthWaveform wav1; //xy=120,90
AudioSynthWaveform wav2; //xy=120,160
AudioMixer4 mixer4L; //xy=260,85
AudioMixer4 mixer4R; //xy=255,160
AudioOutputI2S i2s; //xy=425,75
AudioOutputSPDIF2 spdif2; //xy=410,130
//AudioOutputSPDIF3 spdif3; //xy=405,195
// Audio Connections (all connections (aka wires or links))
AudioConnection patchCord1(wav1, 0, mixer4L, 0);
AudioConnection patchCord2(wav1, 0, mixer4R, 0);
AudioConnection patchCord3(wav2, 0, mixer4L, 1);
AudioConnection patchCord4(wav2, 0, mixer4R, 1);
AudioConnection patchCord5(mixer4L, 0, i2s, 0);
AudioConnection patchCord6(mixer4L, 0, spdif2, 0);
//AudioConnection patchCord7(mixer4L, 0, spdif3, 0);
//AudioConnection patchCord8(mixer4R, 0, spdif3, 1);
AudioConnection patchCord9(mixer4R, 0, spdif2, 1);
AudioConnection patchCord10(mixer4R, 0, i2s, 1);
// Control Nodes (all control nodes (no inputs or outputs))
AudioControlSGTL5000 sgtl5000; //xy=605,100
// TestSPDIFout: end automatically generated code
void setup() {
float freq = 344.0f * 0.75f;
AudioMemory(20);
sgtl5000.enable();
sgtl5000.volume(0.5f);
sgtl5000.lineOutLevel(14);
// allow time for audio engine to start up
delay(20);
// start two waveforms of
// slightly different frequencies
wav1.begin(0.5f,freq, 0);
wav2.begin(0.5f,freq+10.0f,0);
}
void loopWithSPDIF3(void)
{
AudioOutputSPDIF3 spdif3; //xy=405,195
AudioConnection patchCord7(mixer4L, 0, spdif3, 0);
AudioConnection patchCord8(mixer4R, 0, spdif3, 1);
while (true)
{
yield();
}
}
void loop() {
delay(10); // wait then...
loopWithSPDIF3(); // ...create and connect the SPDIF output
}
You can see that the AudioOutputSPDIF3 is outputting incorrect waveform data for part of each update. Judging by the third image, it's actually what should have been emitted 2 audio engine update cycles previously.
Here are some 'scope traces using AudioOutputSPDIF2 in exactly the same way:
Apart from the rather dodgy start-up, you can see the correct waveform emerging. (EDIT: I realise I mucked up the SPDIF2 test a bit, as it was already in existence, which accounts for the "dodgy start-up".)
I hope someone can make sense of this and figure out a fix!
Last edited: