[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src core/Peak.cpp traverso/songcanvas/...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src core/Peak.cpp traverso/songcanvas/... |
Date: |
Tue, 11 Sep 2007 15:15:08 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/09/11 15:15:08
Modified files:
src/core : Peak.cpp
src/traverso/songcanvas: AudioClipView.cpp
Log message:
fix audioclip 'microview' drawing
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Peak.cpp?cvsroot=traverso&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.84&r2=1.85
Patches:
Index: core/Peak.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Peak.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- core/Peak.cpp 11 Sep 2007 14:16:02 -0000 1.46
+++ core/Peak.cpp 11 Sep 2007 15:15:08 -0000 1.47
@@ -268,9 +268,9 @@
// Micro view mode
} else {
+ // Calculate the amount of frames to be read
nframes_t toRead = pixelcount * zoomStep[zoomLevel];
- // Maybe they can be created on the stack for better
performance ?
nframes_t readFrames =
m_source->file_read(m_peakdataDecodeBuffer, startPos, toRead);
if (readFrames == 0) {
@@ -285,14 +285,17 @@
int count = 0;
nframes_t pos = 0;
audio_sample_t valueMax, valueMin, sample;
- short* writeBuffer = (short*)buffer;
+
+ // MicroView needs a buffer to store the calculated peakdata
+ // our decodebuffer's readbuffer is large enough for this
purpose
+ // and it's no problem to use it at this point in the process
chain.
+ float* peakdata = m_peakdataDecodeBuffer->readBuffer;
do {
valueMax = valueMin = 0;
for(int i=0; i < zoomStep[zoomLevel]; i++) {
- if (pos > readFrames)
- break;
+ Q_ASSERT(pos <= readFrames);
sample =
m_peakdataDecodeBuffer->destination[m_channel][pos];
if (sample > valueMax)
valueMax = sample;
@@ -301,10 +304,10 @@
pos++;
}
- if (valueMax > (valueMin * -1)) {
- writeBuffer[count] = (short)(valueMax *
MAX_DB_VALUE);
+ if (valueMax > abs(valueMin)) {
+ peakdata[count] = valueMax;
} else {
- writeBuffer[count] = (short)(valueMin *
MAX_DB_VALUE);
+ peakdata[count] = valueMin;
}
count++;
@@ -317,6 +320,9 @@
printf("Process time: %d useconds\n\n", processtime);
#endif
+ // Assign the supplied buffer to the 'real' peakdata buffer.
+ *buffer = peakdata;
+
return count;
}
Index: traverso/songcanvas/AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- traverso/songcanvas/AudioClipView.cpp 10 Sep 2007 18:44:15 -0000
1.84
+++ traverso/songcanvas/AudioClipView.cpp 11 Sep 2007 15:15:08 -0000
1.85
@@ -211,12 +211,12 @@
// Paint a pixmap if the clip is locked
if (m_clip->is_locked()) {
- int center = m_clip->get_length() / (2 *
m_sv->timeref_scalefactor);
+ int center = (int)(m_clip->get_length() / (2 *
m_sv->timeref_scalefactor));
painter->drawPixmap(center - 8, m_height - 20,
find_pixmap(":/lock"));
}
if (m_dragging) {
- m_posIndicator->set_value(timeref_to_text(x() *
m_sv->timeref_scalefactor, m_sv->timeref_scalefactor));
+ m_posIndicator->set_value(timeref_to_text((qint64)(x() *
m_sv->timeref_scalefactor), m_sv->timeref_scalefactor));
}
painter->restore();
@@ -301,7 +301,7 @@
}
int mixcurvedata = 0;
- int offset = m_clip->get_source_start_location() /
m_sv->timeref_scalefactor;
+ int offset = (int)(m_clip->get_source_start_location() /
m_sv->timeref_scalefactor);
mixcurvedata |= curveView->get_vector(xstart + offset, pixelcount,
curvemixdown);
float fademixdown[pixelcount];
@@ -390,7 +390,7 @@
}
- float scaleFactor = ( (float) height * 0.90 /
(Peak::MAX_DB_VALUE * 2)) * m_clip->get_gain();
+ float scaleFactor = ( (float) height * 0.90 / 2) *
m_clip->get_gain();
float ytrans;
if (m_mergedView) {
@@ -422,8 +422,7 @@
// Microview, paint waveform as polyline
if (microView) {
- QPolygon polygon;
- short* mbuffer = (short*) buffers[chan];
+ QPolygonF polygon;
int bufferPos = 0;
if (m_mergedView) {
@@ -443,7 +442,7 @@
p->drawLine(xstart, 0, xstart + pixelcount, 0);
for (int x = xstart; x < (pixelcount+xstart); x++) {
- polygon.append( QPoint(x, (int) (scaleFactor *
mbuffer[bufferPos++])) );
+ polygon.append( QPointF(x, scaleFactor *
buffers[chan][bufferPos++]) );
}
if
(themer()->get_property("AudioClip:wavemicroview:antialiased", 0).toInt()) {
@@ -469,6 +468,8 @@
}
+ scaleFactor = ( (float) height * 0.90 /
(Peak::MAX_DB_VALUE * 2)) * m_clip->get_gain();
+
QPainterPath path;
// in rectified view, we add an additional point, hence
+ 1
QPolygonF polygontop(pixelcount + 1);
- [Traverso-commit] traverso/src core/Peak.cpp traverso/songcanvas/...,
Remon Sijrier <=