Recording audio to a pulseaudio stream / sink input, and playing from stream on demand












0















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.










share|improve this question



























    0















    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.










    share|improve this question

























      0












      0








      0








      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.










      share|improve this question














      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.







      sound pulseaudio alsa streaming






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 25 '18 at 9:19









      mozcelikorsmozcelikors

      1065




      1065






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1104408%2frecording-audio-to-a-pulseaudio-stream-sink-input-and-playing-from-stream-on%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            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.






            share|improve this answer




























              0














              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.






              share|improve this answer


























                0












                0








                0







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 25 '18 at 10:18









                mozcelikorsmozcelikors

                1065




                1065






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1104408%2frecording-audio-to-a-pulseaudio-stream-sink-input-and-playing-from-stream-on%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Ellipse (mathématiques)

                    Quarter-circle Tiles

                    Mont Emei