Example #1
0
    // 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());
        }
    }
Example #2
0
    public void Play(AudioClip clip, LugusAudioTrackSettings settings = null)
    {
        bool loaded = Load(clip, settings);

        if (loaded)
        {
            Play();
        }
    }
Example #3
0
    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);
    }
Example #4
0
    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);
    }
Example #5
0
    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);
    }
Example #6
0
    // 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;
    }
Example #7
0
    // 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);
    }
Example #8
0
    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;
    }
Example #9
0
 public void FadeIn(AudioClip clip, float duration, LugusAudioTrackSettings settings = null)
 {
     Load(clip, settings);
     FadeIn(duration);
     Play();
 }
Example #10
0
    // 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 () );
        }
    }
Example #11
0
    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;
    }
Example #12
0
 public void Play(AudioClip clip, LugusAudioTrackSettings settings = null)
 {
     bool loaded = Load (clip, settings);
     if( loaded )
         Play ();
 }
Example #13
0
    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;
    }
Example #14
0
 public void FadeIn(AudioClip clip, float duration, LugusAudioTrackSettings settings = null)
 {
     Load ( clip, settings );
     FadeIn (duration);
     Play ();
 }