Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ void AudioParam::exponentialRampToValueAtTime(float value, double endTime) {
// Exponential curve function using power law
auto calculateValue =
[](double startTime, double endTime, float startValue, float endValue, double time) {
if (startValue * endValue < 0 || startValue == 0) {
return startValue;
}

if (time < startTime) {
return startValue;
}
Expand Down Expand Up @@ -143,6 +147,10 @@ void AudioParam::setTargetAtTime(float target, double startTime, double timeCons
// Exponential decay function towards target value
auto calculateValue = [timeConstant, target](
double startTime, double, float startValue, float, double time) {
if (timeConstant == 0) {
return target;
}

if (time < startTime) {
return startValue;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native-audio-api/src/core/AudioParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export default class AudioParam {
value: number,
endTime: number
): AudioParam {
if (value === 0) {
throw new RangeError(`value must be a non-zero number: ${value}`);
}

if (endTime <= 0) {
throw new RangeError(
`endTime must be a finite non-negative number: ${endTime}`
Expand Down
Loading