[SOLVED] Using multiple inputs with Max2Play on RPi2+CirrusLogic sound card Independently

Max2Play Home Forums Max2Play on Raspberry PI [SOLVED] Using multiple inputs with Max2Play on RPi2+CirrusLogic sound card Independently

Viewing 7 posts - 1 through 7 (of 7 total)
  • 11. November 2016 at 19:32 #23885

    After spending far too much time trying to figure out how to get this configured correctly, I actually managed to get it running flawlessly. The end result is running LMS/squeezebox through max2play while also streaming from the S/PDIF In and Line In ports on the Wolfson card. The reason I wanted to do this is so that I could listen to Google Play Music (Max2Play being the only real option), vinyl records from turntable (Line In), or Xbox (games/plex streaming) on their own or in any combination without having to run any commands.

    Max2Play
    Simple to set up, make sure you download the base „Max2Play Raspberry Pi Image“ as it runs Jessie-Lite without any extras. The squeezeplug version runs wheezy which makes installing googleplaymusicapi unreasonable. After you flash your SD card and let M2P install, ensure you have the Raspberry Setting Plugin enabled. Go ahead and install Squeezelite from the „Audioplayer“ tab and if you want, grab shareport and the DLNA client (Also available as Squeezebox plugins). Install Logitech Media Server under „Squeezebox Server“, make sure you install the 7.9 nightly release if you want to use Google Play Music. This installation will take 5-10 minutes so just be patient, Max2Play conveniently shows the installation log as it goes so you don’t have to guess at its success. After it is complete, install the Google Play Music plugin and the ShareTunes2 plugin for airplaying files from iOS devices.

    Cirrus Logic Setup
    Reboot the pi once more and navigate to the „Raspberry Settings“ tab. Select the Wolfson Card from the drop down list and reboot when prompted. Return to the same tab and check the „Enable I2S-MMAP (Mixerdevice for Soundcards)“ check box. Now we get to where I started struggling. After reading every post from Ragnar (GOAT for this forum by the way!!!) numerous times I finally figured it out. First off, even though M2P knows you have a sound card in use at this point, it never changes the card number in the ALSA device structure. This was an oversight on their part so I chose instead to use Ragnar’s .asoundrc file instead.

    Link: Ragnar’s Audio Devices

    sudo cp /etc/asound.conf ~/asound.conf.backup  
    # Make a copy of Ragnar's .asoundrc  
    sudo mv ~/.asoundrc /etc/asound.conf  

    Note: M2P implements a different order for sound cards than Ragnar’s kernel does. So you will have to replace every „card 0“ with „card 1“

    Next, edit /opt/max2play/audioplayer.conf and change the squeezelite command to:
    „SQUEEZELITE_PARAMETER=-o default -a 16“
    This sets the audio device to the default device as configured in /etc/asound.conf which we set up to allow multiple input streams/recordings at once.

    Routing Setup
    M2P implements a slightly varied set of use case scripts that you will find whenever this sound card comes up and will be found in /opt/max2play/wolfson/

    Since I am using the LineOut port, I edited the „Playback_to_Lineout.sh“ file found in this directory. This script is run by Max2Play whenever squeezelite is started so it is kind of the only relevant script in this example. It is pretty straight forward to adapt to other outputs though. But here is my edited script:

    #!/bin/bash  
    # $1 added to support 1st line argument. i.e. "./Playback_to_Lineout.sh -q" will stop all the control information  
    #being displayed on screen  
    #Playback from AP to Line Output, default gain 0dB  
      
      
    amixer $1 -Dhw:sndrpiwsp cset name='SPDIF In Switch' on  
      
      
    # Clear the HPOUT2 Input 1 and 2 mixers. This will ensure no previous paths are connected to the HPOUT2. This doesn't  
    # include Inputs 3 and 4.  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 1' None  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 1' None  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 2' None  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 2' None  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 3' None  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 3' None  
    # Setup HPOUT2 input path and volume for streaming  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 1' AIF1RX1  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 1 Volume' 20  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 1' AIF1RX2  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 1 Volume' 20  
    # Setup HPOUT2 input path and volume for S/PDIF in  
    # Pass through Low/High Pass Filter Fers  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF3 Input 1' AIF2RX1  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF4 Input 1' AIF2RX2  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF3 Mode' High-pass  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF4 Mode' High-pass  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF3 Coefficients' 240,3  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF42 Coefficients' 240,3  
    # Now add as input to HPOUT2  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 2' LHPF3  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 2' LHPF4  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 2 Volume' 15  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 2 Volume' 15  
    # Setup HPOUT2 input path and volume for Line-in better THD in normal mode vs lower noise floor in high performance  
    amixer $1 -Dhw:sndrpiwsp cset name='IN3 High Performance Switch' on  
    # Configure the input path for 0dB Gain, HPF with a low cut off for DC removal  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF1 Input 1' IN3L  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF2 Input 1' IN3R  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF1 Mode' High-pass  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF2 Mode' High-pass  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF1 Coefficients' 240,3  
    amixer $1 -Dhw:sndrpiwsp cset name='LHPF2 Coefficients' 240,3  
    # Now mix to HPOUT2  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 3' LHPF1  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 3' LHPF2  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2L Input 3 Volume' 32  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2R Input 3 Volume' 32  
    #Finally unmute HPOUT2  
    amixer $1 -Dhw:sndrpiwsp cset name='HPOUT2 Digital Switch' on

    That should do it! Now you can play from those three sources independently and simultaneously. All that is left is to open the LMS webui and configure squeezebox plugins to your needs!

    Shoutout to ragnar.jensen for knowing the inner workings better than I ever will!

    • This topic was modified 7 years, 12 months ago by nonchalant.
    • This topic was modified 7 years, 10 months ago by Heiner.
    17. November 2016 at 16:42 #23947

    Nonchalant, this is fantastic news, thank you!

    Although at first read I do not fully understand how to implement the feature 🙁 Do I have to use Ragnar’s .asoundrc file as well as your script? Sorry, but I am a complete noob when it comes to programming. I think I can follow what I have to do with your script and the editing of the audioplayer.config, but I am not sure what to do with Ragnar’s file.

    Thanks for any further help you may be prepared to give me with this.

    Regards,
    Simon

    • This reply was modified 7 years, 11 months ago by gapmedia.
    17. November 2016 at 21:05 #23951

    Yes essentially you replace /opt/max2play/wolfson/Playback_to_LineOut.sh with what I laid out at the end. I actually ended up adding Ragnar’s .asoundrc to the existing /etc/asound.conf, replacing „card 0“ with „card 1“ when necessary and renaming Ragnar’s „@!default“ with „@!default2.“

    Unfortunately, I couldn’t get „default2“ to show up on max2play’s audioplayer page so you have to manually change the parameter in /opt/max2play/audioplayer.conf to „SQUEEZELITE_PARAMETER=-o default2 -a 80:4::“

    Also this isn’t perfect, I haven’t been able to get shairport to work but the Lms plugin works. Also if you change the settings on the audioplayer page, you will have to go back and change the conf file manually again. Don’t use the localplayer plugin in Lms and set squeezelite to autostart (check config afterwards), then it should start fine every boot.

    Lastly, note Ragnar’s comment in the linked thread, this resamples audio from the pi to 16bit, 44100hz so the audio quality could be better.

    19. November 2016 at 4:09 #24018

    Thank you nonchalant. I will attempt your instructions, and see how I go.

    Regards,Simon

    13. April 2017 at 16:48 #28239

    Nonchalant,

    I followed the exact same steps as you have told and I was able to route the music stream from Line-in on to the Line-Out of the Cirrus logic card. However I am not understanding the settings for LMS squeezebox server. I want to receive the same music stream on any device within my Local network. Could you please help me out with this? I just want to be able to stream music from Line-In of the Cirrus logic card to squeezebox server. Thank you in advance.

    Regards,
    Abhijith

    31. Juli 2017 at 17:49 #30266

    Hello

    Would it be possible to integrate the goat/nonchalant solution in an future update of max2play ?

    This might be a nice opportunity for all cirruslogic soundcard users.

    Thanks in advance
    Greetings
    Jof

    4. Juni 2018 at 20:59 #36082

    Nonchalant are there any updates or changes needed now that it’s 2 years later? Did M2P make updates to the code now? Thank you for your detailed explanation!! I am trying to implement audio sources from my TV setups throughout my home and be able to switcher properly.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Register here