mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 21:18:49 +00:00
add Pattern.tune with tunejs + example tune
This commit is contained in:
parent
a1fa306cae
commit
0792ef7288
11
repl/package-lock.json
generated
11
repl/package-lock.json
generated
@ -21,6 +21,7 @@
|
|||||||
"shift-regexp-acceptor": "^2.0.3",
|
"shift-regexp-acceptor": "^2.0.3",
|
||||||
"shift-spec": "^2018.0.2",
|
"shift-spec": "^2018.0.2",
|
||||||
"tone": "^14.7.77",
|
"tone": "^14.7.77",
|
||||||
|
"tune.js": "^1.0.1",
|
||||||
"webmidi": "^2.5.2"
|
"webmidi": "^2.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -11586,6 +11587,11 @@
|
|||||||
"node": ">=0.6.x"
|
"node": ">=0.6.x"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tune.js": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tune.js/-/tune.js-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-w0gHN/2FgY2qQJPSsz7m8td8gGB22WbhWeicPxStnlg8Mp75gHBCJkBX2/KtXcY5hJa9XPGc1DU84ZkopTpjEQ=="
|
||||||
|
},
|
||||||
"node_modules/tunnel-agent": {
|
"node_modules/tunnel-agent": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||||
@ -21042,6 +21048,11 @@
|
|||||||
"integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==",
|
"integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"tune.js": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tune.js/-/tune.js-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-w0gHN/2FgY2qQJPSsz7m8td8gGB22WbhWeicPxStnlg8Mp75gHBCJkBX2/KtXcY5hJa9XPGc1DU84ZkopTpjEQ=="
|
||||||
|
},
|
||||||
"tunnel-agent": {
|
"tunnel-agent": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
"shift-regexp-acceptor": "^2.0.3",
|
"shift-regexp-acceptor": "^2.0.3",
|
||||||
"shift-spec": "^2018.0.2",
|
"shift-spec": "^2018.0.2",
|
||||||
"tone": "^14.7.77",
|
"tone": "^14.7.77",
|
||||||
|
"tune.js": "^1.0.1",
|
||||||
"webmidi": "^2.5.2"
|
"webmidi": "^2.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import './midi';
|
|||||||
import './voicings';
|
import './voicings';
|
||||||
import './tonal.mjs';
|
import './tonal.mjs';
|
||||||
import './xen.mjs';
|
import './xen.mjs';
|
||||||
|
import './tune.mjs';
|
||||||
import shapeshifter from './shapeshifter';
|
import shapeshifter from './shapeshifter';
|
||||||
import { minify } from './parse';
|
import { minify } from './parse';
|
||||||
import * as Tone from 'tone';
|
import * as Tone from 'tone';
|
||||||
|
|||||||
16
repl/src/tune.mjs
Normal file
16
repl/src/tune.mjs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import Tune from './tunejs.js';
|
||||||
|
import { Pattern } from '../../strudel.mjs';
|
||||||
|
|
||||||
|
Pattern.prototype._tune = function (scale, tonic = 220) {
|
||||||
|
const tune = new Tune();
|
||||||
|
if (!tune.isValidScale(scale)) {
|
||||||
|
throw new Error('not a valid tune.js scale name: "' + scale + '". See http://abbernie.github.io/tune/scales.html');
|
||||||
|
}
|
||||||
|
tune.loadScale(scale);
|
||||||
|
tune.tonicize(tonic);
|
||||||
|
return this._asNumber()._withEvent((event) => {
|
||||||
|
return event.withValue(() => tune.note(event.value)).setContext({ ...event.context, type: 'frequency' });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Pattern.prototype.define('tune', (scale, pat) => pat.tune(scale), { composable: true, patternified: true });
|
||||||
233
repl/src/tunejs.js
Normal file
233
repl/src/tunejs.js
Normal file
File diff suppressed because one or more lines are too long
@ -458,3 +458,30 @@ export const barryHarris = `piano()
|
|||||||
.slow(2)
|
.slow(2)
|
||||||
.tone(p.toDestination()))
|
.tone(p.toDestination()))
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const jemblung = `() => {
|
||||||
|
const delay = new FeedbackDelay(1/8, .6).chain(vol(0.15), out());
|
||||||
|
const snare = noise({type:'white',...adsr(0,0.2,0)}).chain(lowpass(5000),vol(1.8),out());
|
||||||
|
const s = polysynth().set({...osc('sawtooth4'),...adsr(0.01,.2,.6,0.2)}).chain(vol(.23).connect(delay),out());
|
||||||
|
return stack(
|
||||||
|
stack(
|
||||||
|
"0 1 4 [3!2 5]".edit(
|
||||||
|
// chords
|
||||||
|
x=>x.add("0,3").len("0.05!3 0.02"),
|
||||||
|
// bass
|
||||||
|
x=>x.add("-8").struct("x*8").len(0.1)
|
||||||
|
),
|
||||||
|
// melody
|
||||||
|
"12 11*3 12 ~".len(0.005)
|
||||||
|
)
|
||||||
|
.add("<0 1>").mul(5/5).round().tune("jemblung2").tone(s),
|
||||||
|
//.add("<0 1>").mul(22/5).round().xen("22edo").tone(s),
|
||||||
|
//.add("<0 1>").mul(12/5).round().xen("12edo").tone(s),
|
||||||
|
// kick
|
||||||
|
"[c2 ~]*2".len(0.05).tone(membrane().chain(out())),
|
||||||
|
// snare
|
||||||
|
"[~ c1]*2".early(0.001).tone(snare),
|
||||||
|
// hihat
|
||||||
|
"c2*8".tone(noise().chain(highpass(6000),vol(0.5).connect(delay),out())),
|
||||||
|
).slow(3)
|
||||||
|
}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user