函数参考
TuttiDAW Code 认识的每个函数、方法和信号,各附一个示例。
本页尚未翻译,因此以英文显示。
Generated from TuttiDAW's pattern engine: every function, method and signal it knows, with a short description and an example that compiles. Names marked (TuttiDAW only) are extensions that strudel.cc does not have.
Functions
all(fn)
Applies one transformation to every program voice.
all(x => x.fast(2)); $: note("60 64")arrange([cycles, pat], ...)
Sections played back to back for the given cycles, looping.
arrange([4, note("c e")], [2, note("f a")])cat(a, b, ...)
One pattern per cycle, in turn.
cat(note("c e"), note("g b"))chooseCycles(a, b, ...)
Picks one pattern at random each cycle.
chooseCycles(s("bd"), s("hh"), s("sd")).fast(4)chord(symbols)
Sets chord symbols; also available as .chord(symbols) or .chord().
chord("<Bbm9 Fm9>/4").dict("ireal").voicing()hush()
Silence.
stack(s("bd").hush(), s("hh*4"))irand(n)
Random whole numbers from 0 to n-1 (continuous).
n(irand(8).segment(4)).scale("C:minor")n(pattern)
Numbers: scale degrees with .scale(), sample variants with s().
n("0 2 4").scale("C:minor")note(pattern)
Plays pitches: note names (c4, eb3) or MIDI numbers (60).
note("c3 e3 g3 b3")pure(value)
One event per cycle with the value.
note(pure(60))register(name, (args..., pat) => pattern)
Defines a new method (and a function) from your own code; the pattern comes last.
register('dub', (pat) => pat.room(0.5))
$: note("c3 e3").dub()run(n)
The numbers 0 to n-1 in one cycle.
n(run(4)).scale("C:major")s(pattern)
Picks the sound: drum names (bd sd hh) or a synth (sawtooth, piano).
s("bd sd [~ bd] sd")samples(mapOrManifest, base?)
Declares external sample references; browser consumers load audio explicitly.
samples('github:user/repo')seq(a, b, ...)
Squeezes all patterns into one cycle, one after another.
seq(s("bd"), s("sd sd"))setcpm(cpm)
Asks for a tempo in cycles per minute (one cycle = one bar).
setcpm(30)setcps(cps)
Asks for a tempo in cycles per second.
setcps(0.5)setDefaultVoicings(name)
Sets the default voicing dictionary for this program only.
setDefaultVoicings('ireal'); chord("Cm9").voicing()silence
A pattern with no events.
cat(s("bd"), silence)slider(value, min = 0, max = 1, step?)
A numeric pattern with an inline literal control.
note(slider(60, 48, 72, 1))squeeze(indices, listOrObject)
Squeezes selected cycles into selector events; also a method.
note(squeeze("0 1", ["60 64", "67 72"]))stack(a, b, ...)
Plays patterns at the same time.
stack(s("bd*4"), note("c2 g2"))timeCat([w, a], [w, b], ...)
Sequence in one cycle with relative lengths; a bare "..." pattern weighs its number of steps.
timeCat([3, s("bd")], [1, s("sd")])toggle(value) (TuttiDAW only)
A value pattern with an inline on/off control (Tutti extension, not in Strudel).
note("60 64").mask(toggle(1))Methods
.add(x)
Adds to every value; on note()/n() patterns add note(...) / n(...).
n("0 2 4".add("<0 3>")).scale("C:major").almostAlways(f)
Applies f to about 90% of the events.
s("hh*8").almostAlways(x => x.gain(0.7)).almostNever(f)
Applies f to about 10% of the events.
s("hh*8").almostNever(x => x.ply(2)).always(f)
Always applies f.
s("hh*4").always(x => x.fast(2)).anchor(note)
Aligns the voicing to a note name or MIDI pitch (default C5).
chord("C").anchor("D5").voicing().arp(indices)
Sequences chord tones inside each event, wrapping indices without octaving.
chord("C").voicing().arp("0 1 2 3").attack(value)
Envelope attack time in seconds.
note("c e").s("sawtooth").attack(0.1).bank(value)
Drum machine bank for s(), e.g. "RolandTR909".
s("bd sd").bank("RolandTR909").begin(value)
Where a sample starts, 0..1 of its length.
s("hh*4").begin("<0 0.25>").bpf(value)
Band-pass filter center in Hz ("1000:4" also sets its Q).
s("hh*8").bpf(2000).bpq(value)
Band-pass filter Q.
s("hh*8").bpf(1500).bpq(4).chop(parts)
Cuts each event and its sample into equal parts played in turn.
s("bd sd").chop(4).chorus(value)
Chorus amount, 0..1.
note("c e g").s("sawtooth").chorus(0.5).chunk(n, f)
Applies f to one of n slices of the cycle, a different slice each cycle.
note("c d e f").chunk(4, x => x.add(note(12))).clip(value)
Multiplies note length (1 = full step); a sample stops at the note end.
note("c a f e").clip(0.5).coarse(value)
Sample-rate reduction: higher is coarser.
s("bd sd").coarse(8).compressor(value)
Compressor threshold in dB ("thr:ratio:knee:attack:release").
s("bd sd").compressor("-20:20:10:.002:.02").compressorAttack(value)
Compressor attack in seconds.
s("bd sd").compressor(-20).compressorAttack(0.01).compressorKnee(value)
Compressor knee in dB.
s("bd sd").compressor(-20).compressorKnee(6).compressorRatio(value)
Compressor ratio.
s("bd sd").compressor(-20).compressorRatio(8).compressorRelease(value)
Compressor release in seconds.
s("bd sd").compressor(-20).compressorRelease(0.2).cpm(cyclesPerMinute)
Plays the pattern at this many cycles per minute, relative to the program tempo.
note("c e g").cpm(45).crush(value)
Bit crusher: lower is crunchier.
s("bd sd").crush(4).cut(value)
Cut group: a hit stops the playing samples of its group.
s("[oh hh]*4").cut(1).decay(value)
Envelope decay time in seconds.
note("c e").s("square").decay(0.2).degrade()
Drops half of the events at random.
s("hh*8").degrade().degradeBy(amount)
Drops events at random with the given probability.
s("hh*8").degradeBy(0.3).delay(value)
Delay wet amount, 0..1 ("0.5:0.25:0.7" also sets time and feedback).
s("cp").delay(0.5).delayfeedback(value)
Delay feedback, 0..1.
s("cp").delay(0.5).delayfeedback(0.6).delaytime(value)
Delay time in cycles.
s("cp").delay(0.5).delaytime(0.125).detune(value)
Unison detune of the voice (supersaw).
note("c3 e3").s("supersaw").detune(0.3).dict(name)
Selects default, ireal, lefthand or legacy voicing shapes.
chord("C7").dict("lefthand").voicing().distort(value)
Distortion amount.
note("c2*4").s("sawtooth").distort(2).div(x)
Divides every value.
n("8 4".div(2)).scale("C:major").early(cycles)
Shifts the pattern earlier by a fraction of a cycle.
s("hh*2").early(0.125).echo(times, time, feedback)
Repeats each event, quieter each time.
s("bd sd").echo(3, 1/8, 0.7).echoWith(times, time, f)
Repeats the pattern, applying f(pattern, index) to each copy.
note("c").echoWith(3, 1/8, (p, i) => p.add(i * 2)).end(value)
Where a sample stops, 0..1 of its length.
s("oh*4").end(0.3).euclid(pulses, steps)
Euclidean rhythm: pulses spread evenly over steps.
note("c3").euclid(3, 8).euclidLegato(pulses, steps)
Euclidean rhythm where each pulse lasts until the next.
note("c3").euclidLegato(3, 8).euclidLegatoRot(pulses, steps, rotation)
Rotated euclidean rhythm where each pulse lasts until the next, across the cycle boundary.
note("c3").euclidLegatoRot(3, 8, 1).euclidRot(pulses, steps, rotation)
Euclidean rhythm, rotated by some steps.
note("c3").euclidRot(3, 8, 2).every(n, f)
Applies f on the first of every n cycles.
note("c d e g").every(4, x => x.rev()).fast(factor)
Speeds the pattern up by the factor (may be a pattern).
note("c e g").fast("<1 2>").firstOf(n, f)
Applies f on cycle 0, n, 2n, ...
note("c d e g").firstOf(4, x => x.rev()).fit()
Plays each sample (its begin..end window) at the speed that fills its event.
s("bd/2").fit().fm(value)
FM modulation index.
note("c e g").fm(2).fmap(fn)
Maps each raw event value, retaining its times and source ranges.
note("60 64".fmap(x => x + 12)).fmattack(value)
FM envelope attack in seconds.
note("c e").fm(4).fmattack(0.1).fmdecay(value)
FM envelope decay in seconds.
note("c e").fm(4).fmdecay(0.2).fmh(value)
FM modulator-to-carrier ratio.
note("c e g").fm(2).fmh(1.5).fmsustain(value)
FM envelope sustain level, 0..1.
note("c e").fm(4).fmdecay(0.2).fmsustain(0.3).fx(name, params) (TuttiDAW only)
TuttiDAW extension, not in Strudel: adds an audio effect after the instrument of the voice, in call order.
note("c4 e4").fx("Reverb:Large Hall", {decayTime: "4s"}).gain(value)
Volume, 0..1 and up.
s("hh*8").gain(0.6).hpf(value)
High-pass filter cutoff in Hz.
s("hh*8").hpf(2000).hpq(value)
High-pass filter resonance.
s("hh*8").hpf(1200).hpq(4).inhabit(listOrObject)
Squeezes one selected cycle into each selector event.
note("0 1".inhabit(["60 64", "67 72"])).inside(n, f)
Applies f as if the cycle were n cycles long.
note("c d e f").inside(2, rev).inst(name, params) (TuttiDAW only)
TuttiDAW extension, not in Strudel: plays the voice on a TuttiDAW instrument ("Device" or "Device:Preset"), params in the device units.
note("c2 eb2").inst("Drift:Deep Bass", {cutoff: 600}).iter(n)
Starts each cycle one subdivision later in the pattern.
note("c d e f").iter(4).iterBack(n)
Like .iter(), going the other way.
note("c d e f").iterBack(4).jux(f)
Original panned left, f of it panned right.
s("bd sd hh").jux(rev).lastOf(n, f)
Applies f on the last of every n cycles.
note("c d e g").lastOf(4, x => x.fast(2)).late(cycles)
Shifts the pattern later by a fraction of a cycle.
s("hh*2").late(0.125).layer(f, ...)
Plays f of the pattern for each f, without the original.
note("c e").layer(x => x.add(7), x => x.add(12)).loopAt(cycles)
Slows the pattern down and plays the sample at the speed that makes it last that many cycles.
s("bd").loopAt(2).lpattack(value)
Filter envelope attack in seconds.
note("c2 e2").s("sawtooth").lpf(300).lpenv(4).lpattack(0.2).lpdecay(value)
Filter envelope decay in seconds.
note("c2 e2").s("sawtooth").lpf(300).lpenv(4).lpdecay(0.2).lpenv(value)
Low-pass filter envelope depth.
note("c2 e2").s("sawtooth").lpf(300).lpenv(4).lpf(value)
Low-pass filter cutoff in Hz ("800:4" also sets resonance).
note("c2*4").s("sawtooth").lpf(800).lpq(value)
Low-pass filter resonance.
note("c2*4").s("sawtooth").lpf(600).lpq(8).lprelease(value)
Filter envelope release in seconds.
note("c2 e2").s("sawtooth").lpf(300).lpenv(4).lprelease(0.5).lpsustain(value)
Filter envelope sustain level, 0..1.
note("c2 e2").s("sawtooth").lpf(300).lpenv(4).lpsustain(0.3).mask(pattern)
Silences the parts where the mask is 0 or ~.
note("c d e f").mask("1 0 1 1").midifx(name, params) (TuttiDAW only)
TuttiDAW extension, not in Strudel: adds a MIDI effect before the instrument of the voice; the notes stay as written.
note("[c3,e3,g3]").midifx("Arpeggiator", {style: "UpDown", rate: "1/16"}).mode(alignment[:note])
Aligns above, below, duck or root; oldabove and oldroot are legacy modes.
chord("C").mode("root:g2").voicing().mul(x)
Multiplies every value.
n("1 2 3".mul(2)).scale("C:major").never(f)
Never applies f.
s("hh*4").never(x => x.fast(2)).off(time, f)
Adds a copy shifted later by time with f applied.
note("c3 eb3 g3").off(1/8, x => x.add(7)).offset(n)
Moves by whole voicing positions; wrapping the dictionary changes octave.
chord("C*4").offset("0 1 2 3").voicing().often(f)
Applies f to about 75% of the events.
s("hh*8").often(x => x.gain(0.4)).outside(n, f)
Applies f as if n cycles were one.
note("<c d> e").outside(2, rev).palindrome()
Forwards on even cycles, backwards on odd ones.
note("c d e g").palindrome().pan(value)
Stereo position, 0 = left, 1 = right.
s("hh*4").pan("<0 1>").pattack(value)
Pitch envelope attack in seconds.
note("c3").penv(12).pattack(0.1).pdecay(value)
Pitch envelope decay in seconds.
note("c2*4").penv(24).pdecay(0.1).penv(value)
Pitch envelope amount in semitones.
note("c2*4").s("sine").penv(24).pdecay(0.1).phaser(value)
Phaser speed in Hz.
note("c e g").s("sawtooth").phaser(2).phasercenter(value)
Phaser center frequency in Hz.
note("c e g").s("sawtooth").phaser(2).phasercenter(2000).phaserdepth(value)
Phaser depth, 0..1.
note("c e g").s("sawtooth").phaser(2).phaserdepth(0.5).pick(listOrObject)
Selects a pattern, preserving its timing; list indices clamp to the ends.
note("<0 1>".pick(["60 64", "67 72"])).pickOut(listOrObject)
Keeps each selector event and plays the selected pattern value at its start.
note("<0 1>".pickOut(["60 64", "67 72"])).pickRestart(listOrObject)
Selects a pattern and restarts it at each selector onset.
note("0 1".pickRestart(["60 64", "67 72"])).ply(n)
Repeats every event n times within its own length.
s("bd ~ sd cp").ply(2).postgain(value)
Volume after the effects.
s("bd").postgain(0.8).prelease(value)
Pitch envelope release in seconds.
note("c3").penv(12).prelease(0.3).psustain(value)
Pitch envelope sustain level, 0..1.
note("c3").penv(12).pdecay(0.1).psustain(0.5).range(min, max)
Maps a 0..1 signal to min..max.
s("hh*8").lpf(sine.range(300, 3000)).range2(min, max)
Maps a -1..1 signal to min..max.
note("c*4").pan(sine2.range2(0, 1)).rangex(min, max)
Like .range() on an exponential curve (good for frequencies).
s("hh*8").lpf(saw.rangex(200, 4000)).rarely(f)
Applies f to about 25% of the events.
note("c*8").rarely(x => x.add(7)).release(value)
Envelope release time in seconds.
note("c e").s("sawtooth").release(0.5).rev()
Plays each cycle backwards.
note("c d e g").rev().room(value)
Reverb amount, 0..1 ("0.5:3" also sets size).
s("cp").room(0.5).rootNotes(octave = 2)
Plays each chord root in the requested scientific octave.
chord("C Am F G").rootNotes(2).scale(name)
Turns n degrees into notes of a scale like "C:minor" (root in octave 3).
n("0 2 4 6").scale("<C:major A:minor>").scrub(positions)
Starts the sample at each position (0..1); "position:speed" sets the speed too.
s("bd").scrub("0 0.5:2 0.25").segment(n)
Samples the pattern n times per cycle (turns signals into notes).
n(saw.range(0, 7).segment(8)).scale("C:major").set(pattern)
Merges values from another pattern while retaining this pattern rhythm.
n("0 1 2 3").set(chord("<C Am>")).voicing().shape(value)
Waveshaping drive, 0..1.
s("bd*4").shape(0.4).size(value)
Reverb room size.
s("cp").room(0.5).size(4).slice(count, indices)
Plays slice i of count equal slices of the sample for each index event (or a list of 0..1 cut points).
s("bd").slice(4, "0 2 1 3").slow(factor)
Stretches the pattern over more cycles.
note("c e g b").slow(2).someCycles(f)
Applies f to about half of the cycles.
s("bd*4").someCycles(x => x.fast(2)).someCyclesBy(p, f)
Applies f to whole cycles with probability p.
s("bd*4").someCyclesBy(0.3, x => x.fast(2)).sometimes(f)
Applies f to about half of the events.
s("hh*8").sometimes(x => x.gain(0.5)).sometimesBy(p, f)
Applies f to events with probability p.
note("c*8").sometimesBy(0.3, x => x.add(12)).speed(value)
Sample playback speed; 2 is an octave up, negative plays backwards.
s("bd*4").speed("1 2 -1 0.5").splice(count, indices)
Like slice, with each slice sped up or slowed down to fill its event.
s("bd").splice(4, "0 2 1 3").striate(parts)
Plays the pattern parts times per cycle, a further part of each sample each time.
s("bd sd").striate(4).struct(pattern)
Plays the values on the rhythm of a pattern of x / ~.
note("c,e,g").struct("x ~ x x").stut(times, feedback, time)
Like .echo() with the last two arguments swapped.
s("bd sd").stut(3, 0.7, 1/8).sub(x)
Subtracts from every value.
n("7 5 3".sub(1)).scale("C:minor").superimpose(f)
Adds f of the pattern on top of the original.
note("c e g").superimpose(x => x.add(12)).sustain(value)
Envelope sustain level, 0..1.
note("c e").s("square").sustain(0.3).swingBy(amount, slices)
Splits each cycle into slices and delays events in the second half of each slice (0 = straight, 1/3 = triplet swing).
s("hh*8").swingBy(1/3, 4).transpose(semitones)
Moves notes up or down by semitones.
note("c e g").transpose("<0 5>").undegrade()
Keeps exactly the events .degrade() drops.
s("hh*8").undegrade().undegradeBy(amount)
Keeps exactly the events .degradeBy(amount) drops.
s("hh*8").undegradeBy(0.3).unison(value)
Number of unison voices (supersaw).
note("c3 e3").s("supersaw").unison(5).unit(value)
With "c", speed counts whole samples per cycle (as loopAt and fit set it).
s("bd").speed(0.5).unit("c").velocity(value)
Note velocity, 0..1.
note("c e g").velocity("<1 0.5>").vib(value)
Vibrato rate in Hz ("5:0.5" also sets its depth).
note("a e").vib(5).vibmod(value)
Vibrato depth in semitones.
note("a e").vib(5).vibmod(0.3).voicing()
Turns chord symbols into pitched voicings, or indexes them with n.
n("0 1 2 3").chord("<C Am F G>").voicing().voicings(dictionary?)
Voicing with an optional dictionary (legacy spelling).
"C7 G7".voicings("lefthand").note().vowel(value)
Formant filter: a, e, i, o or u.
note("c2*4").s("sawtooth").vowel("<a e i o>")Signals
cosine
Sine shifted a quarter cycle: starts at 1.
note("c*8").pan(cosine)cosine2
Cosine from -1 to 1.
note("c*4").pan(cosine2.range2(0, 1))isaw
Ramp from 1 down to 0 every cycle.
s("hh*8").gain(isaw)isaw2
Falling saw from -1 to 1.
note("c*4").pan(isaw2.range2(0, 1))perlin
Smooth random values from 0 to 1.
s("hh*8").lpf(perlin.range(500, 4000))rand
Random values from 0 to 1 (seeded, repeatable).
s("hh*8").gain(rand.range(0.4, 1))rand2
Random values from -1 to 1.
note("c*4").pan(rand2.range2(0, 1))saw
Ramp from 0 up to 1 every cycle.
n(saw.range(0, 7).segment(8)).scale("C:major")saw2
Saw from -1 to 1.
note("c*4").pan(saw2.range2(0, 1))sine
Smooth wave from 0 to 1, starting at 0.5.
note("c*8").lpf(sine.range(300, 2000))sine2
Sine from -1 to 1.
note("c*4").add(sine2.range2(0, 12).segment(4))square
0 for the first half of the cycle, 1 for the second.
s("hh*8").gain(square.range(0.3, 1))square2
Square from -1 to 1.
note("c*4").pan(square2.range2(0, 1))tri
Up from 0 to 1 and back in each cycle.
note("c*8").pan(tri)tri2
Triangle from -1 to 1.
note("c*4").pan(tri2.range2(0, 1))Other names for the same thing
att: Same as .attack().bandf: Same as .bpf().bandq: Same as .bpq().bp: Same as .bpf().ctf: Same as .lpf().cutoff: Same as .lpf().dec: Same as .decay().delayfb: Same as .delayfeedback().delayt: Same as .delaytime().density: Same as .fast().dfb: Same as .delayfeedback().dist: Same as .distort().dt: Same as .delaytime().echowith: Same as .echoWith().fastcat: Same as seq().firstof: Same as .firstOf().fmatt: Same as .fmattack().fmdec: Same as .fmdecay().fmi: Same as .fm().fmsus: Same as .fmsustain().hcutoff: Same as .hpf().hp: Same as .hpf().hresonance: Same as .hpq().iterback: Same as .iterBack().lastof: Same as .lastOf().legato: Same as .clip().lp: Same as .lpf().lpa: Same as .lpattack().lpd: Same as .lpdecay().lpe: Same as .lpenv().lpr: Same as .lprelease().lps: Same as .lpsustain().patt: Same as .pattack().pdec: Same as .pdecay().ph: Same as .phaser().phasdp: Same as .phaserdepth().phc: Same as .phasercenter().phd: Same as .phaserdepth().pickSqueeze: Same as inhabit.prel: Same as .prelease().randcat: Same as chooseCycles().rel: Same as .release().resonance: Same as .lpq().roomsize: Same as .size().seg: Same as .segment().sequence: Same as seq().slowcat: Same as cat().sound: Same as s().sparsity: Same as .slow().stepcat: Same as timeCat().stutwith: Same as .echoWith().stutWith: Same as .echoWith().sus: Same as .sustain().swing: Same as .swingBy(1/3, slices).sz: Same as .size().timecat: Same as timeCat().v: Same as .vib().vel: Same as .velocity().vibrato: Same as .vib().vmod: Same as .vibmod().withValue: Same as fmap: maps raw values, not the pattern itself.
Accepted for Strudel compatibility
These names are accepted so that Strudel code runs, but they do not change
what TuttiDAW plays yet (the diagnostics say so):
_pianoroll, _punchcard, _scope, _spectrum, _spiral, accelerate, amp, analyze, bpenv, channel, color, colour, djf, dry, fanchor, fmenv, freq, ftype, hpattack, hpdecay, hpenv, hprelease, hpsustain, id, ir, iresponse, kcutoff, krush, leslie, log, loop, markcss, noise, orbit, panchor, pcurve, phasersweep, pianoroll, punchcard, scope, spectrum, spiral, spread, squiz, tag, tremolo, tremolodepth.