Sonic Piは和音名でリストを返す機能を内蔵しています。実際に試してみましょう。
play chord(:E3, :minor)
さあ、本当に動きましたね。そのままのリストよりも美しく見えるし、そして他の人にとっても読みやすいでしょう。では、どんな和音をSonic Pi はサポートをしているのでしょうか。沢山あります。次のように、いくつかのコードを試してみましょう。
chord(:E3, :m7)
chord(:E3, :minor)
chord(:E3, :dim7)
chord(:E3, :dom7)
play_pattern
関数で簡単にコード(和音)からアルベジオ(和音を構成する音を一音ずつ順番に弾いていく奏法)に変更して演奏を行うことができます。
play_pattern chord(:E3, :m7)
Ok, that’s not so fun - it played it really slowly. play_pattern
will play each note in the list with a call to sleep 1
after each call to play
. We can use another function play_pattern_timed
to specify our own timings and speed things up:
play_pattern_timed chord(:E3, :m7), 0.25
play_pattern
には時間のリストを渡すこともでき、それは循環する時間として扱われます。
play_pattern_timed chord(:E3, :m13), [0.25, 0.5]
これは次のコードと同じです。
play 52, sustain: 0.25
sleep 0.25
play 55, sustain: 0.5
sleep 0.5
play 59, sustain: 0.25
sleep 0.25
play 62, sustain: 0.5
sleep 0.5
play 66, sustain: 0.25
sleep 0.25
play 69, sustain: 0.5
sleep 0.5
play 73, sustain: 0.25
sleep 0.25
どちらの書き方を好みますか?
Note that play_pattern
and play_pattern_timed
alter the sustain of the notes to fill the times. You can remove this behavior by setting the sustain:
opt to 0
:
play_pattern_timed chord(:E3, :m13), [0.25, 0.5], sustain: 0