kwave  18.07.70
Kwave::StreamObject Class Reference

#include <StreamObject.h>

Inheritance diagram for Kwave::StreamObject:
Inheritance graph
Collaboration diagram for Kwave::StreamObject:
Collaboration graph

Signals

void attributeChanged (const QVariant value)
 

Public Member Functions

 StreamObject (QObject *parent=Q_NULLPTR)
 
virtual ~StreamObject ()
 
virtual unsigned int tracks () const
 
virtual Kwave::StreamObjectoperator[] (unsigned int track)
 
virtual unsigned int tracksOfPort (const char *port) const
 
virtual Kwave::StreamObjectport (const char *port, unsigned int track)
 
virtual unsigned int blockSize () const
 
void setAttribute (const char *attribute, const QVariant &value)
 

Static Public Member Functions

static void setInteractive (bool interactive)
 

Private Attributes

QMutex m_lock_set_attribute
 

Static Private Attributes

static bool m_interactive = false
 

Detailed Description

Definition at line 32 of file StreamObject.h.

Constructor & Destructor Documentation

◆ StreamObject()

Kwave::StreamObject::StreamObject ( QObject *  parent = Q_NULLPTR)
explicit

Constructor

Parameters
parenta parent object, passed to QObject (optional)

Definition at line 29 of file StreamObject.cpp.

30  :QObject(Q_NULLPTR /*parent*/), m_lock_set_attribute(QMutex::Recursive)
31 {
32  Q_UNUSED(parent);
33 }

◆ ~StreamObject()

Kwave::StreamObject::~StreamObject ( )
virtual

Destructor

Definition at line 36 of file StreamObject.cpp.

37 {
38 }

Member Function Documentation

◆ attributeChanged

void Kwave::StreamObject::attributeChanged ( const QVariant  value)
signal

Emitted by setAttribute and connected to the corresponding slot.

Referenced by setAttribute().

Here is the caller graph for this function:

◆ blockSize()

unsigned int Kwave::StreamObject::blockSize ( ) const
virtual

Returns the block size used for producing data.

Returns
currently 32k [samples]

Definition at line 65 of file StreamObject.cpp.

References m_interactive.

Referenced by Kwave::FlacEncoder::encode(), Kwave::SampleBuffer::finished(), Kwave::RecordPlugin::flushPrerecordingQueue(), Kwave::NormalizePlugin::getMaxPowerOfTrack(), Kwave::CurveStreamAdapter::goOn(), Kwave::SampleReader::goOn(), Kwave::Mul::multiply(), Kwave::SampleBuffer::put(), Kwave::ReversePlugin::run(), Kwave::PlayBackPlugin::run(), and Kwave::Delay::setDelay().

66 {
67  return (m_interactive) ? 8*1024 : 512*1024;
68 }
static bool m_interactive
Definition: StreamObject.h:127
Here is the caller graph for this function:

◆ operator[]()

virtual Kwave::StreamObject* Kwave::StreamObject::operator[] ( unsigned int  track)
inlinevirtual

Returns the source that corresponds to one specific track if the object has multiple tracks. For single-track objects it returns "this" for the first index and 0 for all others

Parameters
trackindex of the track
Returns
a stream object or NULL

Reimplemented in Kwave::MultiTrackSource< SOURCE, INITIALIZE >, Kwave::MultiTrackSource< Kwave::SampleReader, false >, Kwave::MultiTrackSource< SOURCE, false >, Kwave::MultiTrackSink< SINK, INITIALIZE >, Kwave::MultiTrackSink< Kwave::Writer, false >, Kwave::MultiTrackSink< Kwave::PlaybackSink, false >, Kwave::MultiTrackSink< Kwave::SampleBuffer, true >, and Kwave::MultiTrackSink< SINK, false >.

Definition at line 59 of file StreamObject.h.

60  {
61  return (track == 0) ? this : Q_NULLPTR;
62  }

◆ port()

virtual Kwave::StreamObject* Kwave::StreamObject::port ( const char *  port,
unsigned int  track 
)
inlinevirtual

Returns an indexed port, identified by name

Parameters
portname of the port (name of signal or slot)
trackindex of the track
Returns
the corresponding stream object

Reimplemented in Kwave::ChannelMixer.

Definition at line 84 of file StreamObject.h.

Referenced by Kwave::_connect_one_by_one().

85  {
86  Q_UNUSED(port);
87  return (*this)[track];
88  }
virtual Kwave::StreamObject * port(const char *port, unsigned int track)
Definition: StreamObject.h:84
Here is the caller graph for this function:

◆ setAttribute()

void Kwave::StreamObject::setAttribute ( const char *  attribute,
const QVariant &  value 
)

Sets an attribute of a Kwave::StreamObject.

Parameters
attributename of the attribute, with the signature of a Qt SLOT(<name>(QVariant value))
valuethe new value of the attribute, stored in a QVariant

Definition at line 41 of file StreamObject.cpp.

References attributeChanged(), Kwave::connect(), m_lock_set_attribute, and tracks().

Referenced by Kwave::MimeData::decode(), Kwave::OpusDecoder::open(), Kwave::SampleRatePlugin::run(), Kwave::PlayBackPlugin::run(), Kwave::OpusEncoder::setupCodingRate(), Kwave::NoisePlugin::updateFilter(), Kwave::BandPassPlugin::updateFilter(), Kwave::PitchShiftPlugin::updateFilter(), Kwave::NotchFilterPlugin::updateFilter(), and Kwave::LowPassPlugin::updateFilter().

43 {
44  QMutexLocker lock(&m_lock_set_attribute);
45 
46  for (unsigned int track = 0; track < tracks(); track++) {
47  Kwave::StreamObject *obj = (*this)[track];
48  if (!obj) continue;
49 
50  // temporary establish a signal->slot connection
51  QObject::connect(this, SIGNAL(attributeChanged(QVariant)),
52  obj, attribute,
53  Qt::DirectConnection);
54 
55  // emit the new value through our own signal
56  emit attributeChanged(value);
57 
58  // remove the temporary signal->slot connection
59  QObject::disconnect(this, SIGNAL(attributeChanged(QVariant)),
60  obj, attribute);
61  }
62 }
virtual unsigned int tracks() const
Definition: StreamObject.h:50
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void attributeChanged(const QVariant value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInteractive()

void Kwave::StreamObject::setInteractive ( bool  interactive)
static

Switch interactive mode on or off. In interactive mode we use a smaller block size for creating objects to get better response time to parameter changes. In non-interactive mode the block size is higher for better performance.

Definition at line 71 of file StreamObject.cpp.

References m_interactive.

Referenced by Kwave::FilterPlugin::run(), and Kwave::PlayBackPlugin::testPlayBack().

72 {
73  m_interactive = interactive;
74 }
static bool m_interactive
Definition: StreamObject.h:127
Here is the caller graph for this function:

◆ tracks()

virtual unsigned int Kwave::StreamObject::tracks ( ) const
inlinevirtual

◆ tracksOfPort()

virtual unsigned int Kwave::StreamObject::tracksOfPort ( const char *  port) const
inlinevirtual

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.

Parameters
portname of the port (name of signal or slot)
Returns
number of tracks of a input or output, default is the same as tracks()

Reimplemented in Kwave::ChannelMixer.

Definition at line 72 of file StreamObject.h.

Referenced by Kwave::connect().

73  {
74  Q_UNUSED(port);
75  return tracks();
76  }
virtual unsigned int tracks() const
Definition: StreamObject.h:50
virtual Kwave::StreamObject * port(const char *port, unsigned int track)
Definition: StreamObject.h:84
Here is the caller graph for this function:

Member Data Documentation

◆ m_interactive

bool Kwave::StreamObject::m_interactive = false
staticprivate

interactive mode: if enabled, use smaller block size

interactive mode

Definition at line 127 of file StreamObject.h.

Referenced by blockSize(), and setInteractive().

◆ m_lock_set_attribute

QMutex Kwave::StreamObject::m_lock_set_attribute
private

Mutex for locking access to setAttribute (recursive)

Definition at line 124 of file StreamObject.h.

Referenced by setAttribute().


The documentation for this class was generated from the following files: