• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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が無効になる

変更サマリ

差分

--- a/src/main.go
+++ b/src/main.go
@@ -79,6 +79,9 @@ func main() {
7979 "PlayerProjectileMax":256,
8080 "ExplodMax":512,
8181 "AfterImageMax":128,
82+ "MasterVolume":100,
83+ "WavVolume":100,
84+ "BgmVolume":100,
8285 "Attack.LifeToPowerMul":0.7,
8386 "GetHit.LifeToPowerMul":0.6,
8487 "Width":640,
@@ -126,6 +129,7 @@ func main() {
126129 "TeamPowerShare":false,
127130 "TeamLifeShare":false,
128131 "Fullscreen":false,
132+ "AudioDucking":false,
129133 "AllowDebugKeys":true,
130134 "PostProcessingShader":0,
131135 "IP":{
@@ -137,6 +141,9 @@ func main() {
137141 PlayerProjectileMax int
138142 ExplodMax int
139143 AfterImageMax int32
144+ MasterVolume int
145+ WavVolume int
146+ BgmVolume int
140147 Attack_LifeToPowerMul float32 `json:"Attack.LifeToPowerMul"`
141148 GetHit_LifeToPowerMul float32 `json:"GetHit.LifeToPowerMul"`
142149 Width int32
@@ -152,15 +159,16 @@ func main() {
152159 Joystick int
153160 Buttons []interface{}
154161 }
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
160168 PostProcessingShader int32
161- CommonAir string
162- CommonCmd string
163- QuickLaunch bool
169+ CommonAir string
170+ CommonCmd string
171+ QuickLaunch bool
164172 }{}
165173 chk(json.Unmarshal(defcfg, &tmp))
166174 const configFile = "data/config.json"
@@ -185,6 +193,10 @@ func main() {
185193 sys.super_TargetDefenceMul = tmp.Super_TargetDefenceMul
186194 sys.lifebarFontScale = tmp.LifebarFontScale
187195 sys.quickLaunch = tmp.QuickLaunch
196+ sys.masterVolume = tmp.MasterVolume
197+ sys.wavVolume = tmp.WavVolume
198+ sys.bgmVolume = tmp.BgmVolume
199+ sys.AudioDucking = tmp.AudioDucking
188200 stoki := func(key string) int {
189201 return int(StringToKey(key))
190202 }
--- a/src/sound.go
+++ b/src/sound.go
@@ -10,6 +10,7 @@ import (
1010 "github.com/timshannon/go-openal/openal"
1111
1212 "github.com/faiface/beep"
13+ "github.com/faiface/beep/effects"
1314 "github.com/faiface/beep/flac"
1415 "github.com/faiface/beep/mp3"
1516 "github.com/faiface/beep/speaker"
@@ -179,13 +180,17 @@ func NewNormalizer() *Normalizer {
179180 func (n *Normalizer) Process(l, r float32) (float32, float32) {
180181 lmul := n.l.process(n.mul, &l)
181182 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+ }
184192 } 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)
189194 }
190195 return l, r
191196 }
@@ -303,6 +308,8 @@ func (bgm *Bgm) ReadVorbis() {
303308
304309 func (bgm *Bgm) ReadFormat(s beep.StreamSeekCloser, format beep.Format) {
305310 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}
306313 resample := beep.Resample(int(3), format.SampleRate, beep.SampleRate(Mp3SampleRate), streamer)
307314 bgm.ctrl = &beep.Ctrl{Streamer: resample}
308315 speaker.Play(bgm.ctrl)
--- a/src/system.go
+++ b/src/system.go
@@ -240,6 +240,10 @@ type System struct {
240240 timerCount []int32
241241 cmdFlags map[string]string
242242 quickLaunch bool
243+ masterVolume int
244+ wavVolume int
245+ bgmVolume int
246+ AudioDucking bool
243247 // Localcoord sceenpack
244248 luaSpriteScale float64
245249 luaSmallPortraitScale float32