How do I play a sound in Octave?

后端 未结 7 2150
后悔当初
后悔当初 2020-12-09 20:36

Octave appears to assume that a specific sound playing utility will be available on a system but doesn\'t seem to provide the ability to specify an alternate. In the error

7条回答
  •  离开以前
    2020-12-09 20:54

    On OSX, this is what I did to get sound working:

    from the sound command help:

    This function writes the audio data through a pipe to the program "play" from the sox distribution. sox runs pretty much anywhere, but it only has audio drivers for OSS (primarily linux and freebsd) and SunOS. In case your local machine is not one of these, write a shell script such as ~/bin/octaveplay, substituting AUDIO_UTILITY with whatever audio utility you happen to have on your system: #!/bin/sh cat > ~/.octave_play.au SYSTEM_AUDIO_UTILITY ~/.octave_play.au rm -f ~/.octave_play.au and set the global variable (e.g., in .octaverc) global sound_play_utility="~/bin/octaveplay";

    I named the following script "octaveplay" and put it in ~/bin:

    cat > ~/.octave_play.aif
    afplay ~/.octave_play.aif
    rm -f ~/.octave_play.aif

    Then I created .octaverc and added: global sound_play_utility="~/bin/octaveplay";

    Voila!

提交回复
热议问题