element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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 4778 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.
  • jpers1
    jpers1 over 1 year 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
  • Former Member
    Former Member over 9 years ago

    Hi all, I'm sorry to say I'm a total newbie to all of this. I have a new raspberry pi 2 Model B and I've just purchased the wolfson audio card.

     

    I've attached the card to the board and tried all of the images and software linked in the tutorial above and the software download on the wolfson audio card page, yet I can never see the wolfson audio card in alsmixer or by checking the ./Record_from_lineIn.sh commands.

     

    Can anyone help me? Much appreciated.    

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

    Hello again Ragnar,

     

    Sorry for bothering you. I don't know if it means something but I found a sony headset, which mic can record when I blow into it, it's like if there was no enaugh volume to hear my voice, even having "IN1R Digital Volume" and "IN1R Volume"  at max.

    Do you know why could it happen?

     

    Thanks again!

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

    Thanks Ragnar for your answer again.

    I hope it is not a hardware problem, If I could try in another board...

    I cleant everything and it keeps like before.

    Thanks for your advice!

     

    Alejandro

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

    It could be broken hardware image

    It could also be dirt inside the jack. I had that problem on my iPhone once, none of my headsets worked at all and at first I thought the phone was broken. But when I shone a flashlight into the headset jack I discovered a small ball of dust at the bottom, that made it impossible to insert the headset plug fully. I had to use a very thin toothpick to get the dust-ball out but afterwards all my headsets worked image

    --

    Ragnar

    • 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