Skip to content

Instantly share code, notes, and snippets.

@lvm
Created April 30, 2019 22:57
Show Gist options
  • Save lvm/679ce48625f2d2be6f71da3857000e99 to your computer and use it in GitHub Desktop.
Save lvm/679ce48625f2d2be6f71da3857000e99 to your computer and use it in GitHub Desktop.
ageispolis midi.scd
z = SimpleMIDIFile.read("/home/mauro/Downloads/General MIDIMan - Ageispolis.mid")
(
x = { |smf, channel, track|
var pending = IdentitySet.new, buf = MIDIRecBuf(\seq).absoluteOnsets_(true),
events = smf.noteEvents(channel, track).sort { |a, b|
if(a[1] == b[1]) {
a[2] > b[2] // equal time, put noteOn first
} {
a[1] < b[1] // earlier time first
}
},
// prevTime = events[0][1],
ppq = smf.division;
events.do { |event|
var note;
case
{ event[2] == \noteOn and: { event[5] > 0 } } {
// store for now with absolute times, not deltas
// length will be filled in during \noteOff processing
note = SequenceNote(event[4], event[1] / ppq, event[1], event[5]);
buf.add(note);
pending.add(note);
}
{ event[2] == \noteOff or: { event[5] == 0 } } {
note = pending.select { |note| note.freq == event[4] }.minItem(_.length);
if(note.notNil) {
note.length = (event[1] - note.length) / ppq;
pending.remove(note);
} {
"noteOff missing a noteOn: %".format(event).warn;
};
};
};
if(pending.notEmpty) {
"These notes are missing noteOff events:".postln;
pending.as(Array).sort { |a, b| a.dur < b.dur }.do(_.postln);
};
// pending
buf // function return value
};
)
a = x.(z)
a.convertToDeltas
a.notes[42..80].collect(_.postln)
46.percussion
f.setProgram(9,10)
(
~age[0] = Pbind(
\type,\md,
\chan, 9,
\seqnote, Pseq(a.notes[42..], inf),
#[midinote, delta, sustain, amp], Pfunc { |ev|
var note = ev[\seqnote];
// [note.freq, note.dur, note.length, note.args.linlin(0, 127, 0.05, 0.75)]
[note.freq, note.dur, note.length, note.args.linlin(0, 127, 0.05, 0.75)]
},
\stretch, 1/2,
);
)
(
~age[1] = { |in| Splay.ar(SoundIn.ar((9..14)))!2 };
~age[2] = \filter -> { |in,wave=1,crush=1,pitch=1|
OffsetOut.ar(0,
Select.ar(MouseX.kr > 0.5,
[
in,
// Stutter.ar(in!2, 1, FSinOsc.kr(1).range(0.1,1), 0.1, 2),
// Stutter.ar(in, 1, 0.1, 1, 1),
PitchShift.ar(
BinFreeze.ar(Decimator.ar(Stutter.ar(in, 1, 5, 0.1, 1)!2, 44100/crush), 4096, 2, 1)
,pitchRatio:pitch),
BlackNoise.ar(23),
// in,
// Stutter.ar(PitchShift.ar(RLPF.ar(PinkNoise.ar(0.5), FSinOsc.kr(1).range(60,1260), FSinOsc.kr(0.1).range(0.1,1)), pitchRatio:pitch), 1, 1, 10),
]
// .scramble
) * 15.dbamp
)
};
~page = Pbind(
\type, \set, \id, ~age.nodeID, \args, #[\wave,\crush,\pitch],
\wave, "92".hexbeat.pseq.stutter([1,1,1,2,1,1,4,1,1,8,1].pseq),
\crush, Pwhite(1,12),
\pitch, Pstutter(8, Pwhite(1,2)),
\dur, 1/8
);
// \dur, 1/[8,4,16,2,1].pxrand);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment