Esempio n. 1
0
    private float PlayScheduled(AudioNode startNode, AudioNode currentNode, double playAtDSPTime, out float volume)
    {
        var   audioData = currentNode.NodeData as AudioData;
        float length    = 0;

        volume = 1;
        if (audioData.Clip != null)
        {
            length = audioData.Clip.samples / (float)audioData.Clip.frequency;

            Current.clip    = audioData.Clip;
            Current.volume  = RuntimeHelper.ApplyVolume(startNode, currentNode);
            volume          = Current.volume;
            Current.volume *= busVolume;

            Current.pitch = RuntimeHelper.ApplyPitch(startNode, currentNode);
            RuntimeHelper.ApplyAttentuation(startNode, currentNode, Current);

            length = RuntimeHelper.LengthFromPitch(length, Current.pitch);
            endTimes[currentIndex] = playAtDSPTime + length;


            Current.PlayScheduled(playAtDSPTime);
        }

        return(length);
    }
Esempio n. 2
0
    private float PlayScheduled(InAudioNode startNode, InAudioNode currentNode, InAudioData audioData, double playAtDSPTime, float offset, out float nodeVolume)
    {
        float length = 0;

        nodeVolume = 1;
        if (audioData.Clip != null)
        {
            var clip = audioData.Clip;
            length = clip.ExactLength();

            length -= offset;
            float lengthOffset = offset * clip.frequency;
            var   source       = Current.AudioSource;


            source.clip = clip;
            nodeVolume  = RuntimeHelper.ApplyVolume(startNode, currentNode);

            SetVolume(Current, attachedToBus.FinalVolume);


            source.pitch = RuntimeHelper.ApplyPitch(startNode, currentNode);
            RuntimeHelper.ApplyAttentuation(startNode, currentNode, source);

            length             = RuntimeHelper.LengthFromPitch(length, source.pitch);
            Current.EndTime    = playAtDSPTime + length;
            Current.StartTime  = playAtDSPTime;
            Current.UsedNode   = currentNode;
            source.pan         = pan2D;
            source.spread      = spread;
            source.panLevel    = pan;
            source.timeSamples = (int)(lengthOffset);
            source.PlayScheduled(playAtDSPTime);
        }

        return(length);
    }