Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[f57d9f]: libkwave / modules / ChannelMixer.h Maximize Restore History

Download this file

ChannelMixer.h    138 lines (104 with data), 4.2 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
/*************************************************************************
ChannelMixer.h - matrix based mixer for multiple channels
-------------------
begin : Sun Oct 10 2010
copyright : (C) 2010 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 _CHANNEL_MIXER_H_
#define _CHANNEL_MIXER_H_
#include "config.h"
#include <QObject>
#include <QString>
#include <QVector>
#include <QPointer>
#include <QQueue>
#include "libkwave/Connect.h"
#include "libkwave/SampleSink.h"
#include "libkwave/SampleSource.h"
#include "libkwave/modules/StreamObject.h"
#include "libkwave/modules/SampleBuffer.h"
//***************************************************************************
namespace Kwave {
class MixerMatrix;
class KDE_EXPORT ChannelMixer: public Kwave::SampleSource
{
Q_OBJECT
public:
/**
* Constructor
* @param inputs number of input channels
* @param outputs number of output channels
*/
ChannelMixer(unsigned int inputs, unsigned int outputs);
/** Destructor */
virtual ~ChannelMixer();
/**
* Init function, you must call it once after creating and before
* using this object. If the return value is false, you should
* delete this object.
* @return true if succeeded, false if failed
*/
virtual bool init();
/**
* Returns the number of tracks of a input or output port.
* Can be overwritten for objects that have a different count
* of inputs and outputs.
* @param port name of the port (name of signal or slot)
* @return number of tracks of a input or output, default is
* the same as tracks()
*/
virtual unsigned int tracksOfPort(const QString &port) const;
/**
* Returns an indexed port, identified by name
* @param port name of the port (name of signal or slot)
* @param track index of the track
*/
virtual Kwave::StreamObject *port(const QString &port,
unsigned int track);
/** does nothing, work is done automatically in mix() */
virtual void goOn()
{
}
signals:
/** emits a block with output data */
void output(Kwave::SampleArray data);
public slots:
/**
* dummy implementation, the real "input" is a multi-track slot
* and available through the port(...) interface only
*/
void input(Kwave::SampleArray data) { Q_UNUSED(data); }
private slots:
/** receives a block with index + input data */
void idxInput(unsigned int index, Kwave::SampleArray data);
private:
/** does the calculation */
virtual void mix();
private:
/** mixer matrix */
Kwave::MixerMatrix *m_matrix;
/** number of inputs */
unsigned int m_inputs;
/** number of outputs */
unsigned int m_outputs;
QVector< QPointer<Kwave::StreamObject> > m_indexer;
/** queues for input data */
QVector< QQueue<Kwave::SampleArray> > m_input_queue;
/** buffers with output data */
QVector< QPointer<Kwave::SampleBuffer> > m_output_buffer;
/** mutex for locking access to the queues */
QMutex m_lock;
};
}
#endif /* _CHANNEL_MIXER_H_ */
//***************************************************************************
//***************************************************************************