Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

izsound::CrossFader Class Reference

#include <crossfader.h>

Inheritance diagram for izsound::CrossFader:

Inheritance graph
[legend]
Collaboration diagram for izsound::CrossFader:

Collaboration graph
[legend]
List of all members.

Detailed Description

A crossfader DSP unit.

It mixes 2 sound streams together. The crossfader lets you specify how much each stream must contribute to the output. This unit has two input slots and one output slot.

Some buffering is performed because IzSound does not work with fixed size data chuncks. Each slot data first gets inside its buffer. If an input slot does not have any incoming data, then the buffer will be filled with silence. This can happen in case of a buffer underrun or when a unit does not have more sound to produce.

Author:
Julien PONGE <julien@izforge.com>

Definition at line 60 of file crossfader.h.

Public Member Functions

 CrossFader (const double &pos=0.0, const unsigned int &sampleRate=44100)
 The constructor.

virtual ~CrossFader ()
 The destructor.

double getPosition () const
 Gets the crossfader position.

void setPosition (const double &pos)
 Sets the crossfader position.

unsigned int getSampleRate () const
 Returns the audio chain sample rate.

unsigned int getMaxInSlots () const
 Returns the maximum number of in-slots.

unsigned int getMaxOutSlots () const
 Returns the maximum number of out-slots.

void connect (DspUnit *dspUnit, const unsigned int &mySlot, const unsigned int &itsSlot)
 Connects the DSP unit with another one.

void disconnect (const unsigned int &mySlot)
 Disconnects the DSP unit from another one.

void run ()
 Runs the DSP unit in the chain.

void bindInput (DspUnit *dsp, const unsigned int &mySlot, const unsigned int itsSlot)
 Binds an input slot of the unit to another DspUnit input slot.

void bindOutput (SlotData *data, const unsigned int &slot)
 Binds an output slot of the unit to a SlotData instance.

virtual void reset ()
 Resets the DSP unit.


Protected Member Functions

virtual void performDsp ()
 Mixes the two streams together.


Protected Attributes

unsigned int m_sampleRate
 The audio chain sample rate.

unsigned int m_maxInSlots
 The maximum number of in-slots.

unsigned int m_maxOutSlots
 The maximum number of out-slots.

vector< SlotData * > m_inSlots
 The in-slots data.

vector< SlotData * > m_outSlots
 The out-slots data.

bit_vector m_bindedSlots
 The binded slots tracker.

vector< DspUnit * > m_outDspUnits
 The output dsp units.

unsigned int m_receptionCounter
 Data reception counter.

unsigned int m_receptionTrigger
 Data reception trigger.


Constructor & Destructor Documentation

CrossFader::CrossFader const double &  pos = 0.0,
const unsigned int &  sampleRate = 44100
 

The constructor.

Parameters:
pos The initial crossfader position.
sampleRate The audio chain sample rate.

Definition at line 56 of file crossfader.cpp.

References setPosition().


Member Function Documentation

void DspUnit::bindInput DspUnit dsp,
const unsigned int &  mySlot,
const unsigned int  itsSlot
[inherited]
 

Binds an input slot of the unit to another DspUnit input slot.

Use with extreme care, this can be dangerous and is only recommended when building a DSP chain inside a DSP unit. There is no checking performed.

Parameters:
dsp The dsp to bind the input to.
mySlot The slot number of this DSP.
itsSlot The other unit slot number.

Definition at line 122 of file dspunit.cpp.

References izsound::DspUnit::m_bindedSlots, and izsound::DspUnit::m_inSlots.

void DspUnit::bindOutput SlotData *  data,
const unsigned int &  slot
[inherited]
 

Binds an output slot of the unit to a SlotData instance.

Use with extreme care, this can be dangerous and is only recommended when building a DSP chain inside a DSP unit. There is no checking performed.

Parameters:
data The data to use as the output.
slot The slot number.

Definition at line 130 of file dspunit.cpp.

References izsound::DspUnit::m_outSlots.

void DspUnit::connect DspUnit dspUnit,
const unsigned int &  mySlot,
const unsigned int &  itsSlot
[inherited]
 

Connects the DSP unit with another one.

The DSP unit will precede the unit it is connected to. If the provided slots numbers are not in the valid ranges, then nothing is done.

Parameters:
dspUnit The dspUnit to connect to.
mySlot The output slot number to connect from.
itsSlot The input slot number to connect to.

Definition at line 77 of file dspunit.cpp.

References izsound::DspUnit::disconnect(), izsound::DspUnit::m_inSlots, izsound::DspUnit::m_maxInSlots, izsound::DspUnit::m_maxOutSlots, izsound::DspUnit::m_outDspUnits, izsound::DspUnit::m_outSlots, and izsound::DspUnit::m_receptionTrigger.

void DspUnit::disconnect const unsigned int &  mySlot  )  [inherited]
 

Disconnects the DSP unit from another one.

The connected DSP unit slot data is cleared.

Parameters:
mySlot The output slot number to disconnect from.

Definition at line 90 of file dspunit.cpp.

References izsound::DspUnit::m_maxOutSlots, izsound::DspUnit::m_outDspUnits, and izsound::DspUnit::m_outSlots.

Referenced by izsound::DspUnit::connect().

unsigned int izsound::DspUnit::getMaxInSlots  )  const [inline, inherited]
 

Returns the maximum number of in-slots.

Returns:
The maximum number of in-slots.

Definition at line 150 of file dspunit.h.

References izsound::DspUnit::m_maxInSlots.

unsigned int izsound::DspUnit::getMaxOutSlots  )  const [inline, inherited]
 

Returns the maximum number of out-slots.

Returns:
The maximum number of out-slots.

Definition at line 157 of file dspunit.h.

References izsound::DspUnit::m_maxOutSlots.

double izsound::CrossFader::getPosition  )  const [inline]
 

Gets the crossfader position.

Returns:
The crossfader position.

Definition at line 107 of file crossfader.h.

unsigned int izsound::DspUnit::getSampleRate  )  const [inline, inherited]
 

Returns the audio chain sample rate.

Returns:
The sample rate.

Definition at line 143 of file dspunit.h.

References izsound::DspUnit::m_sampleRate.

virtual void izsound::DspUnit::reset  )  [inline, virtual, inherited]
 

Resets the DSP unit.

By default, it will not do anything. However, some units can have some kind of state associated with them. For instance, it can have some internal buffer containing work-in-progress data. If the unit is disconnected and connected again latter, it will start working again with some older (and maybe inconsistant) data. That's why a reset makes sense.

As a consequence, redefine this method if the DSP unit that you are developping could be affected by beeing used at discontinuous times because it maintains some kind of state.

As a DSP units user, call this method on DSP units that redefine it whenever you take them out of a chain, but might put them back in later.

Reimplemented in izsound::DataPicker, and izsound::Flanger.

Definition at line 227 of file dspunit.h.

void DspUnit::run  )  [inherited]
 

Runs the DSP unit in the chain.

It calls the performDsp() method then runs the following Dsp units. Consequently, a Dsp units chain should be run inside a loop where the source units run() methods are invocated. NEVER call this method until all your connections are made !. You could get memory errors if you did so.

Definition at line 101 of file dspunit.cpp.

References izsound::DspUnit::m_outDspUnits, izsound::DspUnit::m_receptionCounter, izsound::DspUnit::m_receptionTrigger, and izsound::DspUnit::performDsp().

void CrossFader::setPosition const double &  pos  ) 
 

Sets the crossfader position.

A value of -1.0 means 100% to the first stream while a value of 1.0 means 100% to the second one. The value 0.0 stands for the middle position (50% / 50%).

Parameters:
pos The new position. If pos is out of the [-1.0 ; 1.0] range, it will be clipped.

Definition at line 69 of file crossfader.cpp.

Referenced by CrossFader().


The documentation for this class was generated from the following files:
Generated on Fri Jan 30 18:47:21 2004 for IzSound by doxygen 1.3.5