Skip to content

Instantly share code, notes, and snippets.

@Sciss
Created December 5, 2016 09:58
Show Gist options
  • Save Sciss/45545f2b6f4fa8a62ec0bbfeb43b9a6f to your computer and use it in GitHub Desktop.
Save Sciss/45545f2b6f4fa8a62ec0bbfeb43b9a6f to your computer and use it in GitHub Desktop.
// note: this doesn't demonstrate anything useful yet
SynthDef.recv("SubsampleOffset") {
val addOff = "addOff".kr(3)
val in = Impulse.ar(2) * 0.3 // some input.
val sampDur = SampleDur.ir // duration of one sample
val pad = 4 // DelayC needs at least 4 samples buffer
val sampOff = 1 - SubsampleOffset.ir + // balance out subsample offset
MouseX.kr(0, addOff) // add a mouse dependent offset
// cubic resampling
val resampled = DelayC.ar(in,
maxDelayTime = sampDur * (1 + pad),
delayTime = sampDur * (sampOff + pad)
)
OffsetOut.ar("out".kr, resampled)
}
// create 2 pulse trains 1 sample apart, move one relatively to the other.
// when cursor is at the left, the impulses are adjacent, on the right, they are
// exactly 1 sample apart.
val dt = s.sampleRate.reciprocal // 1 sample delay
val x1, x2 = Synth(s)
val SECONDS_FROM_1900_TO_1970 = 2208988800L
// execute the following three lines together
val t0 = System.currentTimeMillis * 0.001 + SECONDS_FROM_1900_TO_1970
s ! osc.Bundle.secs(t0 + 0.2 , x1.newMsg("SubsampleOffset", args = List("out" -> 0)))
s ! osc.Bundle.secs(t0 + 0.2 + dt , x2.newMsg("SubsampleOffset", args = List("out" -> 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment