[4dad63]: plugins / newsignal / NewSignalPlugin.cpp  Maximize  Restore  History

Download this file

122 lines (100 with data), 3.8 kB

  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
/***************************************************************************
NewSignalPlugin.cpp - plugin for creating a new signal
-------------------
begin : Wed Jul 18 2001
copyright : (C) 2001 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "config.h"
#include "errno.h"
#include <qstringlist.h>
#include "NewSignalPlugin.h"
#include "NewSignalDialog.h"
KWAVE_PLUGIN(NewSignalPlugin,"newsignal","Thomas Eschenbacher");
//***************************************************************************
NewSignalPlugin::NewSignalPlugin(PluginContext &context)
:KwavePlugin(context), m_samples(2646000), m_rate(44100),
m_bits(16), m_tracks(2), m_bytime(true)
{
}
//***************************************************************************
NewSignalPlugin::~NewSignalPlugin()
{
}
//***************************************************************************
int NewSignalPlugin::interpreteParameters(QStringList &params)
{
bool ok;
QString param;
// evaluate the parameter list
ASSERT(params.count() == 5);
if (params.count() != 5) {
warning("NewSignalPlugin::interpreteParams(): params.count()=%d",
params.count());
return -EINVAL;
}
param = params[0];
m_samples = param.toUInt(&ok);
ASSERT(ok);
if (!ok) return -EINVAL;
param = params[1];
m_rate = (unsigned int)param.toDouble(&ok);
ASSERT(ok);
if (!ok) return -EINVAL;
param = params[2];
m_bits = param.toUInt(&ok);
ASSERT(ok);
if (!ok) return -EINVAL;
param = params[3];
m_tracks = param.toUInt(&ok);
ASSERT(ok);
if (!ok) return -EINVAL;
param = params[4];
m_bytime = (param.toUInt(&ok) != 0);
ASSERT(ok);
if (!ok) return -EINVAL;
return 0;
}
//***************************************************************************
QStringList *NewSignalPlugin::setup(QStringList &previous_params)
{
// try to interprete the previous parameters
interpreteParameters(previous_params);
// create the setup dialog
NewSignalDialog *dialog = new NewSignalDialog(parentWidget(),
m_samples, m_rate, m_bits, m_tracks, m_bytime);
ASSERT(dialog);
if (!dialog) return 0;
QStringList *list = new QStringList();
ASSERT(list);
if (list && dialog->exec()) {
// user has pressed "OK"
*list << QString::number(dialog->samples());
*list << QString::number(dialog->rate());
*list << QString::number(dialog->bitsPerSample());
*list << QString::number(dialog->tracks());
*list << (dialog->byTime() ? "1" : "0");
emitCommand("newsignal("+
QString::number(dialog->samples())+","+
QString::number(dialog->rate())+","+
QString::number(dialog->bitsPerSample())+","+
QString::number(dialog->tracks())+")"
);
} else {
// user pressed "Cancel"
if (list) delete list;
list = 0;
}
if (dialog) delete dialog;
return list;
};
//***************************************************************************
//***************************************************************************