strudel.ccというJavascriptで書ける作曲ツールがあるとのことで、
試しにループを作ってみた。
🎶 音楽ジェネレーターのコード解説
以下は、ドラム、ベース、シンセ、コードなど複数の音を重ねて再生するスクリプトです。
📜 コード(整形済み)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
stack( // 🥁 ドラム sound("bd hh bd hh bd hh bd hh*2") .bank("TR909") .gain(1), // 🎸 ベースライン note("<e2 e3 e2 e3*2 e2*2 e3 e2 e4*4>") .sound('square') .fast(8) .cutoff(900) .gain(1), // 🎹 シンセ1(ミュート中) "<e4 e5 e4 e5>" .sound('sawtooth') .fast(8) .note() .cutoff(1500) .gain(0), // 🎹 シンセ2(ミュート中) "<g3 b4 a4 b4 a4 g3 g3 a3>" .sound('square') .fast(8) .note() .cutoff(500) .gain(0), // 🎵 コード(和音) "<Am7!3 <Em7 Bm7 Em7 Bm7>>" .voicings('lefthand') .note() .sound('sawtooth') .lpf("<600 900 1200 1500>") .release("<0 .1 .4 .6>/2") .gain(1) ) |
🔍 詳細解説
stack(...)
- 複数のサウンドレイヤーを同時に再生する関数。
🎧 ドラムセクション
1 2 3 4 |
sound("bd hh bd hh bd hh bd hh*2") .bank("TR909") .gain(1) |
bd
はバスドラム(kick)、hh
はハイハット。"bd hh bd hh bd hh bd hh*2"
:最後のhh*2
でハイハットを2倍の長さで演奏。- 使用ドラム音源はTR-909。
- 音量(ゲイン)は通常の
1
。
🎸 ベースライン
1 2 3 4 5 6 |
note("<e2 e3 e2 e3*2 e2*2 e3 e2 e4*4>") .sound('square') .fast(8) .cutoff(900) .gain(1) |
note(...)
でベース音程を指定。<...>
の中では音の繰り返しができる:e3*2
はe3を2回、e4*4
はe4を4回。- 波形は**square(矩形波)**で、クラシックなチップチューンサウンドに。
fast(8)
:1小節を8等分のテンポで再生(8分音符)。cutoff(900)
:ローパスフィルターのカットオフ周波数を指定。gain(1)
:音量。
🎹 シンセ1(現在は音量0でミュート)
1 2 3 4 5 6 7 |
"<e4 e5 e4 e5>" .sound('sawtooth') .fast(8) .note() .cutoff(1500) .gain(0) |
- 音程:e4とe5を交互に再生。
- 波形:sawtooth(ノコギリ波)。
gain(0)
:現在ミュート状態。必要があれば1に上げてONにできる。
🎹 シンセ2(現在はミュート)
1 2 3 4 5 6 7 |
"<g3 b4 a4 b4 a4 g3 g3 a3>" .sound('square') .fast(8) .note() .cutoff(500) .gain(0) |
- 複雑なメロディライン。
- 使用波形:square。
cutoff(500)
でローパスフィルターをきつくかけて柔らかめの音に。
🎵 コード(和音)
1 2 3 4 5 6 7 8 |
"<Am7!3 <Em7 Bm7 Em7 Bm7>>" .voicings('lefthand') .note() .sound('sawtooth') .lpf("<600 900 1200 1500>") .release("<0 .1 .4 .6>/2") .gain(1) |
- 和音進行:
Am7!3
:Am7コードを3回繰り返す。<Em7 Bm7 Em7 Bm7>
:Em7とBm7を交互に再生。
voicings('lefthand')
:左手風のボイシング(低音域中心の和音構成)。lpf(...)
:ローパスフィルターのカットオフを時間で変化させる。release(...)
:音の余韻(リリース時間)を変化させる。gain(1)
:通常音量で再生。