Re: Unix Sound Problems
- To: mathgroup at smc.vnet.net
- Subject: [mg24129] Re: Unix Sound Problems
- From: "P.J. Hinton" <paulh at wolfram.com>
- Date: Wed, 28 Jun 2000 02:11:47 -0400 (EDT)
- Organization: "Wolfram Research, Inc."
- References: <8j9dmo$51l@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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. http://support.wolfram.com/Systems/Unix/FE/Sound.html 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: http://www.unix.digital.com/demos/freekit/html/audio.htm > 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"]; Return[snd] ) 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] := Module[ {tmpnam = Close[OpenTemporary[]]}, Export[tmpnam, sound, "WAV"]; Run["/usr/bin/mme/decsound -play", tmpnam]; DeleteFile[tmpnam]; Return[snd] ] -- P.J. Hinton Mathematica Programming Group paulh at wolfram.com Wolfram Research, Inc. Disclaimer: Opinions expressed herein are those of the author alone.