Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

After waiting for days for my license I now got the opportunity to install Wolfram Mathematica 8 at home. However, neither the Play nor the Speak functions are doing anything as it seems that Mathematica cannot produce any sound output due to unknown reasons. Might anyone have an idea how I can fix this?

share|improve this question
Does the Mathematica documentation say anything about sound? If there's a configuration somewhere where pulseaudio is a possible setting, select it. – Gilles Jun 17 '11 at 18:49
@Gilles: I found a "solution" here however apt doesn't know the arts package. Any idea how to install it? – Christian Ivicevic Jun 17 '11 at 19:06
Mathematica tries to use OSS, while most linux dists use ALSA. See No sound in Mathematica 8.0.1 under Linux – Simon Jul 8 '11 at 13:12

1 Answer

Ubuntu uses the PulseAudio sound system. It comes with the paplay command to play a sound file. The approach you found on the Ubuntu wiki should work, but you need to use paplay (or some other equivalent program) rather than the now obsolete aRts.

Here's some code adapted from the Ubuntu wiki. Add it to your ~/.Mathematica/Kernel/init.m or to a file that it includes. In addition to running paplay rather than artsplay, I've changed it to pipe the data rather than store it in a temporary file. Untested.

Begin["System`Private`"]
Unprotect[$SoundDisplayFunction]
Clear[$SoundDisplayFunction]
$SoundDisplayFunction =
    Module[{stream},
      stream = OpenWrite["!pacat", BinaryFormat -> True];
      BinaryWrite[stream, ExportString[#1, "WAV"]];
      Close[stream];
    ] &
Protect[$SoundDisplayFunction]
End[];

See also No sound in Mathematica 8.0.1 under Linux, which reports that a similar approach worked in Mathematica 8 (with ALSA rather than PulseAudio).

share|improve this answer
+1; Although to get it working I had to replace OpenWrite["!paplay"] with OpenWrite["!pacat",BinaryFormat -> True]. Also, you get the normal graphics output if you append a #1 to the end of your $SoundDisplayFunction. Finally, I've updated my answer to further discuss OSS (which Mathematica wants to use) versus ALSA/PA (that Ubuntu uses). – Simon Jul 8 '11 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.