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
Hide 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 )
...
@@ -136,6 +136,7 @@ if( VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE )
"src/libsndfileAudiofileReader.cpp"
"src/libsndfileAudiofileReader.cpp"
"src/libsndfileAudiofileWriter.cpp"
"src/libsndfileAudiofileWriter.cpp"
)
)
add_definitions
(
-DITABASE_WITH_SNDFILE
)
endif
(
VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE
)
endif
(
VSNDFILE_FOUND AND ITA_BASE_WITH_SNDFILE
)
...
...
include/ITASampleFrame.h
View file @
9810f41f
...
@@ -116,7 +116,9 @@ public:
...
@@ -116,7 +116,9 @@ public:
*/
*/
void
init
(
int
iChannels
,
int
iLength
,
bool
bZeroinit
);
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
//! Speicher freigeben
/**
/**
...
...
src/ITASampleFrame.cpp
View file @
9810f41f
// $Id: ITASampleFrame.cpp 4124 2015-07-14 13:00:26Z fwefers $
#include <ITASampleFrame.h>
#include <ITASampleFrame.h>
#include <ITAAudiofileReader.h>
#include <ITAAudiofileReader.h>
#include <ITAAudiofileWriter.h>
#include <assert.h>
#include <assert.h>
#include <sstream>
#include <sstream>
...
@@ -35,8 +34,8 @@ ITASampleFrame::ITASampleFrame( const std::string& sFileName )
...
@@ -35,8 +34,8 @@ ITASampleFrame::ITASampleFrame( const std::string& sFileName )
Load
(
sFileName
);
Load
(
sFileName
);
}
}
ITASampleFrame
::~
ITASampleFrame
()
{
ITASampleFrame
::~
ITASampleFrame
()
// Die Kanle werden vom std::vector-Destruktor abgerumt
{
}
}
bool
ITASampleFrame
::
empty
()
const
{
bool
ITASampleFrame
::
empty
()
const
{
...
@@ -71,13 +70,21 @@ void ITASampleFrame::init( int iChannels, int iLength, bool bZeroinit)
...
@@ -71,13 +70,21 @@ void ITASampleFrame::init( int iChannels, int iLength, bool bZeroinit)
m_iLength
=
iLength
;
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
);
ITAAudiofileReader
*
pReader
(
NULL
);
try
{
try
{
// Datei ffnen
// Datei ffnen
pReader
=
ITAAudiofileReader
::
create
(
sFile
Name
);
pReader
=
ITAAudiofileReader
::
create
(
sFile
Path
);
ITAAudiofileProperties
oProps
=
pReader
->
getAudiofileProperties
();
ITAAudiofileProperties
oProps
=
pReader
->
getAudiofileProperties
();
dSampleRate
=
oProps
.
dSampleRate
;
init
(
(
int
)
oProps
.
iChannels
,
(
int
)
oProps
.
iLength
,
false
);
init
(
(
int
)
oProps
.
iChannels
,
(
int
)
oProps
.
iLength
,
false
);
// Zielzeiger zusammenstellen
// Zielzeiger zusammenstellen
...
@@ -89,7 +96,8 @@ void ITASampleFrame::Load( const std::string& sFileName )
...
@@ -89,7 +96,8 @@ void ITASampleFrame::Load( const std::string& sFileName )
pReader
->
read
(
oProps
.
iLength
,
vpfDest
);
pReader
->
read
(
oProps
.
iLength
,
vpfDest
);
}
}
catch
(
...
)
{
catch
(
...
)
{
// Alle Daten verwerfen
// Alle Daten verwerfen
delete
pReader
;
delete
pReader
;
free
();
free
();
...
@@ -106,67 +114,42 @@ void ITASampleFrame::free()
...
@@ -106,67 +114,42 @@ void ITASampleFrame::free()
m_iLength
=
0
;
m_iLength
=
0
;
};
};
/* TODO move Code to ITAUtils (+VistaCoreLibs dependency for FileSystem stuff)
void
ITASampleFrame
::
Store
(
const
std
::
string
&
sFilePath
,
double
dSamplingRate
)
const
void ITASampleFrame::load(const std::string& sFilename) {
{
ITAAudiofileReader* pReader(NULL);
#ifdef ITABASE_WITH_SNDFILE
try {
ITAAudiofileWriter
*
pWriter
(
NULL
);
// Datei ffnen
try
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 {
ITAAudiofileProperties
oProps
;
ITAAudiofileProperties
oProps
;
oProps.dSample
rate = m_dSampler
ate;
oProps
.
dSample
Rate
=
dSamplingR
ate
;
oProps.eDomain = ITA_TIME_DOMAIN;
oProps
.
eDomain
=
ITA
Domain
::
ITA
_TIME_DOMAIN
;
oProps.eQuantization = ITA
_INT16
;
oProps
.
eQuantization
=
ITA
Quantization
::
ITA_FLOAT
;
oProps.
u
iChannels = (unsigned int) m_iChannels;
oProps
.
iChannels
=
(
unsigned
int
)
m_iChannels
;
oProps.
u
iLength = (unsigned int) m_iLength;
oProps
.
iLength
=
(
unsigned
int
)
m_iLength
;
pWriter = ITAAudiofileWriter::create(
sFilename, oProps
);
pWriter
=
ITAAudiofileWriter
::
create
(
sFilePath
,
oProps
);
// Zielzeiger zusammenstellen
std
::
vector
<
const
float
*
>
vpfDest
(
oProps
.
iChannels
);
std::vector<const float*> vpfDest(oProps.uiChannels);
for
(
int
i
=
0
;
i
<
oProps
.
iChannels
;
i
++
)
for (unsigned int i=0; i<oProps.uiChannels; i++)
vpfDest
[
i
]
=
m_vChannels
[
i
].
data
();
vpfDest[i] = m_vChannels[i].data();
// Daten schreiben
pWriter
->
write
(
oProps
.
iLength
,
vpfDest
);
pWriter->write(oProps.uiLength, vpfDest);
} catch (...) {
}
catch
(...)
{
delete
pWriter
;
delete
pWriter
;
throw
;
throw
;
}
}
delete
pWriter
;
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
)
for
(
ch_it
it
=
m_vChannels
.
begin
();
it
!=
m_vChannels
.
end
();
++
it
)
it
->
Fill
(
fValue
);
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