Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Compare Revisions
9d09ea128f0642c0a30a2f8922ddd6b45b787562...4ecf4f6e4fb27b559720b45376d0d685d169a32b
Commits (1)
Switching to buffered audio file writer in stream probe and enabling lazy file path setting
· 4ecf4f6e
Dipl.-Ing. Jonas Stienen
authored
Oct 16, 2018
4ecf4f6e
Hide whitespace changes
Inline
Side-by-side
include/ITAStreamProbe.h
View file @
4ecf4f6e
...
...
@@ -24,7 +24,7 @@
#include <ITASampleFrame.h>
#include <ITAAtomicPrimitives.h>
#include <ITAAudiofile
Common
.h>
#include <ITA
Buffered
Audiofile
Writer
.h>
#include <string>
#include <vector>
...
...
@@ -34,13 +34,14 @@ class ITAAudiofileWriter;
//! A measuring sensor for audio streams
/**
* This class captures (records) the entire data stream passing through and stores
* the result into a file on the hard drive.
* 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.
*/
class
ITA_DATA_SOURCES_API
ITAStreamProbe
:
public
ITADatasource
{
public:
ITAStreamProbe
(
ITADatasource
*
pDatasource
,
const
std
::
string
&
sFilePath
,
ITAQuantization
iQuantization
=
ITAQuantization
::
ITA_FLOAT
);
ITAStreamProbe
(
ITADatasource
*
pDatasource
,
const
std
::
string
&
sFilePath
=
""
,
ITAQuantization
iQuantization
=
ITAQuantization
::
ITA_FLOAT
);
//! Destructor also moves saples from memory to hard drive once.
virtual
~
ITAStreamProbe
();
...
...
@@ -56,10 +57,8 @@ public:
return
GetFilePath
();
};
inline
std
::
string
GetFilePath
()
const
{
return
m_sFilePath
;
};
std
::
string
GetFilePath
()
const
;
void
SetFilePath
(
const
std
::
string
&
sFilePath
);
inline
unsigned
int
GetNumRecordedSamples
()
const
{
...
...
@@ -84,8 +83,7 @@ protected:
ITASampleFrame
m_sfBuffer
;
std
::
vector
<
bool
>
m_vbDataPresent
;
std
::
string
m_sFilePath
;
//!< File path
ITAAudiofileWriter
*
m_pWriter
;
ITABufferedAudiofileWriter
*
m_pBufferedWriter
;
//!< Buffering audio file writer
};
...
...
src/ITAStreamProbe.cpp
View file @
4ecf4f6e
...
...
@@ -4,10 +4,9 @@
#include <cassert>
ITAStreamProbe
::
ITAStreamProbe
(
ITADatasource
*
pDatasource
,
const
std
::
string
&
sFilePath
,
ITAQuantization
iQuantization
)
ITAStreamProbe
::
ITAStreamProbe
(
ITADatasource
*
pDatasource
,
const
std
::
string
&
sFilePath
/* = "" */
,
ITAQuantization
iQuantization
/* = ITAQuantization::ITA_FLOAT */
)
:
m_pDataSource
(
pDatasource
)
,
m_pWriter
(
NULL
)
,
m_sFilePath
(
sFilePath
)
,
m_pBufferedWriter
(
NULL
)
{
assert
(
pDatasource
!=
NULL
);
...
...
@@ -28,12 +27,27 @@ ITAStreamProbe::ITAStreamProbe( ITADatasource* pDatasource, const std::string& s
props
.
eDomain
=
ITADomain
::
ITA_TIME_DOMAIN
;
props
.
eQuantization
=
iQuantization
;
m_pWriter
=
ITABufferedAudiofileWriter
::
create
(
m_sFilePath
,
props
);
m_pBufferedWriter
=
ITABufferedAudiofileWriter
::
create
(
props
);
if
(
!
sFilePath
.
empty
()
)
m_pBufferedWriter
->
SetFilePath
(
sFilePath
);
}
ITAStreamProbe
::~
ITAStreamProbe
()
{
delete
m_pWriter
;
delete
m_pBufferedWriter
;
}
std
::
string
ITAStreamProbe
::
GetFilePath
()
const
{
if
(
m_pBufferedWriter
)
return
m_pBufferedWriter
->
GetFilePath
();
else
return
""
;
}
void
ITAStreamProbe
::
SetFilePath
(
const
std
::
string
&
sFilePath
)
{
m_pBufferedWriter
->
SetFilePath
(
sFilePath
);
}
unsigned
int
ITAStreamProbe
::
GetBlocklength
()
const
...
...
@@ -71,7 +85,7 @@ const float* ITAStreamProbe::GetBlockPointer( unsigned int uiChannel, const ITAS
void
ITAStreamProbe
::
IncrementBlockPointer
()
{
// Moves the internal buffer of a single block into the file writer
m_pWriter
->
write
(
&
m_sfBuffer
);
m_p
Buffered
Writer
->
write
(
&
m_sfBuffer
);
m_iRecordedSamples
=
m_iRecordedSamples
+
GetBlocklength
();
...
...