Raspberry (wav, mp3, ...) --(I2S)--> Teensy --(USB)--> PC ?

Status
Not open for further replies.

faboo

Member
Hi forum!

For my next project, I am trying to play audio from my RPi3, transfer it to my Teensy 4.0 with I2S, and then from the Teensy to my PC via USB.
I have no problem with the audio USB part (I have modified the PlaySynthMusic example with a AudioOutputUSB object and I could perfectly capture the sound with Audacity on my PC.)
Now, I would like to do the same with the audio played on the RPi.
I have setup an I2S connection between the RPi and the Teensy, by connecting GPIO 18, 19, 21 on the RPi to pins BCLK1, LRCLK1, IN1 on the teensy.
I use the following program on teensy:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2Sslave      i2s1;
AudioOutputUSB           usb1;
AudioConnection          patchCord1(i2s1, 0, usb1, 0);
AudioConnection          patchCord2(i2s1, 1, usb1, 1);

void setup() {
   AudioMemory(40);
}

void loop() {
}

On the Raspberry, I have modified /boot/config.txt with
Code:
dtparam=i2s=on
and
Code:
dtoverlay=hifiberry-dac
(I know teensy is not a dac, but what should I use then?)

Then I play some mp3 on the RPi with mpg123, and record on my PC with Audacity.
I get something but... the quality is really bad: the voice sounds like pitched-down + some buzz :lol:

Here is a sample of the sound I get:
http://quefaitesvous.fr/audio/audio-usb.wav

I looked at the wave form of the sound with Audacity, it looks like if the data was chopped and interleaved with blanks:
http://quefaitesvous.fr/audio/scr-audio.png

Any idea for fixing this problem?

Thanks
 

Attachments

  • scr-audio.jpg
    scr-audio.jpg
    84.9 KB · Views: 46
Do you have a multimeter which can measure frequency? Or another Teensy which can run the FreqMeasure library?

Can you check what frequency your Raspberry Pi is actually sending on the LRCLK pin?
 
Do you have a multimeter which can measure frequency? Or another Teensy which can run the FreqMeasure library?

Can you check what frequency your Raspberry Pi is actually sending on the LRCLK pin?

Hi Paul,

Thanks for such a quick answer!
I am poorly equiped and not used to these technicalities :) but I tried with my multimeter on the LRCK pin (see picture).
1 period = 4.5 x 5us = 22.5us
Then that would be 1/0.0000225 = 44 444Hz

That's the most precise I can do, sorry. Does it help ?
 

Attachments

  • oscillo.jpg
    oscillo.jpg
    82.7 KB · Views: 38
Actually, the simplest way to reproduce the problem is as follow:

I took the example file MyPlaySynth.
I changed the output to USB:
Code:
AudioOutputUSB  audioOut;
I added a dummy non-slave I2S input: (I say "dummy" because it's not connected to anything, but without it, I don't get any sound, I don't know why...)
Code:
AudioInputI2S       i2s1;
I record from my PC in Audacity --> PERFECT sound

Now I replace the non-slave I2S input by a slave one:
Code:
AudioInputI2Sslave       i2s1;
(not connected either)
I record from my PC in Audacity --> BAD sound (actually interleaving audio and blanks every ~135 samples, see picture below)

Is it me who does things wrongly or there is a bug somewhere?

Thanks
 

Attachments

  • stereo_chopped.jpg
    stereo_chopped.jpg
    89.1 KB · Views: 54
Status
Not open for further replies.
Back
Top