Closed kd1889 closed 3 years ago
The speakers were initially connected to a PC for power, and the audio jack was connected to a phone using USB-C to audio jack converter. Sound was emitted through the speakers but the quality was not good. When the audio jack was not connected to anything, white noise was emitted when skin contact was made with the jack. The speakers were then connected to the Raspberry Pi using a USB-micro to USB Female:
The white noise was emitted when the headphone jack was not connected to anything and made skin contact. The headphone jack was connected to a phone using a USB-C to audio jack converter. The sound emitted was choppy and quality was not good. A possible reason is the USB-C converter did not work well with the speakers. This was further shown when the headphone jack was directly connected to a PC and Laptop, and the sound output was perfectly fine. The volume knob on the speakers worked well with volume levels going between 0 and max. The volume knob hinged on the volume levels of the connected devices (PC and Laptop).
Next, I2S stereo decoder was wired according to the schematic and circuit is shown below:
The I2S stereo decoder was setup and tested according to the Adafruit setup and test guide for the part: https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a/raspberry-pi-usage.
The following was used in the Pi terminal to fast install the I2S decoder software:
curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash
The resulting terminal is also shown below:
Next, the same command was run again to test for speaker output. However, during the test, the command was not accepting 'y' as a possible input and kept aborting. To get around this, when asked for confirmation, decline it and run the command again, this time confirming. This resulted in the testing phase properly working. The sound was emitted from the speakers and the volume was able to be controlled using the volume wheel. Terminal is shown below:
A few more tests were run. First, white noise was emitted through the speakers using speaker-test -c2
. The white noise was emitted from the speakers alternating left and right. Terminal is shown below:
Next, MP3 file was played. First, the following was downloaded to enable MP3 sound output: sudo apt-get install -y mpg123
.
The following command was used to output an MP3 file: mpg123 http://ice1.somafm.com/u80s-128-mp3
The MP3 file was played successfully and sound was emitted. The terminal is shown below:
One thing to note is that the I2S setup was done using the fast install method. It might be useful to look into doing it manually.
Adafruit I2S decoder setup site was used, and the code for utilizing pygame mp3 player was obtained from: https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a/audio-with-pygame
play_sound
function was updated to play sound, specifically .mp3, files.
setup_pygame_player
function was added to initialize the pygame mp3 player.
demo.py
was updated to test the above two functions. Two sound files were player: a short sound, and a long music file and each outputted sound and demo.py
ran successfully. Terminal shown: