Merge pull request #974 from tidalcycles/velocity-in-value

Velocity in value
This commit is contained in:
Felix Roos 2024-03-10 00:46:51 +01:00 committed by GitHub
commit 3df776d062
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 7984 additions and 7983 deletions

View File

@ -125,6 +125,16 @@ export const { note } = registerControl(['note', 'n']);
* *
*/ */
export const { accelerate } = registerControl('accelerate'); export const { accelerate } = registerControl('accelerate');
/**
*
* Sets the velocity from 0 to 1. Is multiplied together with gain.
* @name velocity
* @example
* s("hh*8")
* .gain(".4!2 1 .4!2 1 .4 1")
* .velocity(".4 1")
*/
export const { velocity } = registerControl('velocity');
/** /**
* Controls the gain by an exponential amount. * Controls the gain by an exponential amount.
* *
@ -1163,11 +1173,9 @@ export const { rate } = registerControl('rate');
export const { slide } = registerControl('slide'); export const { slide } = registerControl('slide');
// TODO: detune? https://tidalcycles.org/docs/patternlib/tutorials/synthesizers/#supersquare // TODO: detune? https://tidalcycles.org/docs/patternlib/tutorials/synthesizers/#supersquare
export const { semitone } = registerControl('semitone'); export const { semitone } = registerControl('semitone');
// TODO: dedup with synth param, see https://tidalcycles.org/docs/reference/synthesizers/#superpiano
// ['velocity'],
// TODO: synth param // TODO: synth param
export const { voice } = registerControl('voice'); export const { voice } = registerControl('voice');
// voicings // https://github.com/tidalcycles/strudel/issues/506 // voicings // https://github.com/tidalcycles/strudel/issues/506
// chord to voice, like C Eb Fm7 G7. the symbols can be defined via addVoicings // chord to voice, like C Eb Fm7 G7. the symbols can be defined via addVoicings
export const { chord } = registerControl('chord'); export const { chord } = registerControl('chord');

View File

@ -2063,7 +2063,7 @@ export const { echoWith, echowith, stutWith, stutwith } = register(
* s("bd sd").echo(3, 1/6, .8) * s("bd sd").echo(3, 1/6, .8)
*/ */
export const echo = register('echo', function (times, time, feedback, pat) { export const echo = register('echo', function (times, time, feedback, pat) {
return pat._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); return pat._echoWith(times, time, (pat, i) => pat.gain(Math.pow(feedback, i)));
}); });
/** /**
@ -2076,7 +2076,7 @@ export const echo = register('echo', function (times, time, feedback, pat) {
* s("bd sd").stut(3, .8, 1/6) * s("bd sd").stut(3, .8, 1/6)
*/ */
export const stut = register('stut', function (times, feedback, time, pat) { export const stut = register('stut', function (times, feedback, time, pat) {
return pat._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); return pat._echoWith(times, time, (pat, i) => pat.gain(Math.pow(feedback, i)));
}); });
/** /**
@ -2221,19 +2221,6 @@ export const { color, colour } = register(['color', 'colour'], function (color,
return pat.withContext((context) => ({ ...context, color })); return pat.withContext((context) => ({ ...context, color }));
}); });
/**
*
* Sets the velocity from 0 to 1. Is multiplied together with gain.
* @name velocity
* @example
* s("hh*8")
* .gain(".4!2 1 .4!2 1 .4 1")
* .velocity(".4 1")
*/
export const velocity = register('velocity', function (velocity, pat) {
return pat.withContext((context) => ({ ...context, velocity: (context.velocity || 1) * velocity }));
});
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Control-related functions, i.e. ones that manipulate patterns of // Control-related functions, i.e. ones that manipulate patterns of
// objects // objects

View File

@ -152,12 +152,14 @@ export const csoundm = register('csoundm', (instrument, pat) => {
const p2 = tidal_time - getAudioContext().currentTime; const p2 = tidal_time - getAudioContext().currentTime;
const p3 = hap.duration.valueOf() + 0; const p3 = hap.duration.valueOf() + 0;
const frequency = getFrequency(hap); const frequency = getFrequency(hap);
let { gain = 1, velocity = 0.9 } = hap.value;
velocity = gain * velocity;
// Translate frequency to MIDI key number _without_ rounding. // Translate frequency to MIDI key number _without_ rounding.
const C4 = 261.62558; const C4 = 261.62558;
let octave = Math.log(frequency / C4) / Math.log(2.0) + 8.0; let octave = Math.log(frequency / C4) / Math.log(2.0) + 8.0;
const p4 = octave * 12.0 - 36.0; const p4 = octave * 12.0 - 36.0;
// We prefer floating point precision, but over the MIDI range [0, 127]. // We prefer floating point precision, but over the MIDI range [0, 127].
const p5 = 127 * (hap.context?.velocity ?? 0.9); const p5 = 127 * velocity;
// The Strudel controls as a string. // The Strudel controls as a string.
const p6 = Object.entries({ ...hap.value, frequency }) const p6 = Object.entries({ ...hap.value, frequency })
.flat() .flat()

View File

@ -7,9 +7,9 @@ const CC_MESSAGE = 0xb0;
Pattern.prototype.midi = function (output) { Pattern.prototype.midi = function (output) {
return this.onTrigger((time, hap, currentTime, cps) => { return this.onTrigger((time, hap, currentTime, cps) => {
const { note, nrpnn, nrpv, ccn, ccv } = hap.value; let { note, nrpnn, nrpv, ccn, ccv, velocity = 0.9, gain = 1 } = hap.value;
const offset = (time - currentTime) * 1000; const offset = (time - currentTime) * 1000;
const velocity = Math.floor((hap.context?.velocity ?? 0.9) * 100); // TODO: refactor velocity velocity = Math.floor(gain * velocity * 100);
const duration = Math.floor((hap.duration.valueOf() / cps) * 1000 - 10); const duration = Math.floor((hap.duration.valueOf() / cps) * 1000 - 10);
const roundedOffset = Math.round(offset); const roundedOffset = Math.round(offset);
const midichan = (hap.value.midichan ?? 1) - 1; const midichan = (hap.value.midichan ?? 1) - 1;

View File

@ -187,7 +187,8 @@ export function pianoroll({
color = isActive ? active : inactive; color = isActive ? active : inactive;
ctx.fillStyle = fillCurrent ? color : 'transparent'; ctx.fillStyle = fillCurrent ? color : 'transparent';
ctx.strokeStyle = color; ctx.strokeStyle = color;
ctx.globalAlpha = event.context.velocity ?? event.value?.gain ?? 1; const { velocity = 1, gain = 1 } = event.value || {};
ctx.globalAlpha = velocity * gain;
const timeProgress = (event.whole.begin - (flipTime ? to : from)) / timeExtent; const timeProgress = (event.whole.begin - (flipTime ? to : from)) / timeExtent;
const timePx = scale(timeProgress, ...timeRange); const timePx = scale(timeProgress, ...timeRange);
let durationPx = scale(event.duration / timeExtent, 0, timeAxis); let durationPx = scale(event.duration / timeExtent, 0, timeAxis);

View File

@ -125,8 +125,9 @@ Pattern.prototype.midi = function (output) {
const timeOffsetString = `+${offset}`; const timeOffsetString = `+${offset}`;
// destructure value // destructure value
const { note, nrpnn, nrpv, ccn, ccv, midichan = 1, midicmd } = hap.value; let { note, nrpnn, nrpv, ccn, ccv, midichan = 1, midicmd, gain = 1, velocity = 0.9 } = hap.value;
const velocity = hap.context?.velocity ?? 0.9; // TODO: refactor velocity
velocity = gain * velocity;
// note off messages will often a few ms arrive late, try to prevent glitching by subtracting from the duration length // note off messages will often a few ms arrive late, try to prevent glitching by subtracting from the duration length
const duration = Math.floor((hap.duration.valueOf() / cps) * 1000 - 10); const duration = Math.floor((hap.duration.valueOf() / cps) * 1000 - 10);

View File

@ -347,7 +347,7 @@ export const superdough = async (value, deadline, hapDuration) => {
//music programs/audio gear usually increments inputs/outputs from 1, so imitate that behavior //music programs/audio gear usually increments inputs/outputs from 1, so imitate that behavior
channels = (Array.isArray(channels) ? channels : [channels]).map((ch) => ch - 1); channels = (Array.isArray(channels) ? channels : [channels]).map((ch) => ch - 1);
gain *= velocity; // legacy fix for velocity gain *= velocity; // velocity currently only multiplies with gain. it might do other things in the future
let toDisconnect = []; // audio nodes that will be disconnected when the source has ended let toDisconnect = []; // audio nodes that will be disconnected when the source has ended
const onended = () => { const onended = () => {
toDisconnect.forEach((n) => n?.disconnect()); toDisconnect.forEach((n) => n?.disconnect());

View File

@ -12,7 +12,7 @@ setLogger(logger);
const hap2value = (hap) => { const hap2value = (hap) => {
hap.ensureObjectValue(); hap.ensureObjectValue();
return { ...hap.value, velocity: hap.context.velocity }; return hap.value;
}; };
export const webaudioOutputTrigger = (t, hap, ct, cps) => superdough(hap2value(hap), t - ct, hap.duration / cps, cps); export const webaudioOutputTrigger = (t, hap, ct, cps) => superdough(hap2value(hap), t - ct, hap.duration / cps, cps);

View File

@ -2131,38 +2131,38 @@ exports[`runs examples > example "early" example index 0 1`] = `
exports[`runs examples > example "echo" example index 0 1`] = ` exports[`runs examples > example "echo" example index 0 1`] = `
[ [
"[ -1/3 ⇜ (0/1 → 1/6) | s:sd ]", "[ -1/3 ⇜ (0/1 → 1/6) | s:sd gain:0.8 ]",
"[ -1/6 ⇜ (0/1 → 1/3) | s:sd ]", "[ -1/6 ⇜ (0/1 → 1/3) | s:sd gain:0.6400000000000001 ]",
"[ 0/1 → 1/2 | s:bd ]", "[ 0/1 → 1/2 | s:bd gain:1 ]",
"[ 1/6 → 2/3 | s:bd ]", "[ 1/6 → 2/3 | s:bd gain:0.8 ]",
"[ 1/3 → 5/6 | s:bd ]", "[ 1/3 → 5/6 | s:bd gain:0.6400000000000001 ]",
"[ 1/2 → 1/1 | s:sd ]", "[ 1/2 → 1/1 | s:sd gain:1 ]",
"[ (2/3 → 1/1) ⇝ 7/6 | s:sd ]", "[ (2/3 → 1/1) ⇝ 7/6 | s:sd gain:0.8 ]",
"[ (5/6 → 1/1) ⇝ 4/3 | s:sd ]", "[ (5/6 → 1/1) ⇝ 4/3 | s:sd gain:0.6400000000000001 ]",
"[ 2/3 ⇜ (1/1 → 7/6) | s:sd ]", "[ 2/3 ⇜ (1/1 → 7/6) | s:sd gain:0.8 ]",
"[ 5/6 ⇜ (1/1 → 4/3) | s:sd ]", "[ 5/6 ⇜ (1/1 → 4/3) | s:sd gain:0.6400000000000001 ]",
"[ 1/1 → 3/2 | s:bd ]", "[ 1/1 → 3/2 | s:bd gain:1 ]",
"[ 7/6 → 5/3 | s:bd ]", "[ 7/6 → 5/3 | s:bd gain:0.8 ]",
"[ 4/3 → 11/6 | s:bd ]", "[ 4/3 → 11/6 | s:bd gain:0.6400000000000001 ]",
"[ 3/2 → 2/1 | s:sd ]", "[ 3/2 → 2/1 | s:sd gain:1 ]",
"[ (5/3 → 2/1) ⇝ 13/6 | s:sd ]", "[ (5/3 → 2/1) ⇝ 13/6 | s:sd gain:0.8 ]",
"[ (11/6 → 2/1) ⇝ 7/3 | s:sd ]", "[ (11/6 → 2/1) ⇝ 7/3 | s:sd gain:0.6400000000000001 ]",
"[ 5/3 ⇜ (2/1 → 13/6) | s:sd ]", "[ 5/3 ⇜ (2/1 → 13/6) | s:sd gain:0.8 ]",
"[ 11/6 ⇜ (2/1 → 7/3) | s:sd ]", "[ 11/6 ⇜ (2/1 → 7/3) | s:sd gain:0.6400000000000001 ]",
"[ 2/1 → 5/2 | s:bd ]", "[ 2/1 → 5/2 | s:bd gain:1 ]",
"[ 13/6 → 8/3 | s:bd ]", "[ 13/6 → 8/3 | s:bd gain:0.8 ]",
"[ 7/3 → 17/6 | s:bd ]", "[ 7/3 → 17/6 | s:bd gain:0.6400000000000001 ]",
"[ 5/2 → 3/1 | s:sd ]", "[ 5/2 → 3/1 | s:sd gain:1 ]",
"[ (8/3 → 3/1) ⇝ 19/6 | s:sd ]", "[ (8/3 → 3/1) ⇝ 19/6 | s:sd gain:0.8 ]",
"[ (17/6 → 3/1) ⇝ 10/3 | s:sd ]", "[ (17/6 → 3/1) ⇝ 10/3 | s:sd gain:0.6400000000000001 ]",
"[ 8/3 ⇜ (3/1 → 19/6) | s:sd ]", "[ 8/3 ⇜ (3/1 → 19/6) | s:sd gain:0.8 ]",
"[ 17/6 ⇜ (3/1 → 10/3) | s:sd ]", "[ 17/6 ⇜ (3/1 → 10/3) | s:sd gain:0.6400000000000001 ]",
"[ 3/1 → 7/2 | s:bd ]", "[ 3/1 → 7/2 | s:bd gain:1 ]",
"[ 19/6 → 11/3 | s:bd ]", "[ 19/6 → 11/3 | s:bd gain:0.8 ]",
"[ 10/3 → 23/6 | s:bd ]", "[ 10/3 → 23/6 | s:bd gain:0.6400000000000001 ]",
"[ 7/2 → 4/1 | s:sd ]", "[ 7/2 → 4/1 | s:sd gain:1 ]",
"[ (11/3 → 4/1) ⇝ 25/6 | s:sd ]", "[ (11/3 → 4/1) ⇝ 25/6 | s:sd gain:0.8 ]",
"[ (23/6 → 4/1) ⇝ 13/3 | s:sd ]", "[ (23/6 → 4/1) ⇝ 13/3 | s:sd gain:0.6400000000000001 ]",
] ]
`; `;
@ -6962,38 +6962,38 @@ exports[`runs examples > example "struct" example index 0 1`] = `
exports[`runs examples > example "stut" example index 0 1`] = ` exports[`runs examples > example "stut" example index 0 1`] = `
[ [
"[ -1/3 ⇜ (0/1 → 1/6) | s:sd ]", "[ -1/3 ⇜ (0/1 → 1/6) | s:sd gain:0.8 ]",
"[ -1/6 ⇜ (0/1 → 1/3) | s:sd ]", "[ -1/6 ⇜ (0/1 → 1/3) | s:sd gain:0.6400000000000001 ]",
"[ 0/1 → 1/2 | s:bd ]", "[ 0/1 → 1/2 | s:bd gain:1 ]",
"[ 1/6 → 2/3 | s:bd ]", "[ 1/6 → 2/3 | s:bd gain:0.8 ]",
"[ 1/3 → 5/6 | s:bd ]", "[ 1/3 → 5/6 | s:bd gain:0.6400000000000001 ]",
"[ 1/2 → 1/1 | s:sd ]", "[ 1/2 → 1/1 | s:sd gain:1 ]",
"[ (2/3 → 1/1) ⇝ 7/6 | s:sd ]", "[ (2/3 → 1/1) ⇝ 7/6 | s:sd gain:0.8 ]",
"[ (5/6 → 1/1) ⇝ 4/3 | s:sd ]", "[ (5/6 → 1/1) ⇝ 4/3 | s:sd gain:0.6400000000000001 ]",
"[ 2/3 ⇜ (1/1 → 7/6) | s:sd ]", "[ 2/3 ⇜ (1/1 → 7/6) | s:sd gain:0.8 ]",
"[ 5/6 ⇜ (1/1 → 4/3) | s:sd ]", "[ 5/6 ⇜ (1/1 → 4/3) | s:sd gain:0.6400000000000001 ]",
"[ 1/1 → 3/2 | s:bd ]", "[ 1/1 → 3/2 | s:bd gain:1 ]",
"[ 7/6 → 5/3 | s:bd ]", "[ 7/6 → 5/3 | s:bd gain:0.8 ]",
"[ 4/3 → 11/6 | s:bd ]", "[ 4/3 → 11/6 | s:bd gain:0.6400000000000001 ]",
"[ 3/2 → 2/1 | s:sd ]", "[ 3/2 → 2/1 | s:sd gain:1 ]",
"[ (5/3 → 2/1) ⇝ 13/6 | s:sd ]", "[ (5/3 → 2/1) ⇝ 13/6 | s:sd gain:0.8 ]",
"[ (11/6 → 2/1) ⇝ 7/3 | s:sd ]", "[ (11/6 → 2/1) ⇝ 7/3 | s:sd gain:0.6400000000000001 ]",
"[ 5/3 ⇜ (2/1 → 13/6) | s:sd ]", "[ 5/3 ⇜ (2/1 → 13/6) | s:sd gain:0.8 ]",
"[ 11/6 ⇜ (2/1 → 7/3) | s:sd ]", "[ 11/6 ⇜ (2/1 → 7/3) | s:sd gain:0.6400000000000001 ]",
"[ 2/1 → 5/2 | s:bd ]", "[ 2/1 → 5/2 | s:bd gain:1 ]",
"[ 13/6 → 8/3 | s:bd ]", "[ 13/6 → 8/3 | s:bd gain:0.8 ]",
"[ 7/3 → 17/6 | s:bd ]", "[ 7/3 → 17/6 | s:bd gain:0.6400000000000001 ]",
"[ 5/2 → 3/1 | s:sd ]", "[ 5/2 → 3/1 | s:sd gain:1 ]",
"[ (8/3 → 3/1) ⇝ 19/6 | s:sd ]", "[ (8/3 → 3/1) ⇝ 19/6 | s:sd gain:0.8 ]",
"[ (17/6 → 3/1) ⇝ 10/3 | s:sd ]", "[ (17/6 → 3/1) ⇝ 10/3 | s:sd gain:0.6400000000000001 ]",
"[ 8/3 ⇜ (3/1 → 19/6) | s:sd ]", "[ 8/3 ⇜ (3/1 → 19/6) | s:sd gain:0.8 ]",
"[ 17/6 ⇜ (3/1 → 10/3) | s:sd ]", "[ 17/6 ⇜ (3/1 → 10/3) | s:sd gain:0.6400000000000001 ]",
"[ 3/1 → 7/2 | s:bd ]", "[ 3/1 → 7/2 | s:bd gain:1 ]",
"[ 19/6 → 11/3 | s:bd ]", "[ 19/6 → 11/3 | s:bd gain:0.8 ]",
"[ 10/3 → 23/6 | s:bd ]", "[ 10/3 → 23/6 | s:bd gain:0.6400000000000001 ]",
"[ 7/2 → 4/1 | s:sd ]", "[ 7/2 → 4/1 | s:sd gain:1 ]",
"[ (11/3 → 4/1) ⇝ 25/6 | s:sd ]", "[ (11/3 → 4/1) ⇝ 25/6 | s:sd gain:0.8 ]",
"[ (23/6 → 4/1) ⇝ 13/3 | s:sd ]", "[ (23/6 → 4/1) ⇝ 13/3 | s:sd gain:0.6400000000000001 ]",
] ]
`; `;
@ -7222,38 +7222,38 @@ exports[`runs examples > example "unit" example index 0 1`] = `
exports[`runs examples > example "velocity" example index 0 1`] = ` exports[`runs examples > example "velocity" example index 0 1`] = `
[ [
"[ 0/1 → 1/8 | s:hh gain:0.4 ]", "[ 0/1 → 1/8 | s:hh gain:0.4 velocity:0.4 ]",
"[ 1/8 → 1/4 | s:hh gain:0.4 ]", "[ 1/8 → 1/4 | s:hh gain:0.4 velocity:0.4 ]",
"[ 1/4 → 3/8 | s:hh gain:1 ]", "[ 1/4 → 3/8 | s:hh gain:1 velocity:0.4 ]",
"[ 3/8 → 1/2 | s:hh gain:0.4 ]", "[ 3/8 → 1/2 | s:hh gain:0.4 velocity:0.4 ]",
"[ 1/2 → 5/8 | s:hh gain:0.4 ]", "[ 1/2 → 5/8 | s:hh gain:0.4 velocity:1 ]",
"[ 5/8 → 3/4 | s:hh gain:1 ]", "[ 5/8 → 3/4 | s:hh gain:1 velocity:1 ]",
"[ 3/4 → 7/8 | s:hh gain:0.4 ]", "[ 3/4 → 7/8 | s:hh gain:0.4 velocity:1 ]",
"[ 7/8 → 1/1 | s:hh gain:1 ]", "[ 7/8 → 1/1 | s:hh gain:1 velocity:1 ]",
"[ 1/1 → 9/8 | s:hh gain:0.4 ]", "[ 1/1 → 9/8 | s:hh gain:0.4 velocity:0.4 ]",
"[ 9/8 → 5/4 | s:hh gain:0.4 ]", "[ 9/8 → 5/4 | s:hh gain:0.4 velocity:0.4 ]",
"[ 5/4 → 11/8 | s:hh gain:1 ]", "[ 5/4 → 11/8 | s:hh gain:1 velocity:0.4 ]",
"[ 11/8 → 3/2 | s:hh gain:0.4 ]", "[ 11/8 → 3/2 | s:hh gain:0.4 velocity:0.4 ]",
"[ 3/2 → 13/8 | s:hh gain:0.4 ]", "[ 3/2 → 13/8 | s:hh gain:0.4 velocity:1 ]",
"[ 13/8 → 7/4 | s:hh gain:1 ]", "[ 13/8 → 7/4 | s:hh gain:1 velocity:1 ]",
"[ 7/4 → 15/8 | s:hh gain:0.4 ]", "[ 7/4 → 15/8 | s:hh gain:0.4 velocity:1 ]",
"[ 15/8 → 2/1 | s:hh gain:1 ]", "[ 15/8 → 2/1 | s:hh gain:1 velocity:1 ]",
"[ 2/1 → 17/8 | s:hh gain:0.4 ]", "[ 2/1 → 17/8 | s:hh gain:0.4 velocity:0.4 ]",
"[ 17/8 → 9/4 | s:hh gain:0.4 ]", "[ 17/8 → 9/4 | s:hh gain:0.4 velocity:0.4 ]",
"[ 9/4 → 19/8 | s:hh gain:1 ]", "[ 9/4 → 19/8 | s:hh gain:1 velocity:0.4 ]",
"[ 19/8 → 5/2 | s:hh gain:0.4 ]", "[ 19/8 → 5/2 | s:hh gain:0.4 velocity:0.4 ]",
"[ 5/2 → 21/8 | s:hh gain:0.4 ]", "[ 5/2 → 21/8 | s:hh gain:0.4 velocity:1 ]",
"[ 21/8 → 11/4 | s:hh gain:1 ]", "[ 21/8 → 11/4 | s:hh gain:1 velocity:1 ]",
"[ 11/4 → 23/8 | s:hh gain:0.4 ]", "[ 11/4 → 23/8 | s:hh gain:0.4 velocity:1 ]",
"[ 23/8 → 3/1 | s:hh gain:1 ]", "[ 23/8 → 3/1 | s:hh gain:1 velocity:1 ]",
"[ 3/1 → 25/8 | s:hh gain:0.4 ]", "[ 3/1 → 25/8 | s:hh gain:0.4 velocity:0.4 ]",
"[ 25/8 → 13/4 | s:hh gain:0.4 ]", "[ 25/8 → 13/4 | s:hh gain:0.4 velocity:0.4 ]",
"[ 13/4 → 27/8 | s:hh gain:1 ]", "[ 13/4 → 27/8 | s:hh gain:1 velocity:0.4 ]",
"[ 27/8 → 7/2 | s:hh gain:0.4 ]", "[ 27/8 → 7/2 | s:hh gain:0.4 velocity:0.4 ]",
"[ 7/2 → 29/8 | s:hh gain:0.4 ]", "[ 7/2 → 29/8 | s:hh gain:0.4 velocity:1 ]",
"[ 29/8 → 15/4 | s:hh gain:1 ]", "[ 29/8 → 15/4 | s:hh gain:1 velocity:1 ]",
"[ 15/4 → 31/8 | s:hh gain:0.4 ]", "[ 15/4 → 31/8 | s:hh gain:0.4 velocity:1 ]",
"[ 31/8 → 4/1 | s:hh gain:1 ]", "[ 31/8 → 4/1 | s:hh gain:1 velocity:1 ]",
] ]
`; `;

File diff suppressed because it is too large Load Diff

View File

@ -239,8 +239,10 @@ export const wavyKalimba = `// "Wavy kalimba"
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ // @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
// @by Felix Roos // @by Felix Roos
setcps(1)
samples({ samples({
'kalimba': { c5:'https://freesound.org/data/previews/536/536549_11935698-lq.mp3' } 'kalimba': { c5:'https://cdn.freesound.org/previews/536/536549_11935698-lq.mp3' }
}) })
const scales = "<C:major C:mixolydian F:lydian [F:minor Db:major]>" const scales = "<C:major C:mixolydian F:lydian [F:minor Db:major]>"
@ -271,19 +273,18 @@ export const festivalOfFingers = `// "Festival of fingers"
const chords = "<Cm7 Fm7 G7 F#7>"; const chords = "<Cm7 Fm7 G7 F#7>";
stack( stack(
chord(chords).dict('lefthand').voicing().struct("x(3,8,-1)") chord(chords).dict('lefthand').voicing()
.velocity(.5).off(1/7,x=>x.add(note(12)).velocity(.2)), .struct("x(3,8,-1)")
.gain(.5).off(1/7,x=>x.add(note(12)).mul(gain(.2))),
chords.rootNotes(2).struct("x(4,8,-2)").note(), chords.rootNotes(2).struct("x(4,8,-2)").note(),
chords.rootNotes(4) chords.rootNotes(4)
.scale(cat('C minor','F dorian','G dorian','F# mixolydian')) .scale(cat('C minor','F dorian','G dorian','F# mixolydian'))
.struct("x(3,8,-2)".fast(2)) .struct("x(3,8,-2)".fast(2))
.scaleTranspose("0 4 0 6".early(".125 .5")).layer(scaleTranspose("0,<2 [4,6] [5,7]>/4")) .scaleTranspose("0 4 0 6".early(".125 .5"))
.layer(scaleTranspose("0,<2 [4,6] [5,7]>/4"))
.note() .note()
).slow(2) ).slow(2)
.velocity(sine.struct("x*8").add(3/5).mul(2/5).fast(8)) .mul(gain(sine.struct("x*8").add(3/5).mul(2/5).fast(8)))
.piano()`; .piano()`;
// iter, echo, echoWith // iter, echo, echoWith
@ -302,14 +303,14 @@ stack(
"[c2 a1 bb1 ~] ~" "[c2 a1 bb1 ~] ~"
.echo(2, 1/16, 1) .echo(2, 1/16, 1)
.slow(2) .slow(2)
.layer(h)
.note().s('square') .note().s('square')
.layer(h)
.clip(.4) .clip(.4)
.cutoff(400).decay(.12).sustain(0) .cutoff(400).decay(.12).sustain(0)
, ,
"[g2,[c3 eb3]]".iter(4) "[g2,[c3 eb3]]".iter(4)
.echoWith(4, 1/8, (x,n)=>x.transpose(n*12).velocity(Math.pow(.4,n))) .echoWith(4, 1/8, (x,n)=>x.transpose(n*12).gain(Math.pow(.4,n)))
.layer(h).note() .note().layer(h)
.clip(.1) .clip(.1)
) )
.fast(2/3) .fast(2/3)
@ -349,11 +350,11 @@ stack(
.n().scale(scale), .n().scale(scale),
n("<0 4>(5,8,-1)").scale(scale).sub(note(12)) n("<0 4>(5,8,-1)").scale(scale).sub(note(12))
) )
.velocity(".6 .7".fast(4)) .gain(".6 .7".fast(4))
.add(note(4)) .add(note(4))
.piano() .piano()
.clip(2) .clip(2)
.velocity(.8) .mul(gain(.8))
.slow(2) .slow(2)
.pianoroll()`; .pianoroll()`;
@ -410,16 +411,16 @@ export const randomBells = `// "Random bells"
// @by Felix Roos // @by Felix Roos
samples({ samples({
bell: { c6: 'https://freesound.org/data/previews/411/411089_5121236-lq.mp3' }, bell: { c6: 'https://cdn.freesound.org/previews/411/411089_5121236-lq.mp3' },
bass: { d2: 'https://freesound.org/data/previews/608/608286_13074022-lq.mp3' } bass: { d2: 'https://cdn.freesound.org/previews/608/608286_13074022-lq.mp3' }
}) })
stack( stack(
// bells // bells
"0".euclidLegato(3,8) n("0").euclidLegato(3,8)
.echo(3, 1/16, .5) .echo(3, 1/16, .5)
.add(rand.range(0,12)) .add(n(rand.range(0,12)))
.scale("D:minor:pentatonic").note() .scale("D:minor:pentatonic")
.velocity(rand.range(.5,1)) .velocity(rand.range(.5,1))
.s('bell').gain(.6).delay(.2).delaytime(1/3).delayfeedback(.8), .s('bell').gain(.6).delay(.2).delaytime(1/3).delayfeedback(.8),
// bass // bass
@ -462,7 +463,7 @@ samples({
hh: '561/561241_12517458-lq.mp3', hh: '561/561241_12517458-lq.mp3',
hh2:'44/44944_236326-lq.mp3', hh2:'44/44944_236326-lq.mp3',
hh3: '44/44944_236326-lq.mp3', hh3: '44/44944_236326-lq.mp3',
}, 'https://freesound.org/data/previews/') }, 'https://cdn.freesound.org/previews/')
stack( stack(
"-7 0 -7 7".struct("x(5,8,1)").fast(2).sub(7) "-7 0 -7 7".struct("x(5,8,1)").fast(2).sub(7)
@ -473,10 +474,9 @@ stack(
.apply(filter1) .apply(filter1)
.lpa(.1).lpenv(2).ftype('24db') .lpa(.1).lpenv(2).ftype('24db')
, ,
"~@3 [<2 3>,<4 5>]" n("~@3 [<2 3>,<4 5>]")
.echo(4,1/16,.7) .echo(4,1/16,.7)
.scale(scales) .scale(scales)
.note()
.s('square').gain(.7) .s('square').gain(.7)
.attack(0.01).decay(0.1).sustain(0) .attack(0.01).decay(0.1).sustain(0)
.apply(filter1), .apply(filter1),
@ -484,12 +484,11 @@ stack(
.superimpose(sub("5")) .superimpose(sub("5"))
.fast(1).euclidLegato(3,8) .fast(1).euclidLegato(3,8)
.mask("<1 0@7>") .mask("<1 0@7>")
.fast(2) .fast(2).n()
.echo(32, 1/8, .8) .echo(32, 1/8, .8)
.scale(scales) .scale(scales)
.note()
.s("sawtooth") .s("sawtooth")
.gain(sine.range(.1,.4).slow(8)) .mul(gain(sine.range(.1,.4).slow(8)))
.attack(.001).decay(.2).sustain(0) .attack(.001).decay(.2).sustain(0)
.apply(filter2) .apply(filter2)
).stack( ).stack(
@ -498,13 +497,14 @@ stack(
"~ sn", "~ sn",
"[~ hh3]*2" "[~ hh3]*2"
).s().fast(2).gain(.7) ).s().fast(2).gain(.7)
).slow(2) ).slow(2)`;
// strudel disable-highlighting`;
export const festivalOfFingers3 = `// "Festival of fingers 3" export const festivalOfFingers3 = `// "Festival of fingers 3"
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ // @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
// @by Felix Roos // @by Felix Roos
setcps(1)
n("[-7*3],0,2,6,[8 7]") n("[-7*3],0,2,6,[8 7]")
.echoWith( .echoWith(
4, // echo 4 times 4, // echo 4 times
@ -514,7 +514,7 @@ n("[-7*3],0,2,6,[8 7]")
.gain(1/(i+1)) // reduce gain .gain(1/(i+1)) // reduce gain
.clip(1/(i+1)) .clip(1/(i+1))
) )
.velocity(perlin.range(.5,.9).slow(8)) .mul(gain(perlin.range(.5,.9).slow(8)))
.stack(n("[22 25]*3") .stack(n("[22 25]*3")
.clip(sine.range(.5,2).slow(8)) .clip(sine.range(.5,2).slow(8))
.gain(sine.range(.4,.8).slow(5)) .gain(sine.range(.4,.8).slow(5))
@ -610,15 +610,17 @@ sd: ['sd/rytm-01-classic.wav','sd/rytm-00-hard.wav'],
hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'], hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'],
}, 'github:tidalcycles/dirt-samples'); }, 'github:tidalcycles/dirt-samples');
note("<8(3,8) <7 7*2> [4 5@3] 8>".sub(1) // sub 1 -> 1-indexed setcps(1)
"<8(3,8) <7 7*2> [4 5@3] 8>".sub(1) // sub 1 -> 1-indexed
.layer( .layer(
x=>x, x=>x,
x=>x.add(7).color('steelblue') x=>x.add(7).color('steelblue')
.off(1/8,x=>x.add("2,4").off(1/8,x=>x.add(5).echo(4,.125,.5))) .off(1/8,x=>x.add("2,4").off(1/8,x=>x.add(5).echo(4,.125,.5)))
.slow(2), .slow(2),
).scale('A1 minor')) ).n().scale('A1 minor')
.s("flbass").n(0) .s("flbass").n(0)
.gain(.3) .mul(gain(.3))
.cutoff(sine.slow(7).range(200,4000)) .cutoff(sine.slow(7).range(200,4000))
.resonance(10) .resonance(10)
//.hcutoff(400) //.hcutoff(400)