Beispiel #1
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);
    }
Beispiel #2
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);
    }
Beispiel #3
0
    protected ILugusAudioTrack CreateTrack()
    {
        FindReferences();

        GameObject trackGO = new GameObject(this._channelType.ToString() + "_Track_" + (_tracks.Count + 1));

        trackGO.AddComponent <AudioSource>();
        ILugusAudioTrack track = trackGO.AddComponent <LugusAudioTrack>();

        track.Channel = this;

        trackGO.transform.parent = trackParent;

        _tracks.Add(track);

        return(track);
    }
    public void SetupLocal()
    {
        //LoadLuGusAudio();
        if (backgroundAmbient == null)
        {
            backgroundAmbient = LugusAudio.use.Ambient().GetTrack();
            backgroundAmbient.Claim();

            backgroundAmbient.Play(backgroundAmbientClip, new LugusAudioTrackSettings().Loop(true));
        }

        if (backgroundMusic == null)
        {
            backgroundMusic = LugusAudio.use.Music().GetTrack();
            backgroundMusic.Claim();

            //backgroundMusic.Play(backgroundMusicClip, new LugusAudioTrackSettings().Loop(true).MaxVolume(0.2f).Volume(0.2f));
        }

        LoadLuGusAudio();
    }
Beispiel #5
0
    public void ApplyTo(ILugusAudioTrack target)
    {
        if (volume_set)
        {
            target.Volume = volume;
        }

        if (loop_set)
        {
            target.Loop = loop;
        }

        if (pitch_set)
        {
            target.Pitch = pitch;
        }

        if (maxVolume_set)
        {
            target.MaxVolume = maxVolume;
        }
    }
Beispiel #6
0
    // get next available track in the pool (not playing, not claimed, not paused)
    public ILugusAudioTrack GetTrack()
    {
        ILugusAudioTrack output = null;

        foreach (ILugusAudioTrack t in _tracks)
        {
            // only if the track is not claimed by someone,
            // and it's not currently playing
            // and it hasn't been paused (which means it's still playing but unity's AudioSource.IsPlaying is false...)
            if (!t.Claimed && !t.Playing && !t.Paused)
            {
                output = t;
                break;
            }
        }

        if (output == null)
        {
            output = CreateTrack();
        }

        return(output);
    }
Beispiel #7
0
    public void ApplyTo(ILugusAudioTrack target)
    {
        if( volume_set )
            target.Volume = volume;

        if( loop_set )
            target.Loop = loop;
    }