-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Gain Modulation with calculated modulation per event #1095
base: main
Are you sure you want to change the base?
Changes from all commits
496d60d
66a27a6
0d900c0
3159f66
7df663e
16472b5
6c05a4e
6a33032
1509ff1
cba9604
19df193
e024ae2
c6c5a30
4ba9d47
d5ab6b7
4a181d5
8ad48e1
bee8c81
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 |
---|---|---|
|
@@ -10,11 +10,8 @@ export class NeoCyclist { | |
constructor({ onTrigger, onToggle, getTime }) { | ||
this.started = false; | ||
this.cps = 0.5; | ||
this.lastTick = 0; // absolute time when last tick (clock callback) happened | ||
this.getTime = getTime; // get absolute time | ||
this.time_at_last_tick_message = 0; | ||
|
||
this.num_cycles_at_cps_change = 0; | ||
this.onToggle = onToggle; | ||
this.latency = 0.1; // fixed trigger time offset | ||
this.cycle = 0; | ||
|
@@ -86,7 +83,7 @@ export class NeoCyclist { | |
this.latency + | ||
this.worker_time_dif; | ||
const duration = hap.duration / this.cps; | ||
onTrigger?.(hap, 0, duration, this.cps, targetTime); | ||
onTrigger?.(hap, 0, duration, this.cps, targetTime, this.cycle); | ||
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. could cycle potentially be deduced from the hap itself? something like 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. That was the original plan, but the events don't line up perfectly unless you get the adjusted cycle that accounts for latency etc. Honestly could use some help here, maybe there is a better way to do this. |
||
} | ||
}); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,7 +260,7 @@ export function resetGlobalEffects() { | |
analysersData = {}; | ||
} | ||
|
||
export const superdough = async (value, t, hapDuration) => { | ||
export const superdough = async (value, t, hapDuration, cps, cycle) => { | ||
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. could there be a default value for cycle to make am (and potential future friends) be relative to seconds? so am(4) would be 4Hz. thinking about using superdough without strudel, where cycle is a non existing concept 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. yeah you could just pass in the time in seconds since clock start and it should work that way. I agree having both options would be nice for different effects |
||
const ac = getAudioContext(); | ||
if (typeof value !== 'object') { | ||
throw new Error( | ||
|
@@ -281,6 +281,10 @@ export const superdough = async (value, t, hapDuration) => { | |
} | ||
// destructure | ||
let { | ||
am, | ||
amdepth = 1, | ||
amskew = 0.5, | ||
amphase = 0, | ||
s = 'triangle', | ||
bank, | ||
source, | ||
|
@@ -322,8 +326,10 @@ export const superdough = async (value, t, hapDuration) => { | |
phasercenter, | ||
// | ||
coarse, | ||
|
||
crush, | ||
shape, | ||
|
||
shapevol = 1, | ||
distort, | ||
distortvol = 1, | ||
|
@@ -470,6 +476,19 @@ export const superdough = async (value, t, hapDuration) => { | |
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush })); | ||
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape, postgain: shapevol })); | ||
distort !== undefined && chain.push(getWorklet(ac, 'distort-processor', { distort, postgain: distortvol })); | ||
am !== undefined && | ||
chain.push( | ||
getWorklet(ac, 'am-processor', { | ||
speed: am, | ||
depth: amdepth, | ||
skew: amskew, | ||
phaseoffset: amphase, | ||
// shape: amshape, | ||
|
||
cps, | ||
cycle, | ||
}), | ||
); | ||
|
||
compressorThreshold !== undefined && | ||
chain.push( | ||
|
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.
What's the idea behind these changes? I can't quite figure out the intention by just looking at the code o_O
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.
The cycle calculation has to be adjusted slightly to compensate for when the event is actually played so that the phase of the modulation can be lined up. I already had made the cycle calculation on the neocyclist, so I just brought that logic over as well as the setCycle function. I could not figure out how to get the cycle offset adjustment to calculate properly with current cyclist implementation. Maybe you might know a better way to get this value?