Skip to content

Audio pitch change implementation #1510

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

Merged
merged 11 commits into from
May 12, 2022
20 changes: 18 additions & 2 deletions src/lime/_internal/backend/native/NativeAudioSource.hx
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class NativeAudioSource
timer.stop();
}

var timeRemaining = getLength() - value;
var timeRemaining = Std.int((getLength() - getCurrentTime()) / getPitch());

if (timeRemaining > 0)
{
Expand Down Expand Up @@ -483,7 +483,7 @@ class NativeAudioSource
timer.stop();
}

var timeRemaining = value - getCurrentTime();
var timeRemaining = Std.int((getLength() - getCurrentTime()) / getPitch());

if (timeRemaining > 0)
{
Expand Down Expand Up @@ -514,6 +514,22 @@ class NativeAudioSource
{
AL.sourcef(handle, AL.PITCH, value);

if (playing)
{
if (timer != null)
{
timer.stop();
}

var timeRemaining = Std.int((getLength() - getCurrentTime()) / getPitch());

if (timeRemaining > 0)
{
timer = new Timer(timeRemaining);
timer.run = timer_onRun;
}
}

return getPitch();
}

Expand Down