Setting volume from C++ on the audio cape (Rev B1)

31 views
Skip to first unread message

Charles Kerr

unread,
Jun 20, 2014, 9:36:32 PM6/20/14
to beagl...@googlegroups.com
I have the following code which I think should set the volume on the audio cape to 100%

int32_t mixer_fd=0;


mixer_fd=open("/dev/mixer", O_WRONLY);

if (mixer_fd>0)


{


        int vol=0x6464;


                                                                if (ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol)==-1)


       {


          std::cout <<"Error setting volume"<<std::endl;

      }

      close(mixer_fd);


}



However, the volume is still barely audible.  Is there something else that needs to be done?

John Syn

unread,
Jun 21, 2014, 4:49:06 AM6/21/14
to beagl...@googlegroups.com

From: Charles Kerr <charle...@gmail.com>
Reply-To: "beagl...@googlegroups.com" <beagl...@googlegroups.com>
Date: Friday, June 20, 2014 at 6:36 PM
To: "beagl...@googlegroups.com" <beagl...@googlegroups.com>
Subject: [beagleboard] Setting volume from C++ on the audio cape (Rev B1)

I have the following code which I think should set the volume on the audio cape to 100%
Use alsamixer to experiment with the various settings. After that, it will be easier to work out how to do this programatically. 

Regards,
John

int32_t mixer_fd=0;


mixer_fd=open("/dev/mixer", O_WRONLY);

if (mixer_fd>0)


{


        int vol=0x6464;


                                                                if (ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol)==-1)


       {


          std::cout <<"Error setting volume"<<std::endl;

      }

      close(mixer_fd);


}



However, the volume is still barely audible.  Is there something else that needs to be done?

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Charles Kerr

unread,
Jun 21, 2014, 5:00:56 AM6/21/14
to beagl...@googlegroups.com
I found the answer, for those trying to do this.

Change this line
ioctl(mixer_fd, SOUND_MIXER_WRITE_VOLUME, &vol)

to 

ioctl(mixer_fd, SOUND_MIXER_WRITE_PCM, &vol)



You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/rTsdO11BIrY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages