Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
07667e10
Commit
07667e10
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#3757] Allow for longer (60 sec) wave file to be loaded
parent
4c6184a3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-common/src/audio/sound/audiofile.cpp
+43
-28
43 additions, 28 deletions
sflphone-common/src/audio/sound/audiofile.cpp
with
43 additions
and
28 deletions
sflphone-common/src/audio/sound/audiofile.cpp
+
43
−
28
View file @
07667e10
...
...
@@ -248,7 +248,9 @@ bool WaveFile::isFileOpened()
bool
WaveFile
::
openExistingWaveFile
(
const
std
::
string
&
fileName
,
int
audioSamplingRate
)
{
SamplerateConverter
_converter
(
88200
,
1000
);
// Sample rate converter initialized with 88200 sample long
int
converterSamples
=
88200
;
SamplerateConverter
_converter
(
converterSamples
,
1000
);
_debug
(
"WaveFile: Opening %s"
,
fileName
.
c_str
());
...
...
@@ -327,19 +329,19 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
if
(
format_tag
==
1
)
{
if
(
dt
==
8
)
_data_type
=
1
;
//
STK_
SINT8;
_data_type
=
1
;
// SINT8;
else
if
(
dt
==
16
)
_data_type
=
2
;
//
STK_
SINT16;
_data_type
=
2
;
// SINT16;
else
if
(
dt
==
32
)
_data_type
=
3
;
//
STK_
SINT32;
_data_type
=
3
;
// SINT32;
}
/*
else if ( format_tag == 3 )
{
if (temp == 32)
dataType_ =
STK_
FLOAT32;
dataType_ = FLOAT32;
else if (temp == 64)
dataType_ =
STK_
FLOAT64;
dataType_ = FLOAT64;
}
*/
else
{
...
...
@@ -367,36 +369,49 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
_debug
(
"WaveFile: data size in frame %ld"
,
_file_size
);
// Should not be longer than a minute
if
(
_file_size
>
(
unsigned
int
)
(
60
*
srate
))
_file_size
=
60
*
srate
;
SFLDataFormat
*
tempBuffer
=
new
SFLDataFormat
[
_file_size
];
SFLDataFormat
*
tempBufferRsmpl
=
NULL
;
// Should not be longer than 2 secs
if
(
_file_size
>
88200
)
_file_size
=
88200
;
_file_stream
.
read
(
(
char
*
)
tempBuffer
,
_file_size
*
sizeof
(
SFLDataFormat
));
_file_stream
.
read
(
(
char
*
)
tempBuffer
,
_file_size
);
// compute size of final buffer
int
nbSample
;
int
nbSample
=
_file_size
;
if
(
srate
!=
audioSamplingRate
)
{
nbSample
=
(
int
)
(
(
float
)
_file_size
*
(
(
float
)
audioSamplingRate
/
(
float
)
srate
));
nbSample
++
;
}
else
nbSample
=
_file_size
;
// _debug ("--------------------- srate %d", srate);
// _debug ("--------------------- audioSamplingRate %d", audioSamplingRate);
// _debug ("--------------------- _file_size %d", _file_size);
// require resampling
if
(
srate
!=
audioSamplingRate
)
{
if
(
srate
<
audioSamplingRate
)
{
int
nb_sample_down
=
_file_size
;
//(_file_size * srate) / audioSamplingRate;
// _debug ("--------------------- nb_sample_down %d", nb_sample_down);
// initialize remaining samples to process
int
remainingSamples
=
_file_size
;
tempBufferRsmpl
=
new
SFLDataFormat
[
_file_size
];
nbSample
=
_converter
.
upsampleData
(
tempBuffer
,
tempBufferRsmpl
,
srate
,
audioSamplingRate
,
nb_sample_down
);
// _debug ("--------------------- nbSample %d", nbSample);
}
else
if
(
srate
>
audioSamplingRate
)
{
int
nb_sample_up
=
_file_size
;
// (_file_size * srate) / audioSamplingRate;
// _debug ("--------------------- nb_sample_up %d", nb_sample_up);
tempBufferRsmpl
=
new
SFLDataFormat
[
nbSample
];
SFLDataFormat
*
in
=
tempBuffer
;
SFLDataFormat
*
out
=
tempBufferRsmpl
;
tempBufferRsmpl
=
new
SFLDataFormat
[
_file_size
];
nbSample
=
_converter
.
downsampleData
(
tempBuffer
,
tempBufferRsmpl
,
audioSamplingRate
,
srate
,
nb_sample_up
);
// _debug ("--------------------- nbSample %d", nbSample);
while
(
remainingSamples
>
0
)
{
int
toProcess
=
remainingSamples
>
converterSamples
?
converterSamples
:
remainingSamples
;
int
nbSamplesConverted
=
0
;
if
(
srate
<
audioSamplingRate
)
{
nbSamplesConverted
=
_converter
.
upsampleData
(
in
,
out
,
srate
,
audioSamplingRate
,
toProcess
);
}
else
if
(
srate
>
audioSamplingRate
)
{
nbSamplesConverted
=
_converter
.
downsampleData
(
in
,
out
,
audioSamplingRate
,
srate
,
toProcess
);
}
in
+=
toProcess
;
out
+=
nbSamplesConverted
;
remainingSamples
-=
toProcess
;
}
}
// Init audio loop buffer info
...
...
@@ -406,9 +421,9 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
// Copy audio into audioloop
if
(
srate
!=
audioSamplingRate
)
memcpy
(
(
void
*
)
_buffer
,
(
void
*
)
tempBufferRsmpl
,
nbSample
);
memcpy
(
(
void
*
)
_buffer
,
(
void
*
)
tempBufferRsmpl
,
nbSample
*
sizeof
(
SFLDataFormat
)
);
else
memcpy
(
(
void
*
)
_buffer
,
(
void
*
)
tempBuffer
,
nbSample
);
memcpy
(
(
void
*
)
_buffer
,
(
void
*
)
tempBuffer
,
nbSample
*
sizeof
(
SFLDataFormat
)
);
_debug
(
"WaveFile: file successfully opened"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment