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
Raspberry Pi Forum Wolfson - voice record volume too low using DMIC
  • 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
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 3 replies
  • Subscribers 663 subscribers
  • Views 777 views
  • Users 0 members are here
Related

Wolfson - voice record volume too low using DMIC

fmpwizard
fmpwizard over 11 years ago

Hi,

 

I just got my wolfson card running on a raspberry pi today, I'm able to record using the built in microphone, but the volume is really low, or I need to be really close to the board. I have no idea what the commands in the Record_from_DMIC.sh really mean, I changed the volume values to a higher value but they don't seem to make any difference.

 

What I would like to do is, be about 8 feet away from the board and have it record my voice (so I can integrate it in my current project Go Cortex - using voice recognition and an ultrasonic sensor )

Any help would be greatly appreciated.

 

I'm using the os I downloaded from the element14 site. Let me know what other information you may need.

 

Thanks

 

Diego

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 11 years ago

    Hi!

     

    Yes, the use case scripts are a bit cryptic, aren't they?

    As you have probably seen, there are two volume controls for each channel involved when recording from the DMICs.

     

    IN2L Digital Volume and IN2R Digital Volume control the output levels of the DMICs. Valid values for these are 0 - 191.

    AIF1TX1 Input 1 Volume and AIF1TX2 Input 1 Volume control the levels of the signals sent to the RPi. Valid values are 0 - 48.

    So, if you want to really max it out, set them to 191 and 48 respectively.

     

    I have observed DC offset when recording the DMICs and a bit of hiss creeps in when you crank the levels up.

    I've made my own script that sends the sound from the DMICs through high-pass and low-pass filters to alleviate that:

    #!/bin/bash
    # Record from on-board DMICs to RPi.
    # First, route signal from DMICs through High-Pass Filter to get rid of DC offset.
    # Then, route output from High-Pass filter through Low-Pass Filter to get rid of high-freq noise and hiss.
    #
    # IN2 --> HPF --> LPF --> AIF1TX
    
    # Set default levels. May be overridden by environment variables.
    DMIC_OUTPUT_LEVEL=128 # Output level from DMICs. Valid values: 0 - 191
    RECORDING_LEVEL=32 # Level of signal sent to the RPi. Valid values: 0 - 48
    
    # Check for environment variables.
    [ ! -z "$DL" ] && DMIC_OUTPUT_LEVEL=$DL
    [ ! -z "$RL" ] && RECORDING_LEVEL=$RL
    
    
    # DMIC output level. Valid values 0 - 191
    amixer -Dhw:0 cset name='IN2L Digital Volume' ${DMIC_OUTPUT_LEVEL}
    amixer -Dhw:0 cset name='IN2R Digital Volume' ${DMIC_OUTPUT_LEVEL}
    
    # DMICs are incorrectly labeled on the board.
    # DMICL is actually the right channel and vice versa, so we swap them here.
    # i.e. IN2R --> LHPF1
    # IN2L --> LHPF2
    # Route DMICs (IN2) to LHPF{1,2} - High-pass filter to get rid of DC offset.
    amixer -q -Dhw:0 cset name='LHPF1 Input 1' IN2R
    amixer -q -Dhw:0 cset name='LHPF2 Input 1' IN2L
    amixer -q -Dhw:0 cset name='LHPF1 Mode' High-pass
    amixer -q -Dhw:0 cset name='LHPF2 Mode' High-pass
    
    # Route output of LPHF{1,2} to LHPF{3,4}. Low-pass filter to get rid of hiss.
    amixer -q -Dhw:0 cset name='LHPF3 Input 1' LHPF1
    amixer -q -Dhw:0 cset name='LHPF4 Input 1' LHPF2
    amixer -q -Dhw:0 cset name='LHPF3 Mode' Low-pass
    amixer -q -Dhw:0 cset name='LHPF4 Mode' Low-pass
    
    
    # Connect outputs of Low-Pass filters to inputs of AIF1 (I2S to RPi)
    amixer -q -Dhw:0 cset name='AIF1TX1 Input 1' LHPF3
    amixer -q -Dhw:0 cset name='AIF1TX2 Input 1' LHPF4
    
    # Recording level. Valid values 0 - 48
    amixer -Dhw:0 cset name='AIF1TX1 Input 1 Volume' ${RECORDING_LEVEL}
    amixer -Dhw:0 cset name='AIF1TX2 Input 1 Volume' ${RECORDING_LEVEL}
    
    amixer -q -Dhw:0 cset name='DMIC Switch' on

     

    Save the above as Record_from_DMIC_HPF_LPF.sh and make it executable with

    chmod +x  Record_from_DMIC_HPF_LPF.sh

     

    In order to save myself from constant editing of the script to set the levels, I've made it so it can take values from two environment variables; DL and RL (Digital Level and Recording Level).

    To set max levels, call the script like this:

    DL=191 RL=48 ./Record_from_DMIC_HPF_LPF.sh

     

    Now, experiment with the DL and RL values!image

    --

    Ragnar

     

     


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 11 years ago

    Hi!

     

    Yes, the use case scripts are a bit cryptic, aren't they?

    As you have probably seen, there are two volume controls for each channel involved when recording from the DMICs.

     

    IN2L Digital Volume and IN2R Digital Volume control the output levels of the DMICs. Valid values for these are 0 - 191.

    AIF1TX1 Input 1 Volume and AIF1TX2 Input 1 Volume control the levels of the signals sent to the RPi. Valid values are 0 - 48.

    So, if you want to really max it out, set them to 191 and 48 respectively.

     

    I have observed DC offset when recording the DMICs and a bit of hiss creeps in when you crank the levels up.

    I've made my own script that sends the sound from the DMICs through high-pass and low-pass filters to alleviate that:

    #!/bin/bash
    # Record from on-board DMICs to RPi.
    # First, route signal from DMICs through High-Pass Filter to get rid of DC offset.
    # Then, route output from High-Pass filter through Low-Pass Filter to get rid of high-freq noise and hiss.
    #
    # IN2 --> HPF --> LPF --> AIF1TX
    
    # Set default levels. May be overridden by environment variables.
    DMIC_OUTPUT_LEVEL=128 # Output level from DMICs. Valid values: 0 - 191
    RECORDING_LEVEL=32 # Level of signal sent to the RPi. Valid values: 0 - 48
    
    # Check for environment variables.
    [ ! -z "$DL" ] && DMIC_OUTPUT_LEVEL=$DL
    [ ! -z "$RL" ] && RECORDING_LEVEL=$RL
    
    
    # DMIC output level. Valid values 0 - 191
    amixer -Dhw:0 cset name='IN2L Digital Volume' ${DMIC_OUTPUT_LEVEL}
    amixer -Dhw:0 cset name='IN2R Digital Volume' ${DMIC_OUTPUT_LEVEL}
    
    # DMICs are incorrectly labeled on the board.
    # DMICL is actually the right channel and vice versa, so we swap them here.
    # i.e. IN2R --> LHPF1
    # IN2L --> LHPF2
    # Route DMICs (IN2) to LHPF{1,2} - High-pass filter to get rid of DC offset.
    amixer -q -Dhw:0 cset name='LHPF1 Input 1' IN2R
    amixer -q -Dhw:0 cset name='LHPF2 Input 1' IN2L
    amixer -q -Dhw:0 cset name='LHPF1 Mode' High-pass
    amixer -q -Dhw:0 cset name='LHPF2 Mode' High-pass
    
    # Route output of LPHF{1,2} to LHPF{3,4}. Low-pass filter to get rid of hiss.
    amixer -q -Dhw:0 cset name='LHPF3 Input 1' LHPF1
    amixer -q -Dhw:0 cset name='LHPF4 Input 1' LHPF2
    amixer -q -Dhw:0 cset name='LHPF3 Mode' Low-pass
    amixer -q -Dhw:0 cset name='LHPF4 Mode' Low-pass
    
    
    # Connect outputs of Low-Pass filters to inputs of AIF1 (I2S to RPi)
    amixer -q -Dhw:0 cset name='AIF1TX1 Input 1' LHPF3
    amixer -q -Dhw:0 cset name='AIF1TX2 Input 1' LHPF4
    
    # Recording level. Valid values 0 - 48
    amixer -Dhw:0 cset name='AIF1TX1 Input 1 Volume' ${RECORDING_LEVEL}
    amixer -Dhw:0 cset name='AIF1TX2 Input 1 Volume' ${RECORDING_LEVEL}
    
    amixer -q -Dhw:0 cset name='DMIC Switch' on

     

    Save the above as Record_from_DMIC_HPF_LPF.sh and make it executable with

    chmod +x  Record_from_DMIC_HPF_LPF.sh

     

    In order to save myself from constant editing of the script to set the levels, I've made it so it can take values from two environment variables; DL and RL (Digital Level and Recording Level).

    To set max levels, call the script like this:

    DL=191 RL=48 ./Record_from_DMIC_HPF_LPF.sh

     

    Now, experiment with the DL and RL values!image

    --

    Ragnar

     

     


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • fmpwizard
    0 fmpwizard over 11 years ago in reply to Former Member

    Thank for the detailed explanation. Using the maximum volume worked and I can be a few feet away froi the board and my voice is recorded, but as you noticed, there is a pretty high volume of noise.

    I just tried using sox to clean up the noice and it seems to be working pretty well for my needs

     

    # Create background noise profile from mp3

    /usr/bin/sox noise.mp3 -n noiseprof noise.prof

     

    # Remove noise from mp3 using profile

    /usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21

     

    sox command taken from https://gist.github.com/devoncrouse/5534261

     

    Thank you very much for the help!

     

    Diego

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • 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