mirror of
https://codeberg.org/uzu/strudel
synced 2026-08-17 10:07:44 -04:00
Top level functions
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
--docsearch-modal-background: var(--background);
|
||||
--docsearch-muted-color: color-mix(in srgb, var(--foreground), #fff 30%);
|
||||
--docsearch-key-gradient: var(--foreground);
|
||||
--docsearch-key-shadow:
|
||||
inset 0 -2px 0 0 var(--gutterForeground), inset 0 0 1px 1px var(--foreground), 0 1px 2px 1px var(--gutterBackground);
|
||||
--docsearch-key-shadow: inset 0 -2px 0 0 var(--gutterForeground), inset 0 0 1px 1px var(--foreground),
|
||||
0 1px 2px 1px var(--gutterBackground);
|
||||
}
|
||||
.dark {
|
||||
--docsearch-muted-color: color-mix(in srgb, var(--foreground), #000 30%);
|
||||
|
||||
@@ -48,7 +48,7 @@ You can also use the `crackle` type to play some subtle noise crackles. You can
|
||||
|
||||
### Additive Synthesis
|
||||
|
||||
Waveforms are often composed of several [harmonics](https://en.wikipedia.org/wiki/Harmonic) above a fundamental frequency, lying at integer multiples. These overtones combine to give a sound its unique timbral quality.
|
||||
Periodic waveforms are composed of several [harmonics](https://en.wikipedia.org/wiki/Harmonic) above a fundamental frequency, lying at integer multiples. These overtones combine to give a sound its unique timbral quality.
|
||||
|
||||
For the basic waveforms, we offer you control over these harmonics with the `partials` and `phases` functions.
|
||||
|
||||
@@ -60,7 +60,7 @@ For the basic waveforms, we offer you control over these harmonics with the `par
|
||||
client:idle
|
||||
tune={`note("c2 <eb2 <g2 g1>>".fast(2))
|
||||
.sound("sawtooth")
|
||||
.partials([1, 1, 0, 1])
|
||||
.partials([1, 1, "<1 0>", "<1 0>", "<1 0>", "<1 0>", "<1 0>"])
|
||||
._scope()`}
|
||||
/>
|
||||
|
||||
@@ -74,25 +74,38 @@ For the basic waveforms, we offer you control over these harmonics with the `par
|
||||
._scope()`}
|
||||
/>
|
||||
|
||||
We may algorithmically construct lists of partials with Javascript code like:
|
||||
We may algorithmically construct lists of magnitudes with Javascript code like:
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`const numHarmonics = 22;
|
||||
note("c2 <eb2 <g2 g1>>".fast(2))
|
||||
.sound("user")
|
||||
.sound("saw")
|
||||
.partials(new Array(numHarmonics).fill(1))
|
||||
._scope()`}
|
||||
/>
|
||||
|
||||
This approach can act as a form of bandlimiting. `partials` is also compatible with pattern functions designed to produce lists, like `randL` or `binaryL`:
|
||||
which acts as a spectral filter or
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`const numHarmonics = 22;
|
||||
note("c2 <eb2 <g2 g1>>".fast(2))
|
||||
tune={`note("c2 <eb2 <g2 g1>>").fast(2)
|
||||
.sound("user")
|
||||
.partials(randL(8))
|
||||
.partials(new Array(50).fill(0)
|
||||
.map((_, idx) => ((-1) ** (idx + 1)) / (idx + 1))
|
||||
)
|
||||
._scope()`}
|
||||
/>
|
||||
|
||||
which recovers a familiar waveform.
|
||||
|
||||
`partials` is also compatible with pattern functions designed to produce lists, like `randL` or `binaryL`:
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`note("c2 <eb2 <g2 g1>>").fast(2)
|
||||
.sound("user")
|
||||
.partials(randL(10))
|
||||
._scope()`}
|
||||
/>
|
||||
|
||||
@@ -110,17 +123,16 @@ Note that the first value in the `partials` array controls the magnitude of the
|
||||
|
||||
#### Phases
|
||||
|
||||
We mentioned that our sounds can be broken into a constituent set of harmonics above a fundamental frequency. These are defined by two values: their magnitude (how loud they are) and their [phase](https://en.wikipedia.org/wiki/Phase_(waves)), which can be thought of as which point in its cycle each sine wave is initialized at when we begin adding them.
|
||||
Earlier, we mentioned that periodic waveforms can be broken into a set of harmonics above a fundamental frequency. Each harmonic has two defining properties: its magnitude (how loud it is) and its phase, which determines where in its cycle that sine wave starts when the waveform is built.
|
||||
|
||||
These phases too can be declared in Strudel and can give your sounds interesting depth.
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`const numHarmonics = 22;
|
||||
note("c2 <eb2 <g2 g1>>".fast(2))
|
||||
.sound("user")
|
||||
.partials(randL(8))
|
||||
.phases(randL(8).late(0.3))
|
||||
tune={`note("c2 <eb2 <g2 g1>>".fast(2))
|
||||
.sound("saw")
|
||||
.partials(randL(100))
|
||||
.phases(randL(100))
|
||||
._scope()`}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user