[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/core AudioClip.cpp Peak.cpp Peak.h
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/core AudioClip.cpp Peak.cpp Peak.h |
Date: |
Fri, 28 Sep 2007 19:12:05 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/09/28 19:12:05
Modified files:
src/core : AudioClip.cpp Peak.cpp Peak.h
Log message:
* 'fixed' AudioClip normalization
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.139&r2=1.140
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Peak.cpp?cvsroot=traverso&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Peak.h?cvsroot=traverso&r1=1.21&r2=1.22
Patches:
Index: AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -b -r1.139 -r1.140
--- AudioClip.cpp 28 Sep 2007 18:33:43 -0000 1.139
+++ AudioClip.cpp 28 Sep 2007 19:12:05 -0000 1.140
@@ -862,7 +862,7 @@
target -= FLT_EPSILON;
}
- double maxamp =
m_peak->get_max_amplitude(m_sourceStartLocation.to_frame(get_rate()),
m_sourceEndLocation.to_frame(get_rate()));
+ double maxamp = m_peak->get_max_amplitude(m_sourceStartLocation,
m_sourceEndLocation);
if (maxamp == 0.0f) {
printf("AudioClip::normalization: max amplitude == 0\n");
Index: Peak.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Peak.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- Peak.cpp 26 Sep 2007 20:46:33 -0000 1.59
+++ Peak.cpp 28 Sep 2007 19:12:05 -0000 1.60
@@ -660,14 +660,17 @@
}
-audio_sample_t Peak::get_max_amplitude(nframes_t startframe, nframes_t
endframe)
+audio_sample_t Peak::get_max_amplitude(TimeRef startlocation, TimeRef
endlocation)
{
foreach(ChannelData* data, m_channelData) {
if (!data->file || !m_peaksAvailable) {
return 0.0f;
}
}
-
+ int rate = m_source->get_file_rate();
+ m_source->set_output_rate(rate);
+ nframes_t startframe = startlocation.to_frame(rate);
+ nframes_t endframe = endlocation.to_frame(rate);
int startpos = startframe / NORMALIZE_CHUNK_SIZE;
uint count = (endframe / NORMALIZE_CHUNK_SIZE) - startpos;
@@ -695,12 +698,13 @@
float f = (float) endframe / NORMALIZE_CHUNK_SIZE;
int endpos = (int) f;
int toRead = (int) ((f - (endframe / NORMALIZE_CHUNK_SIZE)) *
NORMALIZE_CHUNK_SIZE);
-
int read = m_source->file_read(&decodebuffer, endframe - toRead,
toRead);
+ if (read > 0) {
for (uint chan = 0; chan < m_source->get_channel_count(); ++ chan) {
maxamp = Mixer::compute_peak(decodebuffer.destination[chan],
read, maxamp);
}
+ }
// Now that we have covered both boundary situations,
// read in the cached normvalues, and calculate the highest value!
@@ -709,7 +713,7 @@
foreach(ChannelData* data, m_channelData) {
fseek(data->file, data->headerdata.normValuesDataOffset +
(startpos * sizeof(audio_sample_t)), SEEK_SET);
- read = fread(readbuffer, sizeof(audio_sample_t), count,
data->file);
+ int read = fread(readbuffer, sizeof(audio_sample_t), count,
data->file);
if (read != (int)count) {
printf("could only read %d, %d requested\n", read,
count);
@@ -720,6 +724,8 @@
delete [] readbuffer;
+ m_source->set_output_rate(44100);
+
return maxamp;
}
Index: Peak.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Peak.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Peak.h 26 Sep 2007 20:46:33 -0000 1.21
+++ Peak.h 28 Sep 2007 19:12:05 -0000 1.22
@@ -115,7 +115,7 @@
void start_peak_loading();
- audio_sample_t get_max_amplitude(nframes_t startframe, nframes_t
endframe);
+ audio_sample_t get_max_amplitude(TimeRef startlocation, TimeRef
endlocation);
private:
ReadSource* m_source;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/core AudioClip.cpp Peak.cpp Peak.h,
Remon Sijrier <=