ITAStreamProbe.h 2.46 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
Jonas Stienen's avatar
Jonas Stienen committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
*
* ----------------------------------------------------------------
*				    ____  __________  _______
*				   //  / //__   ___/ //  _   |
*				  //  /    //  /    //  /_|  |
*				 //  /    //  /    //  ___   |
*				//__/    //__/    //__/   |__|
*
* ----------------------------------------------------------------
*
*/

#ifndef INCLUDE_WATCHER_ITA_STREAM_PROBE
#define INCLUDE_WATCHER_ITA_STREAM_PROBE

#include <ITADataSourcesDefinitions.h>
#include <ITADataSource.h>

25
#include <ITASampleFrame.h>
26
#include <ITABufferedAudiofileWriter.h>
27

28
#include <atomic>
Jonas Stienen's avatar
Jonas Stienen committed
29
30
31
32
33
34
#include <string>
#include <vector>

// Vorwrtedeklarationen
class ITAAudiofileWriter;

35
//! A measuring sensor for audio streams
Jonas Stienen's avatar
Jonas Stienen committed
36
/**
37
38
39
  * This class captures (records) the entire data stream passing through. It uses
  * a sample buffer and holds the data in the memory until destructor is called.
  * The result is exported into a WAV file on the hard drive.
40
  */
41
42
class ITA_DATA_SOURCES_API ITAStreamProbe : public ITADatasource
{
Jonas Stienen's avatar
Jonas Stienen committed
43
public:
44
	ITAStreamProbe( ITADatasource* pDatasource, const std::string& sFilePath = "", ITAQuantization iQuantization = ITAQuantization::ITA_FLOAT );
Jonas Stienen's avatar
Jonas Stienen committed
45

46
	//! Destructor also moves saples from memory to hard drive once.
Jonas Stienen's avatar
Jonas Stienen committed
47
48
	virtual ~ITAStreamProbe();

49
50
51
52
	inline ITADatasource* GetDatasource() const 
	{ 
		return m_pDataSource;
	}
Jonas Stienen's avatar
Jonas Stienen committed
53

54
	//! Deprecated
55
56
57
58
	inline std::string GetFilename() const
	{
		return GetFilePath();
	};
Jonas Stienen's avatar
Jonas Stienen committed
59

60
61
	std::string GetFilePath() const;
	void SetFilePath( const std::string& sFilePath );
Jonas Stienen's avatar
Jonas Stienen committed
62

63
64
65
66
67
	inline unsigned int GetNumRecordedSamples() const 
	{ 
		return m_iRecordedSamples;
	}
	
Jonas Stienen's avatar
Jonas Stienen committed
68
69
	unsigned int GetBlocklength() const;
	unsigned int GetNumberOfChannels() const;
70
	double GetSampleRate() const;
Jonas Stienen's avatar
Jonas Stienen committed
71

72
	virtual const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* pStreamInfo );
Jonas Stienen's avatar
Jonas Stienen committed
73
74
75
	virtual void IncrementBlockPointer();

protected:
76
77
78
79
80
81
	ITADatasource* m_pDataSource;		//!< Incoming data source

	double m_dSampleRate;				//!< Sampling rate [Hz]
	int m_iChannels;					//!< Number of channels
	int m_iBlockLength;					//!< Streaming buffer size [Samples]

82
	std::atomic< int > m_iRecordedSamples;	//!< Number of recorded samples
83
84
85
	ITASampleFrame m_sfBuffer;
	std::vector< bool > m_vbDataPresent;
	
86
	ITABufferedAudiofileWriter* m_pBufferedWriter; //!< Buffering audio file writer
Jonas Stienen's avatar
Jonas Stienen committed
87
88
89
90

};

#endif // INCLUDE_WATCHER_ITA_STREAM_PROBE