Inputs reversed when compiling with Visual Studio / Visual GDB

I’m experiencing some odd behavior here when compiling the PedalTemplate (or Verb, or any other Petal based code) in Visual Studio with Visual GDB…

My inputs are swapped when reading from an interleaved block. in[i] gives the right channel input, in[i + 1] gives the left channel input.

If I compile the exact same code with GCC I get the correct behavior (in[i] gives left channel, in[i + 1] gives right channel).

The only changes I’ve made to the project are adding “libDaisy/Drivers/CMSIS/Include” to the include paths, and I had to substitute the ARM Toolchain (com.sysprogs.gnuarm.arm-eabi 9.2.1/8.0/r1) with the default ARM toolchain in Visual GDB (GCC 9.3.1, GDB 9.2.0, Revision 1)

Anyone else experience this, or have any idea what is going on?

The code is vanilla code from the DaisyExamples archive, but just for the sake of posterity:

 // Basic Template for DaisyPetal
 #include "daisy_petal.h"
 
 using namespace daisy;
 
 DaisyPetal hw;
 
 void AudioCallback(float *in, float *out, size_t size)
 {
     hw.DebounceControls();
     hw.UpdateAnalogControls();
     for(size_t i = 0; i < size; i += 2)
     {
         out[i]     = in[i];
         out[i + 1] = in[i + 1];
     }
 }
 
 int main(void)
 {
     hw.Init();
     hw.StartAdc();
     hw.StartAudio(AudioCallback);
     for(;;) {}
 }

Channel swapping seems to be a common Daisy problem. They are working on fixing it so try to ignore it for now.

1 Like

Good deal, as long as it’s a known issue I can work around it for the time being.

Channel swapping is indeed a known issue. I just realized there’s not a github issue for it, but I just added one.

For the sake of predictability I have most noticed it when either changing sample rates, or switching between build tools/configurations (i.e. switching from VisualGDB to Make, or switching from Debug to Release builds).

I have narrowed down the problem to a timing issue within the StartAudio function, and am still working on a solution. Certain build settings, specifically optimization seem to affect the issue.

I’ll post more once I find/implement a solution.