add Pattern.tune with tunejs + example tune
This commit is contained in:
parent
a1fa306cae
commit
0792ef7288
6 changed files with 289 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import './midi';
|
|||
import './voicings';
|
||||
import './tonal.mjs';
|
||||
import './xen.mjs';
|
||||
import './tune.mjs';
|
||||
import shapeshifter from './shapeshifter';
|
||||
import { minify } from './parse';
|
||||
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)
|
||||
.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…
Add table
Add a link
Reference in a new issue