// TODO: possible better way of approaching this would be: // baseSettings.ApplyTo( track, alwaysApply = true ) // customSettings.ApplyTo(track, false) // we will apply settings twice, but makes the API simpler + not yet another function besides ApplyTo that needs to keep track of al vars here // this can replace the current way of working: // customSettings.Merge( baseSettings ) // customSettings.ApplyTo(track) public void Merge(LugusAudioTrackSettings baseSettings) { if (baseSettings == null) { return; } if (!volume_set) { Volume(baseSettings.Volume()); } if (!loop_set) { Loop(baseSettings.Loop()); } if (!pitch_set) { Pitch(baseSettings.Pitch()); } if (!maxVolume_set) { MaxVolume(baseSettings.MaxVolume()); } }
public void Play(AudioClip clip, LugusAudioTrackSettings settings = null) { bool loaded = Load(clip, settings); if (loaded) { Play(); } }
public static LugusAudioTrackSettings FromSource(AudioSource src) { // TODO : FIXME : fill this in properly! and add other poperties of AudioSource to this class LugusAudioTrackSettings output = new LugusAudioTrackSettings(); output.volume = src.volume; output.loop = src.loop; output.pitch = src.pitch; return(output); }
public ILugusAudioTrack Play(AudioClip clip, bool stopOthers = false, LugusAudioTrackSettings trackSettings = null) { // TODO: maybe upgrade this option to allow PauseOthers or MuteOthers as well? if (stopOthers) { StopAll(); } ILugusAudioTrack track = GetTrack(); track.Play(clip, trackSettings); return(track); }
public bool Load(AudioClip clip, LugusAudioTrackSettings settings = null) { if (clip == null) { Debug.LogError(name + " : clip was null! ignoring..."); return(false); } if (Channel == null) { Debug.LogError(name + " : Channel was null! ignoring..."); return(false); } Source.clip = clip; Source.time = 0.0f; // reset the settings // otherwhise, if the previous Play had for example Loop set // but the baseSettings didn't have loop set... loop would remain set on the next Play // TODO: make this more decent... this.Loop = false; this.Volume = 1.0f; this.MaxVolume = 1.0f; if (settings != null) { //Debug.LogWarning("Settings: Volume " + settings.Volume() + " " + settings.Volume()); settings.Merge(_channel.BaseTrackSettings); //Debug.LogWarning("Merged settings"); //Debug.LogWarning("Settings: Volume " + settings.Volume() + " " + settings.Volume()); } else { settings = _channel.BaseTrackSettings; } if (settings != null) { settings.ApplyTo(this); if (settings.Position() == LugusUtil.DEFAULTVECTOR) { transform.localPosition = Vector3.zero; //position = LugusCamera.game.transform.position;//LugusAudio.use.transform.position; } } return(true); }
// fades out and stops all active tracks and fades in a new track with the new clip public ILugusAudioTrack CrossFade(AudioClip clip, float duration, LugusAudioTrackSettings settings = null ) { foreach( ILugusAudioTrack t in _tracks ) { if( t.Playing && !t.Paused ) { t.FadeOut(duration, true); } } ILugusAudioTrack newTrack = GetTrack(); newTrack.FadeIn( clip, duration, settings ); return newTrack; }
// fades out and stops all active tracks and fades in a new track with the new clip public ILugusAudioTrack CrossFade(AudioClip clip, float duration, LugusAudioTrackSettings settings = null) { foreach (ILugusAudioTrack t in _tracks) { if (t.Playing && !t.Paused) { t.FadeOut(duration, true); } } ILugusAudioTrack newTrack = GetTrack(); newTrack.FadeIn(clip, duration, settings); return(newTrack); }
public ILugusAudioTrack Play(AudioClip clip, bool stopOthers = false, LugusAudioTrackSettings trackSettings = null ) { // TODO: maybe upgrade this option to allow PauseOthers or MuteOthers as well? if( stopOthers ) { StopAll (); } ILugusAudioTrack track = GetTrack(); track.Play( clip, trackSettings ); return track; }
public void FadeIn(AudioClip clip, float duration, LugusAudioTrackSettings settings = null) { Load(clip, settings); FadeIn(duration); Play(); }
// TODO: possible better way of approaching this would be: // baseSettings.ApplyTo( track, alwaysApply = true ) // customSettings.ApplyTo(track, false) // we will apply settings twice, but makes the API simpler + not yet another function besides ApplyTo that needs to keep track of al vars here // this can replace the current way of working: // customSettings.Merge( baseSettings ) // customSettings.ApplyTo(track) public void Merge(LugusAudioTrackSettings baseSettings) { Debug.Log ("Mergin base settings 0"); if( baseSettings == null ) return; Debug.Log ("Mergin base settings"); if( !volume_set ) { Volume( baseSettings.Volume() ); } if( !loop_set ) { Loop ( baseSettings.Loop () ); } }
public static LugusAudioTrackSettings FromSource(AudioSource src) { // TODO : FIXME : fill this in properly! and add other poperties of AudioSource to this class LugusAudioTrackSettings output = new LugusAudioTrackSettings(); output.volume = src.volume; output.loop = src.loop; return output; }
public void Play(AudioClip clip, LugusAudioTrackSettings settings = null) { bool loaded = Load (clip, settings); if( loaded ) Play (); }
public bool Load(AudioClip clip, LugusAudioTrackSettings settings = null) { if( clip == null ) { Debug.LogError(name + " : clip was null! ignoring..."); return false; } if( Channel == null ) { Debug.LogError(name + " : Channel was null! ignoring..."); return false; } Source.clip = clip; Source.time = 0.0f; // reset the settings // otherwhise, if the previous PLay had for example Loop set // but the baseSettings didn't have loop set... loop would remain set on the next Play // TODO: make this more decent... this.Loop = false; this.Volume = 1.0f; if( settings != null ) { settings.Merge( _channel.BaseTrackSettings ); } else { settings = _channel.BaseTrackSettings; } if( settings != null ) { settings.ApplyTo( this ); if( settings.Position() == LugusUtil.DEFAULTVECTOR ) { transform.localPosition = Vector3.zero;//position = LugusCamera.game.transform.position;//LugusAudio.use.transform.position; } } return true; }
public void FadeIn(AudioClip clip, float duration, LugusAudioTrackSettings settings = null) { Load ( clip, settings ); FadeIn (duration); Play (); }