Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Linux sound output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19225] Re: Linux sound output
  • From: paulh at monon.wolfram.com (P.J. Hinton)
  • Date: Wed, 11 Aug 1999 02:06:44 -0400
  • Organization: "Wolfram Research, Inc."
  • References: <7ook88$i3d@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <7ook88$i3d at smc.vnet.net>, Phil Mendelsohn <mend0070 at tc.umn.edu> writes:

>I run Mathematica v3.01 under Linux (Mandrake 6.0, 2.2.9 kernel).  I
>recently got the OSS driver to talk to my sound hardware.  KDE and other
>apps do, but as yet I cannot get Mathematica to output sound correctly. 
>I have tried starting with the -cleanStart option to rebuild prefs.
>
>If there is anyone with either the specific information or enough
>general knowledge of these matters to help me get Mathematica talking to
>OSS correctly, I'd sure appreciate the input.

Unfortunately, none of the X Window-based front ends on any of the
Unix platforms support the playing of sound.

Fortunately, you can change some settings in the kernel so that
you can have it play the sound every time you invoke Show[] on
a Sound object.  There is a global session variable named 
$SoundDisplay, which is what the kernel uses to play
a sound.  A couple of years ago, Bernd Pfitzinger wrote a clever
little Perl script to translate the MPS expression created by
Display into WAV format so that it can be piped to a command-line
player tool.

[begin Perl script wav.pl]

#!/bin/perl

while(<STDIN>){
    last if(/1 string/)
    }

@sample=split(" ",<STDIN>);
#print "sample rate $sample[0] sample depth(bits) $sample[2]\n";
#print "Currently only 8 bit sample depth is working\n";

open out,"|bplay -s $sample[0]  >& /dev/null";

<STDIN>;
<STDIN>;

while(<STDIN>){
    exit if(/pop/);
    chomp;
    
    for($i=0;$i<=length($_)-2;$i=$i+2){
        $out=pack("c",hex(substr($_,$i,2)));
        print out $out;
    }    
}

[end Perl script wav.pl]

The value of $SoundDisplay should be set to $SoundDisplay="!wav.pl", 
or whatever you name the Perl script above.  

To ensure that the kernel sets this value of $SoundDisplay at startup, 
edit the setting for $SoundDisplay in either
SystemFiles/Graphics/Packages/PSDirect.m (if you run the kernel from the
front end) and SystemFiles/Graphics/Packages/X11.m (if you run the kernel
with from a shell using Motif graphics).

--
P.J. Hinton
Mathematica Programming Group           paulh at wolfram.com
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.


  • Prev by Date: Win32 MathLink .exe from Matheamtica 3 on a Mac
  • Next by Date: Re: Always "Untitled-1"?
  • Previous by thread: Linux sound output
  • Next by thread: Re: Linux sound output