1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
// ------------------------------------------------------------------------
// qechainopevent.cpp: Process audio data with a chain operator
// provided by libecasound
// Copyright (C) 2000 Kai Vehmanen (kaiv@wakkanet.fi)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// ------------------------------------------------------------------------
#include <qaccel.h>
#include <qlayout.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qvgroupbox.h>
#include <qhgroupbox.h>
#include <qpushbutton.h>
#include <qprogressdialog.h>
#include <qmessagebox.h>
#include <string>
#include <map>
#include "qechainopevent.h"
QEChainopEvent::QEChainopEvent (ECA_CONTROL* ctrl,
const string& input,
const string& output,
long int start_pos,
long int length,
QWidget *parent,
const char *name)
: QDialog(parent, name, false),
QENonblockingEvent(ctrl),
ectrl(ctrl),
input_rep(input),
output_rep(output),
start_pos_rep(start_pos),
length_rep(length) {
init_layout();
}
void QEChainopEvent::restart(long int start_pos, long int length) {
start_pos_rep = start_pos;
length_rep = length;
if (mode == process_mode) process();
else preview();
}
long int QEChainopEvent::position_in_samples(void) const {
if (ectrl->is_running() == true)
return(start_pos_rep + ectrl->position_in_samples() - ectrl->get_chainsetup()->buffersize());
return(start_pos_rep);
}
void QEChainopEvent::preview(void) {
mode = preview_mode;
init("chainopevent-preview", "default");
set_input(input_rep);
set_input_position(start_pos_rep);
set_length(length_rep);
set_default_audio_format(input_rep);
ectrl->add_default_output();
if (copinput != 0) {
copinput->update_results();
OPERATOR* c = dynamic_cast<OPERATOR*>(copinput->result());
if (c != 0) {
c = c->clone();
ectrl->add_chain_operator(dynamic_cast<CHAIN_OPERATOR*>(c));
}
// parametrien asetus!!!
}
start();
}
void QEChainopEvent::process(void) {
mode = process_mode;
init("chainopevent-process", "default");
set_input(input_rep);
set_input_position(start_pos_rep);
set_length(length_rep);
set_default_audio_format(input_rep);
set_output(output_rep);
set_output_position(start_pos_rep);
if (copinput != 0) {
copinput->update_results();
OPERATOR* c = dynamic_cast<OPERATOR*>(copinput->result());
if (c != 0) {
c = c->clone();
ectrl->add_chain_operator(dynamic_cast<CHAIN_OPERATOR*>(c));
}
// parametrien asetus!!!
}
blocking_start();
emit finished();
accept();
}
void QEChainopEvent::init_layout(void) {
QBoxLayout* top = new QVBoxLayout(this);
copinput = new QEChainOperatorInput(this, "qechainop");
copinput->setMaximumHeight(500);
top->addWidget(copinput);
top->addSpacing(10);
QBoxLayout* buttons = new QHBoxLayout();
QPushButton* process_button = new QPushButton( "Pr(o)cess", this);
buttons->addWidget(process_button);
QPushButton* preview_button = new QPushButton( "(P)review", this);
buttons->addWidget(preview_button);
QPushButton* cancel_button = new QPushButton( "(C)ancel", this);
buttons->addWidget(cancel_button);
QObject::connect(process_button, SIGNAL(clicked()), this, SLOT(process()));
QObject::connect(preview_button, SIGNAL(clicked()), this, SLOT(preview()));
QObject::connect(cancel_button, SIGNAL(clicked()), this, SLOT(reject()));
QAccel *a = new QAccel(this);
a->connectItem(a->insertItem(CTRL+Key_O), this, SLOT(process()));
a->connectItem(a->insertItem(CTRL+Key_P), this, SLOT(preview()));
a->connectItem(a->insertItem(CTRL+Key_C), this, SLOT(reject()));
top->addLayout(buttons);
}
|