Beispiel #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;
        }
Beispiel #2
0
 /// <summary>
 /// method to change number of channels
 /// Updates statusbar.
 /// redraws window.
 /// </summary>
 /// <param name="nChannels"></param>
 public void changeChannels(short nChannels)
 {
     wave.samples  = Formulas.matchChannels(wave.samples, nChannels);
     wave.channels = nChannels;
     updateFreqStatusBar();
     timeDomain.setSamples(wave.samples);
     timeDomain.Invalidate();
 }