SoundBuffer: Set song volume

- Requires a new column in the database after preview: `volume` REAL
- The value is a volume multiplier, if the value is set to null or 1 there will be no change
- The volume can be set in debugger
- Imported TJA files are now read from disk every time the song is played, freeing some memory and making it easier to create charts
- Correctly parse TJA files with alphabet notes, added "A" and "B" notes, which appear as DON (Big) and KA (Big) respectively
This commit is contained in:
LoveEevee
2019-03-16 00:34:48 +03:00
parent eb4ddb0b1f
commit 61a5d6d496
17 changed files with 135 additions and 49 deletions

View File

@@ -21,6 +21,7 @@ class Controller{
assets.songs.forEach(song => {
if(song.id == this.selectedSong.folder){
this.mainAsset = song.sound
this.volume = song.volume || 1
}
})
@@ -35,6 +36,9 @@ class Controller{
if(syncWith){
this.syncWith = syncWith
}
if(this.multiplayer !== 2){
snd.musicGain.setVolumeMul(this.volume)
}
this.game.run()
this.view.run()
if(this.multiplayer === 1){
@@ -161,8 +165,26 @@ class Controller{
if(this.multiplayer){
new LoadSong(this.selectedSong, false, true, this.touchEnabled)
}else{
var taikoGame = new Controller(this.selectedSong, this.songData, this.autoPlayEnabled, false, this.touchEnabled)
taikoGame.run()
new Promise(resolve => {
var songObj = assets.songs.find(song => song.id === this.selectedSong.folder)
if(songObj.chart){
var reader = new FileReader()
var promise = pageEvents.load(reader).then(event => {
this.songData = event.target.result.replace(/\0/g, "").split("\n")
resolve()
})
if(this.selectedSong.type === "tja"){
reader.readAsText(songObj.chart, "sjis")
}else{
reader.readAsText(songObj.chart)
}
}else{
resolve()
}
}).then(() => {
var taikoGame = new Controller(this.selectedSong, this.songData, this.autoPlayEnabled, false, this.touchEnabled)
taikoGame.run()
})
}
}
playSound(id, time){
@@ -232,6 +254,7 @@ class Controller{
this.stopMainLoop()
this.keyboard.clean()
this.view.clean()
snd.buffer.loadSettings()
if(!this.multiplayer){
debugObj.controller = null