ITAStreamMultiplier1N.h 2.79 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
/*
2
3
4
5
 * ----------------------------------------------------------------
 *
 *		ITA core libs
 *		(c) Copyright Institute of Technical Acoustics (ITA)
6
 *		RWTH Aachen University, Germany, 2015-2019
7
8
9
10
11
12
13
14
15
16
17
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */
Jonas Stienen's avatar
Jonas Stienen committed
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

#ifndef INCLUDE_WATCHER_ITA_STREAM_MULTIPLIER
#define INCLUDE_WATCHER_ITA_STREAM_MULTIPLIER

#include <ITADataSourcesDefinitions.h>
          
#include <ITACriticalSection.h>
#include <ITADataSourceRealization.h>
#include <ITATypes.h>

#include <vector>

// Forward declarations
class ITADatasourceRealization;

/**
 * This class takes in a mono input and gives an N channel output.
 * This class provides functions to set the gain of each channel required.
 */
class ITA_DATA_SOURCES_API ITAStreamMultiplier1N : public ITADatasourceRealization {
public:
	//! Constructor
	/**
	 * Creates a stream multiplier.
	 *
	 * \param pdsInput			Input datasource (must be mono)
	 * \param iOutputChannels	Number of multiplied output channels
	 * \param uiFadeLength      Number of samples for fading gains
	 */
	ITAStreamMultiplier1N(ITADatasource* pdsInput, int iOutputChannels, unsigned int uiFadeLength=32);

	//! Destructor
	virtual ~ITAStreamMultiplier1N();

	//! Returns the assigned input datasource
	ITADatasource* GetInputDatasource() const;

	//! Returns the number of samples used to fade gains
	unsigned int GetFadeLength() const;

	//! Sets the number of samples for fading gains
	/**
	 * \param uiFadeLength  Number of samples for fading gains
	 *
	 * \note Maximum number of samples is the blocklength
	 */
	void SetFadeLength(unsigned int uiFadeLength);

	//! Returns wheather the output is muted
	bool IsMuted() const;

	//! Muted/unmuted the output
	void SetMuted(bool bMuted);

	//! Returns the gain of an output channel
	float GetGain(unsigned int uiChannel) const;

	//! Set the gain of an output channel
	void SetGain(unsigned int uiChannel, float fGain);

	//! Returns the gains of all output channels
	void GetGains(std::vector<float>& vfGains) const;

	//! Sets the gains of all output channels
	void SetGains(const std::vector<float>& vfGains);

	// -= Redefined methods of class "ITADatasource" =-

	void ProcessStream(const ITAStreamInfo* pStreamInfo);
	void PostIncrementBlockPointer();

protected:
	ITADatasource* m_pInputDatasource;
	bool m_bMuted;
	std::vector<float> m_vfCurrentGains,m_vfNewGains;
	unsigned int m_iOutputChannels;
	unsigned int m_uiFadeLength;
	ITACriticalSection m_cs;		// Exklusiver Zugriff auf die Parameter (Stummschaltung & Gain)
};

#endif // INCLUDE_WATCHER_ITA_STREAM_MULTIPLIER