1

I am using CS42888 codec in order to record audio from Line Input. I read the thread Record a program's output with PulseAudio and got some ideas towards what I am trying to achieve. However, I have a few problems.

Problem

Firstly, the only way I'm able to record from the device currently is as follows:

arecord -Dhw:cs42888audio -f S16_LE -r 48000 test.wav

I can play with:

arecord -Dhw:cs42888audio test.wav

I would like to introduce the following:

  • Record the cs42888audio input to a pulseaudio stream (under "radio" name)

Either:

  • Whenever "radio" stream is available, I would like to make that my default stream and route it to cs42888 output.

Or:

  • Always record to "radio" stream on background. Play/stream it whenever needed with a set of commands.

What I've Tried

pactl list sink-inputs                         # Gives nothing
pactl load-module module-null-sink sink_name=radio
pactl move-sink-input 3 radio                  # Fails
parec --format=s16le --rate=48000 -d alsa_output.platform-sound-cs42888.analog-surround-51.monitor | lame -r --quiet -q 3 --lowpass 17 --abr 192 - "temp.mp3"
aplay -Dhw:cs42888audio temp.mp3               # No audio other than noise

Sound Configuration

My .asoundrc is as follows:

pcm.!default {
    type hw
    card 2
    device 0
}

My /etc/pulse/system.pa has:

set-default-source alsa_input.platform-sound.analog-mono
set-default-sink alsa_output.platform-sound.analog-mono

aplay -l gives:

**** List of PLAYBACK Hardware Devices ****
card 0: cs42888audio [cs42888-audio], device 0: HiFi cs42888-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 1: HiFi-ASRC-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: amixaudiosai [amix-audio-sai], device 0: HiFi-AMIX-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: amixaudiosai [amix-audio-sai], device 1: HiFi-AMIX-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

arecord -l gives:

**** List of CAPTURE Hardware Devices ****
card 0: cs42888audio [cs42888-audio], device 0: HiFi cs42888-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 1: HiFi-ASRC-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: amixaudiosai [amix-audio-sai], device 0: HiFi-AMIX-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pactl list short sinks

0   alsa_output.platform-sound-amix-sai.analog-mono module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
1   alsa_output.platform-sound-cs42888.analog-surround-51   module-alsa-card.c  s16le 6ch 48000Hz   SUSPENDED
2   alsa_output.platform-sound.analog-mono  module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED

pactl list short sources

0   alsa_output.platform-sound-amix-sai.analog-mono.monitor module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
1   alsa_input.platform-sound-amix-sai.analog-mono  module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
2   alsa_output.platform-sound-cs42888.analog-surround-51.monitor   module-alsa-card.c  s16le 6ch 48000Hz   SUSPENDED
3   alsa_input.platform-sound-cs42888.analog-mono   module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
4   alsa_output.platform-sound.analog-mono.monitor  module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
5   alsa_input.platform-sound.analog-mono   module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED

Guidance is greately appreciated. Thanks.

1

Solved it!

pactl load-module module-loopback source=alsa_input.platform-sound-cs42888.analog-mono sink=alsa_output.platform-sound-cs42888.analog-surround-51 rate=48000

However, pactl unload-module module-loopback does not work effectively, waits for a few seconds. It would be good if I could unload it instantly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.