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.

262 lines
9.0 KiB
Plaintext

5 years ago
(
//busses
~masterBus = Bus.audio(s, 1);
~guitarBus = Bus.audio(s, 1);
~accompHighBus = Bus.audio(s, 1);
~accompLowLowerBusA = Bus.audio(s, 1);
~accompLowUpperBusA = Bus.audio(s, 1);
~accompLowLowerBusB = Bus.audio(s, 1);
~accompLowUpperBusB = Bus.audio(s, 1);
~interludeBus = Bus.audio(s, 1);
~droneBus = 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,
accompLowLowerVol = 1, accompLowLowerPan = 0, accompLowLowerMute = 1,
accompLowUpperVol = 1, accompLowUpperPan = 0, accompLowUpperMute = 1;
var guitarSig, accompHighSig, accompLowLowerSig, accompLowUpperSig,
guitarSigPanned, accompHighSigPanned, accompLowLowerSigPanned, accompLowUpperSigPanned,
5 years ago
masterSig, imp;
guitarSig = In.ar(~guitarBus) * guitarVol;
accompHighSig = In.ar(~accompHighBus) * accompHighVol;
accompLowLowerSig = Mix.ar(
[
In.ar(~accompLowLowerBusA) * EnvGen.kr(Env.asr(0.001, 1, 0.1), (sel + 1) % 2),
In.ar(~accompLowLowerBusB) * EnvGen.kr(Env.asr(0.001, 1, 0.1), sel)
]
) * accompLowLowerVol;
accompLowUpperSig = Mix.ar(
[
In.ar(~accompLowUpperBusA) * EnvGen.kr(Env.asr(0.001, 1, 0.1), (sel + 1) % 2),
In.ar(~accompLowUpperBusB) * EnvGen.kr(Env.asr(0.001, 1, 0.1), sel)
]
) * accompLowUpperVol;
5 years ago
guitarSigPanned = Pan2.ar(guitarSig * guitarMute, guitarPan);
accompHighSigPanned = Pan2.ar(accompHighSig * accompHighMute, accompHighPan);
accompLowLowerSigPanned = Pan2.ar(accompLowLowerSig * accompLowLowerMute, accompLowLowerPan);
accompLowUpperSigPanned = Pan2.ar(accompLowUpperSig * accompLowUpperMute, accompLowUpperPan);
masterSig = Mix.ar([guitarSigPanned, accompHighSigPanned, accompLowLowerSigPanned, accompLowUpperSigPanned]) * masterVol * masterMute;
5 years ago
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(accompLowLowerSig), Amplitude.kr(accompLowUpperSig),
DC.ar(0)
]
);
5 years ago
}).add;
SynthDef(\transport, {arg measure = 0, beat = 0, gate = 1, dur = 1;
SendReply.kr(Impulse.kr(0) * (measure > 0) * (beat > 0),'/measureClock', values: [measure, beat]);
SendReply.kr(TDelay.kr(Impulse.kr(0) * (measure > 0) * (beat > 0), 0.25),'/measureClockReset');
SendReply.kr(Impulse.kr(0) * (measure < 1) * (beat < 1),'/playNextSubsection');
EnvGen.kr(Env.sine(dur), gate, doneAction: 2);
}).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, busLower, busUpper, cutoff = 0;
var env, lower, upper;
env = EnvGen.kr(Env.perc(0.1, 10, level: amp), Impulse.kr(0) + Changed.kr(freq2));
lower = SinOsc.ar(freq1, 0, 0.5) * env;
upper = SinOsc.ar(freq2, 0, 0.5) * env;
Out.ar(busLower, lower);
Out.ar(busUpper, upper)
5 years ago
}).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;
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(\droneFade, {arg gate = 0;
Out.ar([0, 1], Clip.ar(In.ar(~droneBus, 1), -1, 1) * 0.1 * EnvGen.ar(Env.asr(20, 1, 20), gate))
}).add;
5 years ago
~dronePattern = EventPatternProxy.new;
~dronePattern.source = Pbind(
5 years ago
\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),
\freq, Pwrand([[62.midicps, 250], Prand([62.midicps, 250], inf)], [10, 1].normalizeSum, inf) / 2,
5 years ago
\bus, ~droneBus.index
);
OSCFunc({ arg msg, time; {~updateSection.value(1, false, false)}.defer},'/playNextSubsection', s.addr);
5 years ago
//~~~~gen music
~genPatterns = {arg guitarSeqIn, accompLowSeqIn, accompHighSeqIn, sectionSeqIn, tempo = 0.08;
var calcSustains, genSectionSec, sectionLimits, measureCount;
5 years ago
//~~~~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;
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]});
});
resSeqs
};
measureCount = 0;
5 years ago
sectionLimits = [];
sectionSeqIn.slice(nil, 0).add(100000).doAdjacentPairs({arg a, b; sectionLimits = sectionLimits.add([a, b])});
~sectionStartMeasure = [];
5 years ago
sectionLimits.collect({arg timePair, secIndex;
var startTime, endTime, beatLength, beatSeq, measureSeq,
5 years ago
guitarSecSeq, accompLowSecSeq, accompHighSecSeq,
stringSeq, fretSeq, durSeq, susSeq, trigSeq, openStrings, pattern;
startTime = timePair[0];
5 years ago
endTime = timePair[1];
if((secIndex % 4) == 0, {measureCount = 0});
beatLength = (endTime - startTime) / 8;
beatSeq = ((beatLength / 2) - 1).asInteger.collect({[1, 2]});
beatSeq = if((beatLength % 2) == 0, {beatSeq.add([1, 2])}, {beatSeq.add([1, 2, 3])});
measureSeq = measureCount + beatSeq.collect({arg measure, mIndex; measure.collect({mIndex + 1})}).flat;
~sectionStartMeasure = ~sectionStartMeasure.add(measureCount + 1);
measureCount = measureSeq.last;
beatSeq = beatSeq.flat;
measureSeq = measureSeq.add(0);
beatSeq = beatSeq.add(0);
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]]});
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);
5 years ago
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)),
\busLower, if(secIndex % 2 == 0, {~accompLowLowerBusA.index}, {~accompLowLowerBusB.index}),
\busUpper, if(secIndex % 2 == 0, {~accompLowUpperBusA.index}, {~accompLowUpperBusB.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)),
\busLower, if(secIndex % 2 == 0, {~accompLowLowerBusA.index}, {~accompLowLowerBusB.index}),
\busUpper, if(secIndex % 2 == 0, {~accompLowUpperBusA.index}, {~accompLowUpperBusB.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),
Pbind(
\instrument, \transport,
\measure, Pseq(measureSeq),
\beat, Pseq(beatSeq),
\dur, tempo * 8
)
5 years ago
]);
pattern
});
5 years ago
};
)