-
Notifications
You must be signed in to change notification settings - Fork 24
feat: noisegate unit #231
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
base: master
Are you sure you want to change the base?
feat: noisegate unit #231
Changes from all commits
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 |
|---|---|---|
|
|
@@ -616,6 +616,39 @@ func (s *GoSynth) Render(buffer sointu.AudioBuffer, maxtime int) (samples int, r | |
| unit.state[2+i] = b2*x - a2*y | ||
| stack[l-1-i] = y | ||
| } | ||
| case opGate: | ||
| signal := stack[l-1] * stack[l-1] | ||
| if stereo { | ||
| signal += stack[l-2] * stack[l-2] | ||
| } | ||
| threshold := params[3] * params[3] | ||
| level := unit.state[0] | ||
| holding := unit.state[1] | ||
| // attacking is delayed until "holding" did count down to 0 | ||
| if signal > threshold { | ||
| holding = 1 | ||
| release := nonLinearMap(params[0]) | ||
| level += release | ||
| if level > 1 { | ||
| level = 1 | ||
| } | ||
| } | ||
| holding -= nonLinearMap(params[1]) | ||
| if holding < 0 { | ||
| attack := nonLinearMap(params[2]) | ||
| level -= attack | ||
| if level < 0 { | ||
| level = 0 | ||
| } | ||
| } | ||
| unit.state[0] = level | ||
| unit.state[1] = holding | ||
| // like the compressor, this does not directly multiply the factor | ||
| // but writes it onto the stack for the user to decide what to do | ||
| stack = append(stack, level) | ||
| if stereo { | ||
| stack = append(stack, level) | ||
| } | ||
|
Owner
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 toyed a bit with this and how about restructuring it like this: signal := stack[l-1] * stack[l-1]
if stereo {
signal += stack[l-2] * stack[l-2]
}
threshold := params[3] * params[3]
// unit.state takes inverse level, to be initialized at 1
level := unit.state[0]
// attacking is delayed until "holding" did count down to 0
if signal > threshold {
level += nonLinearMap(params[0])
unit.state[1] = 1
if level > 1 {
level = 1
}
}
holding := unit.state[1]
unit.state[1] = holding - nonLinearMap(params[1])
if holding < 0 {
level -= nonLinearMap(params[2])
if level < 0 {
level = 0
}
}
unit.state[0] = level
// like the compressor, this does not directly multiply the factor
// but writes it onto the stack for the user to decide what to do
stack = append(stack, level)
if stereo {
stack = append(stack, level)
}I think this will help the x86 implementation:
Very much untested (the comparison are probably wrong way around, but I just wanted to roughly see how this would look in code; I think it's less bytes?) |
||
| case opSync: | ||
| break | ||
| default: | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.