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)
ITABase
Commits
5744175d
Commit
5744175d
authored
Jun 14, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Refactoring audio sample 'rate' conversion for special load method
parent
562c5ee1
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/ITAAudioSample.h
View file @
5744175d
...
...
@@ -91,10 +91,10 @@ public:
void
Load
(
const
std
::
string
&
sFilePath
);
//! Load audio sample from file and convert sample rate, if necessary
void
LoadWithSample
Typ
eConversion
(
const
std
::
string
&
sFilePath
);
void
LoadWithSample
Rat
eConversion
(
const
std
::
string
&
sFilePath
);
//! Load audio sample from file and convert sample rate, if necessary
void
LoadWithSample
Typ
eConversion
(
const
CITAAudioSample
&
asSource
);
void
LoadWithSample
Rat
eConversion
(
const
CITAAudioSample
&
asSource
);
private:
...
...
src/ITAAudioSample.cpp
View file @
5744175d
...
...
@@ -39,7 +39,7 @@ void CITAAudioSample::Init( const int iNumChannels, const int iLength, const flo
ITASampleFrame
::
Init
(
iNumChannels
,
iLength
,
bZeroInit
);
}
void
CITAAudioSample
::
LoadWithSample
Typ
eConversion
(
const
std
::
string
&
sFilePath
)
void
CITAAudioSample
::
LoadWithSample
Rat
eConversion
(
const
std
::
string
&
sFilePath
)
{
if
(
m_fSampleRate
<=
0.0
f
)
ITA_EXCEPT_INVALID_PARAMETER
(
"Invalid internal audio sample sampling rate"
);
...
...
@@ -52,7 +52,7 @@ void CITAAudioSample::LoadWithSampleTypeConversion( const std::string& sFilePath
Load
(
sfRaw
,
GetSampleRate
()
);
}
void
CITAAudioSample
::
LoadWithSample
Typ
eConversion
(
const
CITAAudioSample
&
asSource
)
void
CITAAudioSample
::
LoadWithSample
Rat
eConversion
(
const
CITAAudioSample
&
asSource
)
{
ITASampleFrame
*
psfSource
=
(
ITASampleFrame
*
)
&
asSource
;
Load
(
*
psfSource
,
asSource
.
GetSampleRate
()
);
...
...
tests/ITABaseAudioSampleTest.cpp
View file @
5744175d
...
...
@@ -11,7 +11,7 @@ int main( int, char** )
{
CITAAudioSample
asTTS48kHz
(
"tts.wav"
);
CITAAudioSample
asTTS44kHz
;
asTTS44kHz
.
LoadWithSample
Typ
eConversion
(
asTTS48kHz
);
asTTS44kHz
.
LoadWithSample
Rat
eConversion
(
asTTS48kHz
);
asTTS44kHz
.
Store
(
"tts_44khz.wav"
);
cout
<<
"Converted files."
<<
endl
;
...
...
@@ -32,9 +32,9 @@ int main( int, char** )
as44kfs
[
0
][
0
]
=
1.0
f
;
as44kfs
[
0
][
as44kfs
.
GetLength
()
-
1
]
=
-
1.0
f
;
as48kfs
.
LoadWithSample
Typ
eConversion
(
as44kfs
);
as96kfs
.
LoadWithSample
Typ
eConversion
(
as48kfs
);
as128kfs
.
LoadWithSample
Typ
eConversion
(
as96kfs
);
as48kfs
.
LoadWithSample
Rat
eConversion
(
as44kfs
);
as96kfs
.
LoadWithSample
Rat
eConversion
(
as48kfs
);
as128kfs
.
LoadWithSample
Rat
eConversion
(
as96kfs
);
cout
<<
"Converted."
<<
endl
;
}
...
...
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