Skip to content

Commit

Permalink
clean the pitching code
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealJake12 committed Nov 12, 2023
1 parent 1569409 commit ffd5433
Show file tree
Hide file tree
Showing 2 changed files with 1,333 additions and 1,546 deletions.
171 changes: 15 additions & 156 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ class PlayState extends MusicBeatState

playerStrums = new FlxTypedGroup<StaticArrow>();
cpuStrums = new FlxTypedGroup<StaticArrow>();

if (SONG.noteStyle == 'pixel')
{
noteskinPixelSprite = CustomNoteHelpers.Skin.generatePixelSprite(FlxG.save.data.noteskin);
Expand Down Expand Up @@ -1893,7 +1893,6 @@ class PlayState extends MusicBeatState
{
if (inCinematic || inCutscene)
{

if (!arrowsGenerated)
{
generateStaticArrows(1, true);
Expand Down Expand Up @@ -2596,7 +2595,6 @@ class PlayState extends MusicBeatState
vocalsEnemy = new FlxSound();
vocalsPlayer = new FlxSound();
}

#end

if (FlxG.save.data.gen)
Expand Down Expand Up @@ -3138,11 +3136,8 @@ class PlayState extends MusicBeatState
}
}

#if cpp
if (inst.playing)
@:privateAccess
{
#if (lime >= "8.0.0")
inst.pitch = songMultiplier;
if (!SONG.splitVoiceTracks)
{
Expand All @@ -3157,62 +3152,7 @@ class PlayState extends MusicBeatState
vocalsEnemy.pitch = songMultiplier;
}
}
#else
lime.media.openal.AL.sourcef(inst._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, songMultiplier);
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
lime.media.openal.AL.sourcef(vocals._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, songMultiplier);
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
lime.media.openal.AL.sourcef(vocalsPlayer._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, songMultiplier);
lime.media.openal.AL.sourcef(vocalsEnemy._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, songMultiplier);
}
}
#end
}
#elseif html5
if (inst.playing)
@:privateAccess
{
#if lime_howlerjs
#if (lime >= "8.0.0")
inst._channel.__source.__backend.setPitch(songMultiplier);
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.setPitch(songMultiplier);
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.setPitch(songMultiplier);
vocalsEnemy._channel.__source.__backend.setPitch(songMultiplier);
}
}
#else
inst._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
}
else
{
if (vocalsPlayer.playing & vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
vocalsEnemy._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
}
}
#end
#end
}
#end

#if FEATURE_DISCORD
DiscordClient.changePresence(detailsText
Expand Down Expand Up @@ -3254,8 +3194,6 @@ class PlayState extends MusicBeatState
#if !debug
perfectMode = false;
#end
if (FlxG.save.data.background)
Stage.update(elapsed);

if (!addedBotplay && PlayStateChangeables.botPlay)
{
Expand Down Expand Up @@ -3323,11 +3261,8 @@ class PlayState extends MusicBeatState
if (nps >= 0)
updateScoreText();

#if cpp
if (inst.playing)
@:privateAccess
{
#if (lime >= "8.0.0")
inst.pitch = songMultiplier;
if (!SONG.splitVoiceTracks)
{
Expand All @@ -3342,85 +3277,7 @@ class PlayState extends MusicBeatState
vocalsEnemy.pitch = songMultiplier;
}
}
#elseif html5
if (inst.playing)
@:privateAccess
{
#if lime_howlerjs
#if (lime >= "8.0.0")
inst._channel.__source.__backend.setPitch(songMultiplier);
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.setPitch(songMultiplier);
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.setPitch(songMultiplier);
vocalsEnemy._channel.__source.__backend.setPitch(songMultiplier);
}
}
#else
inst._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
if (!SONG.splitVoiceTracks && vocals.playing)
{
if (vocals.playing)
vocals._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
vocalsEnemy._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
}
}
#end
#end
}
#end
}
#elseif html5
if (inst.playing)
@:privateAccess
{
#if lime_howlerjs
#if (lime >= "8.0.0")
inst._channel.__source.__backend.setPitch(songMultiplier);
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.setPitch(songMultiplier);
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.setPitch(songMultiplier);
vocalsEnemy._channel.__source.__backend.setPitch(songMultiplier);
}
}
#else
inst._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
if (!SONG.splitVoiceTracks)
{
if (vocals.playing)
vocals._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
}
else
{
if (vocalsPlayer.playing && vocalsEnemy.playing)
{
vocalsPlayer._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
vocalsEnemy._channel.__source.__backend.parent.buffer.__srcHowl.rate(songMultiplier);
}
}
#end
#end
}
#end

#if FEATURE_HSCRIPT
if (scripts != null)
Expand All @@ -3429,6 +3286,9 @@ class PlayState extends MusicBeatState

super.update(elapsed);

if (FlxG.save.data.background)
Stage.update(elapsed);

if (generatedMusic)
{
if (songStarted && !endingSong && isSM)
Expand Down Expand Up @@ -3530,7 +3390,7 @@ class PlayState extends MusicBeatState
{
char.playAnim(i.value2, true);
}
}
}
}
}
}
Expand Down Expand Up @@ -4479,7 +4339,7 @@ class PlayState extends MusicBeatState
{
luaModchart.executeState('onUpdatePost', [elapsed]);
}
#end
#end
#if FEATURE_HSCRIPT
if (scripts != null)
scripts.executeAllFunc("updatePost", [elapsed]);
Expand Down Expand Up @@ -5570,7 +5430,6 @@ class PlayState extends MusicBeatState
spawnNoteSplashOnNoteDad(daNote);
}
}


if (FlxG.save.data.cpuStrums)
{
Expand Down Expand Up @@ -6253,7 +6112,7 @@ class PlayState extends MusicBeatState
else
healthBar.createFilledBar(0xFFFF0000, 0xFF66FF33);
healthBar.updateBar();

PlayStateChangeables.botPlay = FlxG.save.data.botplay;

for (i in uiGroup)
Expand All @@ -6280,14 +6139,14 @@ class PlayState extends MusicBeatState
bar.alpha = 1;
}
}
botPlayState.kill();
uiGroup.remove(botPlayState);
if (PlayStateChangeables.botPlay)
{
botPlayState.revive();
uiGroup.add(botPlayState);
}

botPlayState.kill();
uiGroup.remove(botPlayState);
if (PlayStateChangeables.botPlay)
{
botPlayState.revive();
uiGroup.add(botPlayState);
}

if (FlxG.save.data.judgementCounter)
{
Expand Down
Loading

0 comments on commit ffd5433

Please sign in to comment.