Unable to stream audio from Raspberry Pi to Mac

Forums / NoMachine for Mac / Unable to stream audio from Raspberry Pi to Mac

This topic contains 16 replies, has 3 voices, and was last updated by Avatar Bilbotine 2 months, 3 weeks ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #22875
    Avatar
    hpb
    Participant

    I’m running NoMachine 6.7.6 on Raspberry Pi stretch, 6.7.6 on macOS Mojave 10.14.5.  These are the free versions of the software.

    I am able to successfully log onto my Raspberry Pi from my MacBook Pro.  But I am unable to stream audio from a USB soundcard on the Pi back to my Mac.

    I have set up accessibility on my MacBook Pro per the instructions in  https://forums.nomachine.com/topic/no-audio-from-macbook-air-to-imac

    On my Pi, under Perferences->Forwarded devices, I have the box checked for Enable audio streaming and microphone forwarding.

    But…I’m not hearing anything from my Pi on my MacBook Pro.  Any ideas?  Thanks.

    #22881
    Avatar
    kroy
    Contributor

    Do you have PulseAudio installed on the Raspbian? Because audio is available only when the PulseAudio service is available (https://www.nomachine.com/AR07N00896). In addition, you have to make sure that your USB soundcard sink is set as the default.

    #22883
    Avatar
    hpb
    Participant

    No, I do not have PulseAudio installed on the Pi.  Thank you.  I will give this a try and get back to you.

    #22889
    Avatar
    hpb
    Participant

    I installed PulseAudio but still have problems.

    I now realize part of the problem is that I did not supply enough details about what I’m trying to accomplish.  I have the output audio from a radio going into the mic input of a USB soundcard.  I would like to hear this radio’s audio on the speakers of my Mac.

    I believe PulseAudio is correctly configured with the mic input of the USB soundcard as a source.  When I look at the Recording tab on pavucontrol,  I  see the audio varying in volume.  When I  reduce the volume on the radio the PulseAudio audio level in pavucontrol goes down and when I increase the volume on the radio the audio level in pavucontrol goes up.  So I believe PulseAudio is capturing the audio output from the radio.

    Am I misunderstanding how NoMachine’s audio forwarding works?  Is the audio from the PulseAudio mic input on my Pi not going to be forwarded to my Mac?  Is there a way to redirect this input audio stream on the Pi so that I can hear it on the Mac?

    Thanks.

    #22890
    Avatar
    hpb
    Participant

    If this will help, here is  the output of my list of sources.  I believe this shows my USB mic input set as the default source.

    pacmd list-sources | grep -e ‘index:’ -e device.string -e ‘name:’

    * index: 1
    name: <alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono>
    device.string = “hw:1”
    index: 2
    name: <alsa_output.platform-soc_audio.analog-stereo.monitor>
    device.string = “0”
    index: 3
    name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo.monitor
    device.string = “1

    #22905
    Avatar
    hpb
    Participant

    One more datapoint…I removed disconnected the USB soundcard and played a YouTube video on the Pi.  I hear audio coming  out  of the Pi when I connect headphones to the Pi’s audio jack but I hear nothing on my Mac.

    I actually removed NoMachine from my Pi and reinstalled it so that it would be aware of Pulseaudio.  I also performed this command on the Pi that I saw in another support  thread:

    sudo /usr/NX/scripts/setup/nxnode --audiosetup

    #22912
    Avatar
    kroy
    Contributor

    First of all check AudioInterface key in the /usr/NX/etc/node.cfg if there is pulseaudio set (you can skip this step if you followed mentioned earlier article and executed /usr/NX/bin/nxnode --audiosetup [path] command after PulseAudio installation).

    Is the audio from the PulseAudio mic input on my Pi not going to be forwarded to my Mac?

    Indeed. It’s possible to forward from client to server machine, but not in the opposite direction. However to receive audio from input device you can use module-loopback. In your case you can execute command: pacmd load-module module-loopback source=alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono

    #22915
    Avatar
    hpb
    Participant

    It works!  Thanks you so much, especially since PulseAudio support is outside typical NoMachine usage.

    I am an amateur radio operator who is looking at operating my station remotely using NoMachine.  I operate mostly modern digital modes and Morse Code, which is all generated on my Raspberry Pi.  It would be nice to be able to operate voice remotely, but I can very much live without it.

    This is excellent support, especially for something that cost me nothing to download.  Thanks!

    #22918
    Avatar
    hpb
    Participant

    To close the loop on this topic so that it is properly documented for anybody searching for a solution….

    I have figured out how to get voice audio from the mic of my MacBook Pro into the output of the USB soundcard connected to my Pi.  This means that I’ll be able to use my Mac as a mic to talk to my amateur radio transceiver.

    The final piece of the puzzle is the following PulseAudio command:

    pactl load-module module-loopback source=nx_voice_out.monitor sink=alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo

    When I plug in a set of headphones into the output of the USB soundcard and use pavucontrol to enable NoMachine output and increase the output, I hear the output of my Mac’s mic!

    Thank you so much for the help and teaching me how to configure PulseAudio.  I have many years of experience as a Linux admin, but in a business environment, so I never had the opportunity to work with PulseAudio before.

    #22919
    Avatar
    hpb
    Participant

    One final question, I want to understand why the command you gave me earlier works.

    pacmd load-module module-loopback source=alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono

    There is no sink specified.  According  to the PulseAudio docs, when this happens, the source is sent to the default sink which on my system is:

    * index: 0
    name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo>

    The * before index means this is the default sink.

    So, my question is, this works because NoMachine automatically connects to the default sink on the Pi and this is how audio gets back to NoMachine on the Mac, right?  Or at least this is what appears to be happening.

    Right now I’m happy this all works, but I’m trying to understand why it works so that I can troubleshoot on my own.

    #22928
    Avatar
    kroy
    Contributor

    This means that I’ll be able to use my Mac as a mic to talk to my amateur radio transceiver.

    You don’t need to use module-loopback to achive that. Just enable microphone on the NoMachine menu https://www.nomachine.com/DT07M00087#6.1.

    We just misunderstood. From you wrote earlier I understand that somehow you have radio pluged to the input on the USB soundcard and you want to stream that to your client machine. Thats why I propose that command.

    So, my question is, this works because NoMachine automatically connects to the default sink on the Pi and this is how audio gets back to NoMachine on the Mac, right?  Or at least this is what appears to be happening.

    Yes, it’s exactly as you written. NoMachine connects to the default sink and set default source.

    #22938
    Avatar
    hpb
    Participant

    Yes, I can now hear audio from my Mac’s mic on the output of the USB soundcard.  Thank you!  One less PulseAudio command to run.

    #22939
    Avatar
    hpb
    Participant

    And, the output of the NoMachine audio can be redirected using the Playback tab on pauvcontrol.  But this is still better than running a pauvcontrol command.

    #22971
    Avatar
    hpb
    Participant

    I believe I  have found a better way to send and receive audio to and from my amateur radio tranceiver.  The problem with the way we were doing it meant that received audio coming from device alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo.monitor,  the input of my USB soundcard, was being redirected to the output of the same soundcard, device alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo.  It seemed to me like there was potential for feedback.  It also bothered me that we had both ouput and input audio on the output of the USB soundcard at the same time, this just didn’t seem right.

    Instead I created a dummy sink, made it the default sink, and assigned the output of the USB soundcard to the dummy sink:

    pactl load-module module-null-sink sink_name=dummy

    pacmd set-default-sink dummy

    pacmd load-module module-loopback source=alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono sink=dummy

    This gets received audio from the radio’s headphone jack picked up by the nx_voice_out sink because dummy is now the default sink and the received audio is sent back  to the speakers/headphones of the Mac.

    Next, I send audio from my Mac to the output of the USB soundcard to be input into the mic jack of my transmitter:

    pactl load-module module-loopback source=nx_voice_out.monitor sink=alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo

    This appears  to work and I don’t have output audio from the ham transceiver also on the 0utput of the USB soundcard going back to the radio’s mic.  The key here is use of the dummy sink using module-null-sink.

    Does this all make sense?

     

    #23002
    Avatar
    kroy
    Contributor

    It does make sense. Now inside the session on the Mac you are hearing only microphone from USB soundcard plugged to RPi. However on the headphones plugged to the same USB soundcard on RPi you can hear desktop + microphone from your Mac (don’t forgot to enable mic in NoMachine menu to make that work).

Viewing 15 posts - 1 through 15 (of 17 total)

This topic was marked as solved, you can't post.