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 142 143 144
|
// ------------------------------------------------------------------------
// audioio-typeselect.cpp: A proxy class for overriding default keyword
// and filename associations.
// Copyright (C) 2001,2002,2008,2009 Kai Vehmanen
//
// Attributes:
// eca-style-version: 3
//
// 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 "eca-logger.h"
#include "eca-object-factory.h"
#include "audioio-null.h"
#include "audioio-typeselect.h"
/**
* Constructor.
*/
AUDIO_IO_TYPESELECT::AUDIO_IO_TYPESELECT (void)
{
// ECA_LOG_MSG(ECA_LOGGER::user_objects, "constructor " + label() + ".");
init_rep = false;
}
/**
* Destructor.
*/
AUDIO_IO_TYPESELECT::~AUDIO_IO_TYPESELECT (void)
{
// ECA_LOG_MSG(ECA_LOGGER::user_objects, "destructor " + label() + ".");
}
AUDIO_IO_TYPESELECT* AUDIO_IO_TYPESELECT::clone(void) const
{
AUDIO_IO_TYPESELECT* target = new AUDIO_IO_TYPESELECT();
for(int n = 0; n < number_of_params(); n++) {
target->set_parameter(n + 1, get_parameter(n + 1));
}
return target;
}
void AUDIO_IO_TYPESELECT::open(void) throw(AUDIO_IO::SETUP_ERROR&)
{
ECA_LOG_MSG(ECA_LOGGER::user_objects, "open " + label() + ".");
if (init_rep != true) {
AUDIO_IO* tmp = 0;
const string& objname =
child_params_as_string(2, ¶ms_rep);
tmp =
ECA_OBJECT_FACTORY::create_audio_object(objname);
if (tmp == 0)
throw(SETUP_ERROR(SETUP_ERROR::io_mode, "AUDIOIO-TYPESELECT: unable to open child object '" + objname + "'"));
set_child(tmp);
int numparams = child()->number_of_params();
for(int n = 0; n < numparams; n++) {
child()->set_parameter(n + 1, get_parameter(n + 3));
if (child()->variable_params())
numparams = child()->number_of_params();
}
init_rep = true; /* must be set after dyn. parameters */
}
pre_child_open();
child()->open();
post_child_open();
/* if child changed the format during open;
* fetch the changes */
if (child()->locked_audio_format() == true) {
set_audio_format(child()->audio_format());
}
set_label(child()->label());
set_length_in_samples(child()->length_in_samples());
AUDIO_IO_PROXY::open();
}
void AUDIO_IO_TYPESELECT::close(void)
{
if (child()->is_open() == true) child()->close();
AUDIO_IO_PROXY::close();
}
string AUDIO_IO_TYPESELECT::parameter_names(void) const
{
return string("typeselect,format,") + child()->parameter_names();
}
void AUDIO_IO_TYPESELECT::set_parameter(int param, string value)
{
ECA_LOG_MSG(ECA_LOGGER::user_objects,
"set_parameter "
+ label() + ".");
if (param > static_cast<int>(params_rep.size())) params_rep.resize(param);
if (param > 0) {
params_rep[param - 1] = value;
}
if (param > 2 &&
init_rep == true) {
child()->set_parameter(param - 2, value);
}
}
string AUDIO_IO_TYPESELECT::get_parameter(int param) const
{
ECA_LOG_MSG(ECA_LOGGER::user_objects,
"get_parameter "
+ label() + ".");
if (param > 0 && param < static_cast<int>(params_rep.size()) + 1) {
if (param > 2 &&
init_rep == true) {
params_rep[param - 1] = child()->get_parameter(param - 2);
}
return params_rep[param - 1];
}
return "";
}
|