You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
8.5 KiB
Plaintext

5 years ago
(
//busses
~masterBus = Bus.audio(s, 1);
~guitarBusA = Bus.audio(s, 1);
~guitarBusB = Bus.audio(s, 1);
~accompHighBusA = Bus.audio(s, 1);
~accompHighBusB = Bus.audio(s, 1);
~accompLowBusA = Bus.audio(s, 1);
~accompLowBusB = Bus.audio(s, 1);
~guitarBus = Bus.audio(s, 1);
~accompHighBus = Bus.audio(s, 1);
~accompLowBus = Bus.audio(s, 1);
5 years ago
SynthDef(\masterPlayerControl, {
arg sel = 0,
masterVol = 1, masterMute = 1,
guitarVol = 1, guitarPan = 0, guitarMute = 1,
accompHighVol = 1, accompHighPan = 0, accompHighMute = 1,
accompLowVol = 1, accompLowPan = 0, accompLowMute = 1;
var guitarSig, accompHighSig, accompLowSig,
guitarSigPanned, accompHighSigPanned, accompLowSigPanned,
masterSig, imp;
//guitarSig = SelectX.ar(sel, [In.ar(~guitarBusA), In.ar(~guitarBusB)]) * guitarVol;
//accompHighSig = SelectX.ar(sel, [In.ar(~accompHighBusA), In.ar(~accompHighBusB)]) * accompHighVol;
//accompLowSig = SelectX.ar(sel, [In.ar(~accompLowBusA), In.ar(~accompLowBusB)]) * accompLowVol;
guitarSig = In.ar(~guitarBus) * guitarVol;
accompHighSig = In.ar(~accompHighBus) * accompHighVol;
//accompLowSig = SelectX.ar(sel, [In.ar(~accompLowBusA), In.ar(~accompLowBusB)]) * accompLowVol;
accompLowSig = Mix.ar(
[
In.ar(~accompLowBusA) * EnvGen.kr(Env.asr(0.001, 1, 0.1), (sel + 1) % 2),
In.ar(~accompLowBusB) * EnvGen.kr(Env.asr(0.001, 1, 0.1), sel)
]
) * accompLowVol;
5 years ago
guitarSigPanned = Pan2.ar(guitarSig * guitarMute, guitarPan);
accompHighSigPanned = Pan2.ar(accompHighSig * accompHighMute, accompHighPan);
accompLowSigPanned = Pan2.ar(accompLowSig * accompLowMute, accompLowPan);
masterSig = Mix.ar([guitarSigPanned, accompHighSigPanned, accompLowSigPanned]) * masterVol * masterMute;
Out.ar(0, masterSig);
imp = Impulse.kr(10);
SendReply.kr(imp,
'/masterLevels',
values: [Amplitude.kr(masterSig)]);
SendReply.kr(imp,
'/trackLevels',
values: [Amplitude.kr(guitarSig), Amplitude.kr(accompHighSig), Amplitude.kr(accompLowSig), DC.ar(0)]);
}).add;
SynthDef(\transport, {arg beat, fin;
SendReply.kr(Changed.kr(beat * (beat < fin)),'/measureClock', values: [beat]);
SendReply.kr(TDelay.kr(Changed.kr(beat * (beat < fin)), 0.25),'/measureClockReset', values: [beat]);
SendReply.kr(Changed.kr(beat < fin),'/playNextSubsection');
}).add;
5 years ago
//~~~~karplus
SynthDef(\karplus, {arg freq, gate = 1, amp = 0.5, bus;
Out.ar(bus,
Pluck.ar(WhiteNoise.ar(0.1), Impulse.kr(0), 220.reciprocal, freq.reciprocal, 10, coef:0) *
Linen.kr(gate, doneAction: 2) * amp
5 years ago
)
}).add;
//~~~~accompaniment
SynthDef(\accompBass, {arg freq1 = 100, freq2 = 100, gate = 1, amp = 0.5, bus, cutoff = 0;
5 years ago
var bassDrop;
bassDrop = Mix.ar(
[
SinOsc.ar(freq1, 0, 0.5),
/*
Select.ar(((freq2 - freq1).poll < 1.1).poll,
[
SinOsc.ar(freq2, 0, 0.5),
SinOsc.ar((freq1 +
(EnvGen.kr(Env.cutoff(10), Impulse.kr(0) + Changed.kr(freq2)) * (freq2 - freq1))).poll, 0, 0.5)
]
);
*/
SinOsc.ar(freq2, 0, 0.5)
]
) *
5 years ago
EnvGen.kr(Env.perc(0.1, 10, level: amp), Impulse.kr(0) + Changed.kr(freq2));
//EnvGen.kr(Env.cutoff(0.1, level: amp), cutoff);
5 years ago
Out.ar(bus, bassDrop)
}).add;
//this is not releasing properly
5 years ago
SynthDef(\accompTreble, {arg freq, gate = 1, sustain, amp, bus;
var treble;
treble = SinOsc.ar(
freq, 0,
EnvGen.kr(Env.sine(sustain, amp * 0.1), gate, doneAction: 2));
5 years ago
Out.ar(bus, treble)
}).add;
~droneBus = Bus.audio(s, 1);
SynthDef(\drone, { arg out=0, freq=440, amp=0.1, pan=0, gate=1, bus;
var z;
z = LPF.ar(
Mix.new(VarSaw.ar(freq + [0, Rand(-0.4,0.0), Rand(0.0,0.4)], 0, 0.3, 0.3)),
XLine.kr(Rand(4000,5000), Rand(2500,3200), 1)
) * Linen.kr(gate, 0.01, 0.7, 0.3, 2);
Out.ar(bus, Pan2.ar(z, pan, amp));
}, [\ir]).add;
SynthDef(\droneOut, {arg gate, bus;
Out.ar([0, 1], Clip.ar(In.ar(bus, 1), -1, 1) * 0.1 * EnvGen.ar(Env.asr(20, 1, 20), gate))
}
).add;
~dronePattern = Pbind(
\instrument, \drone,
\amp, 0.5,
\dur, 0.02,
\sustain, 0.05,
\freq, Pseq(3000.collect({[[62.midicps, 250], [62.midicps, 250].choose].wchoose([10, 1].normalizeSum)}).flat / 2),
\bus, ~droneBus.index
);
OSCFunc({ arg msg, time;
~currentSection = ~currentSection + 1;
~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0)
},'/playNextSubsection', s.addr);
5 years ago
//~~~~gen music
~genPatterns = {arg guitarSeqIn, accompLowSeqIn, accompHighSeqIn, sectionSeqIn, tempo = 0.08;
5 years ago
var calcSustains, genSectionSec, sectionLimits;
//~~~~helper sus function
calcSustains = {arg stringSeq, durSeq;
var res = [];
stringSeq.size.do({arg index;
var curString, dur, count;
if(stringSeq[index].isRest.not, {
curString = stringSeq[index];
dur = durSeq[index];
count = 1;
while({(stringSeq[(index + count).clip(0, stringSeq.size - 1)] != curString) &&
(dur < 16) && (count < 100)}, {
dur = dur + durSeq[(index + count).clip(0, durSeq.size - 1)];
count = count + 1;
});
res = res.add(dur.clip(0, 16));
}, {
res.add(Rest());
});
});
res
};
genSectionSec = {arg seq, startTime, endTime, type;
var durSum, resSeqs, inSecs, mult;
//sectionSeq.postln;
durSum = 0;
resSeqs = [];
seq.do({arg item;
if((durSum >= startTime) && (durSum < endTime), {
var dur = durSum - startTime;
5 years ago
if((resSeqs.size == 0) && (dur > 0), {
switch(type,
0, {resSeqs = resSeqs.add([Rest(-1), Rest(-1), dur])},
1, {resSeqs = resSeqs.add([Rest(-1), Rest(-1), dur])},
2, {resSeqs = resSeqs.add([Rest(-1), dur, dur])})
5 years ago
});
resSeqs = resSeqs.add(item);
});
durSum = durSum + if(type == 2, {item[1]}, {item[2]});
});
//if(type == 1, {resSeqs = resSeqs.add([0, 0, 16])});
resSeqs.postln;
5 years ago
resSeqs
};
sectionLimits = [];
sectionSeqIn.slice(nil, 0).add(100000).doAdjacentPairs({arg a, b; sectionLimits = sectionLimits.add([a, b])});
sectionLimits.collect({arg timePair, secIndex;
var startTime, endTime, endBeat,
5 years ago
guitarSecSeq, accompLowSecSeq, accompHighSecSeq,
stringSeq, fretSeq, durSeq, susSeq, trigSeq, openStrings, pattern;
startTime = timePair[0];
5 years ago
endTime = timePair[1];
endBeat = endTime - startTime;
5 years ago
guitarSecSeq = genSectionSec.value(guitarSeqIn, startTime, endTime, 0);
accompLowSecSeq = genSectionSec.value(accompLowSeqIn, startTime, endTime, 1);
accompHighSecSeq = genSectionSec.value(accompHighSeqIn, startTime, endTime, 2);
if(accompHighSecSeq == [], {accompHighSecSeq = [[Rest(-1), 1, 0], [Rest(-1), 1, 0]]});
//guitarSecSeq.postln;
//accompLowSecSeq.postln;
//accompHighSecSeq.postln;
5 years ago
openStrings = [1/1, 3/2, 2/1, 5/2, 35/12, 7/2];
stringSeq = guitarSecSeq.slice(nil, 0);
fretSeq = guitarSecSeq.slice(nil, 1);
durSeq = guitarSecSeq.slice(nil, 2);
susSeq = calcSustains.value(stringSeq, durSeq);
susSeq.last.postln;
durSeq.last.postln;
accompLowSecSeq.last.postln;
accompHighSecSeq.last.postln;
5 years ago
//trigSeq = guitarSeq.slice(nil, 3);
//~player = EventPatternProxy.new;
pattern = EventPatternProxy.new;
pattern.source = Ppar([
Pbind(
\instrument, \karplus,
\amp, 0.3,
\dur, Pseq(durSeq * tempo),
\sustain, Pseq(susSeq * tempo),
5 years ago
\freq, Pseq(stringSeq.collect({arg string, index;
if(string.isRest, {Rest()}, {
((62.midicps * openStrings[string]).cpsmidi + fretSeq[index]).midicps})})),
//\bus, if(secIndex % 2 == 0, {~guitarBusA.index}, {~guitarBusB.index})),
\bus, ~guitarBus.index),
5 years ago
if(accompLowSecSeq.size > 1, {
Pmono(
\accompBass,
\amp, 0.5,
\freq1, Pseq(accompLowSecSeq.slice(nil, 0)),
\freq2, Pseq(accompLowSecSeq.slice(nil, 1)),
\dur, Pseq(accompLowSecSeq.slice(nil, 2)) * tempo,
//\cutoff, Pseq(accompLowSecSeq.drop(-1).size.collect({0}).add(1)),
5 years ago
\bus, if(secIndex % 2 == 0, {~accompLowBusA.index}, {~accompLowBusB.index}))
//\bus, ~accompLowBus)
5 years ago
}, {
Pmono(
\accompBass,
\amp, 0.5,
\freq1, Pseq([accompLowSecSeq[0][0]]),
\freq2, Pseq([accompLowSecSeq[0][1]]),
\dur, Pseq([accompLowSecSeq[0][2]]) * tempo,
//\cutoff, Pseq(accompLowSecSeq.drop(-1).size.collect({0}).add(1)),
5 years ago
\bus, if(secIndex % 2 == 0, {~accompLowBusA.index}, {~accompLowBusB.index}))
//\bus, ~accompLowBus)
5 years ago
}),
Pbind(
\instrument, \accompTreble,
\freq, Pseq(accompHighSecSeq.slice(nil, 0)),
\dur, Pseq(accompHighSecSeq.slice(nil, 1) * tempo),
\sustain, Pseq(accompHighSecSeq.slice(nil, 2) * tempo),
5 years ago
\amp, 0.5,
//\bus, if(secIndex % 2 == 0, {~accompHighBusA.index}, {~accompHighBusB.index})),
\bus, ~accompHighBus.index),
Pmono(\transport,
\beat, Pseq((0..((endBeat / 8).asInteger))),
\dur, tempo * 8,
\fin, ((endBeat / 8).asInteger).postln
)
5 years ago
]);
pattern
});
5 years ago
};
)