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; }
public void changeSampleRate(int newRate) { if (newRate == wave.sampleRate) { return; } for (int channel = 0; channel < wave.channels; channel++) { wave.samples[channel] = DSP.resample(ref wave.samples[channel], wave.sampleRate, newRate); } wave.sampleRate = newRate; updateStatusBar(); calculateDFT(); panelWave.setSamples(wave.samples); panelWave.Invalidate(); }