YAMAGUCHI::weblog

ジャイトニオ猪場のはからいで、全財産を失いました。トランスマスターケンちゃんこと、剣持です。

TidalCycles環境をセットアップする

はじめに

こんにちは、ファイナンシャル・プランニング技能士です。ちょっと最近普通のプログラミングとは別にオーディオプログラミングとかヴィジュアルアートプログラミングとかで遊びたいなーと思いはじめてたところに、TLでTidalCyclesを見かけました。うまくSuperColliderをラップしてて面白そうなので、とりあえず環境構築をしてみることに。

Arch Linux

SuperColliderをインストール

普通にパッケージがあるのでインストール。

% pacaur -S supercollider sc3-plugins

stackを使ってtidalのインストール

公式サイトのインストール手順 に書いてあるとおりに適当に進めてみたら、家のArchでは cabal install tidal でいろいろ設定をいじってもインストールできなかった。ArchのpacmanでインストールするGHCがデフォルトだと動的リンクをするのに対し、cabalでのデフォルトの設定が静的リンクになっているせいかとも思ったが、設定を変えるても失敗するのでstackで入れることにした。

% pacaur -S stack
% stack setup
% stack install tidal

SuperDirtのインストール

インストール手順にあるようにSuperColliderを起動して、エディターに include("SuperDirt") を入力して実行。するとPost Windowにインストールログが流れ始めてインストール作業が行われていることがわかる。

*** Welcome to SuperCollider 3.9.3. *** For help press Ctrl-D.
Couldn't set realtime scheduling priority 1: 許可されていない操作です
file "/home/ymotongpoo/.local/share/SuperCollider/Help/scdoc_version" does not exist.
SCDoc: Indexing help-files...
SCDoc: Indexed 1802 documents in 0.77 seconds
Fetching https://github.com/supercollider-quarks/quarks.git
Installing SuperDirt
Installing Vowel
Adding path: /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/Vowel
Vowel installed
Installing Dirt-Samples
Adding path: /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/Dirt-Samples
Dirt-Samples installed
Adding path: /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt
SuperDirt installed
... the class library may have to be recompiled.
-> SuperDirt

SuperDirtの起動に失敗するのでjackdを手動で起動

手順どおりに SuperDirt.start を実行するとオーディオを正しく起動できなかったとエラーメッセージが出る。

-> SuperDirt
booting server 'localhost' on address: 127.0.0.1:57110
Found 10 LADSPA plugins
jackd 0.125.0
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.
jackd comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

could not initialize audio.
RESULT = 0

ちょっと調べた結果、どうもSCで利用しているjackdが正しく起動出来ていないようなので、手動でjackdを起動する。

% pacaur -S libffado
% jackd -r -d alsa   
jackd 0.125.0
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.
jackd comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
JACK compiled with System V SHM support.
loading driver ..
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback

改めて SuperDirt.start を実行するときちんと起動できた。

-> SuperDirt
booting server 'localhost' on address: 127.0.0.1:57110
Found 10 LADSPA plugins
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 1024
JackDriver: connected  system:capture_1 to SuperCollider:in_1
JackDriver: connected  system:capture_2 to SuperCollider:in_2
JackDriver: max output latency 21.3 ms
JackDriver: connected  SuperCollider:out_1 to system:playback_1
JackDriver: connected  SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
Requested notification messages from server 'localhost'
localhost: server process's maxLogins (1) matches with my options.
localhost: keeping clientID (0) as confirmed by server process.
Shared memory server interface initialized
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/core-modules.scd
---- core synth defs loaded ----
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/core-synths.scd
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/default-synths.scd
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/try-load-extra-synths.scd
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/tutorial-synths.scd

loading 217 sample banks:
808 (6) 808bd (25) 808cy (25) 808hc (5) 808ht (5) 808lc (5) 808lt (5) 808mc (5) 808mt (5) 808oh (5) 808sd (25) 909 (1) ab (12) ade (10) ades2 (9) ades3 (7) ades4 (6) alex (2) alphabet (26) amencutup (32) armora (7) arp (2) arpy (11) auto (11) baa (7) baa2 (7) bass (4) bass0 (3) bass1 (30) bass2 (5) bass3 (11) bassdm (24) bassfoo (3) battles (2) bd (24) bend (4) bev (2) bin (2) birds (10) birds3 (19) bleep (13) blip (2) blue (2) bottle (13) breaks125 (2) breaks152 (1) breaks157 (1) breaks165 (1) breath (1) bubble (8) can (14) casio (3) cb (1) cc (6) chin (4) chink (1) circus (3) clak (2) click (4) clubkick (5) co (4) control (2) cosmicg (15) cp (2) cr (6) crow (4) d (4) db (13) diphone (38) diphone2 (12) dist (16) dork2 (4) dorkbot (2) dr (42) dr2 (6) dr55 (4) dr_few (8) drum (6) drumtraks (13) e (8) east (9) electro1 (13) erk (1) f (1) feel (7) feelfx (8) fest (1) fire (1) flick (17) fm (17) foo (27) future (17) gab (10) gabba (4) gabbaloud (4) gabbalouder (4) glasstap (3) glitch (8) glitch2 (8) gretsch (24) gtr (3) h (7) hand (17) hardcore (12) hardkick (6) haw (6) hc (6) hh (13) hh27 (13) hit (6) hmm (1) ho (6) hoover (6) house (8) ht (16) if (5) ifdrums (3) incoming (8) industrial (32) insect (3) invaders (18) jazz (8) jungbass (20) jungle (13) juno (12) jvbass (13) kicklinn (1) koy (2) kurt (7) latibro (8) led (1) less (4) lighter (33) linnhats (6) lt (16) made (7) made2 (1) mash (2) mash2 (4) metal (10) miniyeah (4) moan (1) monsterb (6) moog (7) mouth (15) mp3 (4) msg (9) mt (16) mute (28) newnotes (15) noise (1) noise2 (8) notes (15) numbers (9) oc (4) odx (15) off (1) outdoor (6) pad (3) padlong (1) pebbles (1) perc (6) peri (15) pluck (17) popkick (10) print (11) proc (2) procshort (8) psr (30) rave (8) rave2 (4) ravemono (2) realclaps (4) reverbkick (1) rm (2) rs (1) sax (22) sd (2) seawolf (3) sequential (8) sf (18) sheffield (1) short (5) sid (12) sine (6) sitar (8) sn (52) space (18) speakspell (12) speech (7) speechless (10) speedupdown (9) stab (23) stomp (10) subroc3d (11) sugar (2) sundance (6) tabla (26) tabla2 (46) tablex (3) tacscan (22) tech (13) techno (7) tink (5) tok (4) toys (13) trump (11) ul (10) ulgab (5) uxay (3) v (6) voodoo (5) wind (10) wobble (1) world (3) xmas (1) yeah (31) 
... file reading complete. Required 439 MB of memory.

server 'localhost' disconnected shared memory interface
Shared memory server interface initialized
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/core-modules.scd
---- core synth defs loaded ----
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/core-synths.scd
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/default-synths.scd
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/try-load-extra-synths.scd
loading synthdefs in /home/ymotongpoo/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/tutorial-synths.scd

loading 217 sample banks:
808 (6) 808bd (25) 808cy (25) 808hc (5) 808ht (5) 808lc (5) 808lt (5) 808mc (5) 808mt (5) 808oh (5) 808sd (25) 909 (1) ab (12) ade (10) ades2 (9) ades3 (7) ades4 (6) alex (2) alphabet (26) amencutup (32) armora (7) arp (2) arpy (11) auto (11) baa (7) baa2 (7) bass (4) bass0 (3) bass1 (30) bass2 (5) bass3 (11) bassdm (24) bassfoo (3) battles (2) bd (24) bend (4) bev (2) bin (2) birds (10) birds3 (19) bleep (13) blip (2) blue (2) bottle (13) breaks125 (2) breaks152 (1) breaks157 (1) breaks165 (1) breath (1) bubble (8) can (14) casio (3) cb (1) cc (6) chin (4) chink (1) circus (3) clak (2) click (4) clubkick (5) co (4) control (2) cosmicg (15) cp (2) cr (6) crow (4) d (4) db (13) diphone (38) diphone2 (12) dist (16) dork2 (4) dorkbot (2) dr (42) dr2 (6) dr55 (4) dr_few (8) drum (6) drumtraks (13) e (8) east (9) electro1 (13) erk (1) f (1) feel (7) feelfx (8) fest (1) fire (1) flick (17) fm (17) foo (27) future (17) gab (10) gabba (4) gabbaloud (4) gabbalouder (4) glasstap (3) glitch (8) glitch2 (8) gretsch (24) gtr (3) h (7) hand (17) hardcore (12) hardkick (6) haw (6) hc (6) hh (13) hh27 (13) hit (6) hmm (1) ho (6) hoover (6) house (8) ht (16) if (5) ifdrums (3) incoming (8) industrial (32) insect (3) invaders (18) jazz (8) jungbass (20) jungle (13) juno (12) jvbass (13) kicklinn (1) koy (2) kurt (7) latibro (8) led (1) less (4) lighter (33) linnhats (6) lt (16) made (7) made2 (1) mash (2) mash2 (4) metal (10) miniyeah (4) moan (1) monsterb (6) moog (7) mouth (15) mp3 (4) msg (9) mt (16) mute (28) newnotes (15) noise (1) noise2 (8) notes (15) numbers (9) oc (4) odx (15) off (1) outdoor (6) pad (3) padlong (1) pebbles (1) perc (6) peri (15) pluck (17) popkick (10) print (11) proc (2) procshort (8) psr (30) rave (8) rave2 (4) ravemono (2) realclaps (4) reverbkick (1) rm (2) rs (1) sax (22) sd (2) seawolf (3) sequential (8) sf (18) sheffield (1) short (5) sid (12) sine (6) sitar (8) sn (52) space (18) speakspell (12) speech (7) speechless (10) speedupdown (9) stab (23) stomp (10) subroc3d (11) sugar (2) sundance (6) tabla (26) tabla2 (46) tablex (3) tacscan (22) tech (13) techno (7) tink (5) tok (4) toys (13) trump (11) ul (10) ulgab (5) uxay (3) v (6) voodoo (5) wind (10) wobble (1) world (3) xmas (1) yeah (31) 
... file reading complete. Required 439 MB of memory.

SuperDirt: listening to Tidal on port 57120

Atomの設定とテスト

Atomをインストールして、tidalcyclesパッケージをインストール。中で呼び出すghciの起動コマンドの設定があるので、そこを stack ghci に変更しておく。

f:id:ymotongpoo:20180520181340p:plain

その上で、 Packages > TidalCycles > Boot TidalCycles を実行する。インストール手順書にあるように次のコードをEvalしてみて音がなったら成功。

d1 $ sound "bd sn"

jackdとSuperColliderの起動のスクリプト

一応これで動いたけれど、jackdを手動で起動して、かつSuperDirtの起動のためだけにSuperColliderIDEを起動するのは大げさなので、スクリプト化してターミナルだけで完結するようにする。

まず start.scd という名前でSuperDirt.startを呼ぶだけのコードを保存しておく。

(
SuperDirt.start
)

次に先ほどのjackdの起動とstart.scdの読み込みだけの簡単なシェルスクリプトを用意する。

#!/bin/bash

jackd -r -d alsa &
sclang start.scd

これのシェスクリプトを起動すればいちいちSuperCollider IDEを起動しなくて良くなる。終わったあとはjackdをちゃんとkillしないと音声を出すアプリケーションが動かなくなるので注意。

参考