Merge pull request #10 from LoveEevee/soundbuffer

Fix some sounds
This commit is contained in:
Bui 2018-09-11 17:35:51 +01:00 committed by GitHub
commit 47f346eadb
6 changed files with 18 additions and 18 deletions

View File

@ -88,7 +88,7 @@ function Controller(selectedSong, songData, autoPlayEnabled){
if (score.fail == 0) { if (score.fail == 0) {
vp = 'fullcombo'; vp = 'fullcombo';
_this.playSoundMeka('fullcombo', 1350); _this.playSoundMeka('fullcombo', 1.350);
} else if (score.hp >= 50) { } else if (score.hp >= 50) {
vp = 'clear'; vp = 'clear';
} else { } else {

View File

@ -199,11 +199,14 @@ function Game(controller, selectedSong, songData){
if(_fadeOutStarted){ if(_fadeOutStarted){
if(_musicFadeOut==0){ if(_musicFadeOut==0){
snd.musicGain.fadeOut(1.6) snd.musicGain.fadeOut(1.6)
_mainAsset.stop(1.6)
snd.musicGain.fadeIn(0, 1.7)
} }
if(_ellapsedTime.ms>=_fadeOutStarted+1600){ if(_ellapsedTime.ms>=_fadeOutStarted+1600){
controller.fadeOutOver() controller.fadeOutOver()
_mainAsset.stop()
setTimeout(() => {
snd.musicGain.fadeIn()
snd.musicGain.unmute()
}, 1000)
} }
_musicFadeOut++; _musicFadeOut++;
} }
@ -224,7 +227,7 @@ function Game(controller, selectedSong, songData){
this.toggleMainMusic = function(){ this.toggleMainMusic = function(){
if(_mainMusicPlaying){ if(_mainMusicPlaying){
_mainAsset.pause(); _mainAsset.stop();
_mainMusicPlaying=false; _mainMusicPlaying=false;
} }
else{ else{
@ -237,10 +240,6 @@ function Game(controller, selectedSong, songData){
_fadeOutStarted=false; _fadeOutStarted=false;
} }
this.pauseSound = function(soundID, stop){
_soundSystem.pauseSound(soundID, stop);
}
this.getHitcircleSpeed = function(){ this.getHitcircleSpeed = function(){
return _hitcircleSpeed; return _hitcircleSpeed;
} }

View File

@ -97,7 +97,7 @@ function Scoresheet(controller, score){
} }
assets.sounds["results"].play() assets.sounds["results"].play()
assets.sounds["bgm_result"].playLoop(0, false, 0, 0.846625) assets.sounds["bgm_result"].playLoop(0.1, false, 0, 0.847, 17.689)
$("#screen").load("/src/views/scoresheet.html", _this.run); $("#screen").load("/src/views/scoresheet.html", _this.run);

View File

@ -4,7 +4,6 @@ function SongSelect(){
var _selectedSong = {title:'', folder:'', difficulty:''}; var _selectedSong = {title:'', folder:'', difficulty:''};
var _preview; var _preview;
var _preview_ended var _preview_ended
var _preview_startLoad
var _diffNames={ var _diffNames={
easy:"かんたん", easy:"かんたん",
normal:"ふつう", normal:"ふつう",
@ -14,7 +13,7 @@ function SongSelect(){
this.startPreview = function(id, prvtime, first_open=true) { this.startPreview = function(id, prvtime, first_open=true) {
_this.endPreview(); _this.endPreview();
_preview_startLoad = +new Date var startLoad = +new Date
_preview_ended = false _preview_ended = false
if(first_open){ if(first_open){
snd.musicGain.fadeOut(0.4) snd.musicGain.fadeOut(0.4)
@ -28,21 +27,23 @@ function SongSelect(){
if(songObj.sound){ if(songObj.sound){
_preview = songObj.sound _preview = songObj.sound
_preview.gain = snd.previewGain _preview.gain = snd.previewGain
this.previewLoaded(prvtime) this.previewLoaded(startLoad, prvtime, first_open)
}else{ }else{
snd.previewGain.load("/songs/" + id + "/main.mp3").then(sound => { snd.previewGain.load("/songs/" + id + "/main.mp3").then(sound => {
if(!_preview_ended){ if(!_preview_ended){
songObj.sound = sound songObj.sound = sound
_preview = sound _preview = sound
this.previewLoaded(prvtime) this.previewLoaded(startLoad, prvtime, first_open)
} }
}) })
} }
}; };
this.previewLoaded = function(prvtime){ this.previewLoaded = function(startLoad, prvtime, first_open){
var endLoad = +new Date var endLoad = +new Date
var delay = Math.max(1000 - Math.min(1000, endLoad - _preview_startLoad), 300) var difference = endLoad - startLoad
var minDelay = first_open ? 1000 : 300
var delay = minDelay - Math.min(minDelay, difference)
_preview.playLoop(delay / 1000, false, prvtime / 1000) _preview.playLoop(delay / 1000, false, prvtime / 1000)
} }
@ -142,7 +143,7 @@ function SongSelect(){
} }
this.createCode = function(){ this.createCode = function(){
assets.sounds["bgm_songsel"].playLoop(0, false, 0, 1.4423958333333333) assets.sounds["bgm_songsel"].playLoop(0.1, false, 0, 1.442, 3.506)
assets.sounds["song-select"].play(0.2); assets.sounds["song-select"].play(0.2);
var songElements = [0] var songElements = [0]

View File

@ -124,7 +124,7 @@ class Sound{
playLoop(time, absolute, seek1, seek2, until){ playLoop(time, absolute, seek1, seek2, until){
time = this.convertTime(time, absolute) time = this.convertTime(time, absolute)
seek1 = seek1 || 0 seek1 = seek1 || 0
seek2 = seek2 || seek1 seek2 = seek2 || 0
until = until || this.duration until = until || this.duration
this.loop = { this.loop = {
started: time + until - seek1, started: time + until - seek1,

View File

@ -2,7 +2,7 @@ function Tutorial() {
var _this = this; var _this = this;
this.run = function() { this.run = function() {
assets.sounds["bgm_setsume"].playLoop(0, false, 0, 1.0540416666666668) assets.sounds["bgm_setsume"].playLoop(0.1, false, 0, 1.054, 16.054)
$('#tutorial-end-button').click(function(){ $('#tutorial-end-button').click(function(){
assets.sounds["bgm_setsume"].stop(); assets.sounds["bgm_setsume"].stop();