LoginSignup
0
0

More than 1 year has passed since last update.

【TidalCycles】State Valuesの値によってエフェクトを変える

Posted at

はじめに

TidalCyclesのバージョン1.7.2からState Valuesが使えるようになりました。

これによってリズムパターンとは独立にn, pan, gainなどの値をコントロールできるようになりました。詳しくは上のドキュメントを見てください。

どんなときにState Valuesを使うといいか

たとえば以下のコードを実行すると、"newnotes"が再生されるごとにState Values "harold"が1ずつ増えていきます。

d1 $ s "newnotes(5,8)" # nCount "harold" # gain 1

この"harold"は参照することができ、例えば次のようにするとharoldの値が使えます

d2 $ s "newnotes*16" # n "^harold" # gain 0.6

このd1とd2を合わせたサウンドは、State Valuesを用いないで実現しようと思うと難しいと思います。このState Valuesの更新と参照を行うことでアイデアの幅が広がります。

State Valuesの値を元にエフェクト変えたりできないか

上の例では、State Values "harold"の値を直接そのまま利用しただけでした。

ただ、「"harold"が10以上になったらこのエフェクトをかけたい」みたいな欲望がでてくると思います。

これは以下のようなコードで実現できます。

capply func condpat effectpat = every
    (fmap func (segment 1 condpat)) (effectpat)

do
  d1 $ s "newnotes(5,8)" # nCount "harold" # gain 1
  d2
    $ capply (\x -> if x >= 10 then 1 else 0) (cF 0 "harold") (# room 0.4)
    $ s "hc*4"

"harold"の値が10以上になったときに、"hc"に対してroomリバーブがかかるようになります。

ちなみに現在のharoldの値を見たいときは

getState $ "harold"

で確認できます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0