Not sure if this is the right area for this query, so if a mod thinks it needs moving, I have no objection.
Is anyone familiar with the internals of the ArduinoSound library?
The reason I'm asking is that I have uploaded the WavePlayback tutorial sketch (https://www.arduino.cc/en/Tutorial/ArduinoSoundWavePlayback)
/*
This reads a wave file from an SD card and plays it using the I2S interface to
a MAX98357 I2S Amp Breakout board.
Circuit:
* Arduino/Genuino Zero, MKRZero or MKR1000 board
* SD breakout or shield connected
* MAX08357:
* GND connected GND
* VIN connected 5V
* LRC connected to pin 0 (Zero) or pin 3 (MKR1000, MKRZero)
* BCLK connected to pin 1 (Zero) or pin 2 (MKR1000, MKRZero)
* DIN connected to pin 9 (Zero) or pin A6 (MKR1000, MKRZero)
created 15 November 2016
by Sandeep Mistry
*/
#include <SD.h>
#include <ArduinoSound.h>
// filename of wave file to play
const char filename[] = "MUSIC.WAV";
// variable representing the Wave File
SDWaveFile waveFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// setup the SD card, depending on your shield of breakout board
// you may need to pass a pin number in begin for SS
Serial.print("Initializing SD card...");
if (!SD.begin()) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// create a SDWaveFile
waveFile = SDWaveFile(filename);
// check if the WaveFile is valid
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");
// adjust the playback volume
AudioOutI2S.volume(5);
// check if the I2S output can play the wave file
if (!AudioOutI2S.canPlay(waveFile)) {
Serial.println("unable to play wave file using I2S!");
while (1); // do nothing
}
// start playback
Serial.println("starting playback");
AudioOutI2S.play(waveFile);
}
onto my MKRZero and it all works ok in conjunction with the MAX98357 I2S Amp Breakout board (despite the wiring errors illustrated!). I've even added buttons , various waveform choices and led effects, but now want to make my own standalone SAMD21 board with a MAX98357 audio chip. As the audio chip will be permanently hard-wired to the processor, its obviously important I ensure the sketch points to the correct pins!
So at last, we come to my question. What determined the use of the A6 (PA07), D1 (PA10) and D0 (PA11) pins in Sandeep Mistry's sketch? Is there a particular reason for using those pins and where are they defined - in the ArduinoSound library or elsewhere?
I know I can plan my proposed PCB to use those same pins - but I'd like to know if they can be changed.
EDIT: I notice in the I/O multiplexing table (Table 6-1) that the I/O pins mentioned above are I2SD(0), I2S/SCK(0) and I2S/FS(0) respectively, so I guess that must be relevant?