先日ハッカーズバーに行って「extemporeでライブコーディングかっけええええ」ってなりました。
そこでextemporeを勉強し始めたのですが、音を出せるようになったはいいけれどその先進まなくて挫折しかけています。
まずはインストールから。
OSXでhomebrewが入っていれば
brew tap benswift/extempore && brew tap homebrew/versions
brew install extempore --with-extended
これで終わりです。
ターミナルでextemporeと打つと起動します。
コンソールには次のようにうまく起動したことが書かれます。
------------- Extempore --------------
Andrew Sorensen (c) 2010-2015
andrew@moso.com.au, @digego
ARCH : x86_64-apple-darwin15.4.0
LLVM : 3.7.0 MCJIT
Output Device : Built-in Output
Input Device :
SampleRate : 44100
Channels Out : 2
Channels In : 0
Frames : 128
Latency : 0.0129932 sec
---------------------------------------
Allocated: 1 Cell Segements For A Total Of 0, Free Cells = 0
Starting utility process
Trying to connect to 'localhost' on port 7098
New Client Connection
Successfully connected to remote process
Allocated: 1 Cell Segements For A Total Of 0, Free Cells = 0
Starting primary process
Trying to connect to 'localhost' on port 7099
New Client Connection
Successfully connected to remote process
Loading xtmstd library... done in 2.380045 seconds
ここまではいいです。簡単です。
ではextemporeが起動できたところで、言語の勉強に移ります。
言語仕様は次のブログに書かれています。
http://benswift.me/extempore-docs/index.html
まずこの言語、C言語とlispを組み合わせたxtlangという言語仕様に沿って書かれています。
ここで第一関門。lispの勉強。
xtlangを理解する前に、ある程度lispを知っている必要があります。
lispを勉強して、xtlangを勉強して、ようやく一音出るようになりました。
あとはちょっとコピペしたりで何音か出るようにはなります。
例えば以下のコードです。(オリジナルではなくbenswift.meから抜粋です。)
;; load the instruments file (sys:load "libs/core/instruments.xtm") ;; define a synth using the provided components ;; synth_note_c and synth_fx (bind-instrument synth synth_note_c synth_fx) ;; add the instrument to the DSP output sink closure (bind-func dsp:DSP (lambda (in time chan dat) (synth in time chan dat))) (dsp:set! dsp) ;; play a note on our synth (play-note (now) synth (random 60 80) 80 (* 1.0 *second*)) ;; plays a sequence of pitches (define play-seq (lambda (time plst) (play-note time synth (car plst) 80 11025) (if (not (null? (cdr plst))) (callback (+ time 10000) 'play-seq (+ time 11025) (cdr plst)))))
(play-seq (now) '(60 62 63 65 67 68 71 72))
ちなみにsublime textを使ってできます。
環境構築方法は、githubに書いてある通りです。
https://github.com/benswift/extempore-sublime
connectをすると起動しているextemporeに接続しに行きます。
あとはコードを実行することで音を出したりできます。
(ショートカットキーCtrl+Eを設定すると便利)
で、このあとは他のライブラリを使ってリズムを刻みながら音を乗せたりできるはずですが・・・リズムの音が入っているライブラリが読み込めずつまずいて今に至ります。
もっと勉強すれば自分で音を作れたりするのですが、リズムを出せず簡単な音しか出せないところで挫折気味です、、、
一旦このネタは寝かせようかなということで今日のブログは終わりです。