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() {
Serial.begin(9600);
while (!Serial){;};
Serial.print("Initializing SD card...");
if (!SD.begin(28)) {
Serial.println("SD card initialization failed!");
return;
}
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 = ");
Serial.println(waveFile.bitsPerSample());
long channels = waveFile.channels();
Serial.print("Channels = ");
Serial.println(channels);
long sampleRate = waveFile.sampleRate();
Serial.print("Sample rate = ");
Serial.print(sampleRate);
Serial.println(" Hz");
long duration = waveFile.duration();
Serial.print("Duration = ");
Serial.print(duration);
Serial.println(" seconds");
AudioOutI2S.volume(100);
if (!AudioOutI2S.canPlay(waveFile)) {
Serial.println("unable to play wave file using I2S!");
while (1); // do nothing
}
Serial.println("starting playback");
AudioOutI2S.play(waveFile);
}
void loop() {
if (!AudioOutI2S.isPlaying()) {
Serial.println("playback stopped");
while (1);
}
}