I have an Arduino MKR Zero with an UDA1334 I2S module, alongside 2 Speakers and I am trying to play Stereo sound. So far everything seems to work well, connections are also properly done, and i can play wav files. But i also want to be able to play sound either on the right channel only or sometimes only on the left channel. I tried to use audacity to make sounds only on the right channel for example, but when i play the .wav file, i still get the sound on both speakers. How can i fix this please? Is there any syntax to play sound only on the right channel? Thank you.

PS. TestR.wav is a only on the right channel.

#include <SD.h>
#include <ArduinoSound.h> 

const char filename[] = "testR.wav";
SDWaveFile waveFile;

void setup() {
   while (!Serial){;};

   Serial.print("Initializing SD card...");
   if (!SD.begin(28)) {
    Serial.println("SD card initialization failed!");
  Serial.println("SD card is valid.");
  waveFile = SDWaveFile(filename);   // create a SDWaveFile
//  Serial.println(typeof(waveFile));
 if (!waveFile) {
    Serial.println("wave file is invalid!");
    while (1); // do nothing

// print out some info. about the wave file
Serial.print("Bits per sample = ");
long channels = waveFile.channels();
Serial.print("Channels = ");
long sampleRate = waveFile.sampleRate();
Serial.print("Sample rate = ");
Serial.println(" Hz");
long duration = waveFile.duration();
Serial.print("Duration = ");
Serial.println(" seconds");


 if (!AudioOutI2S.canPlay(waveFile)) {
    Serial.println("unable to play wave file using I2S!");
    while (1); // do nothing
 Serial.println("starting playback");

void loop() {
  if (!AudioOutI2S.isPlaying()) {
    Serial.println("playback stopped");
    while (1); 
  • 1
    Can you at least, at the very minimum, post your code?
    – Swedgin
    Commented Jun 7, 2021 at 8:26
  • 2
    Sure, there you go! @Swedgin.
    – Mr. Chin
    Commented Jun 7, 2021 at 10:45
  • I went throught that library and I doens't seem like there is functionality to do what you want. channels() returns hardcoded 2 lol (I think that's the left and right channel). You'll have to write your own function to split the two. I don't know how SDWaveFile looks like (how the data is presented), so can't help you with that.
    – Swedgin
    Commented Jun 7, 2021 at 15:21
  • Thank you @Swedgin
    – Mr. Chin
    Commented Jun 8, 2021 at 8:15


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.