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
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog MagicHat - 15 - Let's MagicHat speak
  • 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: amgalbu
  • Date Created: 28 May 2015 3:17 PM Date Created
  • Views 744 views
  • Likes 4 likes
  • Comments 4 comments
  • mp3_player
  • magic_doctor_hat
  • mp3
  • arduino
  • enchanted-objects
Related
Recommended

MagicHat - 15 - Let's MagicHat speak

amgalbu
amgalbu
28 May 2015

After finishing the data acquisition part of the project, let's see how to make the MagicHat a little more... magic

 

To make Arduino Yun speak, I first need an external USB audio card like this one here

 

image

 

Then, I need to install an mp3 player that will play a file stored on SD card. Installing the mp3 player is just a few packages away...

 

opkg update
 opkg install kmod-sound-core 
 opkg install kmod-usb-audio 
 opkg install madplay

 

Since the control logic runs on the Atmel side of Arduino Yun, we need to devise a way to launch the player. To send data from Atmel to Linino I disabled the bridge, so now Serial1 is read by NodeJS.

So, the firmware running on Atmel will send out (by calling Serial1.println) a string like

 

PLAY helloworld.mp3

 

and NodeJS will launch the mp3 player to play to "helloworld.mp3" file

 

This can easily achieved using the NodeJS's 'exec'  package

 

var exec = require('child_process').exec;
exec('/usr/bin/madplay ' + filename);

  • Sign in to reply

Top Comments

  • amgalbu
    amgalbu over 10 years ago in reply to Workshopshed +2
    Hi clark Looking at the price of the usb sound card (2.21 euros on amazon, shipping included), I imagine that the usb card is really stupid. I think the mp3player and linux drivers do all the decoding…
  • amgalbu
    amgalbu over 10 years ago in reply to Workshopshed +1
    Hi Andy Don't know eaxctly what you mean with "configure the sound card". the first two packages are USB drivers for a generic sound card, the third is the player... That's all you need to play an mp3…
  • amgalbu
    amgalbu over 10 years ago in reply to Workshopshed

    Hi clark

    Looking at the price of the usb sound card (2.21 euros on amazon, shipping included), I imagine that the usb card is really stupid. I think the mp3player and linux drivers do all the decoding works and sends out on usb a stream of pcm data (on in any way another uncompressed format)

    In case of multiple sound devices, a parameter should be added on the madplay command line to select the desired device.

     

    Cheers

    Ambrogio

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago in reply to amgalbu

    I was thinking that there would be something that told the player that sound should play though the USB. I'm not an expert on how drivers work on Linux systems but there must be something that does the internal "wiring" so that it can work with multiple  sound devices.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • amgalbu
    amgalbu over 10 years ago in reply to Workshopshed

    Hi Andy

    Don't know eaxctly what you mean with "configure the sound card". the first two packages are USB drivers for a generic sound card, the third is the player... That's all you need to play an mp3 file

    The exec is asynchronous but you can add a parameter that is a callback that notifies you when the execution completes

     

    Cheers

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago

    Does the installation of the packages configure the soundcard?

    Is the exec call asynchronous?

    • 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