Skip to content

Commit db7c62d

Browse files
committed
pretty lil filter
1 parent fce087b commit db7c62d

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

source/archipelago/APPlayState.hx

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,10 +2036,12 @@ class APPlayState extends PlayState {
20362036

20372037
public var isFrozen:Bool = false;
20382038
var doRandomize:Bool = false;
2039+
var lowpass:FlxSoundFilter;
2040+
var lowpassVocal:FlxSoundFilter;
20392041
override public function update(elapsed:Float)
20402042
{
20412043

2042-
if (archipelago.APInfo.inMinigame != None)
2044+
if (archipelago.APInfo.inMinigame != None)
20432045
{
20442046
// Save current state before switching to minigame
20452047
if (APEntryState.apGame != null) {
@@ -2247,43 +2249,30 @@ class APPlayState extends PlayState {
22472249
}
22482250
trace("Triggering DeathLink!");
22492251
}
2252+
2253+
if (lowpass == null) {
2254+
lowpass = new FlxSoundFilter();
2255+
lowpass.filterType = FlxSoundFilterType.LOWPASS;
2256+
add(lowpass);
2257+
2258+
lowpassVocal = new FlxSoundFilter();
2259+
lowpassVocal.filterType = FlxSoundFilterType.LOWPASS;
2260+
add(lowpassVocal);
2261+
2262+
lowpass.applyFilter(FlxG.sound.music);
2263+
lowpassVocal.applyFilter(vocal);
2264+
lowpassVocal.applyFilter(opponentVocals);
2265+
}
2266+
22502267
#if cpp
22512268
if(FlxG.sound.music != null && FlxG.sound.music.playing)
2252-
{
2253-
@:privateAccess
2254-
{
2255-
var af = lime.media.openal.AL.createFilter(); // create AudioFilter
2256-
lime.media.openal.AL.filteri( af, lime.media.openal.AL.FILTER_TYPE, lime.media.openal.AL.FILTER_LOWPASS ); // set filter type
2257-
lime.media.openal.AL.filterf( af, lime.media.openal.AL.LOWPASS_GAIN, 1 ); // set gain
2258-
lime.media.openal.AL.filterf( af, lime.media.openal.AL.LOWPASS_GAINHF, lowFilterAmount ); // set gainhf
2259-
lime.media.openal.AL.sourcei( FlxG.sound.music._channel.__audioSource.__backend.handle, lime.media.openal.AL.DIRECT_FILTER, af ); // apply filter to source (handle)
2260-
//lime.media.openal.AL.sourcef(FlxG.sound.music._channel.__audioSource.__backend.handle, lime.media.openal.AL.HIGHPASS_GAIN, 0);
2261-
}
2262-
}
2269+
lowpass.gainHF = lowFilterAmount;
2270+
22632271
if(vocals != null && vocals.playing)
2264-
{
2265-
@:privateAccess
2266-
{
2267-
var af = lime.media.openal.AL.createFilter(); // create AudioFilter
2268-
lime.media.openal.AL.filteri( af, lime.media.openal.AL.FILTER_TYPE, lime.media.openal.AL.FILTER_LOWPASS ); // set filter type
2269-
lime.media.openal.AL.filterf( af, lime.media.openal.AL.LOWPASS_GAIN, 1 ); // set gain
2270-
lime.media.openal.AL.filterf( af, lime.media.openal.AL.LOWPASS_GAINHF, vocalLowFilterAmount ); // set gainhf
2271-
lime.media.openal.AL.sourcei( vocals._channel.__audioSource.__backend.handle, lime.media.openal.AL.DIRECT_FILTER, af ); // apply filter to source (handle)
2272-
//lime.media.openal.AL.sourcef(FlxG.sound.music._channel.__audioSource.__backend.handle, lime.media.openal.AL.HIGHPASS_GAIN, 0);
2273-
}
2274-
}
2272+
lowpassVocal.gainHF = vocalLowFilterAmount;
2273+
22752274
if(opponentVocals != null && opponentVocals.playing)
2276-
{
2277-
@:privateAccess
2278-
{
2279-
var af = lime.media.openal.AL.createFilter(); // create AudioFilter
2280-
lime.media.openal.AL.filteri( af, lime.media.openal.AL.FILTER_TYPE, lime.media.openal.AL.FILTER_LOWPASS ); // set filter type
2281-
lime.media.openal.AL.filterf( af, lime.media.openal.AL.LOWPASS_GAIN, 1 ); // set gain
2282-
lime.media.openal.AL.filterf( af, lime.media.openal.AL.LOWPASS_GAINHF, vocalLowFilterAmount ); // set gainhf
2283-
lime.media.openal.AL.sourcei( opponentVocals._channel.__audioSource.__backend.handle, lime.media.openal.AL.DIRECT_FILTER, af ); // apply filter to source (handle)
2284-
//lime.media.openal.AL.sourcef(FlxG.sound.music._channel.__audioSource.__backend.handle, lime.media.openal.AL.HIGHPASS_GAIN, 0);
2285-
}
2286-
}
2275+
lowpassVocal.gainHF = vocalLowFilterAmount;
22872276

22882277
/*if(gfVocals != null && gfVocals.playing)
22892278
{
@@ -2314,6 +2303,7 @@ class APPlayState extends PlayState {
23142303
}
23152304
}*/
23162305
#end
2306+
23172307
curEffect = FlxG.random.int(0, 38);
23182308
if (isFrozen) boyfriend.stunned = true;
23192309
if (notes != null)

0 commit comments

Comments
 (0)