Exemple #1
0
        private static FMOD.RESULT READCALLBACK(ref FMOD.DSP_STATE dsp_state, IntPtr inbuf, IntPtr outbuf, uint length, int inchannels, int outchannels)
        {
            uint   count, temp = 0;
            int    count2, temp1 = 0;
            IntPtr thisdspraw = dsp_state.instance;

            thisdsp.setRaw(thisdspraw);

            /*
             *  This redundant call just shows using the instance parameter of FMOD_DSP_STATE and using it to
             *  call a DSP information function.
             */
            StringBuilder name = new StringBuilder();

            thisdsp.getInfo(name, ref temp, ref temp1, ref temp1, ref temp1);

            /*
             *  This loop assumes inchannels = outchannels, which it will be if the DSP is created with '0'
             *  as the number of channels in FMOD_DSP_DESCRIPTION.
             *  Specifying an actual channel count will mean you have to take care of any number of channels coming in,
             *  but outputting the number of channels specified.  Generally it is best to keep the channel
             *  count at 0 for maximum compatibility.
             */
            unsafe
            {
                float *inbuffer  = (float *)inbuf.ToPointer();
                float *outbuffer = (float *)outbuf.ToPointer();

                for (count = 0; count < length; count++)
                {
                    /*
                     *  Feel free to unroll this.
                     */
                    for (count2 = 0; count2 < outchannels; count2++)
                    {
                        /*
                         *  This DSP filter just halves the volume!
                         *  Input is modified, and sent to output.
                         */
                        outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2] * 0.2f;
                    }
                }
            }

            return(FMOD.RESULT.OK);
        }