Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITABase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
9810f41f
Commit
9810f41f
authored
Nov 28, 2016
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Store() function for ITASampleFrame (exports WAV file).
parent
c684d74b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
59 deletions
+45
-59
CMakeLists.txt
CMakeLists.txt
+1
-0
include/ITASampleFrame.h
include/ITASampleFrame.h
+3
-1
src/ITASampleFrame.cpp
src/ITASampleFrame.cpp
+41
-58
No files found.
CMakeLists.txt
View file @
9810f41f
...
...
@@ -136,6 +136,7 @@ if( VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE )
"src/libsndfileAudiofileReader.cpp"
"src/libsndfileAudiofileWriter.cpp"
)
add_definitions
(
-DITABASE_WITH_SNDFILE
)
endif
(
VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE
)
...
...
include/ITASampleFrame.h
View file @
9810f41f
...
...
@@ -116,7 +116,9 @@ public:
*/
void
init
(
int
iChannels
,
int
iLength
,
bool
bZeroinit
);
void
Load
(
const
std
::
string
&
sFileName
);
void
Load
(
const
std
::
string
&
sFilePath
);
void
Load
(
const
std
::
string
&
sFilePath
,
double
&
dSampleRate
);
void
Store
(
const
std
::
string
&
sFilePath
,
double
dSampleRate
=
44100.0
f
)
const
;
//! Speicher freigeben
/**
...
...
src/ITASampleFrame.cpp
View file @
9810f41f
// $Id: ITASampleFrame.cpp 4124 2015-07-14 13:00:26Z fwefers $
#include <ITASampleFrame.h>
#include <ITAAudiofileReader.h>
#include <ITAAudiofileWriter.h>
#include <assert.h>
#include <sstream>
...
...
@@ -35,8 +34,8 @@ ITASampleFrame::ITASampleFrame( const std::string& sFileName )
Load
(
sFileName
);
}
ITASampleFrame
::~
ITASampleFrame
()
{
// Die Kanle werden vom std::vector-Destruktor abgerumt
ITASampleFrame
::~
ITASampleFrame
()
{
}
bool
ITASampleFrame
::
empty
()
const
{
...
...
@@ -71,13 +70,21 @@ void ITASampleFrame::init( int iChannels, int iLength, bool bZeroinit)
m_iLength
=
iLength
;
}
void
ITASampleFrame
::
Load
(
const
std
::
string
&
sFileName
)
void
ITASampleFrame
::
Load
(
const
std
::
string
&
sFilePath
)
{
double
dSampleRate
;
Load
(
sFilePath
,
dSampleRate
);
}
void
ITASampleFrame
::
Load
(
const
std
::
string
&
sFilePath
,
double
&
dSampleRate
)
{
ITAAudiofileReader
*
pReader
(
NULL
);
try
{
try
{
// Datei ffnen
pReader
=
ITAAudiofileReader
::
create
(
sFile
Name
);
pReader
=
ITAAudiofileReader
::
create
(
sFile
Path
);
ITAAudiofileProperties
oProps
=
pReader
->
getAudiofileProperties
();
dSampleRate
=
oProps
.
dSampleRate
;
init
(
(
int
)
oProps
.
iChannels
,
(
int
)
oProps
.
iLength
,
false
);
// Zielzeiger zusammenstellen
...
...
@@ -89,7 +96,8 @@ void ITASampleFrame::Load( const std::string& sFileName )
pReader
->
read
(
oProps
.
iLength
,
vpfDest
);
}
catch
(
...
)
{
catch
(
...
)
{
// Alle Daten verwerfen
delete
pReader
;
free
();
...
...
@@ -106,67 +114,42 @@ void ITASampleFrame::free()
m_iLength
=
0
;
};
/* TODO move Code to ITAUtils (+VistaCoreLibs dependency for FileSystem stuff)
void ITASampleFrame::load(const std::string& sFilename) {
ITAAudiofileReader* pReader(NULL);
try {
// Datei ffnen
pReader = ITAAudiofileReader::create(sFilename);
ITAAudiofileProperties oProps = pReader->getAudiofileProperties();
init( (int) oProps.uiChannels, (int) oProps.uiLength, false);
// Zielzeiger zusammenstellen
std::vector<float*> vpfDest(oProps.uiChannels);
for (unsigned int i=0; i<oProps.uiChannels; i++)
vpfDest[i] = m_vChannels[i].GetData();
// Daten einlesen
pReader->read(oProps.uiLength, vpfDest);
} catch (...) {
// Alle Daten verwerfen
delete pReader;
free();
throw;
}
delete pReader;
}
*/
/* TODO move Code to ITAUtils (+VistaCoreLibs dependency for FileSystem stuff)
void ITASampleFrame::store(const std::string& sFilename) const {
if (!hasSamplerate())
ITA_EXCEPT1(MODAL_EXCEPTION, "Sampling rate undefined");
ITAAudiofileWriter* pWriter(NULL);
try {
void
ITASampleFrame
::
Store
(
const
std
::
string
&
sFilePath
,
double
dSamplingRate
)
const
{
#ifdef ITABASE_WITH_SNDFILE
ITAAudiofileWriter
*
pWriter
(
NULL
);
try
{
ITAAudiofileProperties
oProps
;
oProps.dSamplerate = m_dSamplerate;
oProps.eDomain = ITA_TIME_DOMAIN;
oProps.eQuantization = ITA_INT16;
oProps.uiChannels = (unsigned int) m_iChannels;
oProps.uiLength = (unsigned int) m_iLength;
pWriter = ITAAudiofileWriter::create(sFilename, oProps);
// Zielzeiger zusammenstellen
std::vector<const float*> vpfDest(oProps.uiChannels);
for (unsigned int i=0; i<oProps.uiChannels; i++)
vpfDest[i] = m_vChannels[i].data();
oProps
.
dSampleRate
=
dSamplingRate
;
oProps
.
eDomain
=
ITADomain
::
ITA_TIME_DOMAIN
;
oProps
.
eQuantization
=
ITAQuantization
::
ITA_FLOAT
;
oProps
.
iChannels
=
(
unsigned
int
)
m_iChannels
;
oProps
.
iLength
=
(
unsigned
int
)
m_iLength
;
pWriter
=
ITAAudiofileWriter
::
create
(
sFilePath
,
oProps
);
std
::
vector
<
const
float
*
>
vpfDest
(
oProps
.
iChannels
);
for
(
int
i
=
0
;
i
<
oProps
.
iChannels
;
i
++
)
vpfDest
[
i
]
=
m_vChannels
[
i
].
data
();
// Daten schreiben
pWriter->write(oProps.uiLength, vpfDest);
pWriter
->
write
(
oProps
.
iLength
,
vpfDest
);
} catch (...) {
}
catch
(...)
{
delete
pWriter
;
throw
;
}
delete
pWriter
;
#else
ITA_EXCEPT1
(
NOT_IMPLEMENTED
,
"ITASampleFrame::Store() function not available without libsndfile"
);
#endif
}
*/
void
ITASampleFrame
::
fill
(
float
fValue
)
{
void
ITASampleFrame
::
fill
(
float
fValue
)
{
for
(
ch_it
it
=
m_vChannels
.
begin
();
it
!=
m_vChannels
.
end
();
++
it
)
it
->
Fill
(
fValue
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment