Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
awood314 committed Jul 23, 2024
1 parent 16668c7 commit f12b6a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions runtime/elem/builtins/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ namespace elem
if (!val.isNumber())
return ReturnCode::InvalidPropertyType();

fade.setFadeInTimeMs(GraphNode<FloatType>::getSampleRate(), static_cast<float>((js::Number) val));
fade.setFadeInTimeMs(GraphNode<FloatType>::getSampleRate(), (js::Number) val);
}

if (key == "fadeOutMs") {
if (!val.isNumber())
return ReturnCode::InvalidPropertyType();

fade.setFadeOutTimeMs(GraphNode<FloatType>::getSampleRate(), static_cast<float>((js::Number) val));
fade.setFadeOutTimeMs(GraphNode<FloatType>::getSampleRate(), (js::Number) val);
}

return GraphNode<FloatType>::setProperty(key, val);
Expand Down
10 changes: 6 additions & 4 deletions runtime/elem/builtins/helpers/GainFade.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ namespace elem

FloatType operator() (FloatType x) {
auto const _currentGain = currentGain.load();
if (_currentGain == targetGain.load())
return (_currentGain * x);
auto const _targetGain = targetGain.load();
if (fpEqual(_currentGain, _targetGain))
return (_targetGain * x);

auto y = x * _currentGain;
currentGain.store(std::clamp(_currentGain + step.load(), FloatType(0), FloatType(1)));
Expand All @@ -54,9 +55,10 @@ namespace elem

void process (const FloatType* input, FloatType* output, int numSamples) {
auto const _currentGain = currentGain.load();
if (_currentGain == targetGain.load()) {
auto const _targetGain = targetGain.load();
if (_currentGain == _targetGain) {
for (int i = 0; i < numSamples; ++i) {
output[i] = input[i] * _currentGain;
output[i] = input[i] * _targetGain;
}
return;
}
Expand Down

0 comments on commit f12b6a9

Please sign in to comment.