This is a lab exercise that is being offered at ICASSP 2011 in Prague. In this lab you will inspect, compile and run code that uses the Linux ALSA sound drivers to capture real-time audio, pass it to the C64x DSP for processing and then out to the speakers.
Compiling the code
Here are the steps to take:
- Open a terminal window. Application:Accessories:Terminal
- In the terminal:
# source /c6run_build/environment.sh # source /c6run_build/loadmodules.sh # cd AudioThru # ls
The first line sets up the environment so you can compile for the C64x. The second lines loads the kernel modules needed to talk to the DSP.
The AudioThru directory contains labs I've used to teach the ALSA sound driver.
- audio_record shows how to capture audio and store it in a file.
- audio_playback takes audio from a file and plays it.
- audio_loopthru has the students combine the first two labs to do real-time audio io.
- audio_c6run builds on the loopthru lab by passing the live data to the DSP for processing.
We only have time for one lab, so do the last one.
# cd lab06d_audio_c6run # ls
There are 3 groups of files here. The source code (*.c and *.h), object files for running on the ARM (gpp) only (audioThru_arm, gpp, gpp_lib) and objects files for running on the DSP (audioThru_dsp, dsp, dsp_lib). What's significant is that the same source code produced both sets of objects (dsp, gpp). It's how the source is compiled determines where it is run.
Run the apps.
# ./audioThru_arm # ./audioThru_dsp
Both will run until you hit ctrl-C. To hear something you need to hookup your mp3 player to the input on the Beagle and speakers to the output.
Once you are sure it is working, try building everything from scratch.
# make clean # make
By default make creates both the ARM only and DSP objects. make takes about 20 seconds on my Beagle.
Experiment with the code
Now that you have something working, play around a bit. git is installed so you can preserve the present contents of the files with:
# git add Makefile audio_input_output.c audio_process.c audio_thread.c # git commit -m "Initial commit"
If needed you can use git to retrieve the original version of the files.
Things to try:
- There are places in the code where timing can be displayed. Remove the comments and display the times. How often is the main loop executed? How long does the DSP take? What's the overhead for the DSP?
- Try making the DSP do more than pass through. Zero out the left channel to be sure it is working.
- Try changing the sampling rate and buffer sizes. What setting cause the buffers to overflow or underflow?
- Implement your own processing on the DSP. Do a simple FIR lowpass filter, etc.
- Switch the input to the microphones on the web cam and listen to your voice.