Go Down

Topic: Interfacing an MKZero to Adafruit I2S 3W breakout board - help direly needed!  (Read 1 time) previous topic - next topic

Protonerd

Hope someone has more experience here with these MAX08357 based breakout boards and this particular protocol.

So far I'm experimenting with audio playback directly from a controller, like the SAMD21. I made it work with the in-built DAC, connecting it directly to an audio amp. So far works as expected.
However the I2S seems to be a lucrative option if 10bit DAC is not enough...

Therefore I wired up this breakout board to the MKZero and uploaded the WavPlayback from the https://github.com/arduino-libraries/ArduinoSound library. But somehow nothing useful happens.

If I use a wav file I get this:

Initializing SD card...initialization done.
wave file is invalid!


Disabling this check sheds some light on the issue:
Initializing SD card...initialization done.
Bits per sample = -1
Channels = -1
Sample rate = -1 Hz
Duration = 1 seconds
unable to play wave file using I2S!


This was with a mono, 8bit/sample wav file. OK, I tried a 16 bit mono, at least this file makes some sense to the parser...?
Bits per sample = 16
Channels = 1
Sample rate = 22050 Hz
Duration = 0 seconds
unable to play wave file using I2S!


16bit stereo is again not recognized by the sketch...
Initializing SD card...initialization done.
Bits per sample = -1
Channels = -1
Sample rate = -1 Hz
Duration = 1 seconds
unable to play wave file using I2S!



gdsports

Look at the source code for AudioOutI2SClass::canPlay. The number of channels must be 2.

Protonerd

Look at the source code for AudioOutI2SClass::canPlay. The number of channels must be 2.

As I converted files for stereo, these files have 2 channels and still not playing. So this is not really helping... is there any way to modify the code to play mono coded wav files?

gdsports

The other check is for the numbers of bits per sample. Must be 8, 16, or 32. Two of the files you tried show -1 for bits per sample which is also going to fail. I have no idea how to mod for mono play back.

If the WAV file cannot pass this test, the example will not play it.

Code: [Select]
int AudioOutI2SClass::canPlay(AudioIn& input)
{
  int bitsPerSample = input.bitsPerSample();
  int channels = input.channels();

  if (bitsPerSample != 8 && bitsPerSample != 16 && bitsPerSample != 32) {
    return 0;
  }

  if (channels != 2) {
    return 0;
  }

  return 1;
}

Protonerd

Interesting, if I disable the check, some of the 16bit wav files will play, not very clean but recognizable. The files are coded as mono (channel=1). But some other files with exactly the same format (22050 sample/sec, 16bit, mono) refuse to play.

Does someone know of a more reliable library for I2S integration? This one does not work and therefore useless.

Protonerd

Does anyone have a simple wav file which can be played on the MKZero using the I2S interface? So far all of my trials run into nirvana, I seriously doubt that this device can interface to I2S!!! I already contacted the library owner but no solution so far. I have to conclude as of now that the library https://github.com/arduino-libraries/ArduinoSound does not work.

gdsports

Quote
I seriously doubt that this device can interface to I2S
You can test the I2S DAC+Amp using the SimpleTone example. It does not require SD or WAV file.

I do not have a Adafruit I2S DAC handy right now. I tried a WAV file to see how if the WavPlayback example decodes the WAV header correctly. The console output is shown below. The file was created using Audacity.

Code: [Select]
Initializing SD card...initialization done.
Bits per sample = 16
Channels = 2
Sample rate = 8000 Hz
Duration = 1 seconds
starting playback
playback stopped


I am using an Adafruit M0 Proto but it contains the same SAMD21 as the Zero and MKZero.

Protonerd

Thanks gdsports, really appreaciate.

I did indeed try the SimpleTone, plays with no issue, but it's not helping me. I need to have the capability to play wav files from SD-card or similar.
All the wav files I tried so far failed to play, but I can play them using the DAC of the SAMD21 connected to an audio amp. Therefore the wav files I have are OK. I just cannot use the DAC as it has only 10bit resolution, a wee bit low for my requirements.

I will try the wav file you attached. But it needs to be found why the sketch only plays certain files, otherwise it's usefulness is severely limited.

Grumpy_Mike

Quote
Therefore the wav files I have are OK.
You can not conclude that. The WAV file format has some optional headers, it could be that the Library does not cope with those options if present or not present. I would examine the file headers and compare them to the headers of the simple tone that you say works.

Protonerd

You can not conclude that. The WAV file format has some optional headers, it could be that the Library does not cope with those options if present or not present. I would examine the file headers and compare them to the headers of the simple tone that you say works.
I came to a similar conclusion, except that I still state that the wav files are OK. PC and widely used Wav Arduino Players like the DFPlayer can play all of them with no issue. It seems that this library only accepts wav files with a certain header, but then it should be defined what.

The simple tone is just a sinus wave played with a certain sample rate, so no wav files involved.

Protonerd

You can test the I2S DAC+Amp using the SimpleTone example. It does not require SD or WAV file.


I used your wav file and it plays all right :)

I also found some wav files which play on the breakout board, even though they are mono coded. Of course they play weird but the melody is recognizable. So now the next hurdle: how to enable playing mono files with I2S. I've seen 3 play modes, PHILIPS, left and right justified. Does any one of them implies mono?

Go Up