Requirements for pyaudio:
sudo apt install libportaudio2 libportaudiocpp0 python3-pip portaudio19-dev
sudo pip3 install pyaudio
sudo pip3 install sounddevice
Some simple test applications:
- play sound from WAV-file: plays 8kHz files on Wandboard, but not on my PC, as 8kHz is not supported by the hardware.
- record sound from mic/line-in to WAV-file
- audio pass through from mic/line-in to line-out, implemented in two ways: using pyaudio and using sounddevice library. On the Wandboard, the sounddevice library only seems to work for 30s or so. After that, there's sonic boom on the output. The Wandboard needs to be power-cycled to restore sound output. The pyaudio library doesn't seem to have that issue and keeps playing Judas Priest without problems.
References:
Audio resampling
Codec2 works with a fixed sample rate of 8kHz. The line-in and line-out work at 48kHz. A sample rate conversion is needed. Several options are considered:
audioop.ratecv
No libraries need to be installed. The implemented filters are simple first order filters and it certainly sounds like that.
This works both on the Core i7 8thGen and the Wandboard.
sudo pip3 install samplerate
This library runs fine on a Core i7 8thGen and on the Wandboard. Be sure to convert the output of this library to int16 before feeding it back to pyAudio. Python doesn't complain about wrong types as a C++ program would, but the result sounds terrible.
This "sync-best"-filter is audibly the best performing filter.
Works fine on a Core i7 8thGen. Takes more than two hours to build on a Wandboard. This package has more than 300MB of dependencies.
sudo apt install gfortran llvm-dev libblas3 liblapack3 liblapack-dev libblas-dev
sudo pip3 install resampy
play_sound_resampy : open a 8kHz wave file, up-sample it to 48kHz and then play it. Works fine on a Core i7 8thGen. On the Wandboard, it takes much longer to start and it hangs. No sound is ever generated.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.