-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
potentially jank/problematic. feel free to do your own magic on top of this or clean up shit.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using BAKKA_Editor.Enums; | ||
using BAKKA_Editor.SoundEngines; | ||
using BAKKA_Editor.Views; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace BAKKA_Editor.Audio; | ||
|
||
internal class Hitsounds | ||
{ | ||
private IBakkaSampleChannel? hitsoundChannel; | ||
private IBakkaSampleChannel? hitsoundSwipeChannel; | ||
private IBakkaSampleChannel? hitsoundBonusChannel; | ||
private IBakkaSampleChannel? hitsoundFlairChannel; | ||
|
||
private IBakkaSample? hitsoundSample; | ||
private IBakkaSample? hitsoundSwipeSample; | ||
private IBakkaSample? hitsoundBonusSample; | ||
private IBakkaSample? hitsoundFlairSample; | ||
private UserSettings userSettings; | ||
private MainView mainView; | ||
|
||
public Hitsounds(UserSettings settings, MainView main) | ||
{ | ||
userSettings = settings; | ||
mainView = main; | ||
} | ||
|
||
public void LoadSamples(string hitsoundPath, string hitsoundSwipePath, string hitsoundBonusPath, string hitsoundFlairPath) | ||
{ | ||
hitsoundSample = new BassBakkaSample(hitsoundPath); | ||
hitsoundSwipeSample = new BassBakkaSample(hitsoundSwipePath); | ||
hitsoundBonusSample = new BassBakkaSample(hitsoundBonusPath); | ||
hitsoundFlairSample = new BassBakkaSample(hitsoundFlairPath); | ||
|
||
if (hitsoundSample.Loaded) hitsoundChannel = hitsoundSample.GetChannel(); | ||
if (hitsoundSwipeSample.Loaded) hitsoundSwipeChannel = hitsoundSwipeSample.GetChannel(); | ||
if (hitsoundBonusSample.Loaded) hitsoundBonusChannel = hitsoundBonusSample.GetChannel(); | ||
if (hitsoundFlairSample.Loaded) hitsoundFlairChannel = hitsoundFlairSample.GetChannel(); | ||
} | ||
|
||
public bool LoadError() | ||
{ | ||
if (userSettings.SoundSettings.HitsoundEnabled && !hitsoundSample.Loaded | ||
Check warning on line 44 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (win-x64)
Check warning on line 44 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (linux-x64)
Check warning on line 44 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (osx-arm64)
|
||
||(userSettings.SoundSettings.HitsoundSwipeEnabled && !hitsoundSwipeSample.Loaded) | ||
Check warning on line 45 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (win-x64)
Check warning on line 45 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (linux-x64)
Check warning on line 45 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (osx-arm64)
|
||
|| (userSettings.SoundSettings.HitsoundBonusEnabled && !hitsoundBonusSample.Loaded) | ||
Check warning on line 46 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (win-x64)
Check warning on line 46 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (linux-x64)
Check warning on line 46 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (osx-arm64)
|
||
|| (userSettings.SoundSettings.HitsoundFlairEnabled && !hitsoundFlairSample.Loaded)) | ||
Check warning on line 47 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (win-x64)
Check warning on line 47 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (linux-x64)
Check warning on line 47 in BAKKA_Editor/Audio/Hitsounds.cs GitHub Actions / build (osx-arm64)
|
||
return true; | ||
|
||
return false; | ||
} | ||
|
||
public bool ChannelsExist() | ||
{ | ||
if ((userSettings.SoundSettings.HitsoundEnabled && hitsoundChannel != null) | ||
|| (userSettings.SoundSettings.HitsoundSwipeEnabled && hitsoundSwipeChannel != null) | ||
|| (userSettings.SoundSettings.HitsoundBonusEnabled && hitsoundBonusChannel != null) | ||
|| (userSettings.SoundSettings.HitsoundFlairEnabled && hitsoundFlairChannel != null)) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
public void SetVolume(float volume) | ||
{ | ||
hitsoundChannel?.SetVolume(volume); | ||
hitsoundSwipeChannel?.SetVolume(volume); | ||
hitsoundBonusChannel?.SetVolume(volume); | ||
hitsoundFlairChannel?.SetVolume(volume); | ||
} | ||
|
||
public void Play(Note note, float lastMeasure) | ||
{ | ||
if (note.NoteType is NoteType.EndOfChart or NoteType.MaskAdd or NoteType.MaskRemove or NoteType.HoldJoint) return; | ||
|
||
if (note.BeatInfo.MeasureDecimal > lastMeasure) | ||
{ | ||
if ((note.IsSnap || note.IsSlide) && userSettings.SoundSettings.HitsoundSwipeEnabled) hitsoundSwipeChannel?.Play(true); | ||
else if (userSettings.SoundSettings.HitsoundEnabled) hitsoundChannel?.Play(true); | ||
if (note.IsBonus && userSettings.SoundSettings.HitsoundBonusEnabled) hitsoundBonusChannel?.Play(true); | ||
if (note.IsFlair && userSettings.SoundSettings.HitsoundFlairEnabled) hitsoundFlairChannel?.Play(true); | ||
} | ||
} | ||
} | ||
|