¿ªÔÆÌåÓý

hacking the audio system of sbitx DE, V2, V3


 

The audio system uses a WM8731 codec. This samples 96000 times a second and produces 32 bit samples in stereo (only 24 bits have actual data).
This means that there are 96000x32x2 , approximately 6.144 million bits per second in each direction (record and play). This is transferred?over the I2S bus. The BCLK runs at twice this frequency?of 12.288 MHz.
An Unfortunate confusion
The WM8731's I2S uses the word "frame" and so does the alsa sound system of linux. for entirely different reasons. The WM8731 frame refers to a pair of single left and right samples of audio (a total of 64 bits). In alsa, it refers to a few hundred of the pairs of left and right samples. So, the ALSA's frame is made of a number of WM8731 frames!
How audio is organized
The audio?system uses the right channel to transmit and the left channel to receive (yes, both can theoretically work at once, we need to write the software that way). The demodulator output?is fed to the left channel line input and the microphone is connected to the right channel. Each time 1024 samples of left and right are ready, the system calls sound_process(). Here the sbitx takes over, depending upon the transmit or receive status, right or left channel is processed and returned to the sound subsystem to be played to the speaker and/or the transmission system.
Hacking the system
The sound system has been abstracted to just two calls: first, sound_thread_start is called and in a seperate thread, sound_process is called with left, right input and output pcm streams at 32-bit arrays. depending upon the transmit/receive status, the appropriate processing is done by sdr.c of these samples. Remember not to call any GUI related code from sound_process as it needs to get back within a few milliseconds to handle the next block of audio.
Playing around
You could (at one time, I havent tried it for a few years) compile the sbitx_sound.c as a separate program? by uncommenting the main() function. You may have to comment out some code to remove the dependencies from sbitx specific code.
- f


Join [email protected] to automatically receive all group messages.