getParameterData() public method

public getParameterData ( int index, IntPtr &data, uint &length ) : RESULT
index int
data IntPtr
length uint
return RESULT
Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        IntPtr unmanagedData;
        uint   length;

        if (debugDrawFFT)
        {
            fft.getParameterData((int)FMOD.DSP_FFT.SPECTRUMDATA, out unmanagedData, out length);
            //Musimy zrzutować dane z pointera unmanagedData na typ DSP_PARAMETER_FFT
            FMOD.DSP_PARAMETER_FFT fftData =
                (FMOD.DSP_PARAMETER_FFT)System.Runtime.InteropServices.Marshal.PtrToStructure(unmanagedData, typeof(FMOD.DSP_PARAMETER_FFT));
            var spectrum = fftData.spectrum;
            //UnityEngine.Debug.Log("Number of channels in track:" + fftData.numchannels);

            //Wrzucamy dane do linerenderera
            if (fftData.numchannels > 0)
            {
                float width  = 80.0f;
                float height = 0.1f;
                var   pos    = Vector3.zero;
                pos.x = width * -0.5f;

                for (int i = 0; i < windowSize; ++i)
                {
                    pos.x += (width / windowSize);
                    //Elementy tablicy spectrum zwracane sa w log dB
                    //TODO: fft w skali logarytmicznej a nie liniowej
                    float level = Lin2dB(spectrum[0][i]);
                    pos.y = (80 + level) * height - 20;

                    lineRendererFFT.SetPosition(i, pos);
                }
            }
        }

        if (sampleCreated)
        {
            lineRendererSamples.positionCount = lineRendererSamplesData.Length;
            for (int i = 0; i < lineRendererSamplesData.Length; i++)
            {
                try
                {
                    lineRendererSamples.SetPosition(i, new Vector3(-40 + i * 0.5f, lineRendererSamplesData[i] - 25, 0));
                } catch (IndexOutOfRangeException ex)
                {
                    UnityEngine.Debug.Log("Oops xD" + ex.Message);
                }
            }
        }
    }