build tutorial

This commit is contained in:
Felix Roos 2022-02-19 19:50:56 +01:00
parent b497967647
commit ce78e0d88d
4 changed files with 174 additions and 9 deletions

33
docs/dist/tone.js vendored
View File

@ -1,5 +1,22 @@
import {Pattern as _Pattern} from "../_snowpack/link/strudel.js";
import {AutoFilter, Destination, Filter, Gain, isNote, Synth, PolySynth} from "../_snowpack/pkg/tone.js";
import {
AutoFilter,
Destination,
Filter,
Gain,
isNote,
Synth,
PolySynth,
MembraneSynth,
MetalSynth,
MonoSynth,
AMSynth,
DuoSynth,
FMSynth,
NoiseSynth,
PluckSynth,
Sampler
} from "../_snowpack/pkg/tone.js";
const Pattern = _Pattern;
Pattern.prototype.tone = function(instrument) {
return this.fmap((value) => {
@ -17,6 +34,17 @@ Pattern.prototype.tone = function(instrument) {
});
};
Pattern.prototype.define("tone", (type, pat) => pat.tone(type), {composable: true, patternified: false});
export const amsynth = (options) => new AMSynth(options);
export const duosynth = (options) => new DuoSynth(options);
export const fmsynth = (options) => new FMSynth(options);
export const membrane = (options) => new MembraneSynth(options);
export const metal = (options) => new MetalSynth(options);
export const monosynth = (options) => new MonoSynth(options);
export const noise = (options) => new NoiseSynth(options);
export const pluck = (options) => new PluckSynth(options);
export const polysynth = (options) => new PolySynth(options);
export const sampler = (options) => new Sampler(options);
export const synth = (options) => new Synth(options);
export const vol = (v) => new Gain(v);
export const lowpass = (v) => new Filter(v, "lowpass");
export const highpass = (v) => new Filter(v, "highpass");
@ -121,9 +149,10 @@ Pattern.prototype._gain = function(g) {
Pattern.prototype._filter = function(freq, q, type = "lowpass") {
return this.chain(filter(freq, q, type));
};
Pattern.prototype.autofilter = function(g) {
Pattern.prototype._autofilter = function(g) {
return this.chain(autofilter(g));
};
Pattern.prototype.define("synth", (type, pat) => pat.synth(type), {composable: true, patternified: true});
Pattern.prototype.define("gain", (gain2, pat) => pat.synth(gain2), {composable: true, patternified: true});
Pattern.prototype.define("filter", (cutoff, pat) => pat.filter(cutoff), {composable: true, patternified: true});
Pattern.prototype.define("autofilter", (cutoff, pat) => pat.filter(cutoff), {composable: true, patternified: true});

View File

@ -7586,10 +7586,97 @@ For sharp notes, the letter "s" is used instead of "#", because JavaScript does
}, `groove, TODO move to core from `, /*#__PURE__*/ _react1.mdx("a", {
parentName: "li",
"href": "https://github.com/tidalcycles/strudel/blob/main/repl/src/groove.ts"
}, `https://github.com/tidalcycles/strudel/blob/main/repl/src/groove.ts`))), /*#__PURE__*/ _react1.mdx("h2", null, `Tone API`), /*#__PURE__*/ _react1.mdx("p", null, `TODO, see `, /*#__PURE__*/ _react1.mdx("a", {
}, `https://github.com/tidalcycles/strudel/blob/main/repl/src/groove.ts`))), /*#__PURE__*/ _react1.mdx("h2", null, `Tone API`), /*#__PURE__*/ _react1.mdx("p", null, `To make the sounds more interesting, we can use Tone.js instruments ands effects.`), /*#__PURE__*/ _react1.mdx("p", null, /*#__PURE__*/ _react1.mdx("a", {
parentName: "p",
"href": "https://github.com/tidalcycles/strudel/blob/main/repl/src/tone.ts"
}, `https://github.com/tidalcycles/strudel/blob/main/repl/src/tone.ts`)), /*#__PURE__*/ _react1.mdx("h2", null, `Tonal API`), /*#__PURE__*/ _react1.mdx("p", null, `TODO, see`), /*#__PURE__*/ _react1.mdx("ul", null, /*#__PURE__*/ _react1.mdx("li", {
}, `Show Source on Github`)), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `stack(
"[c5 c5 bb4 c5] [~ g4 ~ g4] [c5 f5 e5 c5] ~".m
.tone(synth(adsr(0,.1,0,0)).chain(out)),
"[c2 c3]*8".m
.tone(synth({
...osc('sawtooth'),
...adsr(0,.1,0.4,0)
}).chain(lowpass(300), out))
).slow(4)`,
height: 300,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h3", null, `tone(instrument)`), /*#__PURE__*/ _react1.mdx("p", null, `To change the instrument of a pattern, you can pass any `, /*#__PURE__*/ _react1.mdx("a", {
parentName: "p",
"href": "https://tonejs.github.io/docs/14.7.77/index.html"
}, `Tone.js Source`), ` to .tone:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(new FMSynth().toDestination())`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("p", null, `While this works, it is a little bit verbose. To simplify things, all Tone Synths have a shortcut:`), /*#__PURE__*/ _react1.mdx("pre", null, /*#__PURE__*/ _react1.mdx("code", {
parentName: "pre",
"className": "language-js"
}, `const amsynth = (options) => new AMSynth(options);
const duosynth = (options) => new DuoSynth(options);
const fmsynth = (options) => new FMSynth(options);
const membrane = (options) => new MembraneSynth(options);
const metal = (options) => new MetalSynth(options);
const monosynth = (options) => new MonoSynth(options);
const noise = (options) => new NoiseSynth(options);
const pluck = (options) => new PluckSynth(options);
const polysynth = (options) => new PolySynth(options);
const sampler = (options) => new Sampler(options);
const synth = (options) => new Synth(options);
`)), /*#__PURE__*/ _react1.mdx("h3", null, `out`), /*#__PURE__*/ _react1.mdx("p", null, `Shortcut for Tone.Destination. Intended to be used with Tone's .chain:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(membrane().chain(out))`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("p", null, `This alone is not really useful, so read on..`), /*#__PURE__*/ _react1.mdx("h3", null, `vol(volume)`), /*#__PURE__*/ _react1.mdx("p", null, `Helper that returns a Gain Node with the given volume. Intended to be used with Tone's .chain:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(noise().chain(vol(0.5), out))`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h3", null, `osc(type)`), /*#__PURE__*/ _react1.mdx("p", null, `Helper to set the waveform of a synth, monosynth or polysynth:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(synth(osc('sawtooth4')).chain(out))`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("p", null, `The base types are `, /*#__PURE__*/ _react1.mdx("inlineCode", {
parentName: "p"
}, `sine`), `, `, /*#__PURE__*/ _react1.mdx("inlineCode", {
parentName: "p"
}, `square`), `, `, /*#__PURE__*/ _react1.mdx("inlineCode", {
parentName: "p"
}, `sawtooth`), `, `, /*#__PURE__*/ _react1.mdx("inlineCode", {
parentName: "p"
}, `triangle`), `. You can also append a number between 1 and 32 to reduce the harmonic partials.`), /*#__PURE__*/ _react1.mdx("h3", null, `lowpass(cutoff)`), /*#__PURE__*/ _react1.mdx("p", null, `Helper that returns a Filter Node of type lowpass with the given cutoff. Intended to be used with Tone's .chain:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(synth(osc('sawtooth')).chain(lowpass(800), out))`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h3", null, `highpass(cutoff)`), /*#__PURE__*/ _react1.mdx("p", null, `Helper that returns a Filter Node of type highpass with the given cutoff. Intended to be used with Tone's .chain:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(synth(osc('sawtooth')).chain(highpass(2000), out))`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h3", null, `adsr(attack, decay?, sustain?, release?)`), /*#__PURE__*/ _react1.mdx("p", null, `Helper to set the envelope of a Tone.js instrument. Intended to be used with Tone's .set:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.slow(4)
.tone(synth(adsr(0,.1,0,0)).chain(out))`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h3", null, `Experimental: Patternification`), /*#__PURE__*/ _react1.mdx("p", null, `While the above methods work for static sounds, there is also the option to patternify tone methods.
This is currently experimental, because the performance is not stable, and audio glitches will appear after some time.
It would be great to get this to work without glitches though, because it is fun!`), /*#__PURE__*/ _react1.mdx("h4", null, `synth(type)`), /*#__PURE__*/ _react1.mdx("p", null, `With .synth, you can create a synth with a variable wave type:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.
synth('<sawtooth8 square8>'.m).slow(4)`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h4", null, `adsr(attack, decay?, sustain?, release?)`), /*#__PURE__*/ _react1.mdx("p", null, `Chainable Envelope helper:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c5 c5 bb4 c5] [~ g4 ~ g4] [c5 f5 e5 c5] ~".m.slow(4).
synth('sawtooth16').adsr(0,.1,0,0)`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("p", null, `Due to having more than one argument, this method is not patternified.`), /*#__PURE__*/ _react1.mdx("h4", null, `filter(cuttoff)`), /*#__PURE__*/ _react1.mdx("p", null, `Patternified filter:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.
synth('sawtooth16').filter('[500 2000]*8'.m).slow(4)`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h4", null, `gain(value)`), /*#__PURE__*/ _react1.mdx("p", null, `Patternified gain:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"[c4 c4 bb3 c4] [~ g3 ~ g3] [c4 f4 e4 c4] ~".m.
synth('sawtooth16').gain('[.2 .8]*8'.m).slow(4)`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h4", null, `autofilter(value)`), /*#__PURE__*/ _react1.mdx("p", null, `Patternified autofilter:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
tune: `"c2 c3".m.
synth('sawtooth16').autofilter('<1 4 8>'.m)`,
mdxType: "MiniRepl"
}), /*#__PURE__*/ _react1.mdx("h2", null, `Tonal API`), /*#__PURE__*/ _react1.mdx("p", null, `TODO, see`), /*#__PURE__*/ _react1.mdx("ul", null, /*#__PURE__*/ _react1.mdx("li", {
parentName: "ul"
}, /*#__PURE__*/ _react1.mdx("a", {
parentName: "li",
@ -56101,6 +56188,28 @@ exports.default = thunkify;
},{"./curryN.js":"jngJ1","./internal/_curry1.js":"kHmsM","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"aBpVm":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "amsynth", ()=>amsynth
);
parcelHelpers.export(exports, "duosynth", ()=>duosynth
);
parcelHelpers.export(exports, "fmsynth", ()=>fmsynth
);
parcelHelpers.export(exports, "membrane", ()=>membrane
);
parcelHelpers.export(exports, "metal", ()=>metal
);
parcelHelpers.export(exports, "monosynth", ()=>monosynth
);
parcelHelpers.export(exports, "noise", ()=>noise
);
parcelHelpers.export(exports, "pluck", ()=>pluck
);
parcelHelpers.export(exports, "polysynth", ()=>polysynth
);
parcelHelpers.export(exports, "sampler", ()=>sampler
);
parcelHelpers.export(exports, "synth", ()=>synth
);
parcelHelpers.export(exports, "vol", ()=>vol
);
parcelHelpers.export(exports, "lowpass", ()=>lowpass
@ -56123,7 +56232,7 @@ parcelHelpers.export(exports, "gain", ()=>gain
);
var _strudelMjs = require("../../strudel.mjs");
var _tone = require("tone");
// what about
// what about
// https://www.charlie-roberts.com/gibberish/playground/
const Pattern = _strudelMjs.Pattern;
// with this function, you can play the pattern with any tone synth
@ -56150,6 +56259,28 @@ Pattern.prototype.define('tone', (type, pat)=>pat.tone(type)
composable: true,
patternified: false
});
const amsynth = (options)=>new _tone.AMSynth(options)
;
const duosynth = (options)=>new _tone.DuoSynth(options)
;
const fmsynth = (options)=>new _tone.FMSynth(options)
;
const membrane = (options)=>new _tone.MembraneSynth(options)
;
const metal = (options)=>new _tone.MetalSynth(options)
;
const monosynth = (options)=>new _tone.MonoSynth(options)
;
const noise = (options)=>new _tone.NoiseSynth(options)
;
const pluck = (options)=>new _tone.PluckSynth(options)
;
const polysynth = (options)=>new _tone.PolySynth(options)
;
const sampler = (options)=>new _tone.Sampler(options)
;
const synth = (options)=>new _tone.Synth(options)
;
const vol = (v)=>new _tone.Gain(v)
;
const lowpass = (v)=>new _tone.Filter(v, 'lowpass')
@ -56339,7 +56470,7 @@ Pattern.prototype._gain = function(g) {
Pattern.prototype._filter = function(freq, q, type = 'lowpass') {
return this.chain(filter(freq, q, type));
};
Pattern.prototype.autofilter = function(g) {
Pattern.prototype._autofilter = function(g) {
return this.chain(autofilter(g));
};
Pattern.prototype.define('synth', (type, pat)=>pat.synth(type)
@ -56357,6 +56488,11 @@ Pattern.prototype.define('filter', (cutoff, pat)=>pat.filter(cutoff)
composable: true,
patternified: true
});
Pattern.prototype.define('autofilter', (cutoff, pat)=>pat.filter(cutoff)
, {
composable: true,
patternified: true
});
},{"../../strudel.mjs":"ggZqJ","tone":"2tCfN","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"kToux":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
@ -108735,4 +108871,4 @@ exports.default = cx;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}]},["3uVTb"], "3uVTb", "parcelRequire94c2")
//# sourceMappingURL=index.a1b5cf57.js.map
//# sourceMappingURL=index.6618aa59.js.map

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,6 @@
<body>
<div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/tutorial/index.a1b5cf57.js" defer=""></script>
<script src="/tutorial/index.6618aa59.js" defer=""></script>
</body>
</html>