From 3c6e4156914cec6e3b6d822577a030cef993656a Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 23 Jun 2013 15:45:26 +0200 Subject: removed unused WaveView editing capabilities. (Is done by WaveCanvas) --- muse2/muse/waveedit/waveview.cpp | 491 --------------------------------------- muse2/muse/waveedit/waveview.h | 16 -- 2 files changed, 507 deletions(-) diff --git a/muse2/muse/waveedit/waveview.cpp b/muse2/muse/waveedit/waveview.cpp index df579a43..3e3ea057 100644 --- a/muse2/muse/waveedit/waveview.cpp +++ b/muse2/muse/waveedit/waveview.cpp @@ -526,497 +526,6 @@ void WaveView::range(int* s, int *e) *e = MusEGlobal::tempomap.tick2frame(pe); } -//--------------------------------------------------------- -// cmd -//--------------------------------------------------------- -void WaveView::cmd(int n) - { - int modifyoperation = -1; - double paramA = 0.0; - - switch(n) { - case WaveEdit::CMD_SELECT_ALL: - if (!editor->parts()->empty()) { - MusECore::iPart iBeg = editor->parts()->begin(); - MusECore::iPart iEnd = editor->parts()->end(); - iEnd--; - MusECore::WavePart* beg = (MusECore::WavePart*) iBeg->second; - MusECore::WavePart* end = (MusECore::WavePart*) iEnd->second; - selectionStart = beg->frame(); - selectionStop = end->frame() + end->lenFrame(); - redraw(); - } - break; - - case WaveEdit::CMD_EDIT_EXTERNAL: - modifyoperation = EDIT_EXTERNAL; - break; - - case WaveEdit::CMD_SELECT_NONE: - selectionStart = selectionStop = 0; - redraw(); - break; - case WaveEdit::CMD_EDIT_COPY: - modifyoperation = COPY; - break; - case WaveEdit::CMD_EDIT_CUT: - modifyoperation = CUT; - break; - case WaveEdit::CMD_EDIT_PASTE: - modifyoperation = PASTE; - break; - - case WaveEdit::CMD_MUTE: - modifyoperation = MUTE; - break; - - case WaveEdit::CMD_NORMALIZE: - modifyoperation = NORMALIZE; - break; - - case WaveEdit::CMD_FADE_IN: - modifyoperation = FADE_IN; - break; - - case WaveEdit::CMD_FADE_OUT: - modifyoperation = FADE_OUT; - break; - - case WaveEdit::CMD_REVERSE: - modifyoperation = REVERSE; - break; - - case WaveEdit::CMD_GAIN_FREE: { - EditGain* editGain = new EditGain(this, lastGainvalue); - if (editGain->exec() == QDialog::Accepted) { - lastGainvalue = editGain->getGain(); - modifyoperation = GAIN; - paramA = (double)lastGainvalue / 100.0; - } - delete editGain; - } - break; - - case WaveEdit::CMD_GAIN_200: - modifyoperation = GAIN; - paramA = 2.0; - break; - - case WaveEdit::CMD_GAIN_150: - modifyoperation = GAIN; - paramA = 1.5; - break; - - case WaveEdit::CMD_GAIN_75: - modifyoperation = GAIN; - paramA = 0.75; - break; - - case WaveEdit::CMD_GAIN_50: - modifyoperation = GAIN; - paramA = 0.5; - break; - - case WaveEdit::CMD_GAIN_25: - modifyoperation = GAIN; - paramA = 0.25; - break; - - default: - break; - } - - if (modifyoperation != -1) { - if (selectionStart == selectionStop && modifyoperation!=PASTE) { - printf("No selection. Ignoring\n"); //@!TODO: Disable menu options when no selection - QMessageBox::information(this, - QString("MusE"), - QWidget::tr("No selection. Ignoring")); - - return; - } - - //if(!modifyWarnedYet) - //{ - // modifyWarnedYet = true; - // if(QMessageBox::warning(this, QString("Muse"), - // tr("Warning! Muse currently operates directly on the sound file.\n" - // "Undo is supported, but NOT after exit, WITH OR WITHOUT A SAVE!\n" - // "If you are stuck, try deleting the associated .wca file and reloading."), tr("&Ok"), tr("&Cancel"), - // QString::null, 0, 1 ) != 0) - // return; - //} - modifySelection(modifyoperation, selectionStart, selectionStop, paramA); - } - } - - -//--------------------------------------------------------- -// getSelection -//--------------------------------------------------------- -MusECore::WaveSelectionList WaveView::getSelection(unsigned startpos, unsigned stoppos) - { - MusECore::WaveSelectionList selection; - - for (MusECore::iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) { - MusECore::WavePart* wp = (MusECore::WavePart*)(ip->second); - unsigned part_offset = wp->frame(); - - MusECore::EventList* el = wp->events(); - //printf("eventlist length=%d\n",el->size()); - - for (MusECore::iEvent e = el->begin(); e != el->end(); ++e) { - MusECore::Event event = e->second; - if (event.empty()) - continue; - MusECore::SndFileR file = event.sndFile(); - if (file.isNull()) - continue; - - unsigned event_offset = event.frame() + part_offset; - unsigned event_startpos = event.spos(); - unsigned event_length = event.lenFrame() + event.spos(); - unsigned event_end = event_offset + event_length; - //printf("startpos=%d stoppos=%d part_offset=%d event_offset=%d event_startpos=%d event_length=%d event_end=%d\n", startpos, stoppos, part_offset, event_offset, event_startpos, event_length, event_end); - - if (!(event_end <= startpos || event_offset > stoppos)) { - int tmp_sx = startpos - event_offset + event_startpos; - int tmp_ex = stoppos - event_offset + event_startpos; - unsigned sx; - unsigned ex; - - tmp_sx < (int)event_startpos ? sx = event_startpos : sx = tmp_sx; - tmp_ex > (int)event_length ? ex = event_length : ex = tmp_ex; - - //printf("Event data affected: %d->%d filename:%s\n", sx, ex, file.name().toLatin1().constData()); - MusECore::WaveEventSelection s; - s.file = file; - s.startframe = sx; - s.endframe = ex+1; - //printf("sx=%d ex=%d\n",sx,ex); - selection.push_back(s); - } - } - } - - return selection; - } - -//--------------------------------------------------------- -// modifySelection -//--------------------------------------------------------- -void WaveView::modifySelection(int operation, unsigned startpos, unsigned stoppos, double paramA) - { - MusEGlobal::song->startUndo(); - - if (operation == PASTE) { - // we need to redefine startpos and stoppos - if (copiedPart =="") - return; - MusECore::SndFile pasteFile(copiedPart); - pasteFile.openRead(); - startpos = pos[0]; - stoppos = startpos+ pasteFile.samples(); // possibly this is wrong if there are tempo changes - pasteFile.close(); - pos[0]=stoppos; - } - - MusECore::WaveSelectionList selection = getSelection(startpos, stoppos); - for (MusECore::iWaveSelection i = selection.begin(); i != selection.end(); i++) { - MusECore::WaveEventSelection w = *i; - MusECore::SndFileR& file = w.file; - unsigned sx = w.startframe; - unsigned ex = w.endframe; - unsigned file_channels = file.channels(); - - QString tmpWavFile = QString::null; - if (!MusEGlobal::getUniqueTmpfileName("tmp_musewav",".wav", tmpWavFile)) { - break; - } - - MusEGlobal::audio->msgIdle(true); // Not good with playback during operations - MusECore::SndFile tmpFile(tmpWavFile); - tmpFile.setFormat(file.format(), file_channels, file.samplerate()); - if (tmpFile.openWrite()) { - MusEGlobal::audio->msgIdle(false); - printf("Could not open temporary file...\n"); - break; - } - - // - // Write out data that will be changed to temp file - // - unsigned tmpdatalen = ex - sx; - off_t tmpdataoffset = sx; - float* tmpdata[file_channels]; - - for (unsigned i=0; icmdChangeWave(file.dirPath() + "/" + file.name(), tmpWavFile, sx, ex); - MusEGlobal::audio->msgIdle(false); // Not good with playback during operations - } - MusEGlobal::song->endUndo(SC_CLIP_MODIFIED); - redraw(); - } - -//--------------------------------------------------------- -// copySelection -//--------------------------------------------------------- -void WaveView::copySelection(unsigned file_channels, float** tmpdata, unsigned length, bool blankData, unsigned format, unsigned sampleRate) -{ - if (copiedPart!="") { - QFile::remove(copiedPart); - } - if (!MusEGlobal::getUniqueTmpfileName("tmp_musewav",".wav", copiedPart)) { - return; - } - - MusECore::SndFile tmpFile(copiedPart); - tmpFile.setFormat(format, file_channels, sampleRate); - tmpFile.openWrite(); - tmpFile.write(file_channels, tmpdata, length); - tmpFile.close(); - - if (blankData) { - // Set everything to 0! - for (unsigned i=0; i loudest) - loudest = data[i][j]; - } - } - - double scale = 0.99 / (double)loudest; - - for (unsigned i=0; iAudio:External Waveditor\nis set to a valid editor.")); - } - - if (exttmpFile.openRead()) { - printf("Could not reopen temporary file!\n"); - } - else { - // Re-read file again - exttmpFile.seek(0, 0); - size_t sz = exttmpFile.readWithHeap(file_channels, tmpdata, tmpdatalen); - if (sz != tmpdatalen) { - // File must have been shrunken - not good. Alert user. - QMessageBox::critical(this, tr("MusE - file size changed"), - tr("When editing in external editor - you should not change the filesize\nsince it must fit the selected region.\n\nMissing data is muted")); - for (unsigned i=0; i