Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Unix Sound Problems

  • To: mathgroup at
  • Subject: [mg24129] Re: Unix Sound Problems
  • From: "P.J. Hinton" <paulh at>
  • Date: Wed, 28 Jun 2000 02:11:47 -0400 (EDT)
  • Organization: "Wolfram Research, Inc."
  • References: <8j9dmo$>
  • Sender: owner-wri-mathgroup at

On 27 Jun 2000, Andre Heinemann wrote:

> I have some Problems with the Sound under Digital Unix
> Here a example:
> I create a sound object (s1)first:
> s1 = Play[Sin[880 Pi t], {t, 0, 10}];
> Play and "Friends" do'nt work on my Unix OS (Why ???)

In Mathematica, the playing of sounds is done normally through the front
end. The Play[] returns a Sound object and also results in a PostScript
string being sent to the front end.  This PostScript string contains a
waveform of the sound.  Under MacOS and Windows, the front end can then
play the sound by hooking into the operating system interfaces for sound
generation.  The X Window front end does not have this feature.

Part of the reason this is so is because many of the Unices do not have a
uniform interface for playing sound.  Compaq's Tru64 UNIX on Alpha is one
of these cases.  See this page for further reading:

> so I'm going to export the sound object into a file:
> Export["/myhome/tmp/mysound.wav", Show[s1], "WAV"]
> and play it with the decsound command line executable:
> ! "/usr/bin/mme/decsound -play /myhome/tmp/mysound.wav"
> Ok it works - I can here the sound (-:
> Now I created a module:
> MySound[sound_] := Module[{},
>     Export["/myhome/tmp/mysound.wav", Show[sound], "WAV"];
>     ! "/usr/bin/mme/decsound -play /myhome/andre/tmp/mysound.wav"
>     ]
> MySound[s1]
> where the two lines are taken from above, but it doesn't work.

I suspect that it is because the "!" is being interpreted as the prefix
form of Not[] in the module.  A more elegant way to get at what you
describe might be one of the following.

If decsound supports receiving input on stdin, you can do a pipe operation
like so:

mySound[snd_Sound] := 
    Export["!/usr/bin/mme/decsound -play", snd, "WAV"];

Here, the exclamation point tells Export[] that the output should be piped
through the command that follows.

If stdin is not supported, the proper way to do a scratchfile approach
would be:

mySound[snd_Sound] := 
    {tmpnam = Close[OpenTemporary[]]},
    Export[tmpnam, sound, "WAV"];
    Run["/usr/bin/mme/decsound -play", tmpnam];

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

  • Prev by Date: RE: Piecewise functions definition and usage
  • Next by Date: Re: FindMinimum and Gradient
  • Previous by thread: Re: Unix Sound Problems
  • Next by thread: How to operate on strictly numerical functions ?