Beispiel #1
0
 /// <summary>
 /// Administer some special effects. Wheee!
 /// </summary>
 /// <param name="effect"></param>
 /// <param name="args"></param>
 /// <param name="data"></param>
 public static void ApplyFX(DSP_FX effect, object[] args, ref WaveFile data)
 {
     double factor;
     switch (effect) {
         case DSP_FX.reverse:
             for (int channel = 0; channel < data.channels; channel++) {
                 Array.Reverse(data.samples[channel]);
             }
             break;
         case DSP_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 DSP_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;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Administer some special effects. Wheee!
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="args"></param>
        /// <param name="data"></param>
        public static void ApplyFX(DSP_FX effect, object[] args, ref WaveFile data)
        {
            double factor;

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

            case DSP_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 DSP_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;
            }
        }
Beispiel #3
0
        public void applyFX(DSP_FX effect, object[] args)
        {
            int startIndex = Math.Max(tSelStart, 0);
            int endIndex;

            if (tSelEnd != tSelStart)
            {
                endIndex = tSelEnd;
            }
            else
            {
                endIndex = wave.getNumSamples();
            }

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

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