Updating the entire documentation
This commit is contained in:
@ -12,30 +12,30 @@ Music really comes to life when you start playing with algorithmic patterns. The
|
||||
|
||||
JavaScript is using [Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) as a data structure for lists. Topos is extending them with custom methods that allow you to enter softly into a universe of musical patterns. These methods can often be chained to compose a more complex expression: <ic>[1, 2, 3].repeatOdd(5).palindrome().beat()</ic>.
|
||||
|
||||
- <ic>div(division: number)</ic>: this method will return the next value in the list every _n_ pulses. By default, <ic>1</ic> equals to one beat but integer and floating point number values are supported as well. This method is extremely powerful and can be used for many different purposes. Check out the examples.
|
||||
- <ic>beat(division: number)</ic>: this method will return the next value in the list every _n_ pulses. By default, <ic>1</ic> equals to one beat but integer and floating point number values are supported as well. This method is extremely powerful and can be used for many different purposes. Check out the examples.
|
||||
|
||||
${makeExample(
|
||||
"Light drumming",
|
||||
`
|
||||
// Every bar, use a different rhythm
|
||||
mod([1, 0.75].div(4)) :: sound('cp').out()
|
||||
mod([0.5, 1].div(4)) :: sound('kick').out()
|
||||
mod(2)::snd('snare').shape(.5).out()
|
||||
beat([1, 0.75].beat(4)) :: sound('cp').out()
|
||||
beat([0.5, 1].beat(4)) :: sound('kick').out()
|
||||
beat(2)::snd('snare').shape(.5).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
${makeExample(
|
||||
"Using div to create arpeggios",
|
||||
"Using beat to create arpeggios",
|
||||
`
|
||||
// Arpeggio using pulse divisions
|
||||
mod([.5, .25].div(2)) :: sound('sine')
|
||||
beat([.5, .25].div(2)) :: sound('sine')
|
||||
.hcutoff(400)
|
||||
.fmi([1,2].div(8))
|
||||
.fmh([0.5,0.25,1].div(2))
|
||||
.note([50,53,57].div(.25) + [12,24].div(2))
|
||||
.sustain([0.25, 0.5].div(8))
|
||||
.fmi([1,2].beat(8))
|
||||
.fmh([0.5,0.25,1].beat(2))
|
||||
.note([50,53,57].beat(.25) + [12,24].beat(2))
|
||||
.sustain([0.25, 0.5].beat(8))
|
||||
.room(0.9).size(0.5)
|
||||
.delay(0.25).delayt([0.5,0.25].div(16))
|
||||
.delay(0.25).delayt([0.5,0.25].beat(16))
|
||||
.delayfb(0.5)
|
||||
.out()
|
||||
`,
|
||||
@ -44,48 +44,44 @@ mod([.5, .25].div(2)) :: sound('sine')
|
||||
${makeExample(
|
||||
"Cool ambiance",
|
||||
`
|
||||
mod(.5) :: snd(['kick', 'hat'].div(4)).out()
|
||||
mod([2,4].div(2)) :: snd('shaker').delay(.5).delayfb(.75).delayt(0.125).out()
|
||||
div(2)::mod(1)::snd('clap').out()
|
||||
div(4)::mod(2)::snd('pad').n(2).shape(.5).orbit(2).room(0.9).size(0.9).release(0.5).out()
|
||||
beat(.5) :: snd(['kick', 'hat'].beat(4)).out()
|
||||
beat([2,4].beat(2)) :: snd('shaker').delay(.5).delayfb(.75).delayt(0.125).out()
|
||||
flip(2)::beat(1)::snd('clap').out()
|
||||
flip(4)::beat(2)::snd('pad').n(2).shape(.5).orbit(2).room(0.9).size(0.9).release(0.5).out()
|
||||
`,
|
||||
false
|
||||
)}
|
||||
|
||||
|
||||
|
||||
- <ic>beat()</ic>: returns the index of the list corresponding to current beat (with wrapping). This allows you to return a different value for each beat.
|
||||
- <ic>pulse()</ic>: returns the index of the list corresponding to the current pulse (with wrapping). This method will return a different value for each pulse.
|
||||
- <ic>bar()</ic>: returns the index of the list corresponding to the current bar (with wrapping). This method will return a different value for each bar.
|
||||
|
||||
${makeExample(
|
||||
"A simple drumbeat in no time!",
|
||||
`
|
||||
mod(1)::sound(['kick', 'hat', 'snare', 'hat'].beat()).out()
|
||||
mod(1.5)::sound(['jvbass', 'clap'].beat()).out()
|
||||
beat(1)::sound(['kick', 'hat', 'snare', 'hat'].beat()).out()
|
||||
beat(1.5)::sound(['jvbass', 'clap'].beat()).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"Using beat, pulse and bar in the same code",
|
||||
`mod(2)::snd('snare').out()
|
||||
mod([1, 0.5].beat()) :: sound(['bass3'].bar())
|
||||
`beat(2)::snd('snare').out()
|
||||
beat([1, 0.5].beat()) :: sound(['bass3'].bar())
|
||||
.freq(100).n([12, 14].bar())
|
||||
.speed([1,2,3].pulse())
|
||||
.out()
|
||||
`
|
||||
)}
|
||||
|
||||
|
||||
- <ic>palindrome()</ic>: Concatenates a list with the same list in reverse.
|
||||
|
||||
${makeExample(
|
||||
"Palindrome filter sweep",
|
||||
`
|
||||
mod([1,.5,.25].beat()) :: snd('sine')
|
||||
.freq([100,200,300].div(0.25))
|
||||
.fmi([1,2,3].palindrome().div(0.5))
|
||||
beat([1,.5,.25].beat()) :: snd('sine')
|
||||
.freq([100,200,300].beat(0.25))
|
||||
.fmi([1,2,3].palindrome().beat(0.5))
|
||||
.fmh([4, 8].palindrome().beat())
|
||||
.cutoff([500,1000,2000,4000].palindrome().beat())
|
||||
.sustain(0.1)
|
||||
@ -94,7 +90,6 @@ mod([1,.5,.25].beat()) :: snd('sine')
|
||||
true
|
||||
)}
|
||||
|
||||
|
||||
- <ic>random(index: number)</ic>: pick a random element in the given list.
|
||||
- <ic>rand(index: number)</ic>: shorter alias for the same method.
|
||||
- <ic>pick()</ic>: pick a random element in the list.
|
||||
@ -103,8 +98,8 @@ mod([1,.5,.25].beat()) :: snd('sine')
|
||||
${makeExample(
|
||||
"Sipping some gasoline at the robot bar",
|
||||
`
|
||||
mod(1)::snd('kick').shape(0.5).out()
|
||||
mod([.5, 1].random() / 2) :: snd(
|
||||
beat(1)::snd('kick').shape(0.5).out()
|
||||
beat([.5, 1].random() / 2) :: snd(
|
||||
['amencutup', 'synth2'].random())
|
||||
.n(irand(4,10))
|
||||
.cutoff(2000)
|
||||
@ -116,9 +111,7 @@ mod([.5, 1].random() / 2) :: snd(
|
||||
|
||||
${makeExample(
|
||||
"Generate a list of random numbers",
|
||||
`
|
||||
mod(0.5) && sound('arp').freq([].gen(300,600,10).div(3)).out()
|
||||
`,
|
||||
`beat(0.5) && sound('arp').freq([].gen(300,600,10).div(3)).out()`,
|
||||
true
|
||||
)}
|
||||
|
||||
@ -128,7 +121,7 @@ ${makeExample(
|
||||
"Amen break suffering from data loss",
|
||||
`
|
||||
// Tweak the value to degrade this amen break even more!
|
||||
mod(.25)::snd('amencutup').n([1,2,3,4,5,6,7,8,9].degrade(20).loop($(1))).out()
|
||||
beat(.25)::snd('amencutup').n([1,2,3,4,5,6,7,8,9].degrade(20).loop($(1))).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
@ -141,7 +134,7 @@ ${makeExample(
|
||||
"Repeating samples a given number of times",
|
||||
`
|
||||
// Please take this repeat number down a bit!
|
||||
mod(.25)::sound('amencutup').n([1,2,3,4,5,6,7,8].repeatAll(4).beat()).out()
|
||||
beat(.25)::sound('amencutup').n([1,2,3,4,5,6,7,8].repeatAll(4).beat()).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
@ -151,7 +144,7 @@ mod(.25)::sound('amencutup').n([1,2,3,4,5,6,7,8].repeatAll(4).beat()).out()
|
||||
${makeExample(
|
||||
"Don't you know how to count up to 5?",
|
||||
`
|
||||
mod(1) :: sound('numbers').n([1,2,3,4,5].loop($(3, 10, 2))).out()
|
||||
beat(1) :: sound('numbers').n([1,2,3,4,5].loop($(3, 10, 2))).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
@ -161,7 +154,7 @@ mod(1) :: sound('numbers').n([1,2,3,4,5].loop($(3, 10, 2))).out()
|
||||
${makeExample(
|
||||
"Shuffling a list for extra randomness",
|
||||
`
|
||||
mod(1) :: sound('numbers').n([1,2,3,4,5].shuffle().loop($(1)).out()
|
||||
beat(1) :: sound('numbers').n([1,2,3,4,5].shuffle().loop($(1)).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
@ -171,7 +164,7 @@ mod(1) :: sound('numbers').n([1,2,3,4,5].shuffle().loop($(1)).out()
|
||||
${makeExample(
|
||||
"To make things more complex... here you go",
|
||||
`
|
||||
mod(.5) :: snd('sine')
|
||||
beat(.5) :: snd('sine')
|
||||
.freq([100, 150, 200, 250, ,300, 400]
|
||||
.rotate([1,2,3].bar()) // The list of frequencies is rotating
|
||||
.beat()) // while being indexed over!
|
||||
@ -187,7 +180,7 @@ ${makeExample(
|
||||
"Demonstrative filtering. Final list is [100, 200]",
|
||||
`
|
||||
// Remove unique and 100 will repeat four times!
|
||||
mod(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out()
|
||||
beat(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
@ -199,9 +192,5 @@ mod(1)::snd('sine').sustain(0.1).freq([100,100,100,100,200].unique().beat()).out
|
||||
|
||||
${makeExample("Simple addition", `[1, 2 ,3].add(2).beat()`, true)}
|
||||
|
||||
## Simple patterns
|
||||
|
||||
- <ic>divseq(div: number, ...values:any[])</ic>
|
||||
|
||||
`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user