-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix static sounds due to bad sample memory access in loop
- Loading branch information
1 parent
467d312
commit f24bcab
Showing
1 changed file
with
14 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* Author: Romain "Artefact2" Dalmaso <[email protected]> */ | ||
/* Contributor: Daniel Oaks <[email protected]> */ | ||
|
||
/* This program is free software. It comes without any warranty, to the | ||
* extent permitted by applicable law. You can redistribute it and/or | ||
|
@@ -1209,6 +1210,9 @@ static float xm_next_of_sample(xm_channel_context_t* ch) { | |
} | ||
return .0f; | ||
} | ||
if(ch->sample->length == 0) { | ||
return .0f; | ||
} | ||
|
||
float u, v, t; | ||
uint32_t a, b; | ||
|
@@ -1262,6 +1266,11 @@ static float xm_next_of_sample(xm_channel_context_t* ch) { | |
ch->ping = false; | ||
ch->sample_position = (ch->sample->loop_end << 1) - ch->sample_position; | ||
} | ||
/* sanity checking */ | ||
if(ch->sample_position >= ch->sample->length) { | ||
ch->ping = false; | ||
ch->sample_position -= ch->sample->length - 1; | ||
} | ||
} else { | ||
if(XM_LINEAR_INTERPOLATION) { | ||
v = u; | ||
|
@@ -1271,6 +1280,11 @@ static float xm_next_of_sample(xm_channel_context_t* ch) { | |
ch->ping = true; | ||
ch->sample_position = (ch->sample->loop_start << 1) - ch->sample_position; | ||
} | ||
/* sanity checking */ | ||
if(ch->sample_position <= .0f) { | ||
ch->ping = true; | ||
ch->sample_position = .0f; | ||
} | ||
} | ||
break; | ||
|
||
|