いらないモノ、ひつようなモノ

書籍、音楽、そして若干のテクノロジー

csoundをコンパイル。

  • scons -hでオプションを見なさいとマニュアルに言われても、何のことやら。いろいろ調べて、単に引数で指定しなさいということか。今のところはこのようにコンパイル
scons useDouble=1 buildCsoundAC=1 buildCsound5GUI=1 useOSC=1 buildInterfaces=1 buildDSSI=1 buildVirtual=1 buildStkOpcodes=1 buildRelease=1 gcc4opt=pentium3
  • useDouble
    これでOPCODE Pluginは64bit版を使う必要が出てきます。csoundとコマンドラインで入力すると下記のdoubleとありますがこのオプションを指定しないとfloatと出ます。
.
.
0dBFS level = 32768.0
Csound version 5.06 (double samples) Aug 16 2007
.
.
  • buildRelease
    buildRelease=1を指定しないと上記のように"5.06"と"(double sample)"の間に"beta"という文字列が入るようです。これを指定するとnoDebug=1に自動でなってデバッグ情報の取れたバイナリができるそうです。
[root@localhost]# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 8
model name	: Pentium III (Coppermine)
stepping	: 6
cpu MHz		: 863.870
cache size	: 256 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 2
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr sse up
bogomips	: 1728.44
clflush size	: 32
  • buildCsoundAC=1
    AC=Algorithmic Compositionの略なのでなんとなく1にしたが、CsoundVSTで使うほかはまだ使わないのではないだろうか?血迷ったか。FLTK, boost, Python, SWIGが必要になる。
  • useOSC=1
    OSCサポート有
  • buildCsound5GUI=1
    5.06で新しくなったGUI。出し方に悩んだ挙句。csound5guiと打てばよかった。GUIはあまり使わないけど。絵を張っておきます*1
  • buildInterfaces=1
    Python, Java, Lua, C++等他言語のインタフェースライブラリを作る。これも現段階では不要だった。血迷った。
  • buildDSSI=1
    DSSI/LADSPAのopcodesを入れる。
  • buildVirtual=1
    バーチャルMIDIキーボードが出てくるそうなんだけどどうやったら出てくるんだ?
  • buildStkOpcodes=1
    STKのOpcodesのサポートですね。

ちなみにデフォルトで

  • usePortAudio=1, usePortIMIDI=1, useJack=1, useALSA=1, useFLTK=1, buildLoris=1だった。インストールされているのを見つけてくれたからみたい。
  • buildNewParser=0 まだ古い(=バグの枯れてる)パーサーでいいやっ!
  • buildPDClass=0でpuredataではまだ使わないのでそのまま。m_pd.hというヘッダファイルが必要みたいです。
  • buildPythonOpcode=0, buildCsoundVST=0, buildvst4cs=0(多分、funknown.hが必要)。pythonから使ったり、VSTで使ったりする場合に必要。一度はトライしたけど使い道がピンとこないので、とりあえずcsoundもう少し動かしてからにしよ。vstでリアルタイムに使ったらいいのかもしれないけどマシン非力だし。

環境変数の問題回避

コンパイルを始めるとすぐに下記のエラーに遭遇

Checking for C header file stdio.h... no
 *** Failed to compile a simple test program. The compiler is
 *** possibly not set up correctly, or is used with invalid flags.
 *** Check config.log to find out more about the error.

/usr/includeに普通にあるはず。なのにおかしい。http://www.nabble.com/Notes-on-SConstruct-t4141009.htmlを参考にすると、

  • custom.py.mkgをcustom.pyにrenameする
  • stdio.hがないというエラーを避けるために、SConstructの226行目を
commonEnvironment = Environment(ENV = {'PATH' : os.environ['PATH']})

から

commonEnvironment = Environment()

変更。

インストールと実行

  • ./install.pyでインストール*2
  • 環境変数など~/.bashrcに指定。この場合は
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib;/usr/local/lib/plugins64;/usr/local/lib/plugins
OPCODEDIR=/usr/local/lib/csound/plugins
OPCODEDIR64=/usr/local/lib/csound/plugins64
CSSTRNGS=/usr/local/share/csound/xmg
export LD_LIBRARY_PATH OPCODEDIR OPCODEDIR64 CSSTRINGS
  • 動かすと動いた。音も出た。csound studien10.csdでシンプルに動かしてみた。csdファイルは以下のとおり。
<CsoundSynthesizer>
<CsOptions>
 -W -o studien10.wav
</CsOptions>
<CsScore>
f24 0 1024 8 0 256 1 512 -1 256 0

#define ATTACK_TIME    #0.3#
#define DECAY_TIME     #0.2#
#define SUSTAIN_LEVEL  #0.8#
#define RELEASE_TIME   #2.0#

#define ADSR_1 #0.3 0.2 0.8 0.0#
#define ADSR_2 #0.3 0.2 0.8 5.0#
#define ADSR   #$ATTACK_TIME $DECAY_TIME $SUSTAIN_LEVEL $RELEASE_TIME#
#define DUR    #0.5#
#define STRT   #+#

;    stt    dur   amp   frq   att dec sus rel pan fn
i2     0        $DUR    69   7.12  $ADSR_1         0.2 24
i2     $STRT    $DUR    79   6.22  $ADSR_1         0.2 24
i2     $STRT    $DUR    91   6.01  $ADSR_1         0.2 24
i2     $STRT    $DUR    61   6.11  $ADSR_1         0.2 24
i2     $STRT    $DUR    72   6.11  $ADSR_1         0.2 24
i2     $STRT    $DUR    76   6.14  $ADSR_1         0.2 24
i2     $STRT    $DUR    79   6.01  $ADSR_1         0.2 24

</CsScore>

<CsInstruments>
sr     = 44100
kr     = 44100
ksmps  = 1
nchnls = 2   ; 2チャンネルでステレオ

instr 2
 idur      = p3
 iamp      = ampdb(p4)/2
 inote     = cpspch(p5)
 iatt_tm   = p6
 idec_tm   = p7
 isus_lv   = p8
 irel_tm   = p9
 ipan      = p10
 ifn       = p11
 isus_tm   = p3-(iatt_tm-idec_tm)
 p3        = p3+irel_tm
 kpan      = 1.0

 kenv linseg              \
               0.00,      \ ;level(y)0から始まって
     iatt_tm,  1.0     ,  \ ;iatt_tm秒間で1.0まで増加
     idec_tm,  isus_lv,   \ ;idec_tm秒間でisus_lvまで減少
     isus_tm,  isus_lv,   \ ;isus_tm秒間isus_lvを維持
     irel_tm,  0.00       \ ;irel_tm秒間で0まで減少

 k1 linseg           0, \
            idur*0.8,1, \
            idur*0.2,0
 k2 linseg           0, \
            idur*0.2,1, \
            idur*0.8,0

 knote1 linseg       445,   \
            1.0     ,440, \
            1.0     ,445, \
            1.0     ,440, \
            1.0     ,430, \
            1.0     ,447

 knote2 linseg       440,   \
            1.0     ,432, \
            1.0     ,449, \
            1.0     ,445, \
            1.0     ,450, \
            1.0     ,439  

 a1 oscili  iamp,   knote1, ifn
 a2 oscili  iamp,   knote2, ifn
 
 a3 = a1*k1+a2*k2
 
 aout oscili iamp, inote+a3, ifn

 arev reverb aout, 4.0	; 2 second reverb
 adly delay  aout, 0.05, 0
 outs (aout*ipan+arev*0.2+adly) ,(aout*(1-ipan)+arev*0.2+adly)
endin

</CsInstruments>
</CsoundSynthesizer>

*1:ちなみにwindow managerは軽いfluxboxに変更してあります

*2:マニュアルには scons installでもOKと書いてあるが引数一覧を見ると scons install=1が正解な気がするな