Mathematica는 Ubuntu 11.04에서 소리가 나지 않습니다.

Mathematica는 Ubuntu 11.04에서 소리가 나지 않습니다.

라이센스를 며칠 동안 기다린 후 이제 설치할 기회가 생겼습니다.볼프람 수학 8집에서. 그러나 Mathematica는 알 수 없는 이유로 사운드 출력을 생성할 수 없는 것으로 보이기 때문에 Play및 함수는 아무 작업도 수행하지 않습니다. Speak이 문제를 어떻게 해결할 수 있는지 아는 사람 있나요?

답변1

우분투는펄스 오디오사운드 시스템. paplay사운드 파일을 재생하는 명령이 제공됩니다 . 당신이 찾은 방법우분투 위키에서paplay작동해야 하지만 현재는 사용되지 않는 aRts 대신 (또는 다른 동등한 프로그램)을 사용해야 합니다 .

다음은우분투 위키. ~/.Mathematica/Kernel/init.m또는 포함된 파일 에 추가하세요 . paplay대신 실행하는 것 외에도 artsplay데이터를 임시 파일에 저장하는 대신 파이프로 변경했습니다. 검증되지 않은.

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[];

당신은 또한 볼 수 있습니다Mathematica 8.0.1은 Linux에서 소리가 나지 않습니다., 유사한 접근 방식이 Mathematica 8에서도 작동한다고 보고했습니다(PulseAudio 대신 ALSA 사용).

답변2

문제는 Mathematica 버전은 OSS를 사용하는 반면 Ubuntu는 ALSA를 사용한다는 것입니다.

다음 "sound.m" 스크립트를 다음에 추가하세요 ~/.Mathematica/Kernel.

(* ::Package:: *)

(*
  * Set up a $SoundDisplayFunction for the
  * Linux version of Mathematica and potentially other unixes, too.
  *)

Begin["System`Private`"]

Unprotect[$SoundDisplayFunction]
Clear[$SoundDisplayFunction]

$SoundDisplayFunction :=
     Module[{playCmd,soundFileName},
            Export[$SoundDisplay, #1];
         (* is there a way to get the sample rate, etc. from the audio 
stream? *)
         playCmd = "/usr/bin/play";
         soundFileName = "/tmp/" <> ToString[Unique["sound"]] <> ".wav";
         playCmd = playCmd <> " " <> soundFileName;

         Export[soundFileName, #1, "WAV"];
         Run[playCmd];
         Run["/bin/rm -f " <> soundFileName];
        ] &

Protect[$SoundDisplayFunction]

End[];

(********************CODE ENDS***************************)

After creating 'sound.m', add the following line
to ~/.Mathematica/Kernel/init.m :

Get["sound.m"];

커널을 다시 로드하려면 Mathematica를 다시 시작하세요.

답변3

나는 같은 문제를 가지고있다. Mathematica 10으로 업그레이드한 후 Linux에서 사운드 생성을 실행할 수 있습니다.

관련 정보