summaryrefslogtreecommitdiff
path: root/attic/muse2-oom/muse2/muse/waveedit
diff options
context:
space:
mode:
Diffstat (limited to 'attic/muse2-oom/muse2/muse/waveedit')
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt87
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/editgain.cpp91
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/editgain.h39
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui262
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp462
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveedit.h83
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveview.cpp946
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveview.h99
8 files changed, 0 insertions, 2069 deletions
diff --git a/attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt b/attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt
deleted file mode 100644
index 24696887..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-#=============================================================================
-# MusE
-# Linux Music Editor
-# $Id:$
-#
-# Copyright (C) 2002-2006 by Werner Schweer and others
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#=============================================================================
-
-##
-## Expand Qt macros in source files
-##
-QT4_WRAP_CPP ( waveedit_mocs
- editgain.h
- waveedit.h
- waveview.h
- )
-
-##
-## UI files
-##
-file (GLOB waveedit_ui_files
- editgainbase.ui
- )
-QT4_WRAP_UI (waveedit_ui_headers ${waveedit_ui_files} )
-
-##
-## List of source files to compile
-##
-file (GLOB waveedit_source_files
- editgain.cpp
- waveedit.cpp
- waveview.cpp
- )
-
-##
-## Define target
-##
-add_library ( waveedit SHARED
- ${waveedit_source_files}
- ${waveedit_ui_headers}
- ${waveedit_mocs}
- )
-
-##
-## Append to the list of translations
-##
-set (FILES_TO_TRANSLATE
- ${FILES_TO_TRANSLATE}
- ${waveedit_source_files}
- ${waveedit_ui_files}
- CACHE INTERNAL ""
- )
-
-##
-## Compilation flags and target name
-##
-set_target_properties( waveedit
- PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
- OUTPUT_NAME muse_waveedit
- )
-
-##
-## Linkage
-##
-target_link_libraries( waveedit
- ${QT_LIBRARIES}
- widgets
- )
-
-##
-## Install location
-##
-install(TARGETS waveedit
- DESTINATION ${MusE_MODULES_DIR}
- )
diff --git a/attic/muse2-oom/muse2/muse/waveedit/editgain.cpp b/attic/muse2-oom/muse2/muse/waveedit/editgain.cpp
deleted file mode 100644
index c36df603..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/editgain.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// C++ Implementation: editgain
-//
-// Description:
-//
-//
-// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2005
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#include <QDialog>
-
-#include "editgain.h"
-
-EditGain::EditGain(QWidget* parent, int initGainValue)
- : QDialog(parent)
- {
- setupUi(this);
- sliderGain->setValue(sliderGain->maximum() - initGainValue);
- connect(buttonReset, SIGNAL(pressed()), this, SLOT(resetPressed()));
- connect(buttonApply, SIGNAL(pressed()), this, SLOT(applyPressed()));
- connect(buttonCancel,SIGNAL(pressed()), this, SLOT(cancelPressed()));
- connect(sliderGain, SIGNAL(valueChanged(int)), this, SLOT(gainChanged(int)));
- if (sliderGain->value() != 100)
- buttonReset->setEnabled(true);
- }
-
-
-EditGain::~EditGain()
- {
- }
-
-
-/*!
- \fn EditGain::resetPressed
- */
-void EditGain::resetPressed()
- {
- sliderGain->blockSignals(true);
- sliderGain->setValue(100);
- sliderGain->blockSignals(false);
- buttonReset->setEnabled(false);
- buttonApply->setEnabled(false);
- }
-
-
-/*!
- \fn EditGain::applyPressed()
- */
-void EditGain::applyPressed()
- {
- done(QDialog::Accepted);
- }
-
-
-/*!
- \fn EditGain::cancelPressed()
- */
-void EditGain::cancelPressed()
- {
- done(QDialog::Rejected);
- }
-
-
-
-/*!
- \fn EditGain::gainChanged(int value)
- */
-void EditGain::gainChanged(int value)
- {
- gain = sliderGain->maximum() - value;
- if (sliderGain->value() != 100) {
- buttonReset->setEnabled(true);
- buttonApply->setEnabled(true);
- }
- else {
- buttonReset->setEnabled(false);
- buttonApply->setEnabled(false);
- }
- }
-
-
-/*!
- \fn EditGain::getGain()
- */
-int EditGain::getGain()
- {
- return gain;
- }
diff --git a/attic/muse2-oom/muse2/muse/waveedit/editgain.h b/attic/muse2-oom/muse2/muse/waveedit/editgain.h
deleted file mode 100644
index 9cbc1d79..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/editgain.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// C++ Interface: editgain
-//
-// Description:
-//
-//
-// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2005
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#ifndef EDITGAIN_H
-#define EDITGAIN_H
-
-#include "ui_editgainbase.h"
-
-class QDialog;
-
-class EditGain : public QDialog, public Ui::EditGainBase
-{
- Q_OBJECT
-public:
- EditGain(QWidget* parent = 0, int initGainValue=100);
-
- ~EditGain();
- int getGain();
-
-private:
- int gain;
-
-private slots:
- void resetPressed();
- void applyPressed();
- void cancelPressed();
- void gainChanged(int value);
-};
-
-#endif
diff --git a/attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui b/attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui
deleted file mode 100644
index 6d7f4716..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui
+++ /dev/null
@@ -1,262 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>EditGainBase</class>
- <widget class="QDialog" name="EditGainBase">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>284</width>
- <height>367</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>MusE: Modify gain</string>
- </property>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QGroupBox" name="groupBox2">
- <property name="title">
- <string>Gain</string>
- </property>
- <layout class="QVBoxLayout">
- <item>
- <layout class="QHBoxLayout">
- <item>
- <spacer name="spacer6">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>90</width>
- <height>41</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QSlider" name="sliderGain">
- <property name="minimumSize">
- <size>
- <width>40</width>
- <height>150</height>
- </size>
- </property>
- <property name="maximum">
- <number>200</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="tickPosition">
- <enum>QSlider::TicksBothSides</enum>
- </property>
- <property name="tickInterval">
- <number>10</number>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QLabel" name="textLabel2">
- <property name="text">
- <string>200%</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="spacer4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>30</width>
- <height>109</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="textLabel1">
- <property name="text">
- <string>100%</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="spacer3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>30</width>
- <height>108</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="textLabel3">
- <property name="text">
- <string>0%</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="spacer7">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>51</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <item>
- <spacer name="spacer11">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>70</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonReset">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>&amp;Reset</string>
- </property>
- <property name="shortcut">
- <string>Alt+R</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="spacer12">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>71</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="buttonGroup2">
- <property name="title">
- <string/>
- </property>
- <layout class="QVBoxLayout">
- <item>
- <layout class="QHBoxLayout">
- <item>
- <widget class="QPushButton" name="buttonApply">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>&amp;Apply</string>
- </property>
- <property name="shortcut">
- <string>Alt+A</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="spacer5">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>61</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonCancel">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>&amp;Cancel</string>
- </property>
- <property name="shortcut">
- <string>Alt+C</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp b/attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp
deleted file mode 100644
index a6251503..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp
+++ /dev/null
@@ -1,462 +0,0 @@
-//=========================================================
-// MusE
-// Linux Music Editor
-// $Id: waveedit.cpp,v 1.5.2.12 2009/04/06 01:24:54 terminator356 Exp $
-// (C) Copyright 2000 Werner Schweer (ws@seh.de)
-//=========================================================
-
-#include "app.h"
-#include "xml.h"
-#include "waveedit.h"
-#include "mtscale.h"
-#include "scrollscale.h"
-#include "waveview.h"
-#include "ttoolbar.h"
-#include "globals.h"
-#include "audio.h"
-#include "utils.h"
-#include "song.h"
-#include "poslabel.h"
-#include "gconfig.h"
-#include "icons.h"
-#include "shortcuts.h"
-
-#include <QMenu>
-#include <QSignalMapper>
-#include <QToolBar>
-#include <QToolButton>
-#include <QLayout>
-#include <QSizeGrip>
-#include <QScrollBar>
-#include <QLabel>
-#include <QSlider>
-#include <QMenuBar>
-#include <QAction>
-#include <QCloseEvent>
-#include <QResizeEvent>
-#include <QKeyEvent>
-
-extern QColor readColor(Xml& xml);
-
-int WaveEdit::_widthInit = 600;
-int WaveEdit::_heightInit = 400;
-
-//---------------------------------------------------------
-// closeEvent
-//---------------------------------------------------------
-
-void WaveEdit::closeEvent(QCloseEvent* e)
- {
- emit deleted((unsigned long)this);
- e->accept();
- }
-
-//---------------------------------------------------------
-// WaveEdit
-//---------------------------------------------------------
-
-WaveEdit::WaveEdit(PartList* pl)
- : MidiEditor(1, 1, pl)
- {
- resize(_widthInit, _heightInit);
-
- QSignalMapper* mapper = new QSignalMapper(this);
- QAction* act;
-
- //---------Pulldown Menu----------------------------
- // We probably don't need an empty menu - Orcan
- //QMenu* menuFile = menuBar()->addMenu(tr("&File"));
- QMenu* menuEdit = menuBar()->addMenu(tr("&Edit"));
-
- menuFunctions = menuBar()->addMenu(tr("Func&tions"));
-
- menuGain = menuFunctions->addMenu(tr("&Gain"));
-
- act = menuGain->addAction(tr("200%"));
- mapper->setMapping(act, CMD_GAIN_200);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuGain->addAction(tr("150%"));
- mapper->setMapping(act, CMD_GAIN_150);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuGain->addAction(tr("75%"));
- mapper->setMapping(act, CMD_GAIN_75);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuGain->addAction(tr("50%"));
- mapper->setMapping(act, CMD_GAIN_50);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuGain->addAction(tr("25%"));
- mapper->setMapping(act, CMD_GAIN_25);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuGain->addAction(tr("Other"));
- mapper->setMapping(act, CMD_GAIN_FREE);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- connect(mapper, SIGNAL(mapped(int)), this, SLOT(cmd(int)));
-
- menuFunctions->addSeparator();
-
- act = menuEdit->addAction(tr("Edit in E&xternal Editor"));
- mapper->setMapping(act, CMD_EDIT_EXTERNAL);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuFunctions->addAction(tr("Mute Selection"));
- mapper->setMapping(act, CMD_MUTE);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuFunctions->addAction(tr("Normalize Selection"));
- mapper->setMapping(act, CMD_NORMALIZE);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuFunctions->addAction(tr("Fade In Selection"));
- mapper->setMapping(act, CMD_FADE_IN);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuFunctions->addAction(tr("Fade Out Selection"));
- mapper->setMapping(act, CMD_FADE_OUT);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- act = menuFunctions->addAction(tr("Reverse Selection"));
- mapper->setMapping(act, CMD_REVERSE);
- connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
-
- select = menuEdit->addMenu(QIcon(*selectIcon), tr("Select"));
-
- selectAllAction = select->addAction(QIcon(*select_allIcon), tr("Select &All"));
- mapper->setMapping(selectAllAction, CMD_SELECT_ALL);
- connect(selectAllAction, SIGNAL(triggered()), mapper, SLOT(map()));
-
- selectNoneAction = select->addAction(QIcon(*select_allIcon), tr("&Deselect All"));
- mapper->setMapping(selectNoneAction, CMD_SELECT_NONE);
- connect(selectNoneAction, SIGNAL(triggered()), mapper, SLOT(map()));
-
- //---------ToolBar----------------------------------
- tools = addToolBar(tr("Wave edit tools"));
- tools->addActions(undoRedo->actions());
-
- connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
-
- //--------------------------------------------------
- // Transport Bar
- QToolBar* transport = addToolBar(tr("transport"));
- transport->addActions(transportAction->actions());
-
- //--------------------------------------------------
- // ToolBar: Solo Cursor1 Cursor2
-
- addToolBarBreak();
- tb1 = addToolBar(tr("Pianoroll tools"));
-
- //tb1->setLabel(tr("weTools"));
- solo = new QToolButton();
- solo->setText(tr("Solo"));
- solo->setCheckable(true);
- tb1->addWidget(solo);
- connect(solo, SIGNAL(toggled(bool)), SLOT(soloChanged(bool)));
-
- QLabel* label = new QLabel(tr("Cursor"));
- tb1->addWidget(label);
- label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
- label->setIndent(3);
- pos1 = new PosLabel(0);
- pos1->setFixedHeight(22);
- tb1->addWidget(pos1);
- pos2 = new PosLabel(0);
- pos2->setFixedHeight(22);
- pos2->setSmpte(true);
- tb1->addWidget(pos2);
-
- //---------------------------------------------------
- // Rest
- //---------------------------------------------------
-
- int yscale = 256;
- int xscale;
-
- if (!parts()->empty()) { // Roughly match total size of part
- Part* firstPart = parts()->begin()->second;
- xscale = 0 - firstPart->lenFrame()/_widthInit;
- }
- else {
- xscale = -8000;
- }
-
- hscroll = new ScrollScale(1, -32768, xscale, 10000, Qt::Horizontal, mainw, 0, true, 10000.0);
- view = new WaveView(this, mainw, xscale, yscale);
- wview = view; // HACK!
-
- QSizeGrip* corner = new QSizeGrip(mainw);
- ymag = new QSlider(Qt::Vertical, mainw);
- ymag->setMinimum(1);
- ymag->setMaximum(256);
- ymag->setPageStep(256);
- ymag->setValue(yscale);
-
- time = new MTScale(&_raster, mainw, xscale, true);
- ymag->setFixedWidth(16);
- connect(view, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int)));
- connect(ymag, SIGNAL(valueChanged(int)), view, SLOT(setYScale(int)));
- time->setOrigin(0, 0);
-
- mainGrid->setRowStretch(0, 100);
- mainGrid->setColumnStretch(0, 100);
-
- mainGrid->addWidget(time, 0, 0, 1, 2);
- mainGrid->addWidget(hLine(mainw), 1, 0, 1, 2);
- mainGrid->addWidget(view, 2, 0);
- mainGrid->addWidget(ymag, 2, 1);
- mainGrid->addWidget(hscroll, 3, 0);
- mainGrid->addWidget(corner, 3, 1, Qt::AlignBottom | Qt::AlignRight);
-
- view->setFocus(); // Tim.
-
- connect(hscroll, SIGNAL(scrollChanged(int)), view, SLOT(setXPos(int)));
- connect(hscroll, SIGNAL(scaleChanged(int)), view, SLOT(setXMag(int)));
- setWindowTitle(view->getCaption());
- connect(view, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
-
- connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int)));
- connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
-// connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
- connect(view, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
-
- connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
- connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
-
- updateHScrollRange();
- configChanged();
-
- if(!parts()->empty())
- {
- WavePart* part = (WavePart*)(parts()->begin()->second);
- solo->setChecked(part->track()->solo());
- }
- }
-
-//---------------------------------------------------------
-// configChanged
-//---------------------------------------------------------
-
-void WaveEdit::configChanged()
- {
- view->setBg(config.waveEditBackgroundColor);
- selectAllAction->setShortcut(shortcuts[SHRT_SELECT_ALL].key);
- selectNoneAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key);
- }
-
-//---------------------------------------------------------
-// updateHScrollRange
-//---------------------------------------------------------
-void WaveEdit::updateHScrollRange()
-{
- int s, e;
- wview->range(&s, &e);
- // Show one more measure.
- e += AL::sigmap.ticksMeasure(e);
- // Show another quarter measure due to imprecise drawing at canvas end point.
- e += AL::sigmap.ticksMeasure(e) / 4;
- // Compensate for the vscroll width.
- //e += wview->rmapxDev(-vscroll->width());
- int s1, e1;
- hscroll->range(&s1, &e1);
- if(s != s1 || e != e1)
- hscroll->setRange(s, e);
-}
-
-//---------------------------------------------------------
-// setTime
-//---------------------------------------------------------
-
-void WaveEdit::setTime(unsigned samplepos)
- {
-// printf("setTime %d %x\n", samplepos, samplepos);
- unsigned tick = tempomap.frame2tick(samplepos);
- pos1->setValue(tick);
- //pos2->setValue(tick);
- pos2->setValue(samplepos);
- time->setPos(3, tick, false);
- }
-
-//---------------------------------------------------------
-// ~WaveEdit
-//---------------------------------------------------------
-
-WaveEdit::~WaveEdit()
- {
- // undoRedo->removeFrom(tools); // p4.0.6 Removed
- }
-
-//---------------------------------------------------------
-// cmd
-//---------------------------------------------------------
-
-void WaveEdit::cmd(int n)
- {
- view->cmd(n);
- }
-
-//---------------------------------------------------------
-// loadConfiguration
-//---------------------------------------------------------
-
-void WaveEdit::readConfiguration(Xml& xml)
- {
- for (;;) {
- Xml::Token token = xml.parse();
- const QString& tag = xml.s1();
- switch (token) {
- case Xml::TagStart:
- if (tag == "bgcolor")
- config.waveEditBackgroundColor = readColor(xml);
- else if (tag == "width")
- _widthInit = xml.parseInt();
- else if (tag == "height")
- _heightInit = xml.parseInt();
- else
- xml.unknown("WaveEdit");
- break;
- case Xml::TagEnd:
- if (tag == "waveedit")
- return;
- default:
- break;
- case Xml::Error:
- case Xml::End:
- return;
- }
- }
- }
-
-//---------------------------------------------------------
-// saveConfiguration
-//---------------------------------------------------------
-
-void WaveEdit::writeConfiguration(int level, Xml& xml)
- {
- xml.tag(level++, "waveedit");
- xml.colorTag(level, "bgcolor", config.waveEditBackgroundColor);
- xml.intTag(level, "width", _widthInit);
- xml.intTag(level, "height", _heightInit);
- xml.tag(level, "/waveedit");
- }
-
-//---------------------------------------------------------
-// writeStatus
-//---------------------------------------------------------
-
-void WaveEdit::writeStatus(int level, Xml& xml) const
- {
- writePartList(level, xml);
- xml.tag(level++, "waveedit");
- MidiEditor::writeStatus(level, xml);
- xml.intTag(level, "xpos", hscroll->pos());
- xml.intTag(level, "xmag", hscroll->mag());
- xml.intTag(level, "ymag", ymag->value());
- xml.tag(level, "/waveedit");
- }
-
-//---------------------------------------------------------
-// readStatus
-//---------------------------------------------------------
-
-void WaveEdit::readStatus(Xml& xml)
- {
- for (;;) {
- Xml::Token token = xml.parse();
- if (token == Xml::Error || token == Xml::End)
- break;
- QString tag = xml.s1();
- switch (token) {
- case Xml::TagStart:
- if (tag == "midieditor")
- MidiEditor::readStatus(xml);
- else if (tag == "xmag")
- hscroll->setMag(xml.parseInt());
- else if (tag == "ymag")
- ymag->setValue(xml.parseInt());
- else if (tag == "xpos")
- hscroll->setPos(xml.parseInt());
- else
- xml.unknown("WaveEdit");
- break;
- case Xml::TagEnd:
- if (tag == "waveedit")
- return;
- default:
- break;
- }
- }
- }
-
-//---------------------------------------------------------
-// resizeEvent
-//---------------------------------------------------------
-
-void WaveEdit::resizeEvent(QResizeEvent* ev)
- {
- QWidget::resizeEvent(ev);
- _widthInit = ev->size().width();
- _heightInit = ev->size().height();
- }
-
-//---------------------------------------------------------
-// songChanged1
-// signal from "song"
-//---------------------------------------------------------
-
-void WaveEdit::songChanged1(int bits)
- {
-
- if (bits & SC_SOLO)
- {
- WavePart* part = (WavePart*)(parts()->begin()->second);
- solo->blockSignals(true);
- solo->setChecked(part->track()->solo());
- solo->blockSignals(false);
- }
-
- songChanged(bits);
- }
-
-
-//---------------------------------------------------------
-// soloChanged
-// signal from solo button
-//---------------------------------------------------------
-
-void WaveEdit::soloChanged(bool flag)
- {
- WavePart* part = (WavePart*)(parts()->begin()->second);
- audio->msgSetSolo(part->track(), flag);
- song->update(SC_SOLO);
- }
-
-//---------------------------------------------------------
-// viewKeyPressEvent
-//---------------------------------------------------------
-
-void WaveEdit::keyPressEvent(QKeyEvent* event)
- {
- int key = event->key();
- if (key == Qt::Key_Escape) {
- close();
- return;
- }
- else {
- event->ignore();
- }
- }
-
-//---------------------------------------------------------
-// moveVerticalSlider
-//---------------------------------------------------------
-
-void WaveEdit::moveVerticalSlider(int val)
- {
- ymag->setValue(ymag->value() + val);
- }
-
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveedit.h b/attic/muse2-oom/muse2/muse/waveedit/waveedit.h
deleted file mode 100644
index 79102410..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/waveedit.h
+++ /dev/null
@@ -1,83 +0,0 @@
-//=========================================================
-// MusE
-// Linux Music Editor
-// $Id: waveedit.h,v 1.3.2.8 2008/01/26 07:23:21 terminator356 Exp $
-// (C) Copyright 2000 Werner Schweer (ws@seh.de)
-//=========================================================
-
-#ifndef __WAVE_EDIT_H__
-#define __WAVE_EDIT_H__
-
-#include <QMenu>
-
-#include <QWidget>
-#include <QResizeEvent>
-#include <QKeyEvent>
-#include <QCloseEvent>
-#include "midieditor.h"
-
-class QToolButton;
-class PartList;
-class WaveView;
-class ScrollScale;
-class QSlider;
-class PosLabel;
-class QResizeEvent;
-class SNode;
-class QAction;
-
-//---------------------------------------------------------
-// WaveEdit
-//---------------------------------------------------------
-
-class WaveEdit : public MidiEditor {
- WaveView* view;
- QSlider* ymag;
- QToolBar* tools;
- QToolBar* tb1;
- QToolButton* solo;
- PosLabel* pos1;
- PosLabel* pos2;
- QAction* selectAllAction;
- QAction* selectNoneAction;
-
- static int _widthInit, _heightInit;
-
- Q_OBJECT
- virtual void closeEvent(QCloseEvent*);
- virtual void resizeEvent(QResizeEvent* ev);
- virtual void keyPressEvent(QKeyEvent*);
-
- QMenu* menuFunctions, *select, *menuGain;
-
- private slots:
- void cmd(int);
- void setTime(unsigned t);
- void songChanged1(int);
- void soloChanged(bool flag);
- void moveVerticalSlider(int val);
-
- public slots:
- void configChanged();
-
- virtual void updateHScrollRange();
-
- signals:
- void deleted(unsigned long);
-
- public:
- WaveEdit(PartList*);
- ~WaveEdit();
- virtual void readStatus(Xml&);
- virtual void writeStatus(int, Xml&) const;
- static void readConfiguration(Xml&);
- static void writeConfiguration(int, Xml&);
-
- enum { CMD_MUTE=0, CMD_NORMALIZE, CMD_FADE_IN, CMD_FADE_OUT, CMD_REVERSE,
- CMD_GAIN_FREE, CMD_GAIN_200, CMD_GAIN_150, CMD_GAIN_75, CMD_GAIN_50, CMD_GAIN_25,
- CMD_EDIT_EXTERNAL,
- CMD_SELECT_ALL, CMD_SELECT_NONE };
- };
-
-#endif
-
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveview.cpp b/attic/muse2-oom/muse2/muse/waveedit/waveview.cpp
deleted file mode 100644
index 668d8bea..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/waveview.cpp
+++ /dev/null
@@ -1,946 +0,0 @@
-//=========================================================
-// MusE
-// Linux Music Editor
-// $Id: waveview.cpp,v 1.10.2.16 2009/11/14 03:37:48 terminator356 Exp $
-// (C) Copyright 2000 Werner Schweer (ws@seh.de)
-//=========================================================
-
-#include <stdio.h>
-#include <values.h>
-#include <sys/wait.h>
-
-#include <QPainter>
-#include <QDir>
-#include <QFileInfo>
-#include <QMessageBox>
-#include <QMouseEvent>
-
-#include "editgain.h"
-#include "globals.h"
-#include "wave.h"
-#include "waveview.h"
-#include "song.h"
-#include "event.h"
-#include "waveedit.h"
-#include "audio.h"
-#include "gconfig.h"
-
-bool modifyWarnedYet = false;
-//---------------------------------------------------------
-// WaveView
-//---------------------------------------------------------
-
-WaveView::WaveView(MidiEditor* pr, QWidget* parent, int xscale, int yscale)
- : View(parent, xscale, 1)
- {
- editor = pr;
- setVirt(true);
- pos[0] = tempomap.tick2frame(song->cpos());
- pos[1] = tempomap.tick2frame(song->lpos());
- pos[2] = tempomap.tick2frame(song->rpos());
- yScale = yscale;
- mode = NORMAL;
- selectionStart = 0;
- selectionStop = 0;
- lastGainvalue = 100;
-
- setFocusPolicy(Qt::StrongFocus); // Tim.
-
- setMouseTracking(true);
- setBg(QColor(192, 208, 255));
-
- if (editor->parts()->empty()) {
- curPart = 0;
- curPartId = -1;
- }
- else {
- curPart = (WavePart*)(editor->parts()->begin()->second);
- curPartId = curPart->sn();
- }
-
-
- connect(song, SIGNAL(posChanged(int,unsigned,bool)), SLOT(setPos(int,unsigned,bool)));
- connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
- songChanged(SC_SELECTION);
- }
-
-//---------------------------------------------------------
-// setYScale
-//---------------------------------------------------------
-
-void WaveView::setYScale(int val)
- {
- yScale = val;
- redraw();
- }
-
-//---------------------------------------------------------
-// draw
-//---------------------------------------------------------
-
-void WaveView::pdraw(QPainter& p, const QRect& rr)
- {
- int x1 = rr.x();
- int x2 = rr.right() + 1;
- if (x1 < 0)
- x1 = 0;
- if (x2 > width())
- x2 = width();
- int hh = height();
- int h = hh/2;
- int y = rr.y() + h;
-
- // Added by T356.
- int xScale = xmag;
- if (xScale < 0)
- xScale = -xScale;
-
- for (iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) {
- WavePart* wp = (WavePart*)(ip->second);
- int channels = wp->track()->channels();
- int px = wp->frame();
-
- EventList* el = wp->events();
- for (iEvent e = el->begin(); e != el->end(); ++e) {
- Event event = e->second;
- if (event.empty())
- continue;
- SndFileR f = event.sndFile();
- if (f.isNull())
- continue;
-
- unsigned peoffset = px + event.frame() - event.spos();
- int sx, ex;
-
- sx = event.frame() + px + xScale/2;
- ex = sx + event.lenFrame();
- sx = sx / xScale - xpos;
- ex = ex / xScale - xpos;
-
- if (sx < x1)
- sx = x1;
- if (ex > x2)
- ex = x2;
-
- int pos = (xpos + sx) * xScale + event.spos() - event.frame() - px;
-
- //printf("pos=%d xpos=%d sx=%d ex=%d xScale=%d event.spos=%d event.frame=%d px=%d\n",
- // pos, xpos, sx, ex, xScale, event.spos(), event.frame(), px);
-
- h = hh / (channels * 2);
- int cc = hh % (channels * 2) ? 0 : 1;
-
- for (int i = sx; i < ex; i++) {
- y = rr.y() + h;
- SampleV sa[f.channels()];
- f.read(sa, xScale, pos);
- pos += xScale;
- if (pos < event.spos())
- continue;
-
- int selectionStartPos = selectionStart - peoffset; // Offset transformed to event coords
- int selectionStopPos = selectionStop - peoffset;
-
- for (int k = 0; k < channels; ++k) {
- int kk = k % f.channels();
- int peak = (sa[kk].peak * (h - 1)) / yScale;
- int rms = (sa[kk].rms * (h - 1)) / yScale;
- if (peak > h)
- peak = h;
- if (rms > h)
- rms = h;
- QColor peak_color = QColor(Qt::darkGray);
- QColor rms_color = QColor(Qt::black);
-
- // Changed by T356. Reduces (but not eliminates) drawing artifacts.
- //if (pos > selectionStartPos && pos < selectionStopPos) {
- if (pos > selectionStartPos && pos <= selectionStopPos) {
-
- peak_color = QColor(Qt::lightGray);
- rms_color = QColor(Qt::white);
- // Draw inverted
- p.setPen(QColor(Qt::black));
- p.drawLine(i, y - h + cc, i, y + h - cc );
- }
- p.setPen(peak_color);
- p.drawLine(i, y - peak - cc, i, y + peak);
- p.setPen(rms_color);
- p.drawLine(i, y - rms - cc, i, y + rms);
- y += 2 * h;
- }
- }
- }
- }
- View::pdraw(p, rr);
- }
-
-//---------------------------------------------------------
-// draw
-//---------------------------------------------------------
-
-void WaveView::draw(QPainter& p, const QRect& r)
- {
- unsigned x = r.x() < 0 ? 0 : r.x();
- unsigned y = r.y() < 0 ? 0 : r.y();
- int w = r.width();
- int h = r.height();
-
- unsigned x2 = x + w;
- unsigned y2 = y + h;
-
- //
- // draw marker & centerline
- //
- p.setPen(Qt::red);
- if (pos[0] >= x && pos[0] < x2) {
- p.drawLine(pos[0], y, pos[0], y2);
- }
- p.setPen(Qt::blue);
- if (pos[1] >= x && pos[1] < x2) {
- p.drawLine(pos[1], y, pos[1], y2);
- }
- if (pos[2] >= x && pos[2] < x2)
- p.drawLine(pos[2], y, pos[2], y2);
-
- // Changed by T356. Support multiple (or none) selected parts.
- //int n = curPart->track()->channels();
- int n = 1;
- if(curPart)
- n = curPart->track()->channels();
-
- int hn = h / n;
- int hh = hn / 2;
- for (int i = 0; i < n; ++i) {
- int h2 = hn * i;
- int center = hh + h2;
- p.setPen(QColor(i & i ? Qt::red : Qt::blue));
- p.drawLine(x, center, x2, center);
- p.setPen(QColor(Qt::black));
- p.drawLine(x, h2, x2, h2);
- }
- }
-
-//---------------------------------------------------------
-// getCaption
-//---------------------------------------------------------
-
-QString WaveView::getCaption() const
- {
-
- // Changed by T356. Support multiple (or none) selected parts.
- //return QString("Part ") + curPart->name();
- if(curPart)
- return QString("Part ") + curPart->name();
- else
- return QString("Part ");
-
- }
-
-//---------------------------------------------------------
-// songChanged
-//---------------------------------------------------------
-
-void WaveView::songChanged(int flags)
- {
- // Is it simply a midi controller value adjustment? Forget it.
- if(flags == SC_MIDI_CONTROLLER)
- return;
-
- if (flags & SC_SELECTION) {
- startSample = MAXINT;
- endSample = 0;
- curPart = 0;
- for (iPart p = editor->parts()->begin(); p != editor->parts()->end(); ++p) {
- WavePart* part = (WavePart*)(p->second);
- if (part->sn() == curPartId)
- curPart = part;
- int ssample = part->frame();
- int esample = ssample + part->lenFrame();
- if (ssample < startSample) {
- startSample = ssample;
- //printf("startSample = %d\n", startSample);
- }
- if (esample > endSample) {
- endSample = esample;
- //printf("endSample = %d\n", endSample);
- }
- }
- }
- if (flags & SC_CLIP_MODIFIED) {
- redraw(); // Boring, but the only thing possible to do
- }
- if (flags & SC_TEMPO) {
- setPos(0, song->cpos(), false);
- setPos(1, song->lpos(), false);
- setPos(2, song->rpos(), false);
- }
- redraw();
- }
-
-//---------------------------------------------------------
-// setPos
-// set one of three markers
-// idx - 0-cpos 1-lpos 2-rpos
-// flag - emit followEvent()
-//---------------------------------------------------------
-
-void WaveView::setPos(int idx, unsigned val, bool adjustScrollbar)
- {
- val = tempomap.tick2frame(val);
- if (pos[idx] == val)
- return;
- int opos = mapx(pos[idx]);
- int npos = mapx(val);
-
- if (adjustScrollbar && idx == 0) {
- switch (song->follow()) {
- case Song::NO:
- break;
- case Song::JUMP:
- if (npos >= width()) {
- int ppos = val - xorg - rmapxDev(width()/4);
- if (ppos < 0)
- ppos = 0;
- emit followEvent(ppos);
- opos = mapx(pos[idx]);
- npos = mapx(val);
- }
- else if (npos < 0) {
- int ppos = val - xorg - rmapxDev(width()*3/4);
- if (ppos < 0)
- ppos = 0;
- emit followEvent(ppos);
- opos = mapx(pos[idx]);
- npos = mapx(val);
- }
- break;
- case Song::CONTINUOUS:
- if (npos > (width()*5)/8) {
- int ppos = pos[idx] - xorg - rmapxDev(width()*5/8);
- if (ppos < 0)
- ppos = 0;
- emit followEvent(ppos);
- opos = mapx(pos[idx]);
- npos = mapx(val);
- }
- else if (npos < (width()*3)/8) {
- int ppos = pos[idx] - xorg - rmapxDev(width()*3/8);
- if (ppos < 0)
- ppos = 0;
- emit followEvent(ppos);
- opos = mapx(pos[idx]);
- npos = mapx(val);
- }
- break;
- }
- }
-
- int x;
- int w = 1;
- if (opos > npos) {
- w += opos - npos;
- x = npos;
- }
- else {
- w += npos - opos;
- x = opos;
- }
- pos[idx] = val;
- redraw(QRect(x, 0, w, height()));
- }
-
-//---------------------------------------------------------
-// viewMousePressEvent
-//---------------------------------------------------------
-
-void WaveView::viewMousePressEvent(QMouseEvent* event)
- {
- button = event->button();
- unsigned x = event->x();
-
- switch (button) {
- case Qt::LeftButton:
- if (mode == NORMAL) {
- // redraw and reset:
- if (selectionStart != selectionStop) {
- selectionStart = selectionStop = 0;
- redraw();
- }
- mode = DRAG;
- dragstartx = x;
- selectionStart = selectionStop = x;
- }
- break;
-
- case Qt::MidButton:
- case Qt::RightButton:
- default:
- break;
- }
- viewMouseMoveEvent(event);
- }
-
-
-//---------------------------------------------------------
-// wheelEvent
-//---------------------------------------------------------
-void WaveView::wheelEvent(QWheelEvent* event)
- {
- emit mouseWheelMoved(event->delta() / 10);
- }
-
-//---------------------------------------------------------
-// viewMouseReleaseEvent
-//---------------------------------------------------------
-void WaveView::viewMouseReleaseEvent(QMouseEvent* /*event*/)
- {
- button = Qt::NoButton;
-
- if (mode == DRAG) {
- mode = NORMAL;
- //printf("selectionStart=%d selectionStop=%d\n", selectionStart, selectionStop);
- }
- }
-
-//---------------------------------------------------------
-// viewMouseMoveEvent
-//---------------------------------------------------------
-
-void WaveView::viewMouseMoveEvent(QMouseEvent* event)
- {
- unsigned x = event->x();
- emit timeChanged(x);
-
- int i;
- switch (button) {
- case Qt::LeftButton:
- i = 0;
- if (mode == DRAG) {
- if (x < dragstartx) {
- selectionStart = x;
- selectionStop = dragstartx;
- }
- else {
- selectionStart = dragstartx;
- selectionStop = x;
- }
- }
- break;
- case Qt::MidButton:
- i = 1;
- break;
- case Qt::RightButton:
- i = 2;
- break;
- default:
- return;
- }
- Pos p(tempomap.frame2tick(x), true);
- song->setPos(i, p);
- }
-
-//---------------------------------------------------------
-// range
-// returns range in samples
-//---------------------------------------------------------
-
-void WaveView::range(int* s, int *e)
- {
-
- PartList* lst = editor->parts();
- if(lst->empty())
- {
- *s = 0;
- *e = tempomap.tick2frame(song->len());
- return;
- }
- int ps = song->len(), pe = 0;
- int tps, tpe;
- for(iPart ip = lst->begin(); ip != lst->end(); ++ip)
- {
- tps = ip->second->tick();
- if(tps < ps)
- ps = tps;
- tpe = tps + ip->second->lenTick();
- if(tpe > pe)
- pe = tpe;
- }
- *s = tempomap.tick2frame(ps);
- *e = 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()) {
- iPart iBeg = editor->parts()->begin();
- iPart iEnd = editor->parts()->end();
- iEnd--;
- WavePart* beg = (WavePart*) iBeg->second;
- WavePart* end = (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_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) {
- 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
-//---------------------------------------------------------
-WaveSelectionList WaveView::getSelection(unsigned startpos, unsigned stoppos)
- {
- WaveSelectionList selection;
-
- for (iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) {
- WavePart* wp = (WavePart*)(ip->second);
- unsigned part_offset = wp->frame();
-
- EventList* el = wp->events();
- //printf("eventlist length=%d\n",el->size());
-
- for (iEvent e = el->begin(); e != el->end(); ++e) {
- Event event = e->second;
- if (event.empty())
- continue;
- 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());
- 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)
- {
- song->startUndo();
-
- WaveSelectionList selection = getSelection(startpos, stoppos);
- for (iWaveSelection i = selection.begin(); i != selection.end(); i++) {
- WaveEventSelection w = *i;
- SndFileR& file = w.file;
- unsigned sx = w.startframe;
- unsigned ex = w.endframe;
- unsigned file_channels = file.channels();
-
- QString tmpWavFile = QString::null;
- if (!getUniqueTmpfileName(tmpWavFile)) {
- break;
- }
-
- audio->msgIdle(true); // Not good with playback during operations
- SndFile tmpFile(tmpWavFile);
- tmpFile.setFormat(file.format(), file_channels, file.samplerate());
- if (tmpFile.openWrite()) {
- 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; i<file_channels; i++) {
- tmpdata[i] = new float[tmpdatalen];
- }
- file.seek(tmpdataoffset, 0);
- file.readWithHeap(file_channels, tmpdata, tmpdatalen);
- file.close();
- tmpFile.write(file_channels, tmpdata, tmpdatalen);
- tmpFile.close();
-
- switch(operation)
- {
- case MUTE:
- muteSelection(file_channels, tmpdata, tmpdatalen);
- break;
-
- case NORMALIZE:
- normalizeSelection(file_channels, tmpdata, tmpdatalen);
- break;
-
- case FADE_IN:
- fadeInSelection(file_channels, tmpdata, tmpdatalen);
- break;
-
- case FADE_OUT:
- fadeOutSelection(file_channels, tmpdata, tmpdatalen);
- break;
-
- case REVERSE:
- reverseSelection(file_channels, tmpdata, tmpdatalen);
- break;
-
- case GAIN:
- applyGain(file_channels, tmpdata, tmpdatalen, paramA);
- break;
-
- case EDIT_EXTERNAL:
- editExternal(file.format(), file.samplerate(), file_channels, tmpdata, tmpdatalen);
- break;
-
- default:
- printf("Error: Default state reached in modifySelection\n");
- break;
-
- }
-
- file.openWrite();
- file.seek(tmpdataoffset, 0);
- file.write(file_channels, tmpdata, tmpdatalen);
- file.update();
- file.close();
- file.openRead();
-
- for (unsigned i=0; i<file_channels; i++) {
- delete[] tmpdata[i];
- }
-
- // Undo handling
- song->cmdChangeWave(file.dirPath() + "/" + file.name(), tmpWavFile, sx, ex);
- audio->msgIdle(false); // Not good with playback during operations
- }
- song->endUndo(SC_CLIP_MODIFIED);
- redraw();
- }
-
-//---------------------------------------------------------
-// muteSelection
-//---------------------------------------------------------
-void WaveView::muteSelection(unsigned channels, float** data, unsigned length)
- {
- // Set everything to 0!
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length; j++) {
- data[i][j] = 0;
- }
- }
- }
-
-//---------------------------------------------------------
-// normalizeSelection
-//---------------------------------------------------------
-void WaveView::normalizeSelection(unsigned channels, float** data, unsigned length)
- {
- float loudest = 0.0;
-
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length; j++) {
- if (data[i][j] > loudest)
- loudest = data[i][j];
- }
- }
-
- double scale = 0.99 / (double)loudest;
-
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length; j++) {
- data[i][j] = (float) ((double)data[i][j] * scale);
- }
- }
- }
-
-//---------------------------------------------------------
-// fadeInSelection
-//---------------------------------------------------------
-void WaveView::fadeInSelection(unsigned channels, float** data, unsigned length)
- {
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length; j++) {
- double scale = (double) j / (double)length ;
- data[i][j] = (float) ((double)data[i][j] * scale);
- }
- }
- }
-
-//---------------------------------------------------------
-// fadeOutSelection
-//---------------------------------------------------------
-void WaveView::fadeOutSelection(unsigned channels, float** data, unsigned length)
- {
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length; j++) {
- double scale = (double) (length - j) / (double)length ;
- data[i][j] = (float) ((double)data[i][j] * scale);
- }
- }
- }
-
-//---------------------------------------------------------
-// reverseSelection
-//---------------------------------------------------------
-void WaveView::reverseSelection(unsigned channels, float** data, unsigned length)
- {
- if(length <= 1)
- return;
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length/2; j++) {
- float tmpl = data[i][j];
- float tmpr = data[i][length - j - 1];
- data[i][j] = tmpr;
- data[i][length - j - 1] = tmpl;
- }
- }
- }
-//---------------------------------------------------------
-// applyGain
-//---------------------------------------------------------
-void WaveView::applyGain(unsigned channels, float** data, unsigned length, double gain)
- {
- for (unsigned i=0; i<channels; i++) {
- for (unsigned j=0; j<length; j++) {
- data[i][j] = (float) ((double)data[i][j] * gain);
- }
- }
- }
-
-//---------------------------------------------------------
-// editExternal
-//---------------------------------------------------------
-void WaveView::editExternal(unsigned file_format, unsigned file_samplerate, unsigned file_channels, float** tmpdata, unsigned tmpdatalen)
- {
- // Create yet another tmp-file
- QString exttmpFileName;
- if (!getUniqueTmpfileName(exttmpFileName)) {
- printf("Could not create temp file - aborting...\n");
- return;
- }
-
- SndFile exttmpFile(exttmpFileName);
- exttmpFile.setFormat(file_format, file_channels, file_samplerate);
- if (exttmpFile.openWrite()) {
- printf("Could not open temporary file...\n");
- return;
- }
- // Write out change-data to this file:
- exttmpFile.write(file_channels, tmpdata, tmpdatalen);
- exttmpFile.close();
-
- // Forkaborkabork
- int pid = fork();
- if (pid == 0) {
- if (execlp(config.externalWavEditor.toLatin1().constData(), config.externalWavEditor.toLatin1().constData(), exttmpFileName.toLatin1().constData(), NULL) == -1) {
- perror("Failed to launch external editor");
- // Get out of here
-
-
- // cannot report error through gui, we are in another fork!
- //@!TODO: Handle unsuccessful attempts
- exit(99);
- }
- exit(0);
- }
- else if (pid == -1) {
- perror("fork failed");
- }
- else {
- int status;
- waitpid(pid, &status, 0);
- //printf ("status=%d\n",status);
- if( WEXITSTATUS(status) != 0 ){
- QMessageBox::warning(this, tr("MusE - external editor failed"),
- tr("MusE was unable to launch the external editor\ncheck if the editor setting in:\n"
- "Global Settings->Audio: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<file_channels; i++) {
- for (unsigned j=sz; j<tmpdatalen; j++) {
- tmpdata[i][j] = 0;
- }
- }
- }
- }
- QDir dir = exttmpFile.dirPath();
- dir.remove(exttmpFileName);
- dir.remove(exttmpFile.basename() + ".wca");
- }
- }
-
-//---------------------------------------------------------
-// getUniqueTmpfileName
-//---------------------------------------------------------
-bool WaveView::getUniqueTmpfileName(QString& newFilename)
- {
- // Check if tmp-directory exists under project path
- QString tmpWavDir = museProject + "/tmp_musewav"; //!@TODO: Don't hardcode like this
- QFileInfo tmpdirfi(tmpWavDir);
- if (!tmpdirfi.isDir()) {
- // Try to create a tmpdir
- QDir projdir(museProject);
- if (!projdir.mkdir("tmp_musewav")) {
- printf("Could not create undo dir!\n");
- return false;
- }
- }
-
-
- tmpdirfi.setFile(tmpWavDir);
-
- if (!tmpdirfi.isWritable()) {
- printf("Temp directory is not writable - aborting\n");
- return false;
- }
-
- QDir tmpdir = tmpdirfi.dir();
-
- // Find a new filename
- for (int i=0; i<10000; i++) {
- QString filename = "muse_tmp";
- filename.append(QString::number(i));
- filename.append(".wav");
-
- if (!tmpdir.exists(tmpWavDir +"/" + filename)) {
- newFilename = tmpWavDir + "/" + filename;
- return true;
- }
-
- }
-
- printf("Could not find a suitable tmpfilename (more than 10000 tmpfiles in tmpdir - clean up!\n");
- return false;
- }
-
-
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveview.h b/attic/muse2-oom/muse2/muse/waveedit/waveview.h
deleted file mode 100644
index d1f247b3..00000000
--- a/attic/muse2-oom/muse2/muse/waveedit/waveview.h
+++ /dev/null
@@ -1,99 +0,0 @@
-//=========================================================
-// MusE
-// Linux Music Editor
-// $Id: waveview.h,v 1.3.2.6 2009/02/02 21:38:01 terminator356 Exp $
-// (C) Copyright 2000 Werner Schweer (ws@seh.de)
-//=========================================================
-
-#ifndef WAVE_VIEW_H
-#define WAVE_VIEW_H
-
-#include "view.h"
-#include <QWidget>
-#include <QMouseEvent>
-#include "wave.h"
-
-class PartList;
-class QPainter;
-class QRect;
-class WavePart;
-class MidiEditor;
-class SndFileR;
-
-struct WaveEventSelection {
- SndFileR file;
- unsigned startframe;
- unsigned endframe;
- };
-
-typedef std::list<WaveEventSelection> WaveSelectionList;
-typedef std::list<WaveEventSelection>::iterator iWaveSelection;
-
-//---------------------------------------------------------
-// WaveView
-//---------------------------------------------------------
-
-class WaveView : public View {
- MidiEditor* editor;
- unsigned pos[3];
- int yScale;
- int button;
- int startSample;
- int endSample;
-
- WavePart* curPart;
- int curPartId;
-
- enum { NORMAL, DRAG } mode;
- enum { MUTE = 0, NORMALIZE, FADE_IN, FADE_OUT, REVERSE, GAIN, EDIT_EXTERNAL }; //!< Modify operations
-
- unsigned selectionStart, selectionStop, dragstartx;
-
- Q_OBJECT
- virtual void pdraw(QPainter&, const QRect&);
- virtual void draw(QPainter&, const QRect&);
- virtual void viewMousePressEvent(QMouseEvent*);
- virtual void viewMouseMoveEvent(QMouseEvent*);
- virtual void viewMouseReleaseEvent(QMouseEvent*);
- virtual void wheelEvent(QWheelEvent*);
-
- bool getUniqueTmpfileName(QString& newFilename); //!< Generates unique filename for temporary SndFile
- WaveSelectionList getSelection(unsigned startpos, unsigned stoppos);
-
- int lastGainvalue; //!< Stores the last used gainvalue when specifiying gain value in the editgain dialog
- void modifySelection(int operation, unsigned startpos, unsigned stoppos, double paramA); //!< Modifies selection
-
- void muteSelection(unsigned channels, float** data, unsigned length); //!< Mutes selection
- void normalizeSelection(unsigned channels, float** data, unsigned length); //!< Normalizes selection
- void fadeInSelection(unsigned channels, float** data, unsigned length); //!< Linear fade in of selection
- void fadeOutSelection(unsigned channels, float** data, unsigned length); //!< Linear fade out of selection
- void reverseSelection(unsigned channels, float** data, unsigned length); //!< Reverse selection
- void applyGain(unsigned channels, float** data, unsigned length, double gain); //!< Apply gain to selection
-
- void editExternal(unsigned file_format, unsigned file_samplerate, unsigned channels, float** data, unsigned length);
-
- //void applyLadspa(unsigned channels, float** data, unsigned length); //!< Apply LADSPA plugin on selection
-
-
- private slots:
- void setPos(int idx, unsigned val, bool adjustScrollbar);
-
- public slots:
- void setYScale(int);
- void songChanged(int type);
-
- signals:
- void followEvent(int);
- void timeChanged(unsigned);
- void mouseWheelMoved(int);
-
- public:
- WaveView(MidiEditor*, QWidget* parent, int xscale, int yscale);
- QString getCaption() const;
- void range(int*, int*);
- void cmd(int n);
- WavePart* part() { return curPart; }
- };
-
-#endif
-