Go で書き直した Ikemen
リビジョン | 9304ddb84d0a2893606fb9ced7d0d0891d9f1508 (tree) |
---|---|
日時 | 2019-05-15 20:38:07 |
作者 | neatunsou <sisiy4excite@gmai...> |
コミッター | neatunsou |
config.jsonにMasterVolume、WavVolume、BgmVolume、AudioDuckingを追加
MasterVolume、WavVolume、BgmVolumeはMUGENのと似たような機能
AudioDuckingは元々あった音量のノーマライザーをオプション化したもので、有効にするとWavVolumeが無効になる
@@ -79,6 +79,9 @@ func main() { | ||
79 | 79 | "PlayerProjectileMax":256, |
80 | 80 | "ExplodMax":512, |
81 | 81 | "AfterImageMax":128, |
82 | + "MasterVolume":100, | |
83 | + "WavVolume":100, | |
84 | + "BgmVolume":100, | |
82 | 85 | "Attack.LifeToPowerMul":0.7, |
83 | 86 | "GetHit.LifeToPowerMul":0.6, |
84 | 87 | "Width":640, |
@@ -126,6 +129,7 @@ func main() { | ||
126 | 129 | "TeamPowerShare":false, |
127 | 130 | "TeamLifeShare":false, |
128 | 131 | "Fullscreen":false, |
132 | + "AudioDucking":false, | |
129 | 133 | "AllowDebugKeys":true, |
130 | 134 | "PostProcessingShader":0, |
131 | 135 | "IP":{ |
@@ -137,6 +141,9 @@ func main() { | ||
137 | 141 | PlayerProjectileMax int |
138 | 142 | ExplodMax int |
139 | 143 | AfterImageMax int32 |
144 | + MasterVolume int | |
145 | + WavVolume int | |
146 | + BgmVolume int | |
140 | 147 | Attack_LifeToPowerMul float32 `json:"Attack.LifeToPowerMul"` |
141 | 148 | GetHit_LifeToPowerMul float32 `json:"GetHit.LifeToPowerMul"` |
142 | 149 | Width int32 |
@@ -152,15 +159,16 @@ func main() { | ||
152 | 159 | Joystick int |
153 | 160 | Buttons []interface{} |
154 | 161 | } |
155 | - NumTag int | |
156 | - TeamLifeShare bool | |
157 | - AIRandomColor bool | |
158 | - Fullscreen bool | |
159 | - AllowDebugKeys bool | |
162 | + NumTag int | |
163 | + TeamLifeShare bool | |
164 | + AIRandomColor bool | |
165 | + Fullscreen bool | |
166 | + AudioDucking bool | |
167 | + AllowDebugKeys bool | |
160 | 168 | PostProcessingShader int32 |
161 | - CommonAir string | |
162 | - CommonCmd string | |
163 | - QuickLaunch bool | |
169 | + CommonAir string | |
170 | + CommonCmd string | |
171 | + QuickLaunch bool | |
164 | 172 | }{} |
165 | 173 | chk(json.Unmarshal(defcfg, &tmp)) |
166 | 174 | const configFile = "data/config.json" |
@@ -185,6 +193,10 @@ func main() { | ||
185 | 193 | sys.super_TargetDefenceMul = tmp.Super_TargetDefenceMul |
186 | 194 | sys.lifebarFontScale = tmp.LifebarFontScale |
187 | 195 | sys.quickLaunch = tmp.QuickLaunch |
196 | + sys.masterVolume = tmp.MasterVolume | |
197 | + sys.wavVolume = tmp.WavVolume | |
198 | + sys.bgmVolume = tmp.BgmVolume | |
199 | + sys.AudioDucking = tmp.AudioDucking | |
188 | 200 | stoki := func(key string) int { |
189 | 201 | return int(StringToKey(key)) |
190 | 202 | } |
@@ -10,6 +10,7 @@ import ( | ||
10 | 10 | "github.com/timshannon/go-openal/openal" |
11 | 11 | |
12 | 12 | "github.com/faiface/beep" |
13 | + "github.com/faiface/beep/effects" | |
13 | 14 | "github.com/faiface/beep/flac" |
14 | 15 | "github.com/faiface/beep/mp3" |
15 | 16 | "github.com/faiface/beep/speaker" |
@@ -179,13 +180,17 @@ func NewNormalizer() *Normalizer { | ||
179 | 180 | func (n *Normalizer) Process(l, r float32) (float32, float32) { |
180 | 181 | lmul := n.l.process(n.mul, &l) |
181 | 182 | rmul := n.r.process(n.mul, &r) |
182 | - if lmul < rmul { | |
183 | - n.mul = lmul | |
183 | + if sys.AudioDucking { | |
184 | + if lmul < rmul { | |
185 | + n.mul = lmul | |
186 | + } else { | |
187 | + n.mul = rmul | |
188 | + } | |
189 | + if n.mul > 16 { | |
190 | + n.mul = 16 | |
191 | + } | |
184 | 192 | } else { |
185 | - n.mul = rmul | |
186 | - } | |
187 | - if n.mul > 16 { | |
188 | - n.mul = 16 | |
193 | + n.mul = 0.5 * (float64(sys.wavVolume) * float64(sys.masterVolume) * 0.0001) | |
189 | 194 | } |
190 | 195 | return l, r |
191 | 196 | } |
@@ -303,6 +308,8 @@ func (bgm *Bgm) ReadVorbis() { | ||
303 | 308 | |
304 | 309 | func (bgm *Bgm) ReadFormat(s beep.StreamSeekCloser, format beep.Format) { |
305 | 310 | streamer := beep.Loop(-1, s) |
311 | + volume := -5 + float64(sys.bgmVolume)*0.05*(float64(sys.masterVolume)/100) | |
312 | + streamer = &effects.Volume{Streamer: streamer, Base: 2, Volume: volume, Silent: volume <= -5} | |
306 | 313 | resample := beep.Resample(int(3), format.SampleRate, beep.SampleRate(Mp3SampleRate), streamer) |
307 | 314 | bgm.ctrl = &beep.Ctrl{Streamer: resample} |
308 | 315 | speaker.Play(bgm.ctrl) |
@@ -240,6 +240,10 @@ type System struct { | ||
240 | 240 | timerCount []int32 |
241 | 241 | cmdFlags map[string]string |
242 | 242 | quickLaunch bool |
243 | + masterVolume int | |
244 | + wavVolume int | |
245 | + bgmVolume int | |
246 | + AudioDucking bool | |
243 | 247 | // Localcoord sceenpack |
244 | 248 | luaSpriteScale float64 |
245 | 249 | luaSmallPortraitScale float32 |