Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

SDL::Mixer - How to specify the device?

by shotgunefx (Parson)
on Dec 03, 2006 at 11:38 UTC ( #587494=perlquestion: print w/ replies, xml ) Need Help??
shotgunefx has asked for the wisdom of the Perl Monks concerning the following question:

Given how slow XMMS::Remote responds on my laptop (not sure why), I've been thinking of ditching it in favor of SDL::Music;

So I have it a whirl like so...
#!/usr/bin/perl use strict; use warnings; use SDL; use SDL::Mixer; use SDL::Music; my $mixer = new SDL::Mixer(-frequency=>44100, -channels=>2, -size=>1024); my $mp3 = new SDL::Music('./test.mp3'); $mixer->play_channel(0, $mp3, 0);
Which dies with "open /dev/sequencer: No such device".

Why is it looking at /dev/sequencer and how do I change it?

I'm running Debian etch (alsa with oss support). I've looked through the src (SDL 2.1.3) and I can't figure for the life of me how to set it. The one audio example that comes with it (test/loopwave.pl) doesn't use SDL::Mixer, it uses SDL::NewAudioSpec to set up the audio.

Any pointers would be appreciated.

-Lee
"To be civilized is to deny one's nature."

Comment on SDL::Mixer - How to specify the device?
Download Code
Re: SDL::Mixer - How to specify the device?
by zentara (Archbishop) on Dec 03, 2006 at 13:26 UTC
    Just helping you troubleshoot, but your script dosn't play on my linux box with the latest kernel and alsa. So I'm not sure, but there are 2 possible errors I see.

    1. Try this script, it uses play_music instead of play_channel, and puts a loop at the end to keep the script from exiting prematurely.

    #!/usr/bin/perl use strict; use warnings; use SDL; use SDL::Mixer; use SDL::Music; my $mixer = SDL::Mixer->new( -frequency => MIX_DEFAULT_FREQUENCY, # 22050 -format => MIX_DEFAULT_FORMAT, # AUDIO_S16 -channels => MIX_DEFAULT_CHANNELS, # 8 -size => 1024 #higher numbers give sloppy reponse #as buffers continue to empty ); # provides 8 channels of # 16 bit audio at 22050 Hz. and a single channel of music. #background can be mp3,ogg or wav (mp3 needs smpeg libs) my $mp3 = new SDL::Music('1bb.mp3'); $mixer->music_volume(MIX_MAX_VOLUME); #128 $mixer->play_music( $mp3, 100 ); my $done = 0; while (! $done && ( SDL::GetAudioStatus() == SDL_AUDIO_PLAYING())) {SDL::Delay(1); }

    2. Look for /dev/sequencer in /dev. On my alsa setup there is a link to /dev/sound/sequencer, which is what alsa sets up. Maybe you are missing the link?

    See Tk Game Sound demo


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      A kick in the right direction.

      My example wasn't dying, it was just a warning. It just was exiting so quick as I wasn't delaying, I didn't even hear a pop on the speaker.

      Having said that, play_music is what I needed, as play_channel screetches for some seconds and then SEGFAULTs.

      I do have /dev/sequencer , maybe a driver problem, but I don't listen to MIDI so I'm not too concerned.

      Thanks.

      -Lee
      "To be civilized is to deny one's nature."
Re: SDL::Mixer - How to specify the device?
by Anonymous Monk on Dec 03, 2006 at 14:06 UTC
    Try
    die "Could not initialize SDL: ", SDL::GetError() if ( 0 > SDL::Init(SDL_INIT_AUDIO()));
    See http://libsdl.org/
      Still get the warning about sequencer, but it doesn't die.

      -Lee
      "To be civilized is to deny one's nature."
Re: SDL::Mixer - How to specify the device?
by shotgunefx (Parson) on Dec 04, 2006 at 12:17 UTC
    A little update, so far so good on switching to SDL::Music.

    Hit one snag, Perl_SDL doesn't expose any way to pan the mixer. On the plus side, a little googling, some minor additions the XS and panning works. (Hopefully, it gets patched in to the distribution )

    -Lee
    "To be civilized is to deny one's nature."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2015-07-02 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (29 votes), past polls