Commit Graph

9 Commits

Author SHA1 Message Date
Jeff Epler 8f4bab2d24 i2sout: Correctly retrieve channel_count
The meaning of the "single channel" parameter is not well-documented,
but in fact it seems that "true" must be passed or else the returned
channel_count is always 1.  This caused stereo samples to be played
incorrectly.
2019-11-25 10:59:59 -06:00
Jeff Epler c9946dfd63 nrf: i2sout: Use <, not !=, for loop condition
This is good C style, h/t @danh
2019-11-25 09:35:57 -06:00
Jeff Epler 19d122e546 nrf: i2sout: Fix double-increment when copying samples
This caused two problems when playing unsigned samples:
 * When an even number of samples were present, it "worked" but only
   every other sample was copied into the output, changing the waveform
 * When an odd number of samples were present, the copy continued beyond
   the end of the buffers and caused a hard fault
2019-11-25 09:07:20 -06:00
jepler 7b9dfc9952 nrf: i2s: tune audio buffering
.. based on some tasks I found that caused stuttering:

 # Test SD and printing
 while True: os.listdir('.')

 # Test bulk I/O
 while True: len(open('somefile.wav', 'rb').read())

Each of these tasks *WAS* worse and I am improving them in a separate
PR by adding RUN_BACKGROUND_TASKS to them.
2019-09-09 20:13:12 -05:00
jepler c66f5a8536 nrf: i2s: rewrite without 'goto' 2019-09-09 19:26:18 -05:00
jepler fe9605a6a3 nrf: i2s: Comment this slightly tricksy code 2019-09-09 19:25:52 -05:00
jepler ccf08aa3df nrf: I2SOut: deal more gracefully with errors from the sample 2019-09-08 21:59:07 -05:00
jepler f38ee42874 nrf: Add i2s audio output
Testing performed: I used a Particle Xenon with a HDA1334 I2S DAC.
I played a variety of mono 16-bit samples at 11025 and 22050Hz nominal
bit rates.  With this setup, all the 11025Hz samples sound good.
I tested play, pause,  and loop functionality.

During some runs with 22050Hz samples, there were glitches.  However,
these may have only occurred during runs where I had set breakpoints
and watchpoints in gdb.

I also tested with a MAX98357A I2S amplifier.  On this device, everything
sounded "scratchy".  I was powering it from 5V and the 5V rail seemed
steady, so I don't have an explanation for this.  However, I haven't
tried it with a SAMD board.
2019-09-08 16:46:35 -05:00
Jeff Epler 79f8a85786 nrf: stub out audiobusio.PDMIn, audiobusio.I2SOut 2019-08-18 15:55:57 -05:00