[a21201]: libkwave / ArtsKwaveMultiTrackFilter.h Maximize Restore History

Download this file

ArtsKwaveMultiTrackFilter.h    186 lines (161 with data), 5.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/***************************************************************************
ArtsKwaveMultiTrackFilter.h - template for multi-track Kwave filters
-------------------
begin : Tue Dec 11 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. *
* *
***************************************************************************/
#ifndef _ARTS_KWAVE_MULTI_TRACK_FILTER_H_
#define _ARTS_KWAVE_MULTI_TRACK_FILTER_H_
#include "config.h"
#ifdef HAVE_ARTS_SUPPORT
#include <string.h>
#include <qglobal.h> // for qWarning()
#include <qptrvector.h>
#include <arts/artsflow.h>
#include <arts/connect.h>
#include <arts/dynamicrequest.h>
#include "libkwave/ArtsMultiTrackFilter.h"
template <class FILTER, class FILTER_IMPL>
class ArtsKwaveMultiTrackFilter: public ArtsMultiTrackFilter
{
public:
/**
* Constructor. Creates all filter objects.
* @param tracks the number of tracks
*/
ArtsKwaveMultiTrackFilter(unsigned int tracks)
:m_count(tracks), m_filter(tracks)
{
// create all filters
unsigned int i;
for (i=0; i < m_count; ++i) {
m_filter.insert(i, 0);
FILTER_IMPL *f = new FILTER_IMPL();
Q_ASSERT(f);
if (f) m_filter.insert(i, new FILTER(FILTER::_from_base(f)));
if (!m_filter[i]) {
qWarning("ArtsMultiTrackFilter: filter creation failed!!!");
m_count = i;
break;
}
}
};
/**
* Destructor. Removes all filters in reverse order.
*/
virtual ~ArtsKwaveMultiTrackFilter()
{
m_filter.setAutoDelete(true);
while (m_count--) {
m_filter.remove(m_count);
}
};
/**
* Returns a pointer to one of the filter objects. (normally used for
* connecting it to another Arts::Object).
* @param i index of the track [0..count-1]
* @return pointer to the object or 0 if index is out of range
*/
virtual Arts::Object *operator[](unsigned int i) {
return m_filter[i];
};
/**
* Connects the input of the filters to an ArtsMultiSource.
* @param source reference to a source (or previous filter)
* @param output_name name of the output streams of the source
* @param input_name name of the input streams of our filters (sink)
*/
virtual void connectInput(ArtsMultiSource &source,
const std::string &output_name = "output",
const std::string &input_name = "input")
{
for (unsigned int i=0; i < m_count; ++i)
Arts::connect(*(source[i]), output_name,
*(m_filter[i]), input_name);
};
/**
* Connects the input of the filters to the output of a single
* aRts object.
* @param source reference to the Arts::Object used as source
* @param output_name name of the output streams of the source
* @param input_name name of the input streams of our filters (sink)
*/
virtual void connectInput(Arts::Object &source,
const std::string &output_name = "output",
const std::string &input_name = "input")
{
for (unsigned int i=0; i < m_count; ++i)
Arts::connect(source, output_name,
*(m_filter[i]), input_name);
};
/**
* Connects the output of the filters to an ArtsMultiSink.
* @param sink reference to a sink (or next filter)
* @param input_name name of the input streams of the sinks
* @param output_name name of the output streams of our filters (source)
*/
virtual void connectOutput(ArtsMultiSink &sink,
const std::string &input_name = "input",
const std::string &output_name = "output")
{
for (unsigned i=0; i < m_count; ++i)
Arts::connect(*(m_filter[i]), output_name,
*(sink[i]), input_name);
};
/**
* Set all input of the filters to the same constant value.
* @param input_name name of the input of the sinks
* @param value float value to be set
*/
virtual void setValue(
const std::string &input_name,
const float value)
{
for (unsigned int i=0; i < m_count; ++i)
Arts::setValue(*(m_filter[i]), input_name, value);
};
/**
* Set all attributes of the filters to the same constant value.
* @param attribute name of the attribute to set
* @param value float value to be set
*/
virtual void setAttribute(
const std::string &attribute,
const float value)
{
std::string command;
command = "_set_";
command += attribute;
for (unsigned int i=0; i < m_count; ++i) {
Arts::Object &object(*(m_filter[i]));
Arts::DynamicRequest(object).method(
command).param(value).invoke();
}
};
/** Starts all filters. */
virtual void start() {
for (unsigned int i=0; i < m_count; ++i) m_filter[i]->start();
};
/** Stops all filters. */
virtual void stop() {
for (unsigned int i=0; i < m_count; ++i) m_filter[i]->stop();
};
private:
/** number of fiters (tracks) */
unsigned int m_count;
/** list of the filters */
QPtrVector<FILTER> m_filter;
};
#else /* HAVE_ARTS_SUPPORT */
#warning aRts support is disabled
#endif /* HAVE_ARTS_SUPPORT */
#endif /* _ARTS_KWAVE_MULTI_TRACK_FILTER_H_ */