コード例 #1
0
        private void sineWave_Click(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;
            float       pan = 0, frequency = 0;

            if (channel != null)
            {
                channel.stop();
            }

            if (dsp != null)
            {
                dsp.release();
            }

            /*
             *  Create an oscillator DSP unit for the tone.
             */
            result = system.createDSPByType(FMOD.DSP_TYPE.OSCILLATOR, ref dsp);
            ERRCHECK(result);
            result = dsp.setParameter((int)FMOD.DSP_OSCILLATOR.RATE, 440.0f);       /* musical note 'A' */
            ERRCHECK(result);

            result = system.playDSP(FMOD.CHANNELINDEX.REUSE, dsp, true, ref channel);
            ERRCHECK(result);
            channel.setVolume(0.5f);
            result = dsp.setParameter((int)FMOD.DSP_OSCILLATOR.TYPE, 0);
            ERRCHECK(result);
            channel.setPaused(false);

            channel.getFrequency(ref frequency);
            channel.getPan(ref pan);

            trackBarVolume.Value    = 512;
            trackBarFrequency.Value = (int)frequency;
            trackBarPan.Value       = (int)(pan * 512);
        }