void LateUpdate() { ChartEditor editor = ChartEditor.Instance; if (editor.currentState == ChartEditor.State.Playing && tick) { SongAudioManager songAudioManager = editor.currentSongAudio; visibleAudioTime = editor.services.currentVisualAudioTime; AudioStream stream = null; foreach (Song.AudioInstrument audio in audioInstrumentEnumVals) { if (AudioManager.StreamIsValid(songAudioManager.GetAudioStream(audio))) { stream = songAudioManager.GetAudioStream(audio); break; } } audioPosition = AudioManager.StreamIsValid(stream) ? stream.CurrentPositionSeconds : 0; tick = false; } dt += Time.deltaTime; if (dt > tickFrequency) { dt -= tickFrequency; tick = true; } }
public void PlayAudio(float playPoint) { SongAudioManager songAudioManager = currentSongAudio; SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Song), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_song); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Guitar), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_guitar); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Bass), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_bass); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Rhythm), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_rhythm); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Keys), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_keys); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drum), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_2), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_3), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_4), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Vocals), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_vocals); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Crowd), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_crowd); AudioStream primaryStream = null; foreach (var bassStream in songAudioManager.bassAudioStreams) { if (primaryStream != null) { playPoint = primaryStream.CurrentPositionInSeconds(); } if (primaryStream != null) { PlayStream(bassStream, primaryStream); } else if (PlayStream(bassStream, playPoint)) { primaryStream = bassStream; } } }
// Use this for initialization void Awake() { Debug.Log(string.Format("Initialising {0} v{1}", Application.productName, Application.version)); #if !UNITY_EDITOR Application.wantsToQuit += QuittingEditCheck; #endif Application.quitting += FinaliseQuit; currentSongAudio = new SongAudioManager(); assets = GetComponent <ChartEditorAssets>(); selectedObjectsManager = new SelectedObjectsManager(this); sfxAudioStreams = new LoadedStreamStore(soundMapConfig); _minPos = 0; _maxPos = 0; RegisterSystems(); movement = GameObject.FindGameObjectWithTag("Movement").GetComponent <MovementController>(); isDirty = false; gameObject.AddComponent <UITabbing>(); windowHandleManager = new WindowHandleManager(string.Format("{0} v{1} {2}", Application.productName, Application.version, Globals.applicationBranchName), GetComponent <Settings>().productName); errorManager = gameObject.AddComponent <ErrorManager>(); toolManager.Init(); interactionMethodManager.Init(); events.chartReloadedEvent.Register(OnChartReloaded); }
// Use this for initialization void Awake() { Debug.Log("Initialising " + versionNumber.text); currentSongAudio = new SongAudioManager(); assets = GetComponent <ChartEditorAssets>(); selectedObjectsManager = new SelectedObjectsManager(this); sfxAudioStreams = new LoadedStreamStore(soundMapConfig); _minPos = 0; _maxPos = 0; RegisterSystems(); movement = GameObject.FindGameObjectWithTag("Movement").GetComponent <MovementController>(); isDirty = false; gameObject.AddComponent <UITabbing>(); windowHandleManager = new WindowHandleManager(versionNumber.text, GetComponent <Settings>().productName); errorManager = gameObject.AddComponent <ErrorManager>(); toolManager.Init(); interactionMethodManager.Init(); events.chartReloadedEvent.Register(OnChartReloaded); }
public void PlayAudio(float playPoint) { // Update all streams to the correct volume and speed levels SongAudioManager songAudioManager = currentSongAudio; SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Song), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_song); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Guitar), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_guitar); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Bass), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_bass); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Rhythm), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_rhythm); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Keys), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_keys); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drum), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_2), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums2); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_3), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums3); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_4), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums4); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Vocals), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_vocals); SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Crowd), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_crowd); // Set up synchronisation between all the streams otherwise they may go out of sync with each other AudioStream primaryStream = songAudioManager.mainSongAudio; // Finally start playing the song if (primaryStream != null) { primaryStream.PlaySynced(playPoint, songAudioManager.bassAudioStreams); Debug.Log("Playing song audio at " + playPoint); } }
public void StopAudio() { SongAudioManager songAudioManager = currentSongAudio; AudioStream primaryStream = songAudioManager.mainSongAudio; if (primaryStream != null) { primaryStream.Stop(); } }
public void PlayingMovement() { float speed = Globals.gameSettings.hyperspeed; Vector3 pos = transform.position; float deltaTime = Time.deltaTime; float positionOffset = initPos.y; { float timeBeforeMovement = ChartEditor.WorldYPositionToTime(pos.y - positionOffset); float timeAfterMovement = timeBeforeMovement + deltaTime * Globals.gameSettings.gameSpeed; // Make sure we're staying in sync with the audio { SongAudioManager songAudioManager = editor.currentSongAudio; AudioStream stream = null; for (int i = 0; i < EnumX <Song.AudioInstrument> .Count; ++i) { Song.AudioInstrument audio = (Song.AudioInstrument)i; if (AudioManager.StreamIsValid(songAudioManager.GetAudioStream(audio))) { stream = songAudioManager.GetAudioStream(audio); break; } } if (AudioManager.StreamIsValid(stream) && stream.IsPlaying()) { float audioTimePosition = stream.CurrentPositionInSeconds() - editor.services.totalSongAudioOffset; float desyncAmount = audioTimePosition - timeAfterMovement; if (Mathf.Abs(desyncAmount) > DESYNCLENIENCE) { timeAfterMovement += desyncAmount; } } } float maxChangeInTimeAllowed = Application.targetFrameRate > 0 ? 2.0f / Application.targetFrameRate : 1.0f / 120.0f; float totalChangeInTime = timeAfterMovement - timeBeforeMovement; float newTimePosition = ChartEditor.TimeToWorldYPosition(timeBeforeMovement + totalChangeInTime); pos.y = newTimePosition + positionOffset; } selfTransform.position = pos; explicitChartPos = null; lastUpdatedRealTime = Time.time; }
// Use this for initialization void Awake() { Debug.Log("Initialising " + versionNumber.text); #if !UNITY_EDITOR Application.wantsToQuit += QuittingEditCheck; #endif Application.quitting += FinaliseQuit; #if SDL_VIDEO // Init for window manager if (SDL2.SDL.SDL_Init(SDL2.SDL.SDL_INIT_VIDEO) < 0) { Debug.LogError("SDL could not initialise! SDL Error: " + SDL2.SDL.SDL_GetError()); } else { Debug.Log("Successfully initialised video SDL"); } #endif currentSongAudio = new SongAudioManager(); assets = GetComponent <ChartEditorAssets>(); selectedObjectsManager = new SelectedObjectsManager(this); sfxAudioStreams = new LoadedStreamStore(soundMapConfig); _minPos = 0; _maxPos = 0; RegisterSystems(); movement = GameObject.FindGameObjectWithTag("Movement").GetComponent <MovementController>(); isDirty = false; gameObject.AddComponent <UITabbing>(); windowHandleManager = new WindowHandleManager(versionNumber.text, GetComponent <Settings>().productName); errorManager = gameObject.AddComponent <ErrorManager>(); toolManager.Init(); interactionMethodManager.Init(); events.chartReloadedEvent.Register(OnChartReloaded); }