# Accessing mixer values

**URL:** <https://www.ruby-forum.com/t/accessing-mixer-values/133086>\
**Category:** Ruby\
**Created:** [March 27, 2008, 4:31pm UTC](https://www.ruby-forum.com/t/accessing-mixer-values/133086 "2008-03-27T16:31:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@ruud](https://www.ruby-forum.com/u/ruud)\
**Post date:** [March 27, 2008, 4:31pm UTC](https://www.ruby-forum.com/t/accessing-mixer-values/133086/1 "2008-03-27T16:31:23Z")

</div>

hi group

I want to read the volume of the mixer device with a ruby script.  
Can anybody tell me what the ruby equivalent is of what the MIXER\_READ  
macro does in C?

#define SOUND\_MIXER\_VOLUME 0  
#define SOUND\_MIXER\_READ\_VOLUME MIXER\_READ(SOUND\_MIXER\_VOLUME)  
#define MIXER\_READ(dev) \_SIOR(‘M’, dev, int)

I’ve been googling with keywords like ‘ioctl, MIXER\_READ SOUND\_MIXER’,  
but with little result. Hopefully someone can me push me in the right  
direction…

thanks in advance,

Ruud

---

<div class="post-metadata">

**Author:** ![ruud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@ruud](https://www.ruby-forum.com/u/ruud)\
**Post date:** [March 27, 2008, 4:56pm UTC](https://www.ruby-forum.com/t/accessing-mixer-values/133086/2 "2008-03-27T16:56:05Z")

</div>

ruud wrote:

> I want to read the volume of the mixer device with a ruby script.  
> Can anybody tell me what the ruby equivalent is of what the MIXER\_READ  
> macro does in C?

I’m sure that you’ll happy to know that, on linux, MIXER\_READ(dev) do  
this

(((2U) \<\< (((0 +8)+8)+14)) | (((‘M’)) \<\< (0 +8)) | (((dev)) \<\< 0) |  
(((((sizeof(int) == sizeof(int[1]) && sizeof(int) \< (1 \<\< 14)) ?  
sizeof(int) : \_\_invalid\_size\_argument\_for\_IOC))) \<\< ((0 +8)+8)))

🙂

> I’ve been googling with keywords like ‘ioctl, MIXER\_READ SOUND\_MIXER’,  
> but with little result. Hopefully someone can me push me in the right  
> direction…

perhaps best if you use Ruby::Inline to access it

[http://rubyforge.org/projects/rubyinline/](http://rubyforge.org/projects/rubyinline/)

Guy Decoux

---

<div class="post-metadata">

**Author:** ![ruud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@ruud](https://www.ruby-forum.com/u/ruud)\
**Post date:** [March 29, 2008, 5:37am UTC](https://www.ruby-forum.com/t/accessing-mixer-values/133086/3 "2008-03-29T05:37:37Z")

</div>

It encodes the ioctl request argument for a transfer of data from the  
device to the program. See:  
man ioctl

you may also need to look at the ioctl.h header.  
\_SIOR in at least the linux soundcard.h file just maps directly to \_IOR

RF

---

<div class="post-metadata">

**Author:** ![ruud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@ruud](https://www.ruby-forum.com/u/ruud)\
**Post date:** [March 29, 2008, 5:42am UTC](https://www.ruby-forum.com/t/accessing-mixer-values/133086/4 "2008-03-29T05:42:57Z")

</div>

[http://www.4front-tech.com/pguide/sndcrd.html](http://www.4front-tech.com/pguide/sndcrd.html)

May also help now that you know that

\_SIOR is just \_IOR.

search there for MIXER\_READ…below it are the legal values for dev if  
I’m getting this right.
