Update Audio Backend from Vs Camellia v2.75.1 (info at desc)

Before anyone asks why vs cam, the code is public, plus i helped most of the audio backend rewrite in the mod too. :P

- Static sounds can now also seamlessly loop with AL_SOFT_loop_points extension
- Panning stereo sounds is now possible with AL_EXT_STEREO_ANGLES extension (although this was already implemented before)
- Improved streaming sounds, should fix most of the lagspike issues
- Streaming sounds should no longer regenrate if it's in the nearest timestamp (not for reversing though)
! You still can't access FlxSound.latency because of the new procedures that's not available in lime

If there's any crashes with this pls report an issue asap.
This commit is contained in:
Ralty
2025-11-16 15:22:58 +07:00
parent bbe3464085
commit 5d8a9c71a2
8 changed files with 588 additions and 411 deletions
+5 -12
View File
@@ -137,7 +137,6 @@ import lime.media.openal.AL;
#if lime
__source.onComplete.remove(source_onComplete);
__source.onLoop.remove(source_onLoop);
__source.dispose();
__source = null;
#end
@@ -165,14 +164,14 @@ import lime.media.openal.AL;
#if lime_cffi
var backend = __source.__backend, i = 0;
if (backend.streamed) {
size = backend.bufferSizes[i = backend.bufferSizes.length - backend.queuedBuffers];
size = backend.bufferLengths[i = backend.bufferLengths.length - backend.queuedBuffers];
buf = backend.bufferDatas[i].buffer;
pos -= Math.floor(backend.bufferTimes[i] * buffer.sampleRate * buffer.channels * wordSize);
while (pos > size) {
if (++i >= backend.bufferSizes.length) return false;
if (++i >= backend.bufferLengths.length) return false;
pos -= size;
buf = backend.bufferDatas[i].buffer;
size = backend.bufferSizes[i];
size = backend.bufferLengths[i];
}
}
else
@@ -189,10 +188,10 @@ import lime.media.openal.AL;
if (c % 2 == 0) ((b > leftMax) ? (leftMax = b) : (if ((b = -b) > leftMin) (leftMin = b)));
else ((b > rightMax) ? (rightMax = b) : (if ((b = -b) > rightMin) (rightMin = b)));
if ((pos += wordSize) >= size) #if lime_cffi {
if (!backend.streamed || ++i >= backend.bufferSizes.length) break;
if (!backend.streamed || ++i >= backend.bufferLengths.length) break;
pos = 0;
buf = backend.bufferDatas[i].buffer;
size = backend.bufferSizes[i];
size = backend.bufferLengths[i];
}
#else break; #end
@@ -222,7 +221,6 @@ import lime.media.openal.AL;
}
__source.onComplete.add(source_onComplete);
__source.onLoop.add(source_onLoop);
__isValid = true;
__source.play();
@@ -394,11 +392,6 @@ import lime.media.openal.AL;
dispatchEvent(new Event(Event.SOUND_COMPLETE));
}
@:noCompletion private function source_onLoop():Void
{
//dispatchEvent(new Event(Event.SOUND_LOOP));
}
@:noCompletion private function get___audioSource():AudioSource return __source;
@:noCompletion private function set___audioSource(source:AudioSource):AudioSource return __source = source;
}