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:
@@ -3,6 +3,7 @@
|
||||
var AudioContext = window.AudioContext || window.webkitAudioContext
|
||||
this.context = new AudioContext()
|
||||
pageEvents.add(window, ["click", "touchend"], this.pageClicked.bind(this))
|
||||
this.gainList = []
|
||||
}
|
||||
load(url, local, gain){
|
||||
if(local){
|
||||
@@ -27,7 +28,9 @@
|
||||
})
|
||||
}
|
||||
createGain(channel){
|
||||
return new SoundGain(this, channel)
|
||||
var gain = new SoundGain(this, channel)
|
||||
this.gainList.push(gain)
|
||||
return gain
|
||||
}
|
||||
setCrossfade(gain1, gain2, median){
|
||||
if(!Array.isArray(gain1)){
|
||||
@@ -60,6 +63,18 @@
|
||||
this.context.resume()
|
||||
}
|
||||
}
|
||||
saveSettings(){
|
||||
for(var i = 0; i < this.gainList.length; i++){
|
||||
var gain = this.gainList[i]
|
||||
gain.defaultVol = gain.volume
|
||||
}
|
||||
}
|
||||
loadSettings(){
|
||||
for(var i = 0; i < this.gainList.length; i++){
|
||||
var gain = this.gainList[i]
|
||||
gain.setVolume(gain.defaultVol)
|
||||
}
|
||||
}
|
||||
}
|
||||
class SoundGain{
|
||||
constructor(soundBuffer, channel){
|
||||
@@ -85,6 +100,9 @@ class SoundGain{
|
||||
this.gainNode.gain.value = amount * amount
|
||||
this.volume = amount
|
||||
}
|
||||
setVolumeMul(amount){
|
||||
this.setVolume(Math.sqrt(amount * amount * this.defaultVol))
|
||||
}
|
||||
setCrossfade(amount){
|
||||
this.setVolume(Math.sqrt(Math.sin(Math.PI / 2 * amount)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user