Пример #1
0
        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
        /*
         * ================  Interaction Callbacks  ================
         */

        public void wavePlayPause()
        {
            if (player2 == null)
            {
                player2 = new WavePlayer(this);
            }

            if (invalidPlayer)
            {
                if (tSelEnd == tSelStart)
                {
                    player2.setWave(wave.copySelection(tSelStart, wave.getNumSamples()));
                }
                else
                {
                    player2.setWave(wave.copySelection(tSelStart, tSelEnd));
                }
                invalidPlayer = false;
            }

            if (player2.Playing)
            {
                player2.PlaybackPause();
            }
            else
            {
                player2.PlaybackStart();
            }
        }
Пример #3
0
        internal void pasteSelection(int destIndex, WaveFile newWave)
        {
            //TODO: newWave must be resampled to match sampling rate with current sample.
            double[][] result = new double[channels][];
            int        i;

            if (destIndex > getNumSamples())
            {
                destIndex = getNumSamples();
            }
            int pre  = destIndex;
            int mid  = newWave.getNumSamples();
            int post = getNumSamples() - destIndex;

            for (i = 0; i < channels; i++)
            {
                result[i] = new double[pre + mid + post];
            }

            for (int channel = 0; channel < channels; channel++)
            {
                //fill in pre
                for (i = 0; i < pre; i++)
                {
                    result[channel][i] = samples[channel][i];
                }
                //fill in mid
                for (i = pre; i < pre + mid; i++)
                {
                    result[channel][i] = newWave.samples[channel][i - pre];
                }
                //fill in post
                for (i = pre; i < pre + post; i++)
                {
                    result[channel][i + mid] = samples[channel][i];
                }
            }
            samples = result;
        }
Пример #4
0
        internal void pasteSelection(int destIndex, WaveFile newWave)
        {
            //TODO: newWave must be resampled to match sampling rate with current sample.
            double[][] result = new double[channels][];
            int i;
            if (destIndex > getNumSamples()) {
                destIndex = getNumSamples();
            }
            int pre = destIndex;
            int mid = newWave.getNumSamples();
            int post = getNumSamples() - destIndex;

            for (i = 0; i < channels; i++) {
                result[i] = new double[pre + mid + post];
            }

            for (int channel = 0; channel < channels; channel++) {
                //fill in pre
                for (i = 0; i < pre; i++) {
                    result[channel][i] = samples[channel][i];
                }
                //fill in mid
                for (i = pre; i < pre + mid; i++) {
                    result[channel][i] = newWave.samples[channel][i - pre];
                }
                //fill in post
                for (i = pre; i < pre + post; i++) {
                    result[channel][i + mid] = samples[channel][i];
                }
            }
            samples = result;
        }