private IEnumerator PouringBeer() { pourSoundHandle = AudioManager.PlayEffectSafe(SoundEffect.PourBeer); fillProgressBar.Show(); pourProgressBar.Show(); perfectProgressIndicator.gameObject.SetActive(true); while (isPouring && pouringProgress <= pourTime) { pouringProgress += Time.deltaTime; pourProgressBar.UpdateProgress(pouringProgress / pourTime); if (pouringProgress > pourTime) { FillBeer(); break; } yield return(null); } pourSoundHandle?.FadeOutAndStop(0.2f); }
public void Clear() { TrackId = 0; pan = 0; vol = 0; VolFadeDest = 0; VolFadeStep = 0; VolFadeDelay = 0; VolFadeUsed = false; // SoundId = 0; SoundName = null; Used = false; ToBeRemoved = false; SouStreamUsed = false; SndDataExtComp = false; SoundPriority = 0; RegionOffset = 0; DataOffset = 0; CurRegion = 0; CurHookId = 0; VolGroupId = 0; SoundType = 0; FeedSize = 0; DataMod12Bit = 0; MixerFlags = AudioFlags.None; SoundDesc = null; MixChanHandle = new SoundHandle(); Stream = null; }
public void Stop(SoundHandle handle) { var sfx = GetSfx(handle); if (sfx != null) { if (sfx.sound.fadeOutTime <= 0.0f) { Remove(handle); return; } if (sfx.sound.loop) { sfx.loopingData.fadingOut = true; } else if (sfx.oneShotData.startedFadingOutAt == null) { // Only start fading out if before where it would // by default float decayStart = sfx.length - sfx.sound.fadeOutTime; if (sfx.time < decayStart) { sfx.oneShotData.startedFadingOutAt = sfx.time; } } } }
private void Update() { if (!isGamePlayActive) { return; } roundTimer += Time.deltaTime; if (roundDuration - roundTimer <= 10 && !isTenSecondTimerStarted) { clockTickSound = AudioManager.PlayEffectSafe(SoundEffect.ClockTick, true); isTenSecondTimerStarted = true; if (VikingController.Instance != null) { VikingController.Instance.CanSpawn = false; } } if (roundTimer >= roundDuration) { clockTickSound.Stop(); isTenSecondTimerStarted = false; StartIntermission(); } }
public void Stop(SoundHandle handle) { var sfx = GetSfx(handle); if (sfx != null) { RemoveSound(sfx); } }
public void SetPitch(SoundHandle handle, float pitch) { var sfx = GetSfx(handle); if (sfx != null) { sfx.SetVolume(pitch); } }
public void SetTime(SoundHandle handle, float time) { var sfx = GetSfx(handle); if (sfx != null) { sfx.time = time; } }
public void SetVolume(SoundHandle handle, float volume) { var sfx = GetSfx(handle); if (sfx != null) { sfx.SetVolume(volume); } }
public void Remove(SoundHandle handle) { var sfx = GetSfx(handle); if (sfx != null) { RemoveSound(sfx, wasDestroyed: false); } }
public void SetPaused(SoundHandle handle, bool paused) { var sfx = GetSfx(handle); if (sfx != null) { sfx.SetPaused(paused); } }
public void SetNormTime(SoundHandle handle, float normTime) { var sfx = GetSfx(handle); if (sfx != null) { sfx.normTime = normTime; } }
public void Stop(bool disableAutoPlay = true) { SoundManager.instance.Stop(handle); handle = new SoundHandle(); if (disableAutoPlay) { playAutomatically = false; } }
public void StopSounds(List <SoundHandle> sfx) { var soundMan = SoundManager.instance; for (int i = 0; i < sfx.Count; ++i) { SoundHandle handle = sfx[i]; soundMan.Stop(handle); } }
/// <summary>Registers a sound and returns a handle to the sound.</summary> /// <param name="path">The path to the file or folder that contains the sound.</param> /// /// <param name="radius">The sound radius</param> /// <param name="handle">Receives a handle to the sound.</param> /// <returns>Whether loading the sound was successful.</returns> public override bool RegisterSound(string path, double radius, out SoundHandle handle) { if (File.Exists(path) || Directory.Exists(path)) { handle = Program.Sounds.RegisterBuffer(path, radius); return(true); } ReportProblem(ProblemType.PathNotFound, path); handle = null; return(false); }
/// <param name="Host">The </param> /// <param name="TrackPositionDelta">The delta position of the sound within a track block.</param> /// <param name="SoundBuffer">The sound buffer to play.</param> /// <param name="PlayerTrainOnly">Defines whether this sound is played for the player's train only, or for player and AI trains</param> /// <param name="AllCars">Whether this triggers for all cars in a train</param> /// <param name="Once">Defines whether this sound repeats looped, or plays once</param> /// <param name="Dynamic">Whether this sound is dynamic (Attached to a train)</param> /// <param name="Position">The position of the sound relative to it's track location</param> /// <param name="Speed">The speed in km/h at which this sound is played at it's original pitch (Set to zero to play at original pitch at all times)</param> public SoundEvent(HostInterface Host, double TrackPositionDelta, SoundHandle SoundBuffer, bool PlayerTrainOnly, bool AllCars, bool Once, bool Dynamic, Vector3 Position, double Speed) : base(TrackPositionDelta) { this.currentHost = Host; this.DontTriggerAnymore = false; this.SoundBuffer = (SoundBuffer)SoundBuffer; this.PlayerTrainOnly = PlayerTrainOnly; this.Once = Once; this.Dynamic = Dynamic; this.Position = Position; this.Speed = Speed; this.AllCars = AllCars; }
public Music(IMixer mixer, string directory) { _mixer = mixer; _sampleRate = mixer.OutputRate; _volumeL = _volumeR = 192; _soundHandle = _mixer.PlayStream(SoundType.Plain, this, -1, Mixer.MaxChannelVolume, 0, false, true); _handles = new MusicHandle[2]; for (int i = 0; i < _handles.Length; i++) { _handles[i] = new MusicHandle(directory); } }
/// <param name="TrackPositionDelta">The delta position of the sound within a track block.</param> /// <param name="SoundBuffer">The sound buffer to play.</param> /// <param name="PlayerTrainOnly">Defines whether this sound is played for the player's train only, or for player and AI trains</param> /// <param name="Once">Defines whether this sound repeats looped, or plays once</param> /// <param name="Dynamic">Whether this sound is dynamic (Attached to a train)</param> /// <param name="Position">The position of the sound relative to it's track location</param> /// <param name="Host">The </param> public SoundEvent(double TrackPositionDelta, SoundHandle SoundBuffer, bool PlayerTrainOnly, bool Once, bool Dynamic, Vector3 Position, HostInterface Host) { this.TrackPositionDelta = TrackPositionDelta; this.DontTriggerAnymore = false; this.SoundBuffer = (SoundBuffer)SoundBuffer; this.PlayerTrainOnly = PlayerTrainOnly; this.Once = Once; this.Dynamic = Dynamic; this.Position = Position; this.Speed = 0.0; this.currentHost = Host; }
void PlaySound(Sound sound, List <SoundHandle> sfx) { SoundHandle handle = SoundManager.instance.Play( sound, SoundFlag.OneShot | SoundFlag.Looping, parent: transform, attachToUnit: attachedToUnit ); if (handle.hasValue) { sfx.Add(handle); } }
/// <summary>Plays a sound.</summary> /// <param name="buffer">The sound buffer.</param> /// <param name="pitch">The pitch change factor.</param> /// <param name="volume">The volume change factor.</param> /// <param name="position">The position. If a train car is specified, the position is relative to the car, otherwise absolute.</param> /// <param name="looped">Whether to play the sound in a loop.</param> /// <returns>The sound source.</returns> public SoundSource PlaySound(SoundHandle buffer, double pitch, double volume, OpenBveApi.Math.Vector3 position, bool looped) { if (buffer is SoundBuffer) { SoundBuffer b = (SoundBuffer)buffer; if (Sources.Length == SourceCount) { Array.Resize(ref Sources, Sources.Length << 1); } Sources[SourceCount] = new SoundSource(b, b.Radius, pitch, volume, position, null, looped); SourceCount++; return(Sources[SourceCount - 1]); } throw new NotSupportedException(); }
protected override void ShutdownSystems() { musicSfx = new SoundHandle(); soundManager.Clear(); if (player != null) { player.UnregisterCallbacks( onTriggerEnter: PlayerCollided ); } pickups.Shutdown(); pickups = null; level = null; }
public void Stop(SoundHandle sh, float fadeOutTime = 0.0f) { if (!sh.IsValid()) { GameDebug.LogWarning("SoundSystem.Stop(): invalid SoundHandle"); return; } if (fadeOutTime == 0.0f) { sh.emitter.fadeToKill.SetValue(0.0f); } else { sh.emitter.fadeToKill.SetValue(1.0f); sh.emitter.fadeToKill.MoveTo(0.0f, fadeOutTime); } }
public bool StartSpeech(ushort textNum) { if (!SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.AllowSpeech)) { return(false); } var speechFileNum = (ushort)(_speechConvertTable[textNum >> 12] + (textNum & 0xFFF)); var speechData = _skyDisk.LoadFile(speechFileNum + 50000); if (speechData == null) { // TODO: debug(9, "File %d (speechFile %d from section %d) wasn't found", speechFileNum + 50000, textNum & 0xFFF, textNum >> 12); return(false); } var header = ServiceLocator.Platform.ToStructure <DataFileHeader>(speechData, 0); var speechSize = header.s_tot_size - ServiceLocator.Platform.SizeOf <DataFileHeader>(); var playBuffer = new byte[speechSize]; Array.Copy(speechData, ServiceLocator.Platform.SizeOf <DataFileHeader>(), playBuffer, 0, speechSize); // Workaround for BASS bug #897775 - some voice-overs are played at // half speed in 0.0368 (the freeware CD version), in 0.0372 they sound // just fine. int rate; if (_skyDisk.DetermineGameVersion().Version.Minor == 368 && (textNum == 20905 || textNum == 20906)) { rate = 22050; } else { rate = 11025; } _mixer.StopID(SoundSpeech); var stream = new RawStream(AudioFlags.Unsigned, rate, true, new MemoryStream(playBuffer, 0, speechSize)); _ingameSpeech = _mixer.PlayStream(SoundType.Speech, stream, SoundSpeech); return(true); }
public void Start() { Stop(); var stream = AudioStream; if (stream == null) { throw new InvalidOperationException("stream should not be null"); } _handle = Mixer.PlayStream(SoundType, stream, -1, _muted ? 0 : Volume, Balance, false); // Pause the audio again if we're still paused if (IsPaused) { Mixer.PauseHandle(_handle, true); } }
private IEnumerator StartCooking(KitchenTicket ticket) { if (tickets.Count == 0) { cookingSound = AudioManager.Instance.PlayEffect(SoundEffect.Cooking, true); } tickets.Enqueue(ticket); float cookingProgress = 0; isCooking = true; cookingProgressBar.Show(); smokeParticleSystem.Play(true); if (tickets.Count > 1) { if (!cookingCounter.isActiveAndEnabled) { cookingCounter.Enable(); } cookingCounter.SetCounter(tickets.Count); } while (isCooking && cookingProgress <= cookingTime) { cookingProgress += Time.deltaTime; if (ticket == tickets.Peek()) { cookingProgressBar.UpdateProgress(cookingProgress / cookingTime); } if (cookingProgress > cookingTime) { FinishCooking(); break; } yield return(null); } }
// TODO: public void Start(Timestamp limit) { Stop(); throw new NotImplementedException(); var stream = AudioStream; if (stream == null) { throw new InvalidOperationException("stream should not be null"); } // stream = new LimitingAudioStream(stream, limit, false); _handle = Mixer.PlayStream(SoundType, stream, -1, _muted ? 0 : Volume, Balance, true); // Pause the audio again if we're still paused if (IsPaused) { Mixer.PauseHandle(_handle, true); } }
void SetupWithLevel(Level level) { musicSfx = soundManager.Play(level.music, SoundFlag.Looping); player = level.player; cameraManager.followUnit = player; cameraManager.min = level.minPos; cameraManager.max = level.maxPos; cameraManager.backgroundRend.sprite = level.background; if (player != null) { player.RegisterCallbacks( onTriggerEnter: PlayerCollided ); player.SetDirection(level.startDir); } }
private bool Play(SoundHandle sh) { if (Enabled && sh != null && sh.Enabled && !string.IsNullOrWhiteSpace(sh.Path) && sh.HandleID != _currentSoundHandleID) { if (File.Exists(sh.Path)) { _mp.Close(); _mp.SetPlaylist(null); _mp.SourcePath = sh.Path; } else if (Directory.Exists(sh.Path)) { _mp.Close(); _mp.SetPlaylistFromDirectory(sh.Path); } else { return(false); } _currentSoundHandleID = sh.HandleID; _mp.IsLoop = sh.IsLoop; _mp.LoopHeadPosition = sh.LoopHeadPosition; if (!Utility.Configuration.Config.Control.UseSystemVolume) { _mp.Volume = sh.Volume; } _mp.Play(); return(true); } return(false); }
private bool Play(SoundHandle sh) { if (Enabled && sh != null && sh.Enabled && !string.IsNullOrWhiteSpace(sh.Path) && _mp.SourcePath != sh.Path) { _mp.Close(); _mp.SourcePath = sh.Path; _mp.IsLoop = sh.IsLoop; _mp.LoopHeadPosition = sh.LoopHeadPosition; if (!Utility.Configuration.Config.Control.UseSystemVolume) { _mp.Volume = sh.Volume; } _mp.Play(); return(true); } return(false); }
public void Play() { if (!IsPlaying()) { handle = SoundManager.instance.Play( sound, SoundFlag.OneShot | SoundFlag.Looping, parent == null ? transform : parent ); switch (startTimeMode) { case TimeMode.RandomRangeNormTime: SoundManager.instance.SetNormTime(handle, startTimeRange.GetRandom()); break; case TimeMode.RandomRangeTime: SoundManager.instance.SetTime(handle, startTimeRange.GetRandom()); break; default: break; } } }
/// <summary>Registers a sound and returns a handle to the sound.</summary> /// <param name="path">The path to the file or folder that contains the sound.</param> /// <param name="handle">Receives a handle to the sound.</param> /// <returns>Whether loading the sound was successful.</returns> public virtual bool RegisterSound(string path, out SoundHandle handle) { handle = null; return(false); }
/* Plays a sound positioned in 3D space, with panning and volume adjustments. */ public void playSound(SoundHandle theSound, MovableEntity emitterEntity) { if (soundOn) { if (emitterEntity == null) playSound(theSound); //if the listener isn't set, just play the sound normally AudioEmitter emitter = new AudioEmitter(); emitter.Position = emitterEntity.getPosition(); switch (theSound) { case SoundHandle.Truck: Cue newCue = soundBank.GetCue("truck"); Sound newSound = new Sound(newCue, emitterEntity); newCue.Apply3D(listener, emitter); newCue.Play(); soundList.Add(newSound); break; //case SoundHandle.Punch: soundBank.PlayCue("punch", listener, emitter); break; //case SoundHandle.BGM: soundBank.PlayCue("bgm"); break; } } }
/* Plays a sound at its default volume, not positioned in 3D space. */ public void playSound(SoundHandle theSound) { if (soundOn) { switch (theSound) { case SoundHandle.Truck: soundBank.PlayCue("truck"); break; //case SoundHandle.Punch: soundBank.PlayCue("punch"); break; //case SoundHandle.BGM: soundBank.PlayCue("bgm"); break; } } }
/// <summary>Registers a sound and returns a handle to the sound.</summary> /// <param name="sound">The sound data.</param> /// <param name="handle">Receives a handle to the sound.</param> /// <returns>Whether loading the sound was successful.</returns> public virtual bool RegisterSound(Sounds.Sound sound, out SoundHandle handle) { handle = null; return false; }
/// <summary>Registers a sound and returns a handle to the sound.</summary> /// <param name="path">The path to the file or folder that contains the sound.</param> /// <param name="handle">Receives a handle to the sound.</param> /// <returns>Whether loading the sound was successful.</returns> public virtual bool RegisterSound(string path, out SoundHandle handle) { handle = null; return false; }
private bool Play( SoundHandle sh ) { if ( Enabled && sh != null && sh.Enabled && !string.IsNullOrWhiteSpace( sh.Path ) && _mp.SourcePath != sh.Path ) { _mp.Close(); _mp.SourcePath = sh.Path; _mp.IsLoop = sh.IsLoop; _mp.LoopHeadPosition = sh.LoopHeadPosition; if ( !Utility.Configuration.Config.Control.UseSystemVolume ) _mp.Volume = sh.Volume; _mp.Play(); return true; } return false; }