@@ -24,6 +24,8 @@ public sealed class Mod : MonoBehaviour
2424
2525 public ConfigLogic Config { get ; private set ; }
2626
27+ public AudioManager audioManager { get ; set ; }
28+
2729 /// <summary>
2830 /// Method called as soon as the mod is loaded.
2931 /// WARNING: Do not load asset bundles/textures in this function
@@ -79,6 +81,23 @@ public void Initialize(IManager manager)
7981 }
8082 }
8183
84+ /*private void Update()
85+ {
86+ if (Input.anyKey)
87+ {
88+ if (Input.GetKey(KeyCode.O))
89+ audioManager.lowPassFreq_ += 10;
90+ if (Input.GetKey(KeyCode.P))
91+ audioManager.lowPassFreq_ -= 10;
92+ if (Input.GetKey(KeyCode.K))
93+ audioManager.highPassFreq_ += 1;
94+ if (Input.GetKey(KeyCode.L))
95+ audioManager.highPassFreq_ -= 1;
96+
97+ audioManager.SetCustomMusicDSP(audioManager.lowPassFreq_, audioManager.highPassFreq_, false);
98+ }
99+ }*/
100+
82101 private void CreateSettingsMenu ( )
83102 {
84103 MenuTree settingsMenu = new MenuTree ( "menu.mod.littlethings" , "Little Thing Settings" )
@@ -102,6 +121,11 @@ private void CreateSettingsMenu()
102121 . WithGetter ( ( ) => Config . ActiveCompass )
103122 . WithSetter ( ( x ) => Config . ActiveCompass = x )
104123 . WithDescription ( "The compass will always stay active on the carscreen and never change" ) ,
124+
125+ new CheckBox ( MenuDisplayMode . Both , "settings::enable_lowpass" , "ENABLE CUSTOM LOWPASS FILTERS" )
126+ . WithGetter ( ( ) => Config . EnableCustomLowpass )
127+ . WithSetter ( ( x ) => Config . EnableCustomLowpass = x )
128+ . WithDescription ( "Toggles whether or not lowpass filters get applied to custom music." ) ,
105129 } ;
106130
107131 Menus . AddNew ( MenuDisplayMode . Both , settingsMenu , "LITTLE THINGS" , "Settings for the LittleThings mod" ) ;
@@ -111,7 +135,32 @@ public void OnConfigChanged(ConfigLogic configLogic)
111135 {
112136
113137 }
114- }
138+
139+ public System . Collections . IEnumerator CustomMusicDSP ( float lowpassEnd , float timer )
140+ {
141+ if ( audioManager == null )
142+ yield break ;
143+
144+ if ( audioManager . sampleAggregator_ == null || ! audioManager . audioSettings_ . AffectedByGameplay_ )
145+ yield break ;
146+
147+ if ( audioManager . lowPassFreq_ . ApproxEquals ( lowpassEnd ) )
148+ yield break ;
149+
150+ float startLowFreq = ( float ) Math . Log10 ( ( double ) audioManager . lowPassFreq_ ) ;
151+ float endLowFreq = ( float ) Math . Log10 ( ( double ) lowpassEnd ) ;
152+ float time = 0f ;
153+ while ( time < timer )
154+ {
155+ audioManager . lowPassFreq_ = ( float ) Math . Pow ( 10.0 , ( double ) Mathf . Lerp ( startLowFreq , endLowFreq , time / timer ) ) ;
156+ audioManager . SetCustomMusicDSP ( audioManager . lowPassFreq_ , audioManager . highPassFreq_ , false ) ;
157+ time += Time . deltaTime ;
158+ yield return null ;
159+ }
160+ audioManager . SetCustomMusicDSP ( ( float ) Math . Pow ( 10.0 , ( double ) endLowFreq ) , - 1f , false ) ;
161+ yield break ;
162+ }
163+ }
115164}
116165
117166
0 commit comments