Go Down

Topic: madplay mp3 (Read 2220 times) previous topic - next topic


Hello everybody,
Just need a little help for something that drive me crazy.
I successfully managed to play a mp3 with my arduino yun following this tutorial http://dev.mikamai.com/post/69775973742/arduino-yun-with-sound-the-supereasy-way

However I can't manage to stop the mp3 before it's completly finished to play.
I'm putting bellow my current code, the goal of this exercice would be that the mp3 play when I'm pushing the button and stop when I'm not.

Code: [Select]
#include <Process.h>
#include <FileIO.h>

const int buttonPin = 2;
const int ledPin =  13;

int buttonState = 0;
Process p;

void setup() {
  pinMode(ledPin, OUTPUT);     
  pinMode(buttonPin, INPUT);     

void loop(){
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {   
    digitalWrite(ledPin, HIGH); 
    p.runShellCommandAsynchronously("madplay /mnt/sd/Testsong.mp3");
  else {
    digitalWrite(ledPin, LOW);

Hope you can help me,


Code: [Select]
opkg update
opkg install kmod-usb-audio
opkg install madplay
cd /mnt/sda1
wget --no-check-certificate  https://www.dropbox.com/s/zzowqtew6cmspsf/track39.mp3

Code: [Select]
#include <Process.h>
Process p;
void setup() {
  Serial.begin(9600); // Initialize the Serial
  while (!Serial); // Wait until a Serial Monitor is connected.
void loop() {
  if (Serial.available() > 0) {
    int inByte = Serial.read();
    switch (inByte) {
      case 'p':
        p.runShellCommandAsynchronously("/usr/bin/madplay /mnt/sda1/track39.mp3");
      case 's':
        p.runShellCommandAsynchronously("/usr/bin/killall -9 madplay");
      case 'r':
        Serial.println("Repeat Play:");
        p.runShellCommandAsynchronously("/usr/bin/madplay /mnt/sda1/track39.mp3 -r");

p: Play
s: Stop
r: Repeat Play


How can i change the volume of madplay while a process is running?


How can i change the volume of madplay while a process is running?
Google: madplay mp3 manpage


For  each  file,  madplay will also attempt to read and display ID3 tag
       information. The supported tag versions are  ID3v1,  ID3v1.1,  ID3v2.2,
       ID3v2.3,  and  ID3v2.4.  If  a  tag contains relative volume adjustment
       information (RVA2), madplay will use  the  information  to  adjust  the
       master  volume  for  output.  This  behavior can be changed with the -A
       (--adjust-volume) and -G (--replay-gain) options.

        -A or --adjust-volume=decibels
              Adjust the relative volume for all files. This option  overrides
              any per-file volume adjustment settings. For example, -A0 may be
              used to ignore relative volume adjustments given  by  ID3  tags.
              Relative  volume  adjustments specified by this option or by ID3
              tags are used as the base volume against  which  the  signal  is
              further  attenuated  or  amplified  using  the  -a (--attenuate,
              --amplify) option or keyboard controls.  This option  cannot  be
              used together with -G (--replay-gain).

       -G or --replay-gain[=profile]
              Enable  Replay  Gain volume adjustments. Replay Gain information
              contained in the decoded files (if any) is used to  make  volume
              adjustments  for  output.  The  profile may be one of radio (the
              default) or audiophile.  See the NOTES section below for further
              details.  When Replay Gain is enabled, a default pre-amp gain of
              +6 dB  is  also  applied;  this  can  be  changed  with  the  -a
              (--attenuate, --amplify) option.

There is no information if you can adjust volume while it is playing. I assume that you cannot adjust it while it is playing.




Go Up