def setup
@osc = Oscillator.new('sine')
@osc.start
@osc.amp(0)
@playing = false
sel = createSelect
sel.position(0, height + 5)
sel.option(SINE) # 正弦波
sel.option(TRIANGLE) # 三角波
sel.option(SAWTOOTH) # のこぎり波
sel.option(SQUARE) # 矩形波
sel.selected(SINE)
sel.changed do
@osc.setType(sel.value)
end
end
def draw
background(220)
@freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);
@amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);
text('Tap to play', 20, 20)
text("freq: #{@freq}", 20, 50)
text("amp: #{@amp}", 20, 70)
if @playing
@osc.freq(@freq, 0.1)
@osc.amp(@amp, 0.1)
end
end
def mousePressed
@playing = true
end
def mouseReleased
@playing = false
@osc.amp(0, 0.5)
end
def setup
@osc = Oscillator.new(SINE, 300)
background(220)
text('Tap to play', 20, 20)
end
def mousePressed
@osc.start
@osc.amp(0.5)
@osc.freq(700)
@osc.freq(60, 0.7)
@osc.amp(0, 0.1, 0.7)
end
信号の出力時の音量を設定します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| vol | 音量 | 0.0~1.0 | ||
| rampTime | 到達秒数 | 設定値に到達するまでの値(線形に変化) | ○ | 0 (即時到達) |
| timeFromNow | 処理開始秒数 | いまから何秒後に設定するかの値 | ○ | 0 (即時開始) |
Oscillatorオブジェクト