Created
December 5, 2016 09:58
-
-
Save Sciss/45545f2b6f4fa8a62ec0bbfeb43b9a6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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