Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Changing volume in Linux with Perl?

by PipTigger (Friar)
on Jan 16, 2001 at 06:06 UTC ( #52132=perlquestion: print w/ replies, xml ) Need Help??
PipTigger has asked for the wisdom of the Perl Monks concerning the following question:

Hello, oh ye who possess magical wisdom,
I'm trying to manipulate sound volume (both main && pcm) from a script. Right now I've got aumix installed so just doing system("aumix -v$NewVolum") werks for me but is not a good solution. I've STFC (Serched The Fscking CPAN) && only found a wrapper for mixing .wav files together. How can I cleanly manipulate /dev/mixer in order to change volumes && stuff? The source to aumix doesn't give me a good clue of how I might mimic in Perl. Thanks muchly for any assistance you might be able to provide. TTFN.

-PipTigger
p.s. Initiate Nail Removal Immediately!

Comment on Changing volume in Linux with Perl?
Re: Changing volume in Linux with Perl?
by eg (Friar) on Jan 16, 2001 at 06:47 UTC
      Actually I have in fact read almost everything at that linq before too... the problem is that the method described there is basically what the aumix C-code I already have does. Is there an equivalent to 'sys/ioctl.h' in Perl? Is there a way to manipulate /dev/mixer properly without compiling C? If not, aumix will suffice but it'd be nice to do it right in Perl if possible. Maybe it'd make a great CPAN module too. We'll see. Thanks. TTFN.

      -PipTigger
      p.s. I don't need your authority!
        Have a look at ioctl for a way to roll your own in perl. I agree that this would make a handy CPAN module when you get it working. Good luck!

Re: Changing volume in Linux with Perl?
by PipTigger (Friar) on Jan 16, 2001 at 16:15 UTC
    I've tried hard to get ioctl && all the other .ph files to werk. I had to run h2ph on like 7 different .h files to fulfill all the embedded require's but I've tried tons of stuff for the past hour to tweak my new /usr/local/lib/site_perl/i386-linux/linux/soundcard.ph file so that it'd let my little script run to no avail. My little test is:
    #!/usr/bin/perl -w require 'ioctl.ph'; require 'linux/soundcard.ph'; my $data = 0; open MIXR, "</dev/mixer" || die "Can't open mixer!\n"; ioctl(MIXR, &MIXER_READ(0), $data) || die "Can't ioctl!\n"; close MIXR; print "data: $data\n";
    This results in:

    Use of uninitialized value at (eval 621) line 1.
    Can't ioctl!


    && the eval ending on that line looks like another normal one:
    eval 'sub SEQ_PITCHBEND { local($dev, $voice, $value) = @_; eval q( &SEQ_V2_X_CONTROL($dev, $voice, &CTRL_PITCH_BENDER, $ +value) ); }' unless defined(&SEQ_PITCHBEND);
    If you can possibly point me in a better direction, I'd really appreciate it. I've been pounding my head against this for a long time && can't seem to go anywhere with this. I'm feeling really surprised at how difficult this seems to be in Perl! Maybe it's appropriate since it's one of the "hard/possible" things but it seemed like it should be "easy/easy". Anyways, I'm probably just gonna cave in && use C if I can't get Perl to do it within the next day or so. I really wanted to be competent enough to get this to werk on my own but I'm left to conclude that I'm really not experienced enough with Perl || Linux to do this alone yet. Thanks for any help or encouragement you can offer. I'm feeling kinda down (I thinq the caffeine is wearing off). TTFN.

    -PipTigger
    p.s. Mr., would you please help my pony?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://52132]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-08-30 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls