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
Design for a Cause - Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Design for a Cause - Design Challenge
  • More
  • Cancel
Design for a Cause - Design Challenge
Blog Week 4 - Looking At Audio
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: kyle90
  • Date Created: 7 Aug 2018 11:14 PM Date Created
  • Views 603 views
  • Likes 3 likes
  • Comments 1 comment
Related
Recommended

Week 4 - Looking At Audio

kyle90
kyle90
7 Aug 2018

One of the things our device will need to accomplish is reading a wave file (the pre-recorded help message) from the SD card and playing it back so that it can be used by the GSM module, which expects an analog waveform. While it has historically been difficult to use Arduino boards for audio output, the updated 32-bit processor found on the MKR1000 can be used for this, by using the public domain AudioZero library.

 

How is audio stored?

 

Sound moves through the air as pressure waves, which can be picked up by our eardrums so that we can hear, or by the diaphragm of a microphone. The diaphragm will vibrate in response to changing pressure, and this vibration moves a magnet near a small coil of wire. This induces a voltage which can then be recorded in a number of ways. For use by a computer it is first run through an analog-to-digital converter, which takes voltage readings at set time intervals and approximates the voltage as a string of bits.

 

image

image

image

To play back the audio, our Arduino has to take each of these bit strings and turn them back into voltage levels, essentially doing the same process in reverse. Voltage control is achieved using pulse-width modulation (PWM). Since a digital system has only two states - fully on or fully off - it can't actually set the voltage to an intermediate level, so instead it cheats by switching on and off very rapidly to approximate the desired analog voltage. For example, say we are using a 5 volt system. Then if we want 2.5 volts at the output, what will actually happen is that the output will be on 50% of the time and off 50% of the time, and this will get averaged out.

 

Luckily, PWM and its use for audio are fully handled by the AudioZero library, which makes our lives a lot easier. Once we read in the wave file, all it takes is a single function call - AudioZero.play() - to get the output that we need. So with audio fully sorted out, our next step once Dan arrives back home from his vacation this week will be meeting up to assemble the device and begin testing!

  • Sign in to reply

Top Comments

  • aspork42
    aspork42 over 7 years ago +2
    Nice writeup on the process! Could we get a video once you're able to make it work? I'd live to hear the input and the output to see what it sounds like.
  • aspork42
    aspork42 over 7 years ago

    Nice writeup on the process! Could we get a video once you're able to make it work? I'd live to hear the input and the output to see what it sounds like.

    • Cancel
    • Vote Up +2 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