SHARC-ALSA is a framework designed to make a SHARC appear as an audio device in ALSA. It uses RPMsg for the communication between the ARM Core and the SHARC Core. When playing audio through ALSA the audio samples are transferred to the SHARC where additional processing can take place before the audio is played.
An example SHARC image providing 2-channel playback is present in the /lib/firmware folder on the target. The SHARC can be programmed with this image using the sysfs interface to remoteproc as shown below:
# echo 2Channel-SC594.ldr > /sys/class/remoteproc/remoteproc0/firmware # echo start > /sys/class/remoteproc/remoteproc0/state
When executing the “echo start” command you will notice the LEDs on the SOMCRR-EZKIT flashing and then settle on LED7 remaining on. This indicates that the image on the SHARC is running.
Play back the audio sample file stored in /usr/share/sounds/alsa/
# aplay /usr/share/sounds/alsa/2Ch_L440_R200_48kHz_16bit_6s.wav
You will hear a 440Hz tone on the left channel and a 200Hz tone on the right channel being played for 6 seconds.
The SHARC can be instructed to add a tone to the audio played using aplay. This is done through a command interface which also uses RPMsg for passing on the instructions to the SHARC Core. A helper tool for simplifying this is installed on the target. The tool creates a character device which will accept a channel number and a frequency to be added to the audio as strings allowing for simple interaction from the command line.
# rpmsg-bind-chardev -d virtio0.sharc-audioweaver.-1.201 -a 60
Once the binding has been created a character device /dev/rpmsg0 is available and will accept commands with the syntax <channel> <frequency>. To add a 800Hz tone to channel 0 (Left) enter the following at the command line:
# echo 0 800.0 > /dev/rpmsg0
Similarly to add a 500Hz tone to channel 1 (Right) enter the following command:
# echo 1 500.0 > /dev/rpmsg0
When running aplay again you will hear a dual tone frequency on both channels. Left channel will contain 440Hz + 800Hz whereas the right channel will contain 200Hz + 500Hz.
# aplay /usr/share/sounds/alsa/2Ch_L440_R200_48kHz_16bit_6s.wav