Public
Edited
Apr 8, 2024
21 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Modes = Playa.Key.Modes
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
qt = new Playa.Time('4n');
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Playa.Ticks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
free = Playa.Rhythm.free('2:0:0', ['4n', '2n'])
Insert cell
Insert cell
Insert cell
grid = Playa.Rhythm.createGrid('1:0:0', 4)
Insert cell
Insert cell
turn = Playa.Rhythm.turn('1:0:0', 4)
Insert cell
Insert cell
motifFree = Playa.createMotif(key.notes, free)
Insert cell
Insert cell
Insert cell
motifTurn = Playa.createMotif(key.notes, turn)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
euclid = Playa.Euclidean.create(12, 7)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
movement = Playa.createMovement(new Playa.Key('D', Playa.Key.Mixolydian), movementLength, 4)
Insert cell
movement
Insert cell
Insert cell
Insert cell
Insert cell
melodies = Playa.createMelodies(movement.timeline, {
restProb: 0.3,
octaves: [ [4, 1], [3,1] ],
dejaVuChance: 0.6,
rhythmValues: ['8n', '4n']
});
Insert cell
Insert cell
Insert cell
chordProgression = Playa.createChordProgression(movement.timeline, {
octaves: [ [3, 1] ],
structures: [ Playa.Chord.Structures.Triad ],
rhythmValues: ['2n', '4n'],
inversionProb: 0.3,
restProb: 0.2
});
Insert cell
Insert cell
Insert cell
arp = Playa.createArp(new Playa.Scale('G4', Playa.ScaleIntervals.Altered), [1, 6, 3, 5, 3, 2], ['4n', '8n', '4nd', '8n', '4n', '2n'])
Insert cell
Insert cell
Insert cell
bassMovement = {
let turnDuration = 0;
let rhythm;
return movement.timeline.map((turn) => {
// Here we try to keep the same rhythm throughout the whole movement
// if the duration of each turn is the same, the rhythm will never change
if (!rhythm || turn.dur !== turnDuration) {
rhythm = Playa.Rhythm.free(turn.dur, ['4n', '8n', '4nt'], ['8n']);
}
turnDuration = turn.dur;
// create the arpeggio in the turn's key
const arp = Playa.createArp(new Playa.Key(turn.key.root, turn.key.scale, [2, 1]), [ 1, 5 ], rhythm);
// Here we do 2 things:
// * map each arpeggio to the correct starting time
// * add some rests to the arpeggio
return arp.map((evt) => {
const mapdEvt = Playa.mapStartToEvent(evt, turn.time);
if (Playa.Random.float() < 0.3) mapdEvt.isRest = true;
return mapdEvt;
});
}).flat();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
secondaryColor = '#2C3747'
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Playa = require('playa@1.0.0/build/umd/index.js')
Insert cell
Tone = require('tone@14.7.58/build/Tone.js')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
githubIcon = '<img src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fcdn.onlinewebfonts.com%2Fsvg%2Fimg_326384.png&f=1&nofb=1" width="15px"/>'
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more