試験運用中なLinux備忘録・旧記事

はてなダイアリーで公開していた2007年5月-2015年3月の記事を保存しています。

OpenAL Softの新しい設定ファイルとその書式について

Mandriva Linux 2010.0でOpenALライブラリのバージョンが上がり、Tao Frameworkのほうもこれに合わせた修正を「自前で作成もしくは修正した幾つかのMandriva Linux向けRPMパッケージを更新2」で行ったのだが、openBVE上でサウンド出力がうまく指定されていないことに気付いた。
以前はALSAのJACKプラグイン(関連記事)を

(define devices '(alsa))
(define alsa-device "pjack")

のようにして指定してJACKへサウンド出力する使い方をしていたのだが、うまくJACKに出力されず、端末には

AL lib: alcConfig.c:244: Reading ~/.openalrc; this file is deprecated
        Please rename it to ~/.alsoftrc
AL lib: alcConfig.c:146: config parse error: option without a value: "(define"
AL lib: alcConfig.c:146: config parse error: option without a value: "(define"
AL lib: alsa.c:379: Could not open playback device 'default': Device or resource busy
AL lib: oss.c:179: Could not open /dev/dsp: Device or resource busy

と出力されていた。

  1. ファイルと書式が変わっている
  2. 新しい書式
    1. 幾つかの設定項目に関するメモ
  3. 新しい設定

ファイルと書式が変わっている

端末への出力にあるように、設定ファイルは[ホームディレクトリ]/.openalrcから[ホームディレクトリ]/.alsoftrcへと変更されているものの

Please rename it to ~/.alsoftrc

の通りに名前変更だけを行っても不十分で、ファイルの内容も新しい書式に基づいて書き換える必要がある。
システムの設定ファイルは/etc/openal/alsoft.confで記述されており、一般ユーザがこの設定項目の中から変更したいものだけを[ホームディレクトリ]/.alsoftrcに記述することになるが、環境変数ALSOFT_CONFにより別のファイルを指定することもできる。

$ ALSOFT_CONF=[設定ファイル] [OpenALアプリケーション...]

新しい書式

元の設定ファイル(一部省略)を貼り付けておく。コメントに説明,指定可能な値,既定値が書かれているので、参考にできる。
[引用] ファイル名: /etc/openal/alsoft.conf より

format = AL_FORMAT_STEREO16  # Sets the output format. Can be one of:
                             # AL_FORMAT_MONO8    (8-bit mono)
                             # AL_FORMAT_STEREO8  (8-bit stereo)
                             # AL_FORMAT_QUAD8    (8-bit 4-channel)
                             # AL_FORMAT_51CHN8   (8-bit 5.1 output)
                             # AL_FORMAT_61CHN8   (8-bit 6.1 output)
                             # AL_FORMAT_71CHN8   (8-bit 7.1 output)
                             # AL_FORMAT_MONO16   (16-bit mono)
                             # AL_FORMAT_STEREO16 (16-bit stereo)
                             # AL_FORMAT_QUAD16   (16-bit 4-channel)
                             # AL_FORMAT_51CHN16  (16-bit 5.1 output)
                             # AL_FORMAT_61CHN16  (16-bit 6.1 output)
                             # AL_FORMAT_71CHN16  (16-bit 7.1 output)
                             # Default is AL_FORMAT_STEREO16

cf_level = 0  # Sets the crossfeed level for stereo output. Valid values are:
              # 0 - No crossfeed
              # 1 - Low crossfeed
              # 2 - Middle crossfeed
              # 3 - High crossfeed (virtual speakers are closer to itself)
              # 4 - Low easy crossfeed
              # 5 - Middle easy crossfeed
              # 6 - High easy crossfeed
              # Default is 0. Users of headphones may want to try various
              # settings. Has no effect on non-stereo modes.

frequency = 44100  # Sets the output frequency. Default is 44100

refresh = 4096  # Sets the buffer size, in frames. Default is 4096. Note that
                # the actual granularity may or may not be less than this.

sources = 256  # Sets the maximum number of allocatable sources. Lower values
               # may help for systems with apps that try to play more sounds
               # than the CPU can handle. Default is 256

stereodup =  # Sets whether to duplicate stereo sounds on the rear and side
             # speakers for 4+ channel output. This can make stereo sources
             # substantially louder than mono or even 4+ channel sources, but
             # provides a "fuller" playback quality. True, yes, on, and non-0
             # values will duplicate stereo sources. 0 and anything else will
             # cause stereo sounds to only play out the front speakers.
             # Default is false

drivers =  # Sets the backend driver list order, comma-seperated. Unknown
           # backends and duplicated names are ignored, and unlisted backends
           # won't be considered for use. An empty list means the default.
           # Default is:
           # alsa,oss,solaris,dsound,winmm,port,wave

excludefx =  # Sets which effects to exclude, preventing apps from using them.
             # This can help for apps that try to use effects which are too CPU
             # intensive for the system to handle. Available effects are:
             # reverb
             # Default is empty (all available effects enabled)

layout_STEREO =  # Sets the speaker layout when using stereo output. Values are
                 # specified in degrees, where 0 is straight in front, negative
                 # goes left, and positive goes right. The values must define a
                 # circular pattern, starting with the back-left at the most
                 # negative, around the front to back-center. Unspecified
                 # speakers will remain at their default position. Available
                 # speakers are front-left(fl) and front-right(fr).
                 # The default is:
                   fl=-90, fr=90

layout_QUAD =  # Sets the speaker layout when using quadriphonic output.
               # Available speakers are back-left(bl), front-left(fl),
               # front-right(fr), and back-right(br).
               # The default is:
                 bl=-135, fl=-45, fr=45, br=135

layout_51CHN =  # Sets the speaker layout when using 5.1 output. Available
                # speakers are back-left(bl), front-left(fl), front-center(fc),
                # front-right(fr), and back-right(br).
                # The default is:
                  bl=-110, fl=-30, fc=0, fr=30, br=110

layout_61CHN =  # Sets the speaker layout when using 6.1 output. Available
                # speakers are side-left(sl), front-left(fl), front-center(fc),
                # front-right(fr), side-right(sr), and back-center(bc).
                # The default is:
                  sl=-90, fl=-30, fc=0, fr=30, sr=90, bc=180

layout_71CHN =  # Sets the speaker layout when using 7.1 output. Available
                # speakers are back-left(bl), side-left(sl), front-left(fl),
                # front-center(fc), front-right(fr), side-right(sr), and
                # back-right(br).
                # The default is:
                  bl=-150, sl=-90, fl=-30, fc=0, fr=30, sr=90 br=150


[alsa]  # ALSA backend stuff
device = default  # Sets the device name for the default playback device.
                  # Default is default

periods = 0  # Sets the number of update buffers for playback. A value of 0
             # means auto-select. Default is 0

capture = default  # Sets the device name for the default capture device.
                   # Default is default

mmap = true  # Sets whether to try using mmap mode (helps reduce latencies and
             # CPU consumption). If mmap isn't available, it will automatically
             # fall back to non-mmap mode. True, yes, on, and non-0 values will
             # attempt to use mmap. 0 and anything else will force mmap off.
             # Default is true.

[oss]  # OSS backend stuff
device = /dev/dsp  # Sets the device name for OSS output. Default is /dev/dsp

periods = 4  # Sets the number of update buffers. Default is 4

capture = /dev/dsp  # Sets the device name for OSS capture. Default is /dev/dsp

(中略)

[port]  # PortAudio backend stuff
device = -1  # Sets the device index for output. Negative values will use the
             # default as given by PortAudio itself. Default is -1

periods = 4  # Sets the number of update buffers. Default is 4

[wave]  # Wave File Writer stuff
file =  # Sets the filename of the wave file to write to. An empty name
        # prevents the backend from opening, even when explicitly requested.
        # THIS WILL OVERWRITE EXISTING FILES WITHOUT QUESTION!
        # Default is empty

幾つかの設定項目に関するメモ
cf_level(クロスフィードの設定)については、ステレオ出力時(特にヘッドホン使用時など)に左右の振り分けをはっきりさせずにスピーカーに近い音の出かたにしたいときに段階に応じた値を指定するものとなっている(0で無効)。openBVE上で「0」と「3」を比べると、「0」で左右がはっきりし、「3」では自然な形になっているように感じる。
(2009/11/19)この設定の比較動画を
zoome.jp/kakurasan/diary/28/
に作成した。

(2015/1/7)zoomeの動画はサイト閉鎖につき参照できない。
出力先サウンドシステムは「drivers」の値で指定(複数可・コンマ区切り)し、「alsa」などのセクションでサウンドシステムごとの設定を行う。

新しい設定

本記事の最初に書いたJACK向けの古い設定は以下のようになった。
ファイル名: ~/.alsoftrc

drivers = alsa

[alsa]
device = pjack
capture = pjack

PulseAudioへ出力したい場合、${HOME}/.asoundrcなどに「type pulse」なPCM(関連記事)の記述があれば
ファイル名: ~/.alsoftrc

drivers = alsa

[alsa]
device = pulse
capture = pulse

のようになる(ALSAのPCM名は設定したものと同じにする)が、Mandriva Linux 2010.0上のopenBVEの場合は特にこのファイルに設定を記述しなくてもPulseAudioから出力されるようだ。

使用したバージョン: