コード例 #1
0
ファイル: WaveForm.cs プロジェクト: JoePelz/DSPProject
        public void pasteAtSelection()
        {
            if (!Clipboard.ContainsData("WaveFile"))
            {
                MessageBox.Show("No samples in clipboard.");
                return;
            }
            WaveFile data = (WaveFile)Clipboard.GetData("WaveFile");

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

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

            wave.cutSelection(tSelStart, tSelEnd);
            wave.pasteSelection(tSelStart, data);
            updateReport(data.getNumSamples() + " samples pasted from the clipboard!");
            panelWave.SelectionEnd = tSelStart + data.getNumSamples();
            panelWave.setSamples(wave.samples);
            waveStop();
            invalidPlayer = true;
        }
コード例 #2
0
ファイル: WaveFile.cs プロジェクト: JoePelz/DSPProject
        internal WaveFile copySelection(int start, int end)
        {
            if (!inRange(start) || end <= start)
            {
                return(null);
            }
            if (end > getNumSamples())
            {
                end = getNumSamples();
            }
            double[][] duplicate = new double[channels][];
            for (int i = 0; i < channels; i++)
            {
                duplicate[i] = new double[end - start];
            }

            for (int channel = 0; channel < channels; channel++)
            {
                Array.Copy(samples[channel], start, duplicate[channel], 0, end - start);
            }

            WaveFile copy = new WaveFile(bitDepth, channels, sampleRate);

            copy.pasteSelection(0, duplicate);
            return(copy);
        }
コード例 #3
0
ファイル: WaveFile.cs プロジェクト: JoePelz/DSPProject
        internal WaveFile copySelection(int start, int end)
        {
            if (!inRange(start) || end <= start) {
                return null;
            }
            if (end > getNumSamples()) {
                end = getNumSamples();
            }
            double[][] duplicate = new double[channels][];
            for (int i = 0; i < channels; i++) {
                duplicate[i] = new double[end - start];
            }

            for (int channel = 0; channel < channels; channel++) {
                Array.Copy(samples[channel], start, duplicate[channel], 0, end - start);
            }

            WaveFile copy = new WaveFile(bitDepth, channels, sampleRate);
            copy.pasteSelection(0, duplicate);
            return copy;
        }