element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Can you hear the Wolf(son) calling? Setting up and using the Wolfson Audio Card
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: cstanton
  • Date Created: 14 Mar 2014 2:40 PM Date Created
  • Views 5018 views
  • Likes 5 likes
  • Comments 60 comments
Related
Recommended
  • wolfson
  • raspberry
  • audio
  • pi
  • microelectronics
  • micro
  • raspberry_pi
  • wm5102
  • raspeberry_pi_accessories
  • electronics
  • hd_audio
  • card
  • hd

Can you hear the Wolf(son) calling? Setting up and using the Wolfson Audio Card

cstanton
cstanton
14 Mar 2014
image

 

This audio card will push your Pi.

 

The Wolfson Audio CardWolfson Audio Card has taken a good amount of time to come forth from Wolfson Microelectronics and with decent reason. They want to make sure that they have it right and something that you can work with. As with any audio setup it takes a little time to optimise and get it setup correctly, but once you're there then you have a potentially powerful portable audio sensation in your hands. The audio codec with digital signal processor for voice, WM5102 even won an award in 2013 for innovation from the Institute of Engineers and Technology (IET)


The package for the Wolfson Audio Card comes in the standard Raspberry PiRaspberry Pi add-on box that you may be used to if you've picked up a GertduinoGertduino or Pi FacePi Face. The box clearly informs you as to the features the device comes with and where to go for more information. Chances are you're going to need it.

 

Upon opening the packaging you're presented with the regulation anti-static bag containing your card along with a slip of paper covering regulations compliance and rather curiously, a plastic screw. It seemed odd at first why there was a lone screw in the box, but once I fitted the audio card to the Raspberry Pi it became clear.

 

To ensure that the boards push/pogo-pins make contact with the Raspberry Pi, using an unpopulated header next to the GPIO breakout it needs the screws to make sure that the board is pushed securely to the Pi. I found it stranger that it wasn't a metal screw, but this makes sense after making sure that it was fully in, it potentially touches on some on-board circuitry and we wouldn't want any short-outs to happen.

 

Before getting started with the setup, make sure that you have any USB devices that you're going to use with it, plugged in. I had the unfortunate experience later when I exchanged my USB devices for others that the Raspberry Pi restarted. There is warning of using USB hubs in the user manual so I suspect this is related and possibly an issue with power.

 

The best choice to get started is to write the SD Card image provided on element14 to get started with the card, there are a number of modifications and hacks to the stock Raspbian kernel and installed modules that have been necessary to get the device to work.

If you're running Windows then you can download Win32DiskImager to write the image to the SD Card, so long as you have Administrative rights and a way to connect your SD Card to your computer. Or if you're running Linux you can use the dd command to write it to your /dev/<device name> card. If you need to check this, then typing 'man dd' at a terminal will help you with the dd command, and typing 'dmesg' at a terminal will help you to determine what your SD Card is referred to as.

 

You have the option of downloading and compiling the kernel/driver source code and apply the patches to it to get it to work and then install the modules; but unless you're comfortable with cross-compiling on a faster computer and debugging any problems that occur you're going to be waiting a long time, not just for compiling on your Pi but also downloading the source files for the Raspbian kernel. Hopefully Wolfson Microelectronics or a member of the community will bring out a Raspbian package to install from or the changes will be integrated into the Raspbian OS by default in the future.

 

*Edit*: Ragnar Jensen has pulled out the compiled kernel and modules for the Wolfson Audio Card along with the use case scripts and put them into a compressed file that you can extract on your existing Raspbian installation. Note that this will lock you down to using a specific kernel that will not be updated when you update Raspbian, you can get it from here.

 

The SD Card needs to be of Class 6 or higher, especially if you want to read/write high quality audio, of note is that the Raspbian installation, which I downloaded at least, has been modified by Wolfson and attempts to overclock the Raspberry Pi to 900mhz with slight voltage alteration. This can be disabled in the config.txt in the /boot/ folder by finding the relevant lines and removing them.

 

So, let's test it by playing music! When you have booted your Pi with your audio card attached and SD Card setup you will want to open LXTerminal on the desktop, then type one of the relevant commands, assuming that you are in the /pi/home directory, based on how you want to listen to your music:

 

CommandDescription
./Playback_to_Headset.shIf you want to use the black headphone jack
./Playback_to_Lineout.shif you want to use a set of powered speakers from the LineOut jack
./Playback_to_Speakers.shif you want to use a set of speakers powered from/connected to the header(s) on the board
./SPDIF_playback.shUse the S/PDIF digital connection on the board

 

These scripts are located in the 'pi' user account home directory (/home/pi) and they are just a set of commands for setting up AlsaMixer (aka amixer, which PEarle has gone into more detail in his tasty write-up here: Wolfson Audio Card - Command Line recording ) to use the relevant device for outputting the audio. Once you're familiar with Alsa and the scripts you can edit these as you see fit, they commit themselves such that they're persistent after a reboot of the Pi.

 

Once you have setup your output, we can run Music Player from the desktop, the playlist is already populated, then just play away. These audio files are in a very nice .flac format which is a non-loss audio compression standard. For me there was some delay before the play started, and there were gaps, clicks and pops. This is because I was using a Class 4 SD Card, I changed this for a Class 6 and played just fine. It still wasn't very fast on occasion though, with this particular Raspbian installation there is a CPU usage monitor on the taskbar which was regularly sitting at 100% usage.

 

Now, to record on the Wolfson Audio Card is a different matter, it isn't straightforward to install audio software such as Audacity and just record. The best way to check it is to run a command from the terminal again. To setup AlsaMixer using the scripts you can choose one of the following, assuming that you are in the /pi/home directory:

 

CommandDescription
./Record_from_Headset.shRecords from the boom mic' on a headset
./Record_from_lineIn.shRecords from a powered/amplified device/microphone on the line in jack
./Record_from_DMIC.shRecords from the stereo microphones that are situated on the Wolfson Audio Card
./SPDIF_record.shRecords from the digital S/PDIF connector

 

For recording, unfortunately I do not have any S/PDIF equipment, or a boom microphone style headset, so I mainly tested the on board digital stereo microphones! I can confirm that they're definitely in stereo, record quite clearly with minimal post-cleanup, but the channels were opposite to how they are marked on the board (left was right and right was left). Which is just a minor point really.

 

Fullscreen 5706.contentimage_30817.html Download
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>

 

In the picture to the left, in the audio file I recorded via command line and then loaded into Audacity you can see where I spoke into each left/right channel individually at an intentional offset.

 

You can also see what the record quality is like for silence up until that point, initially there is some raised audio level and the click of initialisation. It is probably a good idea to bare this in mind when you're recording and to do some post cleanup depending on what you're using it for.

 

The method suggested to record audio on the Wolfson Audio Card is specified in each of the .sh files, which you can run the command "less ./Record_from_DMIC.sh" to read. I didn't manage to get Audacity to record from the card directly as it only had options for S/PDIF - I am assuming this is because of how Audacity integrates with Alsa and that this is not currently setup in an ideal way even by switching with the scripts (use cases) provided. Edit: It's worth reading Ragnar's post below in the comments regarding using Audacity with the Wolfson Audio Card, in particular the post on altering the use case for the on board digital microphones (DC offset on microphones and workaround.).

 

All in all it's a nice little board but it's going to take a bit of polish and work from Raspbian/the Community/Wolfson microelectronics to get the process streamlined, but I'm thankful we now have the opportunity to do so! The results are definitely worth it.

  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 11 years ago +2
    I have found that if I select wolfson_pi_soundcard: AIF:0 as input in Audacity, it will record from whatever I have selected with the "Record_from..." scripts. There is DC offset when recording from the…
  • Former Member
    Former Member over 11 years ago +1
    Hey Chris, Nice fyi..
  • Former Member
    Former Member over 11 years ago +1
    Thank you Chris for this very useful walk through/review.
Parents
  • rjnorthrow
    rjnorthrow over 11 years ago

    I've brought together the various shell scripts into one that set the output and input for the card and allow you to choose via a menu.

    I hope it's useful to someone.

     

    <code>

    #!/bin/bash

    #

    # Wolfson_Setup.sh

    # ----------------

    # Select the audio input/output for the Wolfson Audio Card

    #

    # Set some standard paths

    AMIXER=/usr/bin/amixer

    GETOPT=/usr/bin/getopt

    ZENITY=/usr/bin/zenity

    #

    # Set variables

    NULL=/dev/null

    CARD="-Dhw:0"

    #

    function set_args {

      #

      # Set command line arguments

      #

      ARGS=$($GETOPT -o qv -l "quiet,verbose" -- "$@");

      eval set -- "$ARGS";

      #

      while true; do

        case "$1" in

          -q|--quiet)

            shift;

            QUIET="-q"

            ;;

          -v|--verbose)

            shift;

            QUIET=""

            ;;

          --)

            shift;

            break;

            ;;

        esac

      done

    }

    #

    function amixer_cget {

      $AMIXER $CARD cget name="$1"

    }

    #

    function amixer_cset {

      $AMIXER $QUIET $CARD cset name="$1" $2

    }

    #

    function reset_paths {

      #

      # Switch everything off

      #

      amixer_cset 'TX Playback Switch'          off

      amixer_cset 'RX Playback Switch'          off

      amixer_cset 'AIF Playback Switch'         off

      amixer_cset 'SPDIF in Switch'             off

      amixer_cset 'SPDIF out Switch'            off

      #amixer_cset 'IN1 Digital Switch'          off

      #amixer_cset 'IN2 Digital Switch'          off

      #amixer_cset 'IN3 Digital Switch'          off

      amixer_cset 'IN3 High Performance Switch' off

      amixer_cset 'Headset Mic Switch'          off

      amixer_cset 'DMIC Switch'                 off

      amixer_cset 'Speaker Digital Switch'      off

      amixer_cset 'AIF1TX1 Input 1'             None

      amixer_cset 'AIF1TX2 Input 1'             None

      amixer_cset 'AIF2TX1 Input 1'             None

      amixer_cset 'AIF2TX2 Input 1'             None

      amixer_cset 'HPOUT1L Input 1'             None

      amixer_cset 'HPOUT1R Input 1'             None

      amixer_cset 'HPOUT1L Input 2'             None

      amixer_cset 'HPOUT1R Input 2'             None

      amixer_cset 'HPOUT2L Input 1'             None

      amixer_cset 'HPOUT2R Input 1'             None

      amixer_cset 'HPOUT2L Input 2'             None

      amixer_cset 'HPOUT2R Input 2'             None

      amixer_cset 'SPKOUTL Input 1'             None

      amixer_cset 'SPKOUTR Input 1'             None

      amixer_cset 'SPKOUTL Input 2'             None

      amixer_cset 'SPKOUTR Input 2'             None

    }

    function get_current {

      #

      # Find the first enabled output and input

      #

      TO_HEADSET=FALSE

      TO_LINEOUT=FALSE

      TO_SPEAKERS=FALSE

      TO_SPDIF=FALSE

      FROM_HEADSET=FALSE

      FROM_LINEIN=FALSE

      FROM_DMIC=FALSE

      FROM_SPDIF=FALSE

      #

      if amixer_cget 'HPOUT1 Digital Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_HEADSET=TRUE

      elif amixer_cget 'HPOUT2 Digital Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_LINEOUT=TRUE

      elif amixer_cget 'Speaker Digital Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_SPEAKERS=TRUE

      elif amixer_cget 'SPDIF out Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_SPDIF=TRUE

      fi

      #

      if amixer_cget 'Headset Mic Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_HEADSET=TRUE

      elif amixer_cget 'IN3 High Performance Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_LINEIN=TRUE

      elif amixer_cget 'DMIC Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_DMIC=TRUE

      elif amixer_cget 'SPDIF in Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_SPDIF=TRUE

      fi

    }

    #

    function to_headset {

      #

      # Playback from AP to Headset

      #

      amixer_cset 'HPOUT1 Digital Switch'  on

      # Set path gain to -6dB for safety. ie mav 0.5Vrms output level

      amixer_cset 'HPOUT1 Digital Volume'  116

      # Do we want to clear the HPOUT mixer inputs?

      amixer_cset 'HPOUT1L Input 1'        None

      amixer_cset 'HPOUT1R Input 1'        None

      amixer_cset 'HPOUT1L Input 2'        None

      amixer_cset 'HPOUT1R Input 2'        None

      amixer_cset 'HPOUT1L Input 1'        AIF1RX1

      amixer_cset 'HPOUT1L Input 1 Volume' 32

      amixer_cset 'HPOUT1R Input 1'        AIF1RX2

      amixer_cset 'HPOUT1R Input 1 Volume' 32

      amixer_cset 'Headset Mic Switch'     on

    }

    #

    function to_lineout {

      #

      # Playback from AP to Lineout

      #

      amixer_cset 'HPOUT2 Digital Switch'  on

      amixer_cset 'HPOUT2L Input 1'        AIF1RX1

      amixer_cset 'HPOUT2L Input 1 Volume' 32

      amixer_cset 'HPOUT2R Input 1'        AIF1RX2

      amixer_cset 'HPOUT2R Input 1 Volume' 32

    }

    #

    function to_speakers {

      #

      # Playback from AP to Speakers

      #

      amixer_cset 'Speaker Digital Volume' 128

      # reset speaker mixer inputs

      amixer_cset 'SPKOUTL Input 1'        None

      amixer_cset 'SPKOUTR Input 1'        None

      amixer_cset 'SPKOUTL Input 2'        None

      amixer_cset 'SPKOUTR Input 2'        None

      # Route AP to Speaker mixer

      amixer_cset 'SPKOUTL Input 1'        AIF1RX1

      amixer_cset 'SPKOUTL Input 1 Volume' 32

      amixer_cset 'SPKOUTR Input 1'        AIF1RX2

      amixer_cset 'SPKOUTR Input 1 Volume' 32

      # Unmute speaker output

      amixer_cset 'Speaker Digital Switch' on

    }

    #

    function to_spdif {

      #

      # Playback from AP to SPDIF

      #

      amixer_cset 'SPDIF out Switch'       on

      amixer_cset 'TX Playback Switch'     on

      amixer_cset 'Input Source'           AIF

      amixer_cset 'AIF Playback Switch'    on

      amixer_cset 'AIF2TX1 Input 1'        AIF1RX1

      amixer_cset 'AIF2TX1 Input 1 Volume' 32

      amixer_cset 'AIF2TX2 Input 1'        AIF1RX2

      amixer_cset 'AIF2TX2 Input 1 Volume' 32

    }

    #

    function from_dmic {

      #

      # Record from onboard DMICs to AP

      #

      #amixer_cset 'IN2 Digital Switch'     on

      # May want to tune the gain here.

      # Need at least -6dB

      amixer_cset 'IN2L Digital Volume'    116

      amixer_cset 'IN2R Digital Volume'    116

      amixer_cset 'AIF1TX1 Input 1'        IN2L

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        IN2R

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

      amixer_cset 'DMIC Switch'            on

    }

    #

    function from_headset {

      #

      # Record from Headset to AP

      #

      # This is set up as a dual mono record.

      # May not be what we want in all scenarios

      amixer_cset 'Headset Mic Switch'     on

      amixer_cset 'IN1R Volume'            20

      #amixer_cset 'IN1 Digital Switch'     on

      amixer_cset 'AIF1TX1 Input 1'        IN1R

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        IN1R

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

    }

    function from_lineout {

      #

      # Record from onboard Line Input to AP

      #

      # +9dB input PGA gain

      amixer_cset 'IN3L Volume' 8

      amixer_cset 'IN3R Volume' 8

      #

      # Better THD in normal mode vs lower noise floor in high performance

      amixer_cset 'IN3 High Performance Switch' on

      #

      #amixer_cset 'IN3 Digital Switch' on

      amixer_cset 'IN3L Digital Volume' 128

      amixer_cset 'IN3R Digital Volume' 128

      #

      amixer_cset 'AIF1TX1 Input 1'        IN3L

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        IN3R

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

    }

    #

    function from_spdif {

      #

      # Record from SPDIF in

      #

      amixer_cset 'SPDIF in Switch' on

      #

      # Switch off SPDIF TX in case already active

      # as WM8804 must run at RX rate if enabled

      amixer_cset 'TX Playback Switch'     off

      amixer_cset 'RX Playback Switch'     on

      amixer_cset 'AIF Playback Switch'    on

      amixer_cset 'AIF1TX1 Input 1'        AIF2RX1

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        AIF2RX2

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

    }

    #

    # MAIN

    #

    # Default to being quiet

    QUIET="-q"

    #

    set_args $@

    #

    get_current

    #

    reset_paths

    #

    OUTPUT=$($ZENITY --list --width=350 --height=250 --radiolist \

      --title="Choose Wolfson Audio Output" \

      --column "Select" --column="Output" $TO_HEADSET "Headset" $TO_LINEOUT "Line Out" $TO_SPEAKERS "Speakers" $TO_SPDIF "SPDIF" )

    if [ "$OUTPUT" = "Headset" ]; then

      to_headset

    elif [ "$OUTPUT" = "Line Out" ]; then

      to_lineout

    elif [ "$OUTPUT" = "Speakers" ]; then

      to_speakers

    elif [ "$OUTPUT" = "SPDIF" ]; then

      to_spdif

    else

      echo "cancel"

    fi

    #

    OUTPUT=$($ZENITY --list --width=350 --height=250 --radiolist \

      --title="Choose Wolfson Recording Input" \

      --column "Select" --column="Input" $FROM_HEADSET "Headset" $FROM_LINEIN "Line In" $FROM_DMIC "Onboard Microphones" $FROM_SPDIF "SPDIF" )

    if [ "$OUTPUT" = "Headset" ]; then

      from_headset

    elif [ "$OUTPUT" = "Line In" ]; then

      from_lineout

    elif [ "$OUTPUT" = "Onboard Microphones" ]; then

      from_dmic

    elif [ "$OUTPUT" = "SPDIF" ]; then

      from_spdif

    else

      echo "cancel"

    fi

    </code>

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • rjnorthrow
    rjnorthrow over 11 years ago

    I've brought together the various shell scripts into one that set the output and input for the card and allow you to choose via a menu.

    I hope it's useful to someone.

     

    <code>

    #!/bin/bash

    #

    # Wolfson_Setup.sh

    # ----------------

    # Select the audio input/output for the Wolfson Audio Card

    #

    # Set some standard paths

    AMIXER=/usr/bin/amixer

    GETOPT=/usr/bin/getopt

    ZENITY=/usr/bin/zenity

    #

    # Set variables

    NULL=/dev/null

    CARD="-Dhw:0"

    #

    function set_args {

      #

      # Set command line arguments

      #

      ARGS=$($GETOPT -o qv -l "quiet,verbose" -- "$@");

      eval set -- "$ARGS";

      #

      while true; do

        case "$1" in

          -q|--quiet)

            shift;

            QUIET="-q"

            ;;

          -v|--verbose)

            shift;

            QUIET=""

            ;;

          --)

            shift;

            break;

            ;;

        esac

      done

    }

    #

    function amixer_cget {

      $AMIXER $CARD cget name="$1"

    }

    #

    function amixer_cset {

      $AMIXER $QUIET $CARD cset name="$1" $2

    }

    #

    function reset_paths {

      #

      # Switch everything off

      #

      amixer_cset 'TX Playback Switch'          off

      amixer_cset 'RX Playback Switch'          off

      amixer_cset 'AIF Playback Switch'         off

      amixer_cset 'SPDIF in Switch'             off

      amixer_cset 'SPDIF out Switch'            off

      #amixer_cset 'IN1 Digital Switch'          off

      #amixer_cset 'IN2 Digital Switch'          off

      #amixer_cset 'IN3 Digital Switch'          off

      amixer_cset 'IN3 High Performance Switch' off

      amixer_cset 'Headset Mic Switch'          off

      amixer_cset 'DMIC Switch'                 off

      amixer_cset 'Speaker Digital Switch'      off

      amixer_cset 'AIF1TX1 Input 1'             None

      amixer_cset 'AIF1TX2 Input 1'             None

      amixer_cset 'AIF2TX1 Input 1'             None

      amixer_cset 'AIF2TX2 Input 1'             None

      amixer_cset 'HPOUT1L Input 1'             None

      amixer_cset 'HPOUT1R Input 1'             None

      amixer_cset 'HPOUT1L Input 2'             None

      amixer_cset 'HPOUT1R Input 2'             None

      amixer_cset 'HPOUT2L Input 1'             None

      amixer_cset 'HPOUT2R Input 1'             None

      amixer_cset 'HPOUT2L Input 2'             None

      amixer_cset 'HPOUT2R Input 2'             None

      amixer_cset 'SPKOUTL Input 1'             None

      amixer_cset 'SPKOUTR Input 1'             None

      amixer_cset 'SPKOUTL Input 2'             None

      amixer_cset 'SPKOUTR Input 2'             None

    }

    function get_current {

      #

      # Find the first enabled output and input

      #

      TO_HEADSET=FALSE

      TO_LINEOUT=FALSE

      TO_SPEAKERS=FALSE

      TO_SPDIF=FALSE

      FROM_HEADSET=FALSE

      FROM_LINEIN=FALSE

      FROM_DMIC=FALSE

      FROM_SPDIF=FALSE

      #

      if amixer_cget 'HPOUT1 Digital Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_HEADSET=TRUE

      elif amixer_cget 'HPOUT2 Digital Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_LINEOUT=TRUE

      elif amixer_cget 'Speaker Digital Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_SPEAKERS=TRUE

      elif amixer_cget 'SPDIF out Switch' | grep 'values=on' >$NULL 2>&1

      then

        TO_SPDIF=TRUE

      fi

      #

      if amixer_cget 'Headset Mic Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_HEADSET=TRUE

      elif amixer_cget 'IN3 High Performance Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_LINEIN=TRUE

      elif amixer_cget 'DMIC Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_DMIC=TRUE

      elif amixer_cget 'SPDIF in Switch' | grep 'values=on' >$NULL 2>&1

      then

        FROM_SPDIF=TRUE

      fi

    }

    #

    function to_headset {

      #

      # Playback from AP to Headset

      #

      amixer_cset 'HPOUT1 Digital Switch'  on

      # Set path gain to -6dB for safety. ie mav 0.5Vrms output level

      amixer_cset 'HPOUT1 Digital Volume'  116

      # Do we want to clear the HPOUT mixer inputs?

      amixer_cset 'HPOUT1L Input 1'        None

      amixer_cset 'HPOUT1R Input 1'        None

      amixer_cset 'HPOUT1L Input 2'        None

      amixer_cset 'HPOUT1R Input 2'        None

      amixer_cset 'HPOUT1L Input 1'        AIF1RX1

      amixer_cset 'HPOUT1L Input 1 Volume' 32

      amixer_cset 'HPOUT1R Input 1'        AIF1RX2

      amixer_cset 'HPOUT1R Input 1 Volume' 32

      amixer_cset 'Headset Mic Switch'     on

    }

    #

    function to_lineout {

      #

      # Playback from AP to Lineout

      #

      amixer_cset 'HPOUT2 Digital Switch'  on

      amixer_cset 'HPOUT2L Input 1'        AIF1RX1

      amixer_cset 'HPOUT2L Input 1 Volume' 32

      amixer_cset 'HPOUT2R Input 1'        AIF1RX2

      amixer_cset 'HPOUT2R Input 1 Volume' 32

    }

    #

    function to_speakers {

      #

      # Playback from AP to Speakers

      #

      amixer_cset 'Speaker Digital Volume' 128

      # reset speaker mixer inputs

      amixer_cset 'SPKOUTL Input 1'        None

      amixer_cset 'SPKOUTR Input 1'        None

      amixer_cset 'SPKOUTL Input 2'        None

      amixer_cset 'SPKOUTR Input 2'        None

      # Route AP to Speaker mixer

      amixer_cset 'SPKOUTL Input 1'        AIF1RX1

      amixer_cset 'SPKOUTL Input 1 Volume' 32

      amixer_cset 'SPKOUTR Input 1'        AIF1RX2

      amixer_cset 'SPKOUTR Input 1 Volume' 32

      # Unmute speaker output

      amixer_cset 'Speaker Digital Switch' on

    }

    #

    function to_spdif {

      #

      # Playback from AP to SPDIF

      #

      amixer_cset 'SPDIF out Switch'       on

      amixer_cset 'TX Playback Switch'     on

      amixer_cset 'Input Source'           AIF

      amixer_cset 'AIF Playback Switch'    on

      amixer_cset 'AIF2TX1 Input 1'        AIF1RX1

      amixer_cset 'AIF2TX1 Input 1 Volume' 32

      amixer_cset 'AIF2TX2 Input 1'        AIF1RX2

      amixer_cset 'AIF2TX2 Input 1 Volume' 32

    }

    #

    function from_dmic {

      #

      # Record from onboard DMICs to AP

      #

      #amixer_cset 'IN2 Digital Switch'     on

      # May want to tune the gain here.

      # Need at least -6dB

      amixer_cset 'IN2L Digital Volume'    116

      amixer_cset 'IN2R Digital Volume'    116

      amixer_cset 'AIF1TX1 Input 1'        IN2L

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        IN2R

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

      amixer_cset 'DMIC Switch'            on

    }

    #

    function from_headset {

      #

      # Record from Headset to AP

      #

      # This is set up as a dual mono record.

      # May not be what we want in all scenarios

      amixer_cset 'Headset Mic Switch'     on

      amixer_cset 'IN1R Volume'            20

      #amixer_cset 'IN1 Digital Switch'     on

      amixer_cset 'AIF1TX1 Input 1'        IN1R

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        IN1R

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

    }

    function from_lineout {

      #

      # Record from onboard Line Input to AP

      #

      # +9dB input PGA gain

      amixer_cset 'IN3L Volume' 8

      amixer_cset 'IN3R Volume' 8

      #

      # Better THD in normal mode vs lower noise floor in high performance

      amixer_cset 'IN3 High Performance Switch' on

      #

      #amixer_cset 'IN3 Digital Switch' on

      amixer_cset 'IN3L Digital Volume' 128

      amixer_cset 'IN3R Digital Volume' 128

      #

      amixer_cset 'AIF1TX1 Input 1'        IN3L

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        IN3R

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

    }

    #

    function from_spdif {

      #

      # Record from SPDIF in

      #

      amixer_cset 'SPDIF in Switch' on

      #

      # Switch off SPDIF TX in case already active

      # as WM8804 must run at RX rate if enabled

      amixer_cset 'TX Playback Switch'     off

      amixer_cset 'RX Playback Switch'     on

      amixer_cset 'AIF Playback Switch'    on

      amixer_cset 'AIF1TX1 Input 1'        AIF2RX1

      amixer_cset 'AIF1TX1 Input 1 Volume' 32

      amixer_cset 'AIF1TX2 Input 1'        AIF2RX2

      amixer_cset 'AIF1TX2 Input 1 Volume' 32

    }

    #

    # MAIN

    #

    # Default to being quiet

    QUIET="-q"

    #

    set_args $@

    #

    get_current

    #

    reset_paths

    #

    OUTPUT=$($ZENITY --list --width=350 --height=250 --radiolist \

      --title="Choose Wolfson Audio Output" \

      --column "Select" --column="Output" $TO_HEADSET "Headset" $TO_LINEOUT "Line Out" $TO_SPEAKERS "Speakers" $TO_SPDIF "SPDIF" )

    if [ "$OUTPUT" = "Headset" ]; then

      to_headset

    elif [ "$OUTPUT" = "Line Out" ]; then

      to_lineout

    elif [ "$OUTPUT" = "Speakers" ]; then

      to_speakers

    elif [ "$OUTPUT" = "SPDIF" ]; then

      to_spdif

    else

      echo "cancel"

    fi

    #

    OUTPUT=$($ZENITY --list --width=350 --height=250 --radiolist \

      --title="Choose Wolfson Recording Input" \

      --column "Select" --column="Input" $FROM_HEADSET "Headset" $FROM_LINEIN "Line In" $FROM_DMIC "Onboard Microphones" $FROM_SPDIF "SPDIF" )

    if [ "$OUTPUT" = "Headset" ]; then

      from_headset

    elif [ "$OUTPUT" = "Line In" ]; then

      from_lineout

    elif [ "$OUTPUT" = "Onboard Microphones" ]; then

      from_dmic

    elif [ "$OUTPUT" = "SPDIF" ]; then

      from_spdif

    else

      echo "cancel"

    fi

    </code>

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • Former Member
    Former Member over 11 years ago in reply to rjnorthrow

    Nice menu! Thanks!
    I just find that I get an error if recording after selecting Line.

    The error does not come up if using Record_from_lineIn.sh

     

     

    Agus

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • rjnorthrow
    rjnorthrow over 11 years ago in reply to Former Member

    Hi Agus,

     

    Thanks! I've fixed it now in the code above and the downloadable file.

    It was a typo I'm afraid image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to rjnorthrow

    Thanks. I confirm the error is fixed.

    I still get just silence with an external mic plugged on the Line In  though, as explained below.

    Agus

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to rjnorthrow

    Do you know the command line for SPDIF in to LineOut ?

     

    Also SPDIF in to SPDIF Out Command ?

     

    If you do would be most helpful image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jpers1
    jpers1 over 2 years ago in reply to rjnorthrow

    I deeply apologize for reviving 10 year old thread. I have 4 of original Wolfson Audio cards and (fortunately) enough Raspberry Pi 1s on which it fits without a problem. I installed the last available version of legacy Raspberry Pi OS, and quite beautifully, wm5102 codec driver and arizona drivers are included, they needed only enabling via hw overlay. I ran the examples I got from here: https://www.horus.com/~hias/cirrus-driver.html Let me say that everything works. Now, I studied the docs from Element14 and the scripts itself and it seems that wm5102 supports up to 8 channels for recording on AIF1TX interface (AIF1TX1 to AIF1TX8). Basically the "use case scripts" for recording essentially route different sources (e.g. DMICs, that is IN2L, IN2R or headset microphone input IN1R). Why am I examining this? Because I want to record 3 or 4 channel sound, and this ought to be possible, given the HW abilities AND the wm5102.c driver. It has the following sections:

    ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
    ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),

    and

    tatic struct snd_soc_dai_driver wm5102_dai[] = {
        {
            .name = "wm5102-aif1",
            .id = 1,
            .base = ARIZONA_AIF1_BCLK_CTRL,
            .playback = {
                .stream_name = "AIF1 Playback",
                .channels_min = 1,
                .channels_max = 8,
                .rates = WM5102_RATES,
                .formats = WM5102_FORMATS,
            },
            .capture = {
                 .stream_name = "AIF1 Capture",
                 .channels_min = 1,
                 .channels_max = 8,
                 .rates = WM5102_RATES,
                 .formats = WM5102_FORMATS,
             },
            .ops = &arizona_dai_ops,
            .symmetric_rate = 1,
            .symmetric_sample_bits = 1,
        },

    Now this is all nice, but when I run:   arecord --device=hw:0,0 --dump-hw-params

    I get the answer that only 2 channel sound is supported. WHY and WHERE is the limitation?


    Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
    HW Params of device "hw:0,0":
    --------------------
    ACCESS:  MMAP_INTERLEAVED RW_INTERLEAVED
    FORMAT:  S16_LE S24_LE S32_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: [16 32]
    FRAME_BITS: [32 64]
    CHANNELS: 2
    RATE: [8000 192000]
    PERIOD_TIME: (10 8192000]
    PERIOD_SIZE: [2 65536]
    PERIOD_BYTES: [16 524288]
    PERIODS: [2 65536]
    BUFFER_TIME: (20 16384000]
    BUFFER_SIZE: [4 131072]
    BUFFER_BYTES: [16 524288]
    TICK_TIME: ALL
    --------------------
    arecord: set_params:1343: Sample format non available
    Available formats:
    - S16_LE
    - S24_LE
    - S32_LE

    I also tried to create /etc/asound,conf  from scratchm but no change...

    pcm.multi_capture {
        type multi
        slaves.a.pcm "hw:0,0"
        slaves.a.channels 8
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave a
        bindings.2.channel 2
        bindings.3.slave a
        bindings.3.channel 3
        bindings.4.slave a
        bindings.4.channel 4
        bindings.5.slave a
        bindings.5.channel 5
        bindings.6.slave a
        bindings.6.channel 6
        bindings.7.slave a
        bindings.7.channel 7
    }

    pcm.!default {
        type plug
        slave.pcm "multi_capture"
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube