コード例 #1
0
    //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    // OnAudioFilterRead (separate thread)
    //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

    /// <summary>
    /// Raises the audio filter read event.
    /// We will spatialize the audio here
    /// NOTE: It's important that we get the audio attenuation curve for volume,
    /// that way we can feed it into our spatializer and have things sound match
    /// with bypass on/off
    /// </summary>
    /// <param name="data">Data.</param>
    /// <param name="channels">Channels.</param>
    ///
    void OnAudioFilterRead(float[] data, int channels)
    {
#if DEBUG_AudioSource
        if (debugOn)
        {
            if (audioFrames > 0)
            {
                audioFrames--;
            }
        }
#endif
        // Problem: We cannot read timer here.
        // However, we can read time-stamp via plugin
        // This is required to smooth out the position,
        // since the main loop is only allowed to update position
        // of sound, but is running at a different frequency then
        // the audio loop.
        //
        // Therefore, we will need to dead reckon the position of the sound.

        // Do not spatialize if we are not playing
        if ((isPlaying == false) ||
            (Bypass == true) ||
            (OSPManager.GetBypass() == true) ||
            (OSPManager.IsInitialized() == false))
        {
            return;
        }


        float dTime = GetTime(true) - relPosTime;
        lock (this)
        {
            relPos    += relVel * dTime;
            relPosTime = GetTime(true);
        }

        // TODO: Need to ensure that sound is not played before context is
        // legal
        if (context != sNoContext)
        {
            // Set the position for this context and sound
            OSPManager.SetPositionRel(context, relPos.x, relPos.y, relPos.z);
            //Spatialize (local override of InvSq is passed in)
            OSPManager.Spatialize(context, data, useInverseSquare, falloffNear, falloffFar);
        }
    }
コード例 #2
0
    // Token: 0x06003728 RID: 14120 RVA: 0x0011AAB0 File Offset: 0x00118EB0
    private void OnAudioFilterRead(float[] data, int channels)
    {
        if (!this.isPlaying || this.Bypass || OSPManager.GetBypass() || !OSPManager.IsInitialized())
        {
            return;
        }
        float d = this.GetTime(true) - this.relPosTime;

        lock (this)
        {
            this.relPos    += this.relVel * d;
            this.relPosTime = this.GetTime(true);
        }
        if (this.context != -1)
        {
            OSPManager.SetPositionRel(this.context, this.relPos.x, this.relPos.y, this.relPos.z);
            OSPManager.Spatialize(this.context, data, this.useInverseSquare, this.falloffNear, this.falloffFar);
        }
    }