build
This commit is contained in:
parent
d5c79f697a
commit
629d36c63c
7 changed files with 184 additions and 53 deletions
|
|
@ -7531,16 +7531,19 @@ For sharp notes, the letter "s" is used instead of "#", because JavaScript does
|
|||
}), /*#__PURE__*/ _react1.mdx("h3", null, `late(cycles)`), /*#__PURE__*/ _react1.mdx("p", null, `Like early, but in the other direction:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `cat(e5, b4.late(0.5))`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `TODO: shouldn't it sound different?`), /*#__PURE__*/ _react1.mdx("h3", null, `rev()`), /*#__PURE__*/ _react1.mdx("p", null, `Will reverse the pattern:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
}), /*#__PURE__*/ _react1.mdx("h3", null, `rev()`), /*#__PURE__*/ _react1.mdx("p", null, `Will reverse the pattern:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `cat(c3,d3,e3,f3).rev()`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("h3", null, `every(n, func)`), /*#__PURE__*/ _react1.mdx("p", null, `Will apply the given function every n cycles:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `cat(e5, pure(b4).every(4, late(0.5)))`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `TODO: should be able to do b4.every => like already possible with fast slow etc..`), /*#__PURE__*/ _react1.mdx("p", null, `Note that late is called directly. This is a shortcut for:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `Note that late is called directly. This is a shortcut for:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `cat(e5, pure(b4).every(4, x => x.late(0.5)))`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `TODO: should the function really run the first cycle?`), /*#__PURE__*/ _react1.mdx("h3", null, `Functions not documented yet`), /*#__PURE__*/ _react1.mdx("ul", null, /*#__PURE__*/ _react1.mdx("li", {
|
||||
}), /*#__PURE__*/ _react1.mdx("h3", null, `add(n)`), /*#__PURE__*/ _react1.mdx("p", null, `Adds the given number to each item in the pattern:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `stack(0, 2, 4).add(slowcat(0, -2, -4, -5)).scale('C minor')`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("h3", null, `Functions not documented yet`), /*#__PURE__*/ _react1.mdx("ul", null, /*#__PURE__*/ _react1.mdx("li", {
|
||||
parentName: "ul"
|
||||
}, `add`), /*#__PURE__*/ _react1.mdx("li", {
|
||||
parentName: "ul"
|
||||
|
|
@ -7681,7 +7684,7 @@ It would be great to get this to work without glitches though, because it is fun
|
|||
}), /*#__PURE__*/ _react1.mdx("h3", null, `voicings(range?)`), /*#__PURE__*/ _react1.mdx("p", null, `Turns chord symbols into voicings, using the smoothest voice leading possible:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `stack("<C^7 A7 Dm7 G7>".voicings(), "<C3 A2 D3 G2>")`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `TODO: use voicing collection as first param + patternify.`), /*#__PURE__*/ _react1.mdx("h3", null, `rootNotes(octave = 2)`), /*#__PURE__*/ _react1.mdx("p", null, `Turns chord symbols into root notes of chords in given octave.`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
}), /*#__PURE__*/ _react1.mdx("h3", null, `rootNotes(octave = 2)`), /*#__PURE__*/ _react1.mdx("p", null, `Turns chord symbols into root notes of chords in given octave.`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
tune: `"<C^7 A7b13 Dm7 G7>".rootNotes(3)`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `Together with edit, struct and voicings, this can be used to create a basic backing track:`), /*#__PURE__*/ _react1.mdx(_miniReplDefault.default, {
|
||||
|
|
@ -7690,8 +7693,7 @@ It would be great to get this to work without glitches though, because it is fun
|
|||
x => x.rootNotes(2).tone(synth(osc('sawtooth4')).chain(out()))
|
||||
)`,
|
||||
mdxType: "MiniRepl"
|
||||
}), /*#__PURE__*/ _react1.mdx("p", null, `TODO: use range instead of octave.
|
||||
TODO: find out why composition does not work`), /*#__PURE__*/ _react1.mdx("h2", null, `MIDI API`), /*#__PURE__*/ _react1.mdx("p", null, `Strudel also supports midi via `, /*#__PURE__*/ _react1.mdx("a", {
|
||||
}), /*#__PURE__*/ _react1.mdx("h2", null, `MIDI API`), /*#__PURE__*/ _react1.mdx("p", null, `Strudel also supports midi via `, /*#__PURE__*/ _react1.mdx("a", {
|
||||
parentName: "p",
|
||||
"href": "https://npmjs.com/package/webmidi"
|
||||
}, `webmidi`), `.`), /*#__PURE__*/ _react1.mdx("h3", null, `midi(outputName?)`), /*#__PURE__*/ _react1.mdx("p", null, `Make sure to have a midi device connected or to use an IAC Driver.
|
||||
|
|
@ -7944,10 +7946,7 @@ const defaultSynth = new _tone.PolySynth().chain(new _tone.Gain(0.5), _tone.Dest
|
|||
}
|
||||
});
|
||||
// "balanced" | "interactive" | "playback";
|
||||
_tone.setContext(new _tone.Context({
|
||||
latencyHint: 'playback',
|
||||
lookAhead: 1
|
||||
}));
|
||||
// Tone.setContext(new Tone.Context({ latencyHint: 'playback', lookAhead: 1 }));
|
||||
function MiniRepl({ tune , maxHeight =500 }) {
|
||||
const [editor, setEditor] = _react.useState();
|
||||
const { code , setCode , activateCode , activeCode , setPattern , error , cycle , dirty , log , togglePlay , hash } = _useReplDefault.default({
|
||||
|
|
@ -42117,7 +42116,7 @@ class Hap {
|
|||
this.value = value;
|
||||
this.context = context;
|
||||
this.stateful = stateful;
|
||||
if (stateful) assert(typeof this.value === "function", "Stateful values must be functions");
|
||||
if (stateful) console.assert(typeof this.value === "function", "Stateful values must be functions");
|
||||
}
|
||||
withSpan(func) {
|
||||
// Returns a new event with the function f applies to the event timespan.
|
||||
|
|
@ -42135,11 +42134,12 @@ class Hap {
|
|||
}
|
||||
resolveState(state) {
|
||||
if (this.stateful && this.hasOnset()) {
|
||||
const func = this.value[newValue] = func(state);
|
||||
console.log("stateful");
|
||||
const func = this.value;
|
||||
const [newState, newValue] = func(state);
|
||||
return [
|
||||
newState,
|
||||
this.withValue(()=>newValue
|
||||
)
|
||||
new Hap(this.whole, this.part, newValue, this.context, false)
|
||||
];
|
||||
}
|
||||
return [
|
||||
|
|
@ -42631,6 +42631,16 @@ class Pattern {
|
|||
hush() {
|
||||
return silence;
|
||||
}
|
||||
// sets absolute duration of events
|
||||
_duration(value) {
|
||||
return this.withEventSpan((span)=>new TimeSpan(span.begin, span.begin.add(value))
|
||||
);
|
||||
}
|
||||
// sets event relative duration of events
|
||||
_legato(value) {
|
||||
return this.withEventSpan((span)=>new TimeSpan(span.begin, span.begin.add(span.end.sub(span.begin).mul(value)))
|
||||
);
|
||||
}
|
||||
}
|
||||
// methods of Pattern that get callable factories
|
||||
Pattern.prototype.patternified = [
|
||||
|
|
@ -42638,7 +42648,9 @@ Pattern.prototype.patternified = [
|
|||
'fast',
|
||||
'slow',
|
||||
'early',
|
||||
'late'
|
||||
'late',
|
||||
'duration',
|
||||
'legato'
|
||||
];
|
||||
// methods that create patterns, which are added to patternified Pattern methods
|
||||
Pattern.prototype.factories = {
|
||||
|
|
@ -56533,6 +56545,8 @@ parcelHelpers.export(exports, "polysynth", ()=>polysynth
|
|||
);
|
||||
parcelHelpers.export(exports, "sampler", ()=>sampler
|
||||
);
|
||||
parcelHelpers.export(exports, "players", ()=>players
|
||||
);
|
||||
parcelHelpers.export(exports, "synth", ()=>synth
|
||||
);
|
||||
parcelHelpers.export(exports, "piano", ()=>piano
|
||||
|
|
@ -56568,19 +56582,41 @@ Pattern.prototype.tone = function(instrument) {
|
|||
// instrument.toDestination();
|
||||
return this._withEvent((event1)=>{
|
||||
const onTrigger = (time, event)=>{
|
||||
if (instrument.constructor.name === 'PluckSynth') instrument.triggerAttack(event.value, time);
|
||||
else if (instrument.constructor.name === 'NoiseSynth') instrument.triggerAttackRelease(event.duration, time); // noise has no value
|
||||
else if (instrument.constructor.name === 'Piano') {
|
||||
instrument.keyDown({
|
||||
note: event.value,
|
||||
time,
|
||||
velocity: 0.5
|
||||
});
|
||||
instrument.keyUp({
|
||||
note: event.value,
|
||||
time: time + event.duration
|
||||
});
|
||||
} else instrument.triggerAttackRelease(event.value, event.duration, time);
|
||||
let note = event.value;
|
||||
switch(instrument.constructor.name){
|
||||
case 'PluckSynth':
|
||||
// note = getPlayableNoteValue(event);
|
||||
instrument.triggerAttack(note, time);
|
||||
break;
|
||||
case 'NoiseSynth':
|
||||
instrument.triggerAttackRelease(event.duration, time); // noise has no value
|
||||
break;
|
||||
case 'Piano':
|
||||
// note = getPlayableNoteValue(event);
|
||||
instrument.keyDown({
|
||||
note,
|
||||
time,
|
||||
velocity: 0.5
|
||||
});
|
||||
instrument.keyUp({
|
||||
note,
|
||||
time: time + event.duration
|
||||
});
|
||||
break;
|
||||
case 'Sampler':
|
||||
// note = getPlayableNoteValue(event);
|
||||
instrument.triggerAttackRelease(note, event.duration, time);
|
||||
break;
|
||||
case 'Players':
|
||||
if (!instrument.has(event.value)) throw new Error(`name "${event.value}" not defined for players`);
|
||||
const player = instrument.player(event.value);
|
||||
player.start(time);
|
||||
player.stop(time + event.duration);
|
||||
break;
|
||||
default:
|
||||
// note = getPlayableNoteValue(event);
|
||||
instrument.triggerAttackRelease(note, event.duration, time);
|
||||
}
|
||||
};
|
||||
return event1.setContext({
|
||||
...event1.context,
|
||||
|
|
@ -56612,8 +56648,22 @@ const pluck = (options)=>new _tone.PluckSynth(options)
|
|||
;
|
||||
const polysynth = (options)=>new _tone.PolySynth(options)
|
||||
;
|
||||
const sampler = (options)=>new _tone.Sampler(options)
|
||||
const sampler = (options, baseUrl)=>new Promise((resolve)=>{
|
||||
const s = new _tone.Sampler(options, ()=>resolve(s)
|
||||
, baseUrl);
|
||||
})
|
||||
;
|
||||
const players = (options, baseUrl = '')=>{
|
||||
options = !baseUrl ? options : Object.fromEntries(Object.entries(options).map(([key, value])=>[
|
||||
key,
|
||||
baseUrl + value
|
||||
]
|
||||
));
|
||||
return new Promise((resolve)=>{
|
||||
const s = new _tone.Players(options, ()=>resolve(s)
|
||||
);
|
||||
});
|
||||
};
|
||||
const synth = (options)=>new _tone.Synth(options)
|
||||
;
|
||||
const piano = async (options = {
|
||||
|
|
@ -64067,9 +64117,9 @@ function scaleTranspose(scale, offset, note1) {
|
|||
while(Math.abs(i - noteIndex) < Math.abs(offset)){
|
||||
i += direction;
|
||||
const index = mod(i, notes.length);
|
||||
if (direction < 0 && n === 'C') o += direction;
|
||||
if (direction < 0 && n[0] === 'C') o += direction;
|
||||
n = notes[index];
|
||||
if (direction > 0 && n === 'C') o += direction;
|
||||
if (direction > 0 && n[0] === 'C') o += direction;
|
||||
}
|
||||
return n + o;
|
||||
}
|
||||
|
|
@ -64081,7 +64131,9 @@ Pattern.prototype._transpose = function(intervalOrSemitones) {
|
|||
return event.withValue(()=>event.value + semitones
|
||||
);
|
||||
}
|
||||
return event.withValue(()=>_tonal.Note.transpose(event.value, interval)
|
||||
// TODO: move simplify to player to preserve enharmonics
|
||||
// tone.js doesn't understand multiple sharps flats e.g. F##3 has to be turned into G3
|
||||
return event.withValue(()=>_tonal.Note.simplify(_tonal.Note.transpose(event.value, interval))
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
@ -110892,4 +110944,4 @@ exports.default = cx;
|
|||
|
||||
},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}]},["3uVTb"], "3uVTb", "parcelRequire94c2")
|
||||
|
||||
//# sourceMappingURL=index.26c147ee.js.map
|
||||
//# sourceMappingURL=index.dc7f72be.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -11,6 +11,6 @@
|
|||
<body>
|
||||
<div id="root"></div>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<script src="/tutorial/index.26c147ee.js" defer=""></script>
|
||||
<script src="/tutorial/index.dc7f72be.js" defer=""></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue