-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to merge back changes from SuperDough fork #303
base: develop
Are you sure you want to change the base?
Changes from all commits
b0dce42
fc4c24f
e58583e
789eace
42b282f
d0c7fcb
7b768d0
c0e7366
9b85220
04bd40a
88bfe27
e6350ab
e60f514
7a0e601
cbbe8ba
cda96c6
fd6c624
36be99b
368613d
f32c1b9
561903a
7072d23
2859c80
287947f
266b616
1becbcc
a47e9ff
c96ef2a
bcf605e
b114473
48d2bad
019c1ba
ad53027
e9ab9d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,14 @@ DirtEvent { | |
} | ||
|
||
play { | ||
|
||
|
||
event.parent = orbit.defaultParentEvent; | ||
event.use { | ||
|
||
// s and n stand for synth/sample and note/number | ||
~s ?? { this.splitName }; | ||
|
||
// unless orbit wide diversion returns something, we proceed | ||
~diversion.(this) ?? { | ||
if(~s != \) { // backslash stands for do nothing | ||
|
@@ -35,15 +39,27 @@ DirtEvent { | |
} | ||
|
||
splitName { | ||
|
||
var s, n; | ||
|
||
|
||
|
||
#s, n = ~sound.asString.split($:); | ||
if(~bank.notNil) { s = ~bank ++ s }; | ||
~s = s.asSymbol; | ||
|
||
|
||
|
||
|
||
~n = if(n.notNil) { n.asFloat } { 0.0 }; | ||
} | ||
|
||
mergeSoundEvent { | ||
var soundEvent = orbit.dirt.soundLibrary.getEvent(~s, ~n); | ||
var soundEvent; | ||
|
||
|
||
soundEvent = orbit.dirt.soundLibrary.getEvent(~s, ~n); | ||
|
||
if(soundEvent.isNil) { | ||
// only call ~notFound if no ~diversion is given that anyhow redirects control | ||
if(~diversion.isNil) { ~notFound.value } | ||
|
@@ -67,6 +83,7 @@ DirtEvent { | |
var accelerate = ~accelerate.value; | ||
var avgSpeed, endSpeed; | ||
var useUnit; | ||
~release = ~release.value ? 0.01; | ||
|
||
~freq = ~freq.value; | ||
unitDuration = ~unitDuration.value; | ||
|
@@ -102,24 +119,38 @@ DirtEvent { | |
}; | ||
|
||
sustain = ~sustain.value; | ||
|
||
sustain = sustain ?? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes below: are you sure strudel couldn't translate its logic to the way tidalcycles works? It will be very confusing to change all that … |
||
delta = ~delta.value; | ||
if(~legato.notNil) { | ||
delta * ~legato.value | ||
} { | ||
if (useUnit and: ~clip.isNil) { | ||
unitDuration = unitDuration ? delta; | ||
loop !? { unitDuration = unitDuration * loop.abs }; | ||
} | ||
} { | ||
(delta / ~cps) * (~clip.value ? 1) | ||
}; | ||
|
||
// if(~clip.notNil) { | ||
// (delta / ~cps) * ~clip.value | ||
// } { | ||
// unitDuration = unitDuration ? delta; | ||
// loop !? { unitDuration = unitDuration * loop.abs }; | ||
// } | ||
}; | ||
|
||
|
||
|
||
// end samples if sustain exceeds buffer duration | ||
// for every buffer, unitDuration is (and should be) defined. | ||
if(useUnit) { sustain = min(unitDuration, sustain) }; | ||
|
||
~fadeTime = min(~fadeTime.value, sustain * 0.19098); | ||
~fadeInTime = if(~begin != 0) { ~fadeTime } { 0.0 }; | ||
// if(useUnit) { sustain = min(unitDuration, sustain) }; | ||
|
||
|
||
// ~fadeTime = min(~fadeTime.value, sustain * 0.19098); | ||
// ~fadeTime = ~fadeTime.value ? .001; | ||
// ~fadeInTime = if(~begin != 0) { ~fadeTime } { 0.0 }; | ||
if (~timescale.notNil) {sustain = sustain * ~timescale }; | ||
~sustain = sustain - (~fadeTime + ~fadeInTime); | ||
~totalDuration = if (useUnit) {min(unitDuration, sustain + ~release)} {sustain + ~release}; | ||
// ~sustain = sustain - (~fadeTime + ~fadeInTime); | ||
~sustain = sustain; | ||
|
||
~speed = speed; | ||
~endSpeed = endSpeed; | ||
|
||
|
@@ -129,6 +160,7 @@ DirtEvent { | |
~channel !? { ~pan = ~pan.value + (~channel.value / ~numChannels) }; | ||
~pan = ~pan * 2 - 1; // convert unipolar (0..1) range into bipolar one (-1...1) | ||
~delayAmp = ~delay ? 0.0; // for clarity | ||
~z1 = ~z1 ? ~n; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain what |
||
~latency = ~latency + ~lag.value + (~offset.value * ~speed.value.abs); | ||
} | ||
|
||
|
@@ -140,14 +172,15 @@ DirtEvent { | |
sendSynth { |instrument, args| | ||
var group = ~synthGroup; | ||
args = args ?? { this.getMsgFunc(instrument).valueEnvir }; | ||
|
||
args.asControlInput.flop.do { |each| | ||
server.sendMsg(\s_new, | ||
server.sendMsg(\s_new, | ||
instrument, | ||
-1, // no id | ||
1, // add action: addToTail | ||
group, // send to group | ||
*each.asOSCArgArray // append all other args | ||
) | ||
) | ||
} | ||
} | ||
|
||
|
@@ -160,11 +193,12 @@ DirtEvent { | |
*[ | ||
in: orbit.synthBus.index, // read from synth bus, which is reused | ||
out: orbit.dryBus.index, // write to orbital dry bus | ||
amp: ~amp, | ||
gain: ~gain, | ||
overgain: ~overgain, | ||
sample: ~hash, // required for the cutgroup mechanism | ||
cut: ~cut.abs, | ||
release: ~release, | ||
totalDuration: ~totalDuration, | ||
sustain: ~sustain, // after sustain, free all synths and group | ||
fadeInTime: ~fadeInTime, // fade in | ||
fadeTime: ~fadeTime // fade out | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,8 @@ DirtEventTypes { | |
var freq, lag, sustain; | ||
var args, midiout, hasGate, midicmd, latency, chan; | ||
var sendNRPN, schedmidi, schedmidicmd, donecmd; | ||
var hasNote = (~n != \none or: {~note.notNil}); | ||
// var hasNote = (~n != \none or: {~note.notNil}); | ||
var hasNote = (~n.notNil or: {~note.notNil}); | ||
var midiCommandPending = ~midicmd.notNil; | ||
var nrpnMSB, nrpnLSB, valMSB, valLSB; | ||
var ctlNum, control, num, val, note; | ||
|
@@ -108,15 +109,15 @@ DirtEventTypes { | |
|
||
if (hasNote) { | ||
freq = ~freq.value; | ||
~midinote = (freq.cpsmidi).round(1).asInteger; | ||
~midinote = ((freq.cpsmidi).round(1) ? 0).asInteger; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the default is not necessary and can be dropped. |
||
// Assume aftertouch means no noteOn, for now.. | ||
if(~polyTouch.notNil) { | ||
val = ~polyTouch; | ||
note = ~midinote; | ||
schedmidi.value({ midiout.polyTouch(chan, note, val) }) | ||
} { | ||
// match dirt_gate SynthDef amplitude scaling | ||
~amp = ~amp.value * pow(~gain.min(2) + ~overgain, 4); | ||
~amp = ~amp.value * StrudelUtils.gainCurve(~gain + ~overgain, 4); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's introduce |
||
|
||
sustain = ~sustain = ~sustain.value; | ||
if(~uid.notNil and: { midiout.notNil }) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,11 +58,12 @@ DirtOrbit { | |
initDefaultGlobalEffects { | ||
this.globalEffects = [ | ||
// all global effects sleep when the input is quiet for long enough and no parameters are set. | ||
GlobalDirtEffect(\dirt_shimmer, [\delaytime, \delayfeedback, \delaySend, \shimmer, \cps]), | ||
GlobalDirtEffect(\dirt_delay, [\delaytime, \delayfeedback, \delaySend, \delayAmp, \lock, \cps]), | ||
GlobalDirtEffect(\dirt_reverb, [\size, \room, \dry]), | ||
GlobalDirtEffect(\dirt_leslie, [\leslie, \lrate, \lsize]), | ||
GlobalDirtEffect(\dirt_rms, [\rmsReplyRate, \rmsPeakLag]).alwaysRun_(true), | ||
GlobalDirtEffect(\dirt_monitor, [\limitertype]).alwaysRun_(true), | ||
GlobalDirtEffect(\dirt_monitor, [\limitertype, \outgain, \dry, \wet]).alwaysRun_(true), | ||
] | ||
} | ||
|
||
|
@@ -163,6 +164,7 @@ DirtOrbit { | |
makeDefaultParentEvent { | ||
defaultParentEvent = Event.make { | ||
|
||
|
||
~cps = 1.0; | ||
~offset = 0.0; | ||
~begin = 0.0; | ||
|
@@ -173,22 +175,26 @@ DirtOrbit { | |
~overgain = 0.0; | ||
~cut = 0.0; | ||
~unit = \r; | ||
~n = \none; // sample number or note | ||
~octave = 5; | ||
~midinote = #{ ~note ? ~n + (~octave * 12) }; | ||
~n = nil; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should find a way around setting this to nil. Why can't it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically, you can just directly replace the default if you need, no need for StrudelUtils:
|
||
~octave = 0; | ||
~midinote = #{ (~note ? ~n ? StrudelUtils.baseNote()) + (~octave * 12) }; | ||
~freq = #{ ~midinote.value.midicps }; | ||
~dur = 1.0; | ||
~delta = #{ ~dur.value }; | ||
|
||
~latency = 0.0; | ||
~lag = 0.0; | ||
~length = 1.0; | ||
~loop = 1.0; | ||
~dry = 0.0; | ||
~dry = 1.0; | ||
~wet = 1.0; | ||
~lock = 0; // if set to 1, syncs delay times with cps | ||
|
||
~amp = 0.4; | ||
~amp = 1; | ||
~fadeTime = 0.001; | ||
~delaytime = 0.1875; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not 100% sure, but I think this means that there is always delay on. This can be set for each piece separately. |
||
~delayfeedback = 0.15; | ||
~lock = 1; | ||
~outgain = 1; // output gain that drives the final limiter | ||
|
||
|
||
// values from the dirt bus | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,27 @@ DirtSoundLibrary { | |
synthEvents.clear; | ||
this.freeAllSoundFiles; | ||
} | ||
// extractParts { |str| | ||
// // Regex to split the string into numeric and non-numeric parts | ||
// str.collect { |part| | ||
// part.isNumber ifTrue: { part.asInteger } ifFalse: { part } | ||
// }; | ||
// } | ||
|
||
// sortStringsAlphanumerically { |stringArray| | ||
// stringArray.sort { |a, b| | ||
// var partsA = this.extractParts.(a); | ||
// var partsB = this.extractParts.(b); | ||
|
||
// partsA.zip(partsB).detect { |pair| | ||
// var (partA, partB) = pair; | ||
// partA < partB ifTrue: { ^-1 }; | ||
// partA > partB ifTrue: { ^1 }; | ||
// }; | ||
|
||
// 0 // They are equal | ||
// }; | ||
// } | ||
|
||
addBuffer { |name, buffer, appendToExisting = false, metaData| | ||
var event, index; | ||
|
@@ -51,6 +72,7 @@ DirtSoundLibrary { | |
} | ||
|
||
addSynth { |name, event, appendToExisting = false, useSynthDefSustain = false, metaData| | ||
|
||
if(bufferEvents[name].notNil) { | ||
"a sample buffer with that name already exists: %\nSkipping...".format(name).warn; | ||
^this | ||
|
@@ -107,6 +129,8 @@ DirtSoundLibrary { | |
|
||
set { |name, indices ... pairs| | ||
var allEvents = this.at(name); | ||
|
||
|
||
if(allEvents.isNil) { | ||
"set: no events found with this name: %\n".format(name).warn | ||
} { | ||
|
@@ -179,7 +203,9 @@ DirtSoundLibrary { | |
}; | ||
|
||
files = pathMatch(folderPath.standardizePath +/+ "*"); // dependent on operating system | ||
if(sortFiles) { files.sort }; | ||
if(sortFiles) { | ||
files.sort; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in sclang, there is no |
||
}; | ||
|
||
if(files.notEmpty) { | ||
name = name.asSymbol; | ||
|
@@ -195,7 +221,9 @@ DirtSoundLibrary { | |
|
||
filePaths.do { |filepath| | ||
try { | ||
|
||
var buf, metaData; | ||
|
||
buf = this.readSoundFile(filepath); | ||
if(buf.notNil) { | ||
metaData = this.readMetaData(filepath); | ||
|
@@ -283,6 +311,7 @@ DirtSoundLibrary { | |
|
||
var allEvents = this.at(name); | ||
var event; | ||
|
||
|
||
if(allEvents.isNil) { | ||
// first look up buffers, then synths | ||
|
@@ -298,8 +327,7 @@ DirtSoundLibrary { | |
^event | ||
|
||
} { | ||
// the index may be \none (a Symbol), but this converts it to 0 | ||
event = allEvents.wrapAt(index.asInteger); | ||
event = allEvents.wrapAt((index ? 0).asInteger); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be revisited in SuperDirt. |
||
}; | ||
|
||
if(doNotReadYet and: { event.notNil and: { event[\notYetRead] ? false } }) { | ||
|
@@ -320,8 +348,9 @@ DirtSoundLibrary { | |
} | ||
|
||
makeEventForBuffer { |buffer, metaData| | ||
var baseFreq = 60.midicps; | ||
var baseFreq = StrudelUtils.baseNote().midicps; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I intentionally kept separate |
||
var baseFreqToMetaFreqRatio = metaData !? _[\baseFreqToMetaFreqRatio] ? 1.0; | ||
|
||
^( | ||
buffer: buffer.bufnum, | ||
bufferObject: buffer, | ||
|
@@ -340,7 +369,7 @@ DirtSoundLibrary { | |
}, | ||
unitDuration: { buffer.duration * baseFreq / (~freq.value * ~metaDataTuneRatio.value) }, | ||
hash: buffer.identityHash, | ||
note: 0 | ||
note: StrudelUtils.baseNote() | ||
) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default values are usually given in the default event. Unless you need to caclulate something with
~release
here, also the.value
will be called automatically.