supriya-project / supriya

A Python API for SuperCollider
http://supriya-project.github.io/supriya
MIT License
252 stars 29 forks source link

EventPattern playing at about half speed #362

Closed macduff111 closed 10 months ago

macduff111 commented 10 months ago

Discussed in https://github.com/josiah-wolf-oberholtzer/supriya/discussions/360

Running the code below I expect it to generate 4 notes in series, each a second long as set by the delta and duration keys , however they are each about 2 secs long.

@synthdef()
def test(gate=1,freq=440):
    env=Linen.kr(gate,0.01,1.0,0.01,done_action=DoneAction.FREE_SYNTH)
    osc=SinOsc.ar(frequency=freq)
    out=env*osc
    Out.ar(bus=0,source=out)

pattern=EventPattern(
    freq=SequencePattern([440,880],2),
    delta=1,
    duration=1,
    synthdef=test)
josiah-wolf-oberholtzer commented 10 months ago

Timing's not quite the same as with SuperCollider.

1.0 duration is a whole note.

The default clock (Clock.default() will get it for you) defaults to 120BPM. That's 2 beats per second, making 4 beats (4/4) take 2 seconds.

josiah-wolf-oberholtzer commented 10 months ago

If you don't want to adjust your durations and deltas, you can just bump the tempo on the clock.

See: https://josiahwolfoberholtzer.com/supriya/api/supriya/clocks/bases.html#supriya.clocks.bases.BaseClock.change

Clock.default.change(beats_per_minute=240) probably gets you the tempo you want.

macduff111 commented 10 months ago

ah ok, that makes sense. many thanks

oh, and that should be brackets after default ie Clock.default().change(beats_per_minute=240)