知识库



按索引浏览词汇表

特殊 | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | 全部

S

strudel

API Reference

This is the long list functions you can use! Remember that you don't need to remember all of those and that you can already make music with a small set of functions!

accelerate

A pattern of numbers that speed up (or slow down) samples while they play. Currently only supported by osc / superdirt.

s("sax").accelerate("<0 1 2 4 8 16>").slow(2).osc()

add

Assumes a pattern of numbers. Adds the given number to each item in the pattern.

// Here, the triad 0, 2, 4 is shifted by different amounts
"0 2 4".add("<0 3 4 0>").scale('C major').note()
// Without add, the equivalent would be:
// "<[0 2 4] [3 5 7] [4 6 8] [0 2 4]>".scale('C major').note()
// You can also use add with notes:
"c3 e3 g3".add("<0 5 7 0>").note()
// Behind the scenes, the notes are converted to midi numbers:
// "48 52 55".add("<0 5 7 0>").note()

addVoicings

Adds a new custom voicing dictionary.

addVoicings('cookie', {
  7: ['3M 7m 9M 12P 15P', '7m 10M 13M 16M 19P'],
  '^7': ['3M 6M 9M 12P 14M', '7M 10M 13M 16M 19P'],
  m7: ['8P 11P 14m 17m 19P', '5P 8P 11P 14m 17m'],
  m7b5: ['3m 5d 8P 11P 14m', '5d 8P 11P 14m 17m'],
  o7: ['3m 6M 9M 11A 15P'],
  '7alt': ['3M 7m 10m 13m 15P'],
  '7#11': ['7m 10m 13m 15P 17m'],
}, ['C3', 'C6'])
"<C^7 A7 Dm7 G7>".voicings('cookie').note()

almostAlways

Shorthand for .sometimesBy(0.9, fn)

s("hh*8").almostAlways(x=>x.speed("0.5"))

almostNever

Shorthand for .sometimesBy(0.1, fn)

s("hh*8").almostNever(x=>x.speed("0.5"))

always

Shorthand for .sometimesBy(1, fn) (always calls fn)

s("hh*8").always(x=>x.speed("0.5"))

amp

Like {@link gain}, but linear.

s("bd*8").amp(".1*2 .5 .1*2 .5 .1 .5").osc()

appBoth

When this method is called on a pattern of functions, it matches its haps with those in the given pattern of values. A new pattern is returned, with each matching value applied to the corresponding function.

In this _appBoth variant, where timespans of the function and value haps are not the same but do intersect, the resulting hap has a timespan of the intersection. This applies to both the part and the whole timespan.

appLeft

As with {@link Pattern#appBoth}, but the whole timespan is not the intersection, but the timespan from the function of patterns that this method is called on. In practice, this means that the pattern structure, including onsets, are preserved from the pattern of functions (often referred to as the left hand or inner pattern).

apply

Like layer, but with a single function:

"<c3 eb3 g3>".scale('C minor').apply(scaleTranspose("0,2,4")).note()

appRight

As with {@link Pattern#appLeft}, but whole timespans are instead taken from the pattern of values, i.e. structure is preserved from the right hand/outer pattern.

appWhole

Assumes 'this' is a pattern of functions, and given a function to resolve wholes, applies a given pattern of values to that pattern of functions.

arp

Selects indices in in stacked notes.

note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
.arp("0 [0,2] 1 [0,2]").slow(2)

arpWith

Selects indices in in stacked notes.

note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
.arpWith(haps => haps[2])

arrange

Allows to arrange multiple patterns together over multiple cycles. Takes a variable number of arrays with two elements specifying the number of cycles and the pattern to use.

arrange([4, "<c a f e>(3,8)"],[2, "<g a>(5,8)"]).note()

attack

Amplitude envelope attack time: Specifies how long it takes for the sound to reach its peak value, relative to the onset.

note("c3 e3").attack("<0 .1 .5>")

bank

Select the sound bank to use. To be used together with s. The bank name (+ "_") will be prepended to the value of s.

s("bd sd").bank('RolandTR909') // = s("RolandTR909_bd RolandTR909_sd")

begin

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. 0.25 to cut off the first quarter from each sample.

samples({ rave: 'rave/AREUREADY.wav' }, 'github:tidalcycles/Dirt-Samples/master/')
s("rave").begin("<0 .25 .5 .75>")

bpf

Sets the center frequency of the band-pass filter. When using mininotation, you can also optionally supply the 'bpq' parameter separated by ':'.

s("bd sd,hh*3").bpf("<1000 2000 4000 8000>")

bpq

Sets the band-pass q-factor (resonance).

s("bd sd").bpf(500).bpq("<0 1 2 3>")

brak

Returns a new pattern where every other cycle is played once, twice as fast, and offset in time by one quarter of a cycle. Creates a kind of breakbeat feel.

cat

Appends the given pattern(s) to the next cycle.

s("hh*2").cat(
  note("c2(3,8)")
)

cat

The given items are concatenated, where each one takes one cycle.

cat(e5, b4, [d5, c5]).note() // "<e5 b4 [d5 c5]>".note()

ceil

Assumes a numerical pattern. Returns a new pattern with all values set to their mathematical ceiling. E.g. 3.2 replaced with 4, and -4.2 replaced with -4.

"42 42.1 42.5 43".ceil().note()

channel

choose the channel the pattern is sent to in superdirt

choose

Chooses randomly from the given list of elements.

choose

Chooses from the given list of values (or patterns of values), according to the pattern that the method is called on. The pattern should be in the range 0 .. 1.

choose2

As with choose, but the pattern that this method is called on should be in the range -1 .. 1

chooseCycles

Picks one of the elements at random each cycle.

chooseCycles("bd", "hh", "sd").s().fast(4)
"bd | hh | sd".s().fast(4)

chooseInWith

As with {chooseWith}, but the structure comes from the chosen values, rather than the pattern you're using to choose with.

chooseWith

Choose from the list of values (or patterns of values) using the given pattern of numbers, which should be in the range of 0..1

chop

Cuts each sample into the given number of parts, allowing you to explore a technique known as 'granular synthesis'. It turns a pattern of samples into a pattern of parts of samples.

samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
s("rhodes")
 .chop(4)
 .rev() // reverse order of chops
 .loopAt(4) // fit sample into 4 cycles

chunk

Divides a pattern into a given number of parts, then cycles through those parts in turn, applying the given function to each part in turn (one part per cycle).

"0 1 2 3".chunk(4, x=>x.add(7)).scale('A minor').note()

chunkBack

Like chunk, but cycles through the parts in reverse order. Known as chunk' in tidalcycles

"0 1 2 3".chunkBack(4, x=>x.add(7)).scale('A minor').note()

clip

Multiplies the duration with the given number. Also cuts samples off at the end if they exceed the duration. In tidal, this would be done with legato, which has a complicated history in strudel. For now, if you're coming from tidal, just think clip = legato.

note("c a f e").s("piano").clip("<.5 1 2>")

coarse

fake-resampling for lowering the sample rate. Caution: This effect seems to only work in chromium based browsers

s("bd sd,hh*4").coarse("<1 4 8 16 32>")

compress

Compress each cycle into the given timespan, leaving a gap

cat(
  s("bd sd").compress(.25,.75),
  s("~ bd sd ~")
)

cosine

A cosine signal between 0 and 1.

stack(sine,cosine).segment(16).range(0,15).slow(2).scale('C minor').note()

cpm

Plays the pattern at the given cycles per minute.

s("<bd sd>,hh*2").cpm(90) // = 90 bpm

crush

bit crusher effect.

s("<bd sd>,hh*3").fast(2).crush("<16 8 7 6 5 4 3 2>")

csoundm

Sends notes to Csound for rendering with MIDI semantics. The hap value is translated to these Csound pfields:

p1 -- Csound instrument either as a number (1-based, can be a fraction), or as a string name. p2 -- time in beats (usually seconds) from start of performance. p3 -- duration in beats (usually seconds). p4 -- MIDI key number (as a real number, not an integer but in [0, 127]. p5 -- MIDI velocity (as a real number, not an integer but in [0, 127]. p6 -- Strudel controls, as a string.

cut

In the style of classic drum-machines, cut will stop a playing sample as soon as another samples with in same cutgroup is to be played. An example would be an open hi-hat followed by a closed one, essentially muting the open.

s("rd*4").cut(1)

decay

Amplitude envelope decay time: the time it takes after the attack time to reach the sustain level. Note that the decay is only audible if the sustain value is lower than 1.

note("c3 e3").decay("<.1 .2 .3 .4>").sustain(0)

defragmentHaps

Combines adjacent haps with the same value and whole. Only intended for use in tests.

degrade

Randomly removes 50% of events from the pattern. Shorthand for .degradeBy(0.5)

s("hh*8").degrade()
s("[hh?]*8")

degradeBy

Randomly removes events from the pattern by a given amount. 0 = 0% chance of removal 1 = 100% chance of removal

s("hh*8").degradeBy(0.2)
s("[hh?0.2]*8")

delay

Sets the level of the delay signal.

When using mininotation, you can also optionally add the 'delaytime' and 'delayfeedback' parameter, separated by ':'.

s("bd").delay("<0 .25 .5 1>")
s("bd bd").delay("0.65:0.25:0.9 0.65:0.125:0.7")

delayfeedback

Sets the level of the signal that is fed back into the delay. Caution: Values >= 1 will result in a signal that gets louder and louder! Don't do it

s("bd").delay(.25).delayfeedback("<.25 .5 .75 1>").slow(2)

delaytime

Sets the time of the delay effect.

s("bd").delay(.25).delaytime("<.125 .25 .5 1>").slow(2)

detune

Set detune of oscillators. Works only with some synths, see tidal doc

n("0 3 7").s('superzow').octave(3).detune("<0 .25 .5 1 2>").osc()

discreteOnly

Returns a new pattern, with 'continuous' haps (those without 'whole' timespans) removed from query results.

div

Divides each number by the given factor.

djf

DJ filter, below 0.5 is low pass filter, above is high pass filter.

n("0 3 7 [10,24]").s('superzow').octave(3).djf("<.5 .25 .5 .75>").osc()

drawLine

Intended for a debugging, drawLine renders the pattern as a string, where each character represents the same time span. Should only be used with single characters as values, otherwise the character slots will be messed up. Character legend:

  • "|" cycle separator
  • "-" hold previous value
  • "." silence

const line = drawLine("0 [1 2 3]", 10); // |0--123|0--123
console.log(line);
silence;

dry

Set dryness of reverb. See {@link room} and {@link size} for more information about reverb.

n("[0,3,7](3,8)").s("superpiano").room(.7).dry("<0 .5 .75 1>").osc()

early

Nudge a pattern to start earlier in time. Equivalent of Tidal's <~ operator

"bd ~".stack("hh ~".early(.1)).s()

echo

Superimpose and offset multiple times, gradually decreasing the velocity

s("bd sd").echo(3, 1/6, .8)

echoWith

Superimpose and offset multiple times, applying the given function each time.

"<0 [2 4]>"
.echoWith(4, 1/8, (p,n) => p.add(n*2))
.scale('C minor').note().clip(.2)

end

The same as .begin, but cuts off the end off each sample.

s("bd*2,oh*4").end("<.1 .2 .5 1>")

euclid

Changes the structure of the pattern to form an euclidean rhythm. Euclidian rhythms are rhythms obtained using the greatest common divisor of two numbers. They were described in 2004 by Godfried Toussaint, a canadian computer scientist. Euclidian rhythms are really useful for computer/algorithmic music because they can describe a large number of rhythms with a couple of numbers.

// The Cuban tresillo pattern.
note("c3").euclid(3,8)

euclidLegato

Similar to euclid, but each pulse is held until the next pulse, so there will be no gaps.

n("g2").decay(.1).sustain(.3).euclidLegato(3,8)

euclidRot

Like euclid, but has an additional parameter for 'rotating' the resulting sequence.

// A Samba rhythm necklace from Brazil
note("c3").euclidRot(3,16,14)

every

An alias for {@link firstOf}

note("c3 d3 e3 g3").every(4, x=>x.rev())

fast

Speed up a pattern by the given factor. Used by "*" in mini notation.

s("<bd sd> hh").fast(2) // s("[<bd sd> hh]*2")

fastGap

speeds up a pattern like fast, but rather than it playing multiple times as fast would it instead leaves a gap in the remaining space of the cycle. For example, the following will play the sound pattern "bd sn" only once but compressed into the first half of the cycle, i.e. twice as fast.

s("bd sd").fastGap(2)

filterHaps

Returns a new Pattern, which only returns haps that meet the given test.

filterValues

As with {@link Pattern#filterHaps}, but the function is applied to values inside haps.

firstCycle

Queries the pattern for the first cycle, returning Haps. Mainly of use when debugging a pattern.

firstCycleValues

Accessor for a list of values returned by querying the first cycle.

firstOf

Applies the given function every n cycles, starting from the first cycle.

note("c3 d3 e3 g3").firstOf(4, x=>x.rev())

floor

Assumes a numerical pattern. Returns a new pattern with all values set to their mathematical floor. E.g. 3.7 replaced with to 3, and -4.2 replaced with -5.

"42 42.1 42.5 43".floor().note()

fmap

see {@link Pattern#withValue}

focus

Similar to compress, but doesn't leave gaps, and the 'focus' can be bigger than a cycle

s("bd hh sd hh").focus(1/4, 3/4)

freq

Set frequency of sound.

freq("220 110 440 110").s("superzow").osc()
freq("110".mul.out(".5 1.5 .6 [2 3]")).s("superzow").osc()

fromBipolar

Assumes a numerical pattern, containing bipolar values in the range -1 .. 1 Returns a new pattern with values scaled to the unipolar range 0 .. 1

gain

Controls the gain by an exponential amount.

s("hh*8").gain(".4!2 1 .4!2 1 .4 1")

hpf

Applies the cutoff frequency of the high-pass filter.

When using mininotation, you can also optionally add the 'hpq' parameter, separated by ':'.

s("bd sd,hh*4").hpf("<4000 2000 1000 500 200 100>")
s("bd sd,hh*4").hpf("<2000 2000:25>")

hpq

Controls the high-pass q-value.

s("bd sd,hh*4").hpf(2000).hpq("<0 10 20 30>")

hurry

Both speeds up the pattern (like 'fast') and the sample playback (like 'speed').

s("bd sd:2").hurry("<1 2 4 3>").slow(1.5)

hush

Silences a pattern.

stack(
  s("bd").hush(),
  s("hh*3")
)

inside

Carries out an operation 'inside' a cycle.

"0 1 2 3 4 3 2 1".inside(4, rev).scale('C major').note()
// "0 1 2 3 4 3 2 1".slow(4).rev().fast(4).scale('C major').note()

invert

Swaps 1s and 0s in a binary pattern.

s("bd").struct("1 0 0 1 0 0 1 0".lastOf(4, invert))

irand

A continuous pattern of random integers, between 0 and n-1.

// randomly select scale notes from 0 - 7 (= C to C)
irand(8).struct("x(3,8)").scale('C minor').note()

iter

Divides a pattern into a given number of subdivisions, plays the subdivisions in order, but increments the starting subdivision each cycle. The pattern wraps to the first subdivision after the last subdivision is played.

note("0 1 2 3".scale('A minor')).iter(4)

iterBack

Like iter, but plays the subdivisions in reverse order. Known as iter' in tidalcycles

note("0 1 2 3".scale('A minor')).iterBack(4)

jux

The jux function creates strange stereo effects, by applying a function to a pattern, but only in the right-hand channel.

s("lt ht mt ht hh").jux(rev)

juxBy

Jux with adjustable stereo width. 0 = mono, 1 = full stereo.

s("lt ht mt ht hh").juxBy("<0 .5 1>/2", rev)

lastOf

Applies the given function every n cycles, starting from the last cycle.

note("c3 d3 e3 g3").lastOf(4, x=>x.rev())

late

Nudge a pattern to start later in time. Equivalent of Tidal's ~> operator

"bd ~".stack("hh ~".late(.1)).s()

layer

Layers the result of the given function(s). Like {@link Pattern.superimpose}, but without the original pattern:

"<0 2 4 6 ~ 4 ~ 2 0!3 ~!5>*4"
  .layer(x=>x.add("0,2"))
  .scale('C minor').note()

legato

a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. 0.25 to cut off the first quarter from each sample.

"c4 eb4 g4 bb4".legato("<0.125 .25 .5 .75 1 2 4>")

legato

Multiplies the hap duration with the given factor. With samples, clip might be a better function to use (more info)

note("c3 eb3 g3 c4").legato("<.25 .5 1 2>")

leslie

Emulation of a Leslie speaker: speakers rotating in a wooden amplified cabinet.

n("0,4,7").s("supersquare").leslie("<0 .4 .6 1>").osc()

linger

Selects the given fraction of the pattern and repeats that part to fill the remainder of the cycle.

s("lt ht mt cp, [hh oh]*2").linger("<1 .5 .25 .125>")

loop

Loops the sample (from begin to end) the specified number of times. Note that the tempo of the loop is not synced with the cycle tempo.

s("bd").loop("<1 2 3 4>").osc()

loopAt

Makes the sample fit the given number of cycles by changing the speed.

samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
s("rhodes").loopAt(4)

loopAtCps

Makes the sample fit the given number of cycles and cps value, by changing the speed. Please note that at some point cps will be given by a global clock and this function will be deprecated/removed.

samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
s("rhodes").loopAtCps(4,1.5).cps(1.5)

lpf

Applies the cutoff frequency of the low-pass filter.

When using mininotation, you can also optionally add the 'lpq' parameter, separated by ':'.

s("bd sd,hh*3").lpf("<4000 2000 1000 500 200 100>")
s("bd*8").lpf("1000:0 1000:10 1000:20 1000:30")

lpq

Controls the low-pass q-value.

s("bd sd,hh*4").lpf(2000).lpq("<0 10 20 30>")

lrate

Rate of modulation / rotation for leslie effect

n("0,4,7").s("supersquare").leslie(1).lrate("<1 2 4 8>").osc()

lsize

Physical size of the cabinet in meters. Be careful, it might be slightly larger than your computer. Affects the Doppler amount (pitch warble)

n("0,4,7").s("supersquare").leslie(1).lrate(2).lsize("<.1 .5 1>").osc()

mask

Returns silence when mask is 0 or "~"

note("c [eb,g] d [eb,g]").mask("<1 [0 1]>").slow(2)

mul

Multiplies each number by the given factor.

"1 1.5 [1.66, <2 2.33>]".mul(150).freq()

n

Selects the given index from the sample map. Numbers too high will wrap around. n can also be used to play midi numbers, but it is recommended to use note instead.

s("bd sd,hh*3").n("<0 1>")

never

Shorthand for .sometimesBy(0, fn) (never calls fn)

s("hh*8").never(x=>x.speed("0.5"))

note

Plays the given note name or midi number. A note name consists of

  • a letter (a-g or A-G)
  • optional accidentals (b or #)
  • optional octave number (0-9). Defaults to 3

Examples of valid note names: cbbBbf#c3A4Eb2c#5

You can also use midi numbers instead of note names, where 69 is mapped to A4 440Hz in 12EDO.

note("c a f e")
note("c4 a4 f4 e4")
note("60 69 65 64")

octave

Sets the default octave of a synth.

n("0,4,7").s('supersquare').octave("<3 4 5 6>").osc()

off

Superimposes the function result on top of the original pattern, delayed by the given time.

"c3 eb3 g3".off(1/8, x=>x.add(7)).note()

often

Shorthand for .sometimesBy(0.75, fn)

s("hh*8").often(x=>x.speed("0.5"))

onsetsOnly

Returns a new pattern, with all haps without onsets filtered out. A hap with an onset is one with a whole timespan that begins at the same time as its part timespan.

orbit

An orbit is a global parameter context for patterns. Patterns with the same orbit will share the same global effects.

stack(
  s("hh*3").delay(.5).delaytime(.25).orbit(1),
  s("~ sd").delay(.5).delaytime(.125).orbit(2)
)

osc

Sends each hap as an OSC message, which can be picked up by SuperCollider or any other OSC-enabled software. For more info, read MIDI & OSC in the docs

outside

Carries out an operation 'outside' a cycle.

"<[0 1] 2 [3 4] 5>".outside(4, rev).scale('C major').note()
// "<[0 1] 2 [3 4] 5>".fast(4).rev().slow(4).scale('C major').note()

palindrome

Applies rev to a pattern every other cycle, so that the pattern alternates between forwards and backwards.

note("c d e g").palindrome()

pan

Sets position in stereo.

s("[bd hh]*2").pan("<.5 1 .5 0>")

Pattern

Create a pattern. As an end user, you will most likely not create a Pattern directly.

perlin

Generates a continuous pattern of perlin noise, in the range 0..1.

// randomly change the cutoff
s("bd sd,hh*4").cutoff(perlin.range(500,2000))

ply

The ply function repeats each event the given number of times.

s("bd ~ sd cp").ply("<1 2 3>")

polymeter

Combines the given lists of patterns with the same pulse. This will create so called polymeters when different sized sequences are used.

polymeter(["c", "eb", "g"], ["c2", "g2"]).note()
// "{c eb g, c2 g2}".note()

polymeterSteps

Aligns one or more given sequences to the given number of steps per cycle.

polymeterSteps(2, ["c", "d", "e", "f", "g", "f", "e", "d"])
.note().stack(s("bd")) // 1 cycle = 1 bd = 2 notes
// note("{c d e f g f e d}%2").stack(s("bd"))

press

Syncopates a rhythm, by shifting each event halfway into its timespan.

stack(s("hh*4"),
      s("bd mt sd ht").every(4, press)
     ).slow(2)

pressBy

Like press, but allows you to specify the amount by which each event is shifted. pressBy(0.5) is the same as press, while pressBy(1/3) shifts each event by a third of its timespan.

stack(s("hh*4"),
      s("bd mt sd ht").pressBy("<0 0.5 0.25>")
     ).slow(2)

pure

A discrete value that repeats once per cycle.

pure('e4') // "e4"

queryArc

Query haps inside the given time span.

const pattern = sequence('a', ['b', 'c'])
const haps = pattern.queryArc(0, 1)
console.log(haps)
silence

rand

A continuous pattern of random numbers, between 0 and 1.

// randomly change the cutoff
s("bd sd,hh*4").cutoff(rand.range(500,2000))

rand2

A continuous pattern of random numbers, between -1 and 1

range

Assumes a numerical pattern, containing unipolar values in the range 0 .. 1. Returns a new pattern with values scaled to the given min/max range. Most useful in combination with continuous patterns.

s("bd sd,hh*4").cutoff(sine.range(500,2000).slow(4))

range2

Assumes a numerical pattern, containing bipolar values in the range -1 .. 1 Returns a new pattern with values scaled to the given min/max range.

s("bd sd,hh*4").cutoff(sine2.range2(500,2000).slow(4))

rangex

Assumes a numerical pattern, containing unipolar values in the range 0 .. 1 Returns a new pattern with values scaled to the given min/max range, following an exponential curve.

s("bd sd,hh*4").cutoff(sine.rangex(500,2000).slow(4))

rarely

Shorthand for .sometimesBy(0.25, fn)

s("hh*8").rarely(x=>x.speed("0.5"))

ratio

Allows dividing numbers via list notation using ":". Returns a new pattern with just numbers.

ratio("1, 5:4, 3:2").mul(110).freq().s("piano").slow(2)

register

Registers a new pattern method. The method is added to the Pattern class + the standalone function is returned from register.

release

Amplitude envelope release time: The time it takes after the offset to go from sustain level to zero.

note("c3 e3 g3 c4").release("<0 .1 .4 .6 1>/2")

removeUndefineds

Returns a new pattern, with haps containing undefined values removed from query results.

reset

Resets the pattern to the start of the cycle for each onset of the reset pattern.

s("<bd lt> sd, hh*4").reset("<x@3 x(3,8)>")

restart

Restarts the pattern for each onset of the restart pattern. While reset will only reset the current cycle, restart will start from cycle 0.

s("<bd lt> sd, hh*4").restart("<x@3 x(3,8)>")

rev

Reverse all haps in a pattern

note("c3 d3 e3 g3").rev()

ribbon

Loops the pattern inside at offset for cycles.

// Looping a portion of randomness
note(irand(8).segment(4).scale('C3 minor')).ribbon(1337, 2)

room

Sets the level of reverb.

When using mininotation, you can also optionally add the 'size' parameter, separated by ':'.

s("bd sd").room("<0 .2 .4 .6 .8 1>")
s("bd sd").room("<0.9:1 0.9:4>")

roomsize

Sets the room size of the reverb, see {@link room}.

s("bd sd").room(.8).roomsize("<0 1 2 4 8>")

rootNotes

Maps the chords of the incoming pattern to root notes in the given octave.

"<C^7 A7 Dm7 G7>".rootNotes(2).note()

round

Assumes a numerical pattern. Returns a new pattern with all values rounded to the nearest integer.

"0.5 1.5 2.5".round().scale('C major').note()

run

A discrete pattern of numbers from 0 to n-1

run(4).scale('C4 major').note()
// "0 1 2 3".scale('C4 major').note()

s

Select a sound / sample by name. When using mininotation, you can also optionally supply 'n' and 'gain' parameters separated by ':'.

s("bd hh")
s("bd:0 bd:1 bd:0:0.3 bd:1:1.4")

samples

Loads a collection of samples to use with s

samples('github:tidalcycles/Dirt-Samples/master');
s("[bd ~]*2, [~ hh]*2, ~ sd")
samples({
 bd: '808bd/BD0000.WAV',
 sd: '808sd/SD0010.WAV'
 }, 'https://raw.githubusercontent.com/tidalcycles/Dirt-Samples/master/');
s("[bd ~]*2, [~ hh]*2, ~ sd")

saw

A sawtooth signal between 0 and 1.

"c3 [eb3,g3] g2 [g3,bb3]".note().clip(saw.slow(4))
saw.range(0,8).segment(8).scale('C major').slow(4).note()

scale

Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like {@link Pattern#scaleTranspose}.

A scale consists of a root note (e.g. c4cf#bb4) followed by semicolon (':') and then a scale type.

The root note defaults to octave 3, if no octave number is given.

n("0 2 4 6 4 2").scale("C:major")
n("[0,7] 4 [2,7] 4")
.scale("C:<major minor>/2")
.s("piano")
n(rand.range(0,12).segment(8).round())
.scale("C:ritusen")
.s("folkharp")

scaleTranspose

Transposes notes inside the scale by the number of steps. Expected to be called on a Pattern which already has a {@link Pattern#scale}

"-8 [2,4,6]"
.scale('C4 bebop major')
.scaleTranspose("<0 -1 -2 -3 -4 -5 -6 -4>")
.note()

segment

Samples the pattern at a rate of n events per cycle. Useful for turning a continuous pattern into a discrete one.

note(saw.range(0,12).segment(24)).add(40)

seq

Appends the given pattern(s) to the current pattern.

s("hh*2").seq(
  note("c2(3,8)")
)

seq

Like cat, but the items are crammed into one cycle.

seq(e5, b4, [d5, c5]).note() // "e5 b4 [d5 c5]".note()

sequence

See {@link fastcat}

setContext

Returns a new pattern with the context field set to every hap set to the given value.

shape

Wave shaping distortion. CAUTION: it might get loud

s("bd sd,hh*4").shape("<0 .2 .4 .6 .8>")

showFirstCycle

More human-readable version of the {@link Pattern#firstCycleValues} accessor.

silence

Does absolutely nothing..

silence // "~"

sine

A sine signal between 0 and 1.

sine.segment(16).range(0,15).slow(2).scale('C minor').note()

slice

Chops samples into the given number of slices, triggering those slices with a given pattern of slice numbers. Instead of a number, it also accepts a list of numbers from 0 to 1 to slice at specific points.

await samples('github:tidalcycles/Dirt-Samples/master')
s("breaks165").slice(8, "0 1 <2 2*2> 3 [4 0] 5 6 7".every(3, rev)).slow(1.5)
await samples('github:tidalcycles/Dirt-Samples/master')
s("breaks125/2").fit().slice([0,.25,.5,.75], "0 1 1 <2 3>")

slow

Slow down a pattern over the given number of cycles. Like the "/" operator in mini notation.

s("<bd sd> hh").slow(2) // s("[<bd sd> hh]/2")

slowcat

Concatenation: combines a list of patterns, switching between them successively, one per cycle:

synonyms: {@link cat}

slowcat(e5, b4, [d5, c5])

slowcatPrime

Concatenation: combines a list of patterns, switching between them successively, one per cycle. Unlike slowcat, this version will skip cycles.

someCycles

Shorthand for .someCyclesBy(0.5, fn)

s("hh(3,8)").someCycles(x=>x.speed("0.5"))

someCyclesBy

Randomly applies the given function by the given probability on a cycle by cycle basis. Similar to {@link Pattern#sometimesBy}

s("hh(3,8)").someCyclesBy(.3, x=>x.speed("0.5"))

sometimes

Applies the given function with a 50% chance

s("hh*4").sometimes(x=>x.speed("0.5"))

sometimesBy

Randomly applies the given function by the given probability. Similar to {@link Pattern#someCyclesBy}

s("hh(3,8)").sometimesBy(.4, x=>x.speed("0.5"))

sortHapsByPart

Returns a new pattern, which returns haps sorted in temporal order. Mainly of use when comparing two patterns for equality, in tests.

source

Define a custom webaudio node to use as a sound source.

speed

Changes the speed of sample playback, i.e. a cheap way of changing pitch.

s("bd").speed("<1 2 4 1 -2 -4>")
speed("1 1.5*2 [2 1.1]").s("piano").clip(1)

splitQueries

Returns a new pattern, with queries split at cycle boundaries. This makes some calculations easier to express, as all haps are then constrained to happen within a cycle.

square

A square signal between 0 and 1.

square.segment(2).range(0,7).scale('C minor').note()

squiz

Made by Calum Gunn. Reminiscent of some weird mixture of filter, ring-modulator and pitch-shifter. The SuperCollider manual defines Squiz as:

"A simplistic pitch-raising algorithm. It's not meant to sound natural; its sound is reminiscent of some weird mixture of filter, ring-modulator and pitch-shifter, depending on the input. The algorithm works by cutting the signal into fragments (delimited by upwards-going zero-crossings) and squeezing those fragments in the time domain (i.e. simply playing them back faster than they came in), leaving silences inbetween. All the parameters apart from memlen can be modulated."

squiz("2 4/2 6 [8 16]").s("bd").osc()

stack

Stacks the given pattern(s) to the current pattern.

s("hh*2").stack(
  note("c2(3,8)")
)

stack

The given items are played at the same time at the same length.

stack(g3, b3, [e4, d4]).note() // "g3,b3,[e4,d4]".note()

stripContext

Returns a new pattern with the context field of every hap set to an empty object.

struct

Applies the given structure to the pattern:

note("c3,eb3,g3")
  .struct("x ~ x ~ ~ x ~ x ~ ~ ~ x ~ x ~ ~")
  .slow(4)

stut

Deprecated. Like echo, but the last 2 parameters are flipped.

s("bd sd").stut(3, .8, 1/6)

sub

Like add, but the given numbers are subtracted.

"0 2 4".sub("<0 1 2 3>").scale('C4 minor').note()
// See add for more information.

superimpose

Superimposes the result of the given function(s) on top of the original pattern:

"<0 2 4 6 ~ 4 ~ 2 0!3 ~!5>*4"
  .superimpose(x=>x.add(2))
  .scale('C minor').note()

sustain

Amplitude envelope sustain level: The level which is reached after attack / decay, being sustained until the offset.

note("c3 e3").decay(.2).sustain("<0 .1 .4 .6 1>")

timeCat

Like {@link Pattern.seq}, but each step has a length, relative to the whole.

timeCat([3,e3],[1, g3]).note() // "e3@3 g3".note()

toBipolar

Assumes a numerical pattern, containing unipolar values in the range 0 ..

  1. Returns a new pattern with values scaled to the bipolar range -1 .. 1

transpose

Change the pitch of each value by the given amount. Expects numbers or note strings as values. The amount can be given as a number of semitones or as a string in interval short notation. If you don't care about enharmonic correctness, just use numbers. Otherwise, pass the interval of the form: ST where S is the degree number and T the type of interval with

  • M = major
  • m = minor
  • P = perfect
  • A = augmented
  • d = diminished

Examples intervals:

  • 1P = unison
  • 3M = major third
  • 3m = minor third
  • 4P = perfect fourth
  • 4A = augmented fourth
  • 5P = perfect fifth
  • 5d = diminished fifth

"c2 c3".fast(2).transpose("<0 -2 5 3>".slow(2)).note()
"c2 c3".fast(2).transpose("<1P -2M 4P 3m>".slow(2)).note()

tri

A triangle signal between 0 and 1.

tri.segment(8).range(0,7).scale('C minor').note()

undegradeBy

Inverse of {@link Pattern#degradeBy}: Randomly removes events from the pattern by a given amount. 0 = 100% chance of removal 1 = 0% chance of removal Events that would be removed by degradeBy are let through by undegradeBy and vice versa (see second example).

s("hh*8").undegradeBy(0.2)

unit

Used in conjunction with {@link speed}, accepts values of "r" (rate, default behavior), "c" (cycles), or "s" (seconds). Using unit "c" means speed will be interpreted in units of cycles, e.g. speed "1" means samples will be stretched to fill a cycle. Using unit "s" means the playback speed will be adjusted so that the duration is the number of seconds specified by speed.

speed("1 2 .5 3").s("bd").unit("c").osc()

velocity

Sets the velocity from 0 to 1. Is multiplied together with gain.

s("hh*8")
.gain(".4!2 1 .4!2 1 .4 1")
.velocity(".4 1")

voicing

Turns chord symbols into voicings. You can use the following control params:

  • chord: Note, followed by chord symbol, e.g. C Am G7 Bb^7
  • dict: voicing dictionary to use, falls back to default dictionary
  • anchor: the note that is used to align the chord
  • mode: how the voicing is aligned to the anchor
    • below: top note <= anchor
    • duck: top note <= anchor, anchor excluded
    • above: bottom note >= anchor
  • offset: whole number that shifts the voicing up or down to the next voicing
  • n: if set, the voicing is played like a scale. Overshooting numbers will be octaved

All of the above controls are optional, except chord. If you pass a pattern of strings to voicing, they will be interpreted as chords.

voicing("<C Am F G>")
n("0 1 2 3 4 5 6 7").chord("<C Am F G>").voicing()

voicings

DEPRECATED: still works, but it is recommended you use .voicing instead (without s). Turns chord symbols into voicings, using the smoothest voice leading possible. Uses chord-voicings package.

stack("<C^7 A7 Dm7 G7>".voicings('lefthand'), "<C3 A2 D3 G2>").note()

vowel

Formant filter to make things sound like vowels.

note("c2 <eb2 <g2 g1>>").s('sawtooth')
.vowel("<a e i <o u>>")

when

Applies the given function whenever the given pattern is in a true state.

"c3 eb3 g3".when("<0 1>/2", x=>x.sub(5)).note()

withContext

Returns a new pattern with the given function applied to the context field of every hap.

withHap

As with {@link Pattern#withHaps}, but applies the function to every hap, rather than every list of haps.

withHaps

Returns a new pattern with the given function applied to the list of haps returned by every query.

withHapSpan

Similar to {@link Pattern#withQuerySpan}, but the function is applied to the timespans of all haps returned by pattern queries (both part timespans, and where present, whole timespans).

withHapTime

As with {@link Pattern#withHapSpan}, but the function is applied to both the begin and end time of the hap timespans.

withLoc

Returns a new pattern with the given location information added to the context of every hap.

withQuerySpan

Returns a new pattern, where the given function is applied to the query timespan before passing it to the original pattern.

withQueryTime

As with {@link Pattern#withQuerySpan}, but the function is applied to both the begin and end time of the query timespan.

withValue

Returns a new pattern, with the function applied to the value of each hap. It has the alias {@link Pattern#fmap}.

"0 1 2".withValue(v => v + 10).log()

zoom

Plays a portion of a pattern, specified by the beginning and end of a time span. The new resulting pattern is played over the time period of the original pattern:

s("bd*2 hh*3 [sd bd]*2 perc").zoom(0.25, 0.75)
// s("hh*3 [sd bd]*2") // equivalent


Superformula

超级方程式
📖算法说明
▶️曲线绘制过程演示



超级公式是超椭圆的推广,由 Johan Gielis 在 2000 年左右提出。 Gielis 认为该公式可以用来描述自然界中存在的许多复杂形状和曲线。Gielis 已提交与超级公式生成的模式合成相关的专利申请,该专利于 2020 年 5 月 10 日到期。

极坐标中,有r半径和\varphi角度,超级公式为:

r\left(\varphi\right) = \left( \left| \frac{\cos\left(\frac{m\varphi}{4}\right)}{a} \right| ^{n_2} + \左| \frac{\sin\left(\frac{m\varphi}{4}\right)}{b} \right| ^{n_3} \right) ^{-\frac{1}{n_{1} }}。

通过为参数选择不同的值{\displaystyle a,b,m,n_{1},n_{2},}{\displaystyle n_{3},}可以生成不同的形状。

该公式是对超椭圆进行推广得到的,由丹麦数学家皮特·海因命名并推广。

在以下示例中,每个图上方显示的值应为m123

SF2D.png


通过超级公式的球积,可以将公式扩展到 3、4 或n维。例如,通过将两个超级公式r 12相乘获得3D参数化表面。坐标由以下关系定义:

x=r_{1}(\theta )\cos \theta \cdot r_{2}(\phi )\cos \phi ,
y=r_{1}(\theta )\sin \theta \cdot r_{2}(\phi )\cos \phi ,
z=r_{2}(\phi )\sin \phi ,

\phi纬度)在 − π /2 和π /2 之间变化,θ经度)在 − ππ之间变化。

3D超级公式:a = b = 1;m123显示在图片中。

  • SF3D 3257.SVGSF3D 3.5.5.5.svgSF3D 3301515.svgSF3D 7284.SVGSF3D 5111.SVGSF3D 4.5.54.svgSF3D 8.5.58.svgSF3D 4121515.svg

可以通过在超级公式的两项中允许不同的m个参数来概括超级公式。通过替换第一个参数{\displaystyle m}米带有y和第二个参数{\displaystyle m}米z : 

{\displaystyle r\left(\varphi \right)=\left(\left|{\frac {\cos \left({\frac {y\varphi }{4}}\right)}{a}}\right |^{n_{2}}+\left|{\frac {\sin \left({\frac {z\varphi }{4}}\right)}{b}}\right|^{n_{3} }\right)^{-{\frac {1}{n_{1}}}}}

这允许创建旋转不对称和嵌套结构。在下面的例子中 a, b、{\displaystyle {n_{2}}}{\displaystyle {n_{3}}}是 1:

超级公式U-several-structures.svg