Skip to content

Commit

Permalink
Add SFX Volume and Star Power FX Controls to new audio engine (#106)
Browse files Browse the repository at this point in the history
* Add update check on startup (#91)

* Created update checker, runs on startup

* Add current version and update notification to main menu

* Update version back to 0.8.2

* Moved engine constants to `Constants`

* Awesomeness Detection (#89)

* Awesomeness detection

EXTREMLY IMPORTANT

* Awesomeness Detection

Very important!

* Pretty awesome if you ask me

* Add native bass library folders + READMEs for installation

* IAudioManager interface and BASS implementation

* Add ManagedBass to NuGet packages

* Change Play and AbstractTrack to use new audio engine

* Deleted old audio code and added StreamingAssets folder

* Add gitignore to ignore BASS libraries

* Adding generation of currentsong.text (#93)

This is mainly for OBS to show on twitch streams.
More stuff can be added but let's see if this works right first, ya? :)

* Added reverb to player stems when star power is active

* "ThirdParty" folder

* Fix lefty flip on 4 and 5 lane drums (#96)

* 4 lane drum lefty flip fix

* 5 lane drum lefty flip fix

* Updated credits

* Add PlasticBand-Unity for input mappings, and HIDrogen for Linux HID support (#95)

* Add PlasticBand-Unity package

* Switch Pro Guitar support to PlasticBand's

* Update input actions
Guitar actions now use PlasticBand
Removed most guitar UI actions, as they are covered by usages in PlasticBand

* Add HIDrogen package for HID support on Linux

* Fix lefty flip drum inputs (#99)

* fixed lefty flip drum inputs

* fixed bot drum lefty flip

* Re-enable incremental garbage collection (#101)

* Improve HO/PO overstrum forgiveness (#100)

* Allow anchoring chord HO/POs (togglable)

* Improve HO/PO overstrum forgiveness

* Small fix

* Add clap and starpower deploy sfx

* Add clap sfx to code

* Reverb keys stems and all drums stems

* Stem gain on SP and volume control settings

* Update and add new starpower SFX

* meta file update?

* Weird curly brace problem and 2 update checkers? Whats happening

* Add note miss sfx

* Add sfx volume and use star power fx controls. Play note miss on combo >= 10

---------

Co-authored-by: EliteAsian <lavasnakegaming@gmail.com>
Co-authored-by: TheFatBastid <tfb@sof.ws>
Co-authored-by: Rodrigo Oliveira <39157156+santorfo@users.noreply.github.com>
Co-authored-by: Nathan <nathanhurst03@gmail.com>
Co-authored-by: Raphael Goulart <contact@raphaelgoul.art>
  • Loading branch information
6 people authored Apr 16, 2023
1 parent 766dd17 commit d764d4a
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 69 deletions.
3 changes: 2 additions & 1 deletion Assets/Script/Audio/AudioEnums.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace YARG {
public enum SongStem {
Master = -1,
Master = -2,
Sfx = -1,
Song,
Guitar,
Bass,
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Audio/AudioHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static class AudioHelpers {
};

public static readonly IList<double> SfxVolume = new[] {
0.5,
0.7,
0.3,
0.5,
0.3,
Expand Down
13 changes: 11 additions & 2 deletions Assets/Script/Audio/BassAudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace YARG {
public class BassAudioManager : MonoBehaviour, IAudioManager {
public bool UseStarpowerFx { get; set; }

public IList<string> SupportedFormats { get; private set; }

public int StemsLoaded { get; private set; }
Expand All @@ -32,6 +34,8 @@ public class BassAudioManager : MonoBehaviour, IAudioManager {

private double[] stemVolumes;

private double sfxVolume;

private DSPProcedure dspGain;

private Dictionary<int, Dictionary<EffectType, int>> stemEffects;
Expand Down Expand Up @@ -259,7 +263,7 @@ public void PlaySoundEffect(SfxSample sample) {
}

int channel = Bass.SampleGetChannel(sfxSamples[(int) sample]);
Bass.ChannelSetAttribute(channel, ChannelAttribute.Volume, AudioHelpers.SfxVolume[(int) sample]);
Bass.ChannelSetAttribute(channel, ChannelAttribute.Volume, sfxVolume * AudioHelpers.SfxVolume[(int) sample]);

Bass.ChannelPlay(channel);
}
Expand All @@ -282,7 +286,12 @@ public void UpdateVolumeSetting(SongStem stem, double volume) {
Bass.GlobalStreamVolume = (int)(10_000 * volume);
return;
}


if (stem == SongStem.Sfx) {
sfxVolume = volume;
return;
}

stemVolumes[(int)stem] = volume;
}

Expand Down
2 changes: 2 additions & 0 deletions Assets/Script/Audio/IAudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace YARG {
public interface IAudioManager {

public bool UseStarpowerFx { get; set; }

public IList<string> SupportedFormats { get; }

public int StemsLoaded { get; }
Expand Down
6 changes: 5 additions & 1 deletion Assets/Script/PlayMode/AbstractTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public EventInfo StarpowerSection {
protected int Combo {
get => _combo;
set {
if (_combo >= 10 && value == 0) {
GameManager.AudioManager.PlaySoundEffect(SfxSample.NoteMiss);
}

_combo = value;

// End starpower if combo ends
Expand Down Expand Up @@ -249,7 +253,7 @@ private void UpdateInfo() {
}

private void BeatAction() {
if (starpowerActive) {
if (starpowerActive && GameManager.AudioManager.UseStarpowerFx) {
GameManager.AudioManager.PlaySoundEffect(SfxSample.Clap);
}
Beat = true;
Expand Down
77 changes: 20 additions & 57 deletions Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,46 +184,6 @@ private void Update() {
return;
}

// Audio raising and lowering based on player preformance
if (SettingsManager.GetSettingValue<bool>("muteOnMiss")) {
// Mute guitars
UpdateAudio(new string[] {
"guitar",
"realGuitar"
}, new string[] {
"guitar"
});

// Mute bass
UpdateAudio(new string[] {
"bass",
"realBass"
}, new string[] {
"bass",
"rhythm"
});

// Mute keys
UpdateAudio(new string[] {
"keys",
"realKeys"
}, new string[] {
"keys"
});

// Mute drums
UpdateAudio(new string[] {
"drums",
"realDrums"
}, new string[] {
"drums",
"drums_1",
"drums_2",
"drums_3",
"drums_4"
});
}

UpdateAudio(new string[] {
"guitar",
"realGuitar"
Expand Down Expand Up @@ -327,24 +287,27 @@ private void UpdateAudio(string[] trackNames, string[] stemNames) {
}

// Reverb audio with starpower

foreach (var name in stemNames) {
var stem = AudioHelpers.GetStemFromName(name);

if(GameManager.AudioManager.UseStarpowerFx)
{
foreach (var name in stemNames) {
var stem = AudioHelpers.GetStemFromName(name);

bool applyReverb = audioReverb.GetCount(name) > 0;

// Drums have multiple stems so need to reverb them all if it is drums
switch (stem) {
case SongStem.Drums:
GameManager.AudioManager.ApplyReverb(SongStem.Drums, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums1, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums2, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums3, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums4, applyReverb);
break;
default:
GameManager.AudioManager.ApplyReverb(stem, applyReverb);
break;
bool applyReverb = audioReverb.GetCount(name) > 0;

// Drums have multiple stems so need to reverb them all if it is drums
switch (stem) {
case SongStem.Drums:
GameManager.AudioManager.ApplyReverb(SongStem.Drums, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums1, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums2, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums3, applyReverb);
GameManager.AudioManager.ApplyReverb(SongStem.Drums4, applyReverb);
break;
default:
GameManager.AudioManager.ApplyReverb(stem, applyReverb);
break;
}
}
}
}
Expand Down
39 changes: 32 additions & 7 deletions Assets/Script/Settings/SettingsManager.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public void LowQualityChange() {
[SettingType("Toggle")]
public bool showHitWindow = false;

[SettingLocation("general", 8)]
[SettingType("Toggle")]
public bool useAudioTime = false;

[SettingLocation("general", 9)]
[SettingType("Toggle")]
public bool muteOnMiss = true;
Expand Down Expand Up @@ -135,6 +131,16 @@ public void SongVolumeChange() {
public void GuitarVolumeChange() {
GameManager.AudioManager.UpdateVolumeSetting(SongStem.Guitar, guitarVolume);
}

[SettingShowInGame]
[SettingLocation("general", 17)]
[SettingType("Volume")]
public float rhythmVolume = 1f;

[SettingChangeFunc("rhythmVolume")]
public void RhythmVolumeChange() {
GameManager.AudioManager.UpdateVolumeSetting(SongStem.Rhythm, rhythmVolume);
}

[SettingShowInGame]
[SettingLocation("general", 17)]
Expand All @@ -144,7 +150,6 @@ public void GuitarVolumeChange() {
[SettingChangeFunc("bassVolume")]
public void BassVolumeChange() {
GameManager.AudioManager.UpdateVolumeSetting(SongStem.Bass, bassVolume);
GameManager.AudioManager.UpdateVolumeSetting(SongStem.Rhythm, bassVolume);
}

[SettingShowInGame]
Expand Down Expand Up @@ -202,10 +207,30 @@ public void MusicVolumeChange() {
public void CrowdVolumeChange() {
GameManager.AudioManager.UpdateVolumeSetting(SongStem.Crowd, crowdVolume);
}

[SettingShowInGame]
[SettingLocation("general", 23)]
[SettingType("Volume")]
public float sfxVolume = 0f;

[SettingChangeFunc("sfxVolume")]
public void SfxVolumeChange() {
GameManager.AudioManager.UpdateVolumeSetting(SongStem.Sfx, sfxVolume);
}

[SettingShowInGame]
[SettingLocation("general", 24)]
[SettingType("Toggle")]
public bool useStarpowerFx = true;

[SettingChangeFunc("useStarpowerFx")]
public void UseStarpowerFxChange() {
GameManager.AudioManager.UseStarpowerFx = useStarpowerFx;
}

[SettingShowInGame]
[SettingLocation("general", 25)]
[SettingType("Volume")]
public float vocalMonitoring = 0.75f;

[SettingChangeFunc("vocalMonitoring")]
Expand All @@ -215,7 +240,7 @@ public void VocalMonitoringChange() {

[SettingSpace]
[SettingShowInGame]
[SettingLocation("general", 24)]
[SettingLocation("general", 26)]
[SettingType("Toggle")]
public bool amIAwesome = false;
}
Expand Down
12 changes: 12 additions & 0 deletions Assets/Settings/Localization/Settings Shared Data.asset
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ MonoBehaviour:
m_Key: copyCurrentSongTextFilePath
m_Metadata:
m_Items: []
- m_Id: 7748727102816256
m_Key: sfxVolume
m_Metadata:
m_Items: []
- m_Id: 7748836536401920
m_Key: useStarpowerFx
m_Metadata:
m_Items: []
- m_Id: 7760843058757632
m_Key: rhythmVolume
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
12 changes: 12 additions & 0 deletions Assets/Settings/Localization/Settings_en-US.asset
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ MonoBehaviour:
m_Localized: Copy "Current Song" Text File Path
m_Metadata:
m_Items: []
- m_Id: 7748727102816256
m_Localized: SFX Volume
m_Metadata:
m_Items: []
- m_Id: 7748836536401920
m_Localized: Use Star Power FX
m_Metadata:
m_Items: []
- m_Id: 7760843058757632
m_Localized: Rhythm Volume
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
Binary file added Assets/StreamingAssets/sfx/note_miss.ogg
Binary file not shown.
7 changes: 7 additions & 0 deletions Assets/StreamingAssets/sfx/note_miss.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d764d4a

Please sign in to comment.