mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 02:58:32 +00:00
Merge pull request #142 from tidalcycles/pianoroll-object-support
Pianoroll Object Support
This commit is contained in:
commit
85f03fb1d0
@ -36,8 +36,7 @@ Pattern.prototype.draw = function (callback, { from, to, onQuery }) {
|
|||||||
const begin = currentCycle + from;
|
const begin = currentCycle + from;
|
||||||
const end = currentCycle + to;
|
const end = currentCycle + to;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
events = this._asNumber(true) // true = silent error
|
events = this.query(new State(new TimeSpan(begin, end)))
|
||||||
.query(new State(new TimeSpan(begin, end)))
|
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.filter((event) => event.part.begin.equals(event.whole.begin));
|
.filter((event) => event.part.begin.equals(event.whole.begin));
|
||||||
onQuery?.(events);
|
onQuery?.(events);
|
||||||
|
|||||||
@ -7,6 +7,13 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
import { Pattern } from '@strudel.cycles/core';
|
import { Pattern } from '@strudel.cycles/core';
|
||||||
|
|
||||||
const scale = (normalized, min, max) => normalized * (max - min) + min;
|
const scale = (normalized, min, max) => normalized * (max - min) + min;
|
||||||
|
const getValue = (e) => {
|
||||||
|
let value = typeof e.value === 'object' ? e.value.n : e.value;
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
value = toMidi(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
Pattern.prototype.pianoroll = function ({
|
Pattern.prototype.pianoroll = function ({
|
||||||
cycles = 4,
|
cycles = 4,
|
||||||
@ -75,9 +82,9 @@ Pattern.prototype.pianoroll = function ({
|
|||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
const timePx = scale((event.whole.begin - (flipTime ? to : from)) / timeExtent, ...timeRange);
|
const timePx = scale((event.whole.begin - (flipTime ? to : from)) / timeExtent, ...timeRange);
|
||||||
let durationPx = scale(event.duration / timeExtent, 0, timeAxis);
|
let durationPx = scale(event.duration / timeExtent, 0, timeAxis);
|
||||||
|
const value = getValue(event);
|
||||||
const valuePx = scale(
|
const valuePx = scale(
|
||||||
fold ? foldValues.indexOf(event.value) / foldValues.length : (Number(event.value) - minMidi) / valueExtent,
|
fold ? foldValues.indexOf(value) / foldValues.length : (Number(value) - minMidi) / valueExtent,
|
||||||
...valueRange,
|
...valueRange,
|
||||||
);
|
);
|
||||||
let margin = 0;
|
let margin = 0;
|
||||||
@ -105,7 +112,6 @@ Pattern.prototype.pianoroll = function ({
|
|||||||
from: from - overscan,
|
from: from - overscan,
|
||||||
to: to + overscan,
|
to: to + overscan,
|
||||||
onQuery: (events) => {
|
onQuery: (events) => {
|
||||||
const getValue = (e) => Number(e.value);
|
|
||||||
const { min, max, values } = events.reduce(
|
const { min, max, values } = events.reduce(
|
||||||
({ min, max, values }, e) => {
|
({ min, max, values }, e) => {
|
||||||
const v = getValue(e);
|
const v = getValue(e);
|
||||||
|
|||||||
@ -967,3 +967,30 @@ export const swimmingWithSoundfonts = `stack(
|
|||||||
).s('Acoustic Bass: Bass')
|
).s('Acoustic Bass: Bass')
|
||||||
).slow(51)
|
).slow(51)
|
||||||
.out()`;
|
.out()`;
|
||||||
|
|
||||||
|
export const outroMusic = `samples({
|
||||||
|
bd: ['bd/BT0AADA.wav','bd/BT0AAD0.wav','bd/BT0A0DA.wav','bd/BT0A0D3.wav','bd/BT0A0D0.wav','bd/BT0A0A7.wav'],
|
||||||
|
sd: ['sd/rytm-01-classic.wav','sd/rytm-00-hard.wav'],
|
||||||
|
hh: ['hh27/000_hh27closedhh.wav','hh/000_hh3closedhh.wav'],
|
||||||
|
perc: ['perc/002_perc2.wav'],
|
||||||
|
}, 'github:tidalcycles/Dirt-Samples/master/');
|
||||||
|
|
||||||
|
"C^7 Am7 Dm7 G7".slow(2).voicings()
|
||||||
|
.stack("0@6 [<1 2> <2 0> 1]@2".scale('C5 major'))
|
||||||
|
.n().slow(4)
|
||||||
|
.s('0040_FluidR3_GM_sf2_file')
|
||||||
|
.color('steelblue')
|
||||||
|
.stack(
|
||||||
|
"<-7 ~@2 [~@2 -7] -9 ~@2 [~@2 -9] -10!2 ~ [~@2 -10] -5 ~ [-3 -2 -10]@2>*2".scale('C3 major')
|
||||||
|
.n().s('sawtooth').color('brown')
|
||||||
|
)
|
||||||
|
.attack(0.05).decay(.1).sustain(.7)
|
||||||
|
.cutoff(perlin.range(800,2000))
|
||||||
|
.gain(.3)
|
||||||
|
.stack(
|
||||||
|
s("<bd!3 [bd ~ bd]> sd,hh*3,~@5 <perc perc*3>")
|
||||||
|
.speed(perlin.range(.9,1.1))
|
||||||
|
.n(3).color('gray')
|
||||||
|
).slow(3/2)
|
||||||
|
//.pianoroll({autorange:1,vertical:1,fold:0})
|
||||||
|
.out()`;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user