Commit ae4fe6f9 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Updating License and style and API appearance update for stream patch bay

parent 98cda513
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University. Any usage and distribution is prohibited, unless explicitly granted by the authors.
\ No newline at end of file
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
You may obtain a copy of the License at
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITAStreamPatchBay.h 2900 2012-09-17 08:42:42Z stienen $
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_STREAM_PATCH_BAY
#define INCLUDE_WATCHER_ITA_STREAM_PATCH_BAY
#include <ITADataSourcesDefinitions.h>
#include <ITAAtomicPrimitives.h>
#include <ITADataSourceRealization.h>
#include <ITAUncopyable.h>
......@@ -42,50 +41,45 @@
pb->Clear();
*/
*/
//! Patchbay for audio streams
/**
* TODO: Documentation
* TODO: Crossfading für Parameter-Änderungen ist nicht sauber implementiert.
*/
/**
* @TODO: Documentation
* @TODO: Crossfading for param change not well implemented
*/
class ITA_DATA_SOURCES_API ITAStreamPatchbay : public ITADatasourceRealizationEventHandler, public ITAUncopyable
{
public:
//! Strategien zur Lautstärke-Anpassung
enum
//! Strategies of switching
enum SwitchingMode
{
GAIN_SWITCH =0, //!< Hartes umschalten der Verstärkung
GAIN_LINEAR_FADE //!< Lineare Anpassung innerhalb eines Stream-Blocks
GAIN_SWITCH = 0, //!< Hartes umschalten der Verstärkung
GAIN_LINEAR_FADE, //!< Lineare Anpassung innerhalb eines Stream-Blocks
};
//! Constructor
/**
* Creates a new patchbay without any inputs and outputs.
*
* \param dSamplerate Sampling rate [Hz]
* \param iBlockLength Blocklength [samples]
* @param dSamplerate Sampling rate [Hz]
* @param iBlockLength Blocklength [samples]
*/
ITAStreamPatchbay( const double dSamplerate,
const int iBlockLength,
const int iFadeLength=128,
const int iGainAdaption=GAIN_LINEAR_FADE );
ITAStreamPatchbay( const double dSamplerate, const int iBlockLength, const int iFadeLength = 128, const int iGainAdaption = GAIN_LINEAR_FADE );
//! Destructor
virtual ~ITAStreamPatchbay();
//! Reset
/**
* Resets the streams of all outputs and clears internal buffers.
*
* \important Do not call when streaming
* @important Do not call when streaming
*/
void Reset();
//! Remove all inputs, outputs and channel routings
/*
* \important Do not call when streaming
* @important Do not call when streaming
*/
void Clear();
......@@ -99,86 +93,63 @@ public:
int GetInputNumChannels( const int iInput ) const;
//! Returns the number of channels of an output
int GetOutputNumChannels(const int iOutput ) const;
int GetOutputNumChannels( const int iOutput ) const;
//! Creates a new input and returns its index
/*
* \important Do not call when streaming
* @important Do not call when streaming
*/
int AddInput( const int iNumChannels );
//! Creates a new input, connects the given datasource and returns input index
/*
* \important Do not call when streaming
* @important Do not call when streaming
*/
int AddInput( ITADatasource* pIn );
//! Removes an input
/*
* \important Do not call when streaming
* \note All subsequent input IDs will be decreased
* @important Do not call when streaming
* @note All subsequent input IDs will be decreased
*/
bool RemoveInput( int uiInput );
//! Creates a new output and returns its index
/*
* \important Do not call when streaming
* @important Do not call when streaming
*/
int AddOutput( const int iNumChannels );
//! Return the datasource of an input
/**
* \note Returns NULL if no datasource is attached to this input
*/
* @note Returns NULL if no datasource is attached to this input
*/
ITADatasource* GetInputDatasource( const int iInput ) const;
//! Set the datasource for an input
/**
* \note Passing NULL removes a present datasource assignment
* \important Do not call when streaming
*/
* @note Passing NULL removes a present datasource assignment
* @important Do not call when streaming
*/
void SetInputDatasource( const int iInput, ITADatasource* pdsDatasource );
//! Return the datasource of an output
ITADatasource* GetOutputDatasource( const int iOutput ) const;
/* Evtl. later:
//! For an output return the connected input (-1 => output not connected)
void GetOutputConnectedToInput(const int iInput,
const int iInputChannel,
int& iOutput,
int& iOutputChannel);
//! For an input return the connected output (-1 => input not connected)
void GetInputConnectedToOutput(const int iOutput,
const int iOutputChannel,
int& iInput,
int& iInputChannel);
*/
//! Connect an input channel to an output channel
void ConnectChannels( const int iInput,
const int iInputChannel,
const int iOutput,
const int iOutputChannel );
void ConnectChannels( const int iInput, const int iInputChannel, const int iOutput, const int iOutputChannel );
//! Connect an input channel to an output channel with a gain
void ConnectChannels( const int iInput,
const int iInputChannel,
const int iOutput,
const int iOutputChannel,
const double dGain );
void ConnectChannels( const int iInput, const int iInputChannel, const int iOutput, const int iOutputChannel, const double dGain );
//! Disconnect one input of an output
void Disconnect( const int iInput,
const int iOutput );
void Disconnect( const int iInput, const int iOutput );
//! Disconnect all channels of an output
void DisconnectOutput( const int iOutput );
//! Disconnect a specific channel of an output
void DisconnectOutputChannel( const int iOutput,
const int iOutputChannel );
void DisconnectOutputChannel( const int iOutput, const int iOutputChannel );
//! Remove all connections between all inputs and all outputs
void DisconnectAllOutputs();
......@@ -208,17 +179,10 @@ public:
void SetOutputGain( const int iOutput, const double dGain );
//! Returns the gain of an input-output connection
double GetConnectionGain( const int iInput,
const int iInputChannel,
const int iOutput,
const int iOutputChannel ) const;
double GetConnectionGain( const int iInput, const int iInputChannel, const int iOutput, const int iOutputChannel ) const;
//! Set the gain of an input-output connection
void SetConnectionGain( const int iInput,
const int iInputChannel,
const int iOutput,
const int iOutputChannel,
const double dGain );
void SetConnectionGain( const int iInput, const int iInputChannel, const int iOutput, const int iOutputChannel, const double dGain );
//! Return the method for gain adaption
unsigned int GetGainAdaption() const;
......@@ -226,10 +190,10 @@ public:
//! Sets the method for gain adaption
void SetGainAdaption( const int iGainAdaption );
//! Returns the number of samples used for gain fading
//! Returns the number of samples used for gain fading
unsigned int GetGainFadeLength() const;
//! Sets the number of samples for gain fading
//! Sets the number of samples for gain fading
/**
* \param iFadeLength Number of samples for fading gains
*
......@@ -237,35 +201,33 @@ public:
*/
void SetGainFadeLength( const int iFadeLength );
//! Prints channel connections on the console (stdout)
//! Prints channel connections on the console (stdout)
void PrintConnections() const;
// --= Realisierte Methoden der Schnittstelle "ITADatasourceRealizationEventHandler" =--
void HandlePreGetBlockPointer( ITADatasourceRealization* pSender, unsigned int uiChannel );
void HandlePostIncrementBlockPointer( ITADatasourceRealization* pSender);
void HandlePostIncrementBlockPointer( ITADatasourceRealization* pSender );
void HandleProcessStream( ITADatasourceRealization* pSender, const ITAStreamInfo* pStreamInfo );
private:
//! Input description
class InputDesc
class InputDesc
{
public:
int iChannels; //!< Number of channels;
ITAAtomicFloat fCurrentGain,fNewGain; //!< Gain (amplification factor)
ITAAtomicFloat fCurrentGain, fNewGain; //!< Gain (amplification factor)
ITAAtomicBool bMuted; //!< Muted?
ITADatasource* pDatasource; //!< Datasource assigned to the input
std::vector< const float* > vpfInputData; //!< Pointers to the next stream blocks
InputDesc( const int iChannels, const int iBlockLength )
: vpfInputData( iChannels, nullptr )
inline InputDesc( const int iChannels, const int iBlockLength )
: vpfInputData( iChannels, nullptr )
, iChannels( iChannels )
, fCurrentGain( 1.0f )
, fNewGain( 1.0f )
, pDatasource( NULL )
{
this->iChannels = iChannels;
fCurrentGain = 1.0F, fNewGain = 1.0F;
bMuted = false;
pDatasource = NULL;
}
};
};
//! Connections from an output channel to an input channel
......@@ -274,28 +236,21 @@ private:
public:
int iFirst; //!< Input index
int iSecond; //!< Input channel
ITAAtomicFloat fCurrentGain, fNewGain; // Gain (amplification factor)
Connection( const int iFirst, const int iSecond )
ITAAtomicFloat fCurrentGain; //!< Gain (current block amplification factor)
ITAAtomicFloat fNewGain; //!< Gain (next block amplification factor)
inline Connection( const int iFirst, const int iSecond, const float fGain = 1.0f )
: iFirst( iFirst )
, iSecond( iSecond )
, fCurrentGain( fGain )
, fNewGain( fGain )
{
this->iFirst = iFirst;
this->iSecond = iSecond;
this->fCurrentGain = 1.0F;
this->fNewGain = 1.0F;
}
Connection( const int iFirst, const int iSecond, const float fGain )
{
this->iFirst = iFirst;
this->iSecond = iSecond;
this->fCurrentGain = fGain;
this->fNewGain = fGain;
}
};
};
struct CompareConnection
{
bool operator()( const Connection &lhs, const Connection &rhs ) const
inline bool operator()( const Connection &lhs, const Connection &rhs ) const
{
// Important: Define a linear ordering relation for set! The order is unimportant.
if( lhs.iFirst == rhs.iFirst )
......@@ -316,20 +271,18 @@ private:
ITAAtomicBool bMuted; // Muted?
Connections conns; // Input -> Output assignments
OutputDesc( ITAStreamPatchbay* pParent,
const int iChannels,
const double dSamplerate,
const int iBlockLength )
: ITADatasourceRealization( (unsigned int) iChannels, dSamplerate, iBlockLength )
inline OutputDesc( ITAStreamPatchbay* pParent, const int iChannels, const double dSamplerate, const int iBlockLength )
: ITADatasourceRealization( ( unsigned int ) iChannels, dSamplerate, iBlockLength )
, iChannels( iChannels )
, fCurrentGain( 1.0f )
, fNewGain( 1.0f )
, bMuted( false )
{
this->iChannels = iChannels;
fCurrentGain = 1.0F,fNewGain = 1.0F;
bMuted = false;
SetStreamEventHandler( pParent );
conns.resize( iChannels );
};
~OutputDesc() {};
inline ~OutputDesc() {};
};
double m_dSamplerate;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment