Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Sep 2020
    Posts
    11

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

    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
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	scr-audio.jpg 
Views:	10 
Size:	84.9 KB 
ID:	21868  

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    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?

  3. #3
    Junior Member
    Join Date
    Sep 2020
    Posts
    11
    Quote Originally Posted by PaulStoffregen View Post
    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 ?
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	oscillo.jpg 
Views:	4 
Size:	82.7 KB 
ID:	21869  

  4. #4
    Junior Member
    Join Date
    Sep 2020
    Posts
    11
    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
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	stereo_chopped.jpg 
Views:	8 
Size:	89.1 KB 
ID:	21878  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •