Exemplo n.º 1
0
        /// <summary>
        /// Method to perform FX effects on the wave data.
        /// </summary>
        /// <param name="edit"></param>
        /// <param name="args"></param>
        /// <param name="data"></param>
        public static void ApplyFX(EDIT_FX edit, object[] args, ref WaveFile data)
        {
            double factor;

            switch (edit)
            {
            case EDIT_FX.reverse:
                for (int channel = 0; channel < data.channels; channel++)
                {
                    Array.Reverse(data.samples[channel]);
                }
                break;

            case EDIT_FX.normalize:
                for (int channel = 0; channel < data.channels; channel++)
                {
                    factor = maxAmplitude(data.samples[channel]) * 1.1;
                    for (int sample = 0; sample < data.samples[channel].Length; sample++)
                    {
                        data.samples[channel][sample] = data.samples[channel][sample] / factor;
                    }
                }
                break;

            case EDIT_FX.pitchshift:
                for (int channel = 0; channel < data.channels; channel++)
                {
                    data.samples[channel] = pitchShift(ref data.samples[channel], data.sampleRate, (int)args[0]);
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to apply FX effects
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="args"></param>
        public void applyDSPFX(EDIT_FX effect, object[] args)
        {
            int startIndex = Math.Max(timeSelStart, 0);
            int endIndex;

            if (timeSelEnd != timeSelStart)
            {
                endIndex = timeSelEnd;
            }
            else
            {
                endIndex = wave.getNumSamples();
            }

            WaveFile data = wave.cutSelection(startIndex, endIndex);

            Formulas.ApplyFX(effect, args, ref data);
            wave.pasteSelection(startIndex, data.samples);
            timeDomain.setSamples(wave.samples);
            timeDomain.Invalidate();
            invalidPlayer = true;
        }