«One chord requiem» by 56228375
on 04 Jun'23 08:49 inGenerating minimal music by repeating a random chord over and over again, varying individual note volumes (and after a while also timings) to bring out different aspects of the chord. Every time you run it, it will generate a new piece. I use it with in combination with a virtual piano. The code is the result of experimentation and is not cleaned up; may still contain useless statements :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
( s.waitForBoot({ var midiout; var no_of_bins; var bins = Set[]; var table; var lut; var period = 127; var phase = 0; var rangemin = 20; var rangemax = 80; var strum = 0.0025.neg; var delay_between_chords = 0.25; var direction = 1; var stopit = false; var idx = 0; var ampmod = 1.0; CmdPeriod.doOnce{ 127.do({ |note| midiout.noteOff(1, note); }); }; if (MIDIClient.initialized.not) { MIDIClient.init; }; midiout = MIDIOut.new(0); no_of_bins = 24; table = { | period, phase, rangemin, rangemax | 127.collect({ |time| sin(2pi*time/period + phase).linlin(-1, 1, rangemin, rangemax); }); }; bins = Set[]; while ({bins.size < no_of_bins}) { bins = bins.add(20.rrand(100)); }; bins = bins.asList.sort; idx = 0; while({stopit.not}) { var wrappedidx = idx.mod(127); idx.postln; if (idx.mod(127) == 0) { period = period / 2; lut = table.(period, phase, rangemin, rangemax); direction = direction.neg; //lut.debug("new lut"); direction.debug("new direction"); }; if (idx.mod(127*2*2) == 0) { strum = strum + 0.0025; delay_between_chords = delay_between_chords * 0.9; strum.debug("new strum"); bins = bins.scramble; bins.debug("new order"); }; if ((idx > 0) && (idx.mod(890) == 0)) { strum = 0.01; bins = bins.scramble; }; if (idx > 890) { direction = direction * [1,-1].choose; // one last chaotic period period = period * 2.6329.rrand(1.0/2.6329); ampmod = ampmod * 0.97; strum = strum * 1.2; delay_between_chords = delay_between_chords * 0.9; }; if (idx == 915) { stopit = true; "preparing to stop....".postln; }; bins.do({ |bin| var finalidx = (wrappedidx + (bin*direction)).wrap(0, 126); midiout.noteOn(1, bin, ampmod * lut[finalidx]); strum.wait; }); delay_between_chords.wait; bins.do({ |bin| midiout.noteOff(1, bin); }); idx = idx+1; }; midiout.control(1, 64, 127); 127.do({ |note| midiout.noteOff(1, note); }); 10.wait; midiout.control(1, 64, 0); "The End.".postln; }); )
reception
You can listen to a realization of the program here: https://www.youtube.com/watch?v=aUGN7PIJmts