Ejemplo n.º 1
0
        /// <summary>
        /// Method to paste user's selection to desired position
        /// </summary>
        public void pasteAtSelection()
        {
            if (!Clipboard.ContainsData("WaveFile"))
            {
                MessageBox.Show("No samples in clipboard.", "Error");
                return;
            }
            WaveFile data = (WaveFile)Clipboard.GetData("WaveFile");

            if (data == null)
            {
                MessageBox.Show("Error reading clipboard.", "Error");
                return;
            }
            //match number of channels
            data.samples  = Formulas.matchChannels(data.samples, wave.channels);
            data.channels = wave.channels;

            //match sampling rate
            for (int channel = 0; channel < data.channels; channel++)
            {
                data.samples[channel] = Formulas.resample(ref data.samples[channel], data.sampleRate, wave.sampleRate);
            }
            data.sampleRate = wave.sampleRate;

            wave.cutSelection(timeSelStart, timeSelEnd);
            wave.pasteSelection(timeSelStart, data);
            updateReport(data.getNumSamples() + " samples pasted");
            timeDomain.SelectionEnd = timeSelStart + data.getNumSamples();
            timeDomain.setSamples(wave.samples);
            waveStop();
            invalidPlayer = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to change the sample rate of active waveWindow
        /// </summary>
        /// <param name="newRate"></param>
        public void changeSampleRate(int newRate)
        {
            if (newRate == wave.sampleRate)
            {
                return;
            }

            for (int channel = 0; channel < wave.channels; channel++)
            {
                wave.samples[channel] = Formulas.resample(ref wave.samples[channel], wave.sampleRate, newRate);
            }
            wave.sampleRate = newRate;
            updateFreqStatusBar();
            calculateDFT();
            timeDomain.setSamples(wave.samples);
            timeDomain.Invalidate();
        }