Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7f1c954
Merge pull request #8 from LMMS/master
LostRobotMusic Jun 21, 2019
0bb50a8
Merge pull request #11 from LMMS/master
LostRobotMusic Aug 7, 2019
a332d47
Merge pull request #12 from LMMS/master
LostRobotMusic Aug 30, 2019
5f0aacc
Merge pull request #13 from LMMS/master
LostRobotMusic Sep 4, 2019
6e5132b
Merge pull request #14 from LMMS/master
LostRobotMusic Nov 7, 2019
36eece4
Merge pull request #16 from LMMS/master
LostRobotMusic Mar 15, 2020
b33596a
Merge pull request #17 from LMMS/master
LostRobotMusic Apr 19, 2020
d691fb0
Merge pull request #18 from LMMS/master
LostRobotMusic May 8, 2020
e6474d4
Merge pull request #20 from LMMS/master
LostRobotMusic Oct 25, 2020
a1409ed
Merge pull request #21 from LMMS/master
LostRobotMusic Mar 2, 2021
742ddf0
Buff Sample Track display performance and visuals, and add RMS display
LostRobotMusic Mar 2, 2021
18c1d9a
Improve grey background temperature
LostRobotMusic Mar 2, 2021
a837356
Fix muted/selected sample track colors
LostRobotMusic Mar 3, 2021
d62ce57
Vector time
LostRobotMusic Mar 3, 2021
8a03107
Remove fpp limit and fix potential SEGFAULT
LostRobotMusic Mar 3, 2021
8b2b256
Fix stuff
LostRobotMusic Mar 3, 2021
932e88a
Fix the fixes of stuff
LostRobotMusic Mar 3, 2021
f6d6634
Fix the fixing of the fixes for the stuff
LostRobotMusic Mar 3, 2021
e3857cb
Remove unnecessary comments
LostRobotMusic Mar 7, 2021
0a80f2f
Spanish Inquisition
LostRobotMusic Mar 12, 2021
c71767e
Fix the buffer being drawn after width
IanCaio Mar 14, 2021
f876e23
Bugfixes on sample drawing
IanCaio Mar 14, 2021
58ea29b
a
LostRobotMusic Mar 14, 2021
064fbba
Draw multiple separate lines instead of one large group of connected …
LostRobotMusic Apr 14, 2021
e29c254
Fix sleep deprivation errors
LostRobotMusic Apr 14, 2021
b7549af
Fix inaccurate comments
LostRobotMusic Apr 14, 2021
5bf5cfb
Precision upgrade
LostRobotMusic Apr 15, 2021
79b6c34
Precision Upgrade 2: Electric Boogaloo
LostRobotMusic Apr 15, 2021
1f5d535
Fix integer division to make it double
LostRobotMusic Apr 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@ PatternView {

/* sample track pattern */
SampleTCOView {
background-color: rgb( 74, 253, 133 );
color: rgb( 187, 227, 236 );
background-color: rgba(42,51,59,255);
color: #FF8F05;
}

/* automation pattern */
Expand Down
4 changes: 2 additions & 2 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,8 @@ PatternView {

/* sample track pattern */
SampleTCOView {
background-color: #DE7C05;
color: #FFE8CD;
background-color: rgba(42,51,59,255);
color: #FF8F05;
}

/* automation pattern */
Expand Down
81 changes: 67 additions & 14 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,13 @@ f_cnt_t SampleBuffer::getPingPongIndex(f_cnt_t index, f_cnt_t startf, f_cnt_t en
}


/* @brief Draws a sample buffer on the QRect given in the range [fromFrame, toFrame)
* @param QPainter p: Painter object for the painting operations
* @param QRect dr: QRect where the buffer will be drawn in
* @param QRect clip: QRect used for clipping
* @param f_cnt_t fromFrame: First frame of the range
* @param f_cnt_t toFrame: Last frame of the range non-inclusive
*/
void SampleBuffer::visualize(
QPainter & p,
const QRect & dr,
Expand All @@ -1009,6 +1016,7 @@ void SampleBuffer::visualize(
if (m_frames == 0) { return; }

const bool focusOnRange = toFrame <= m_frames && 0 <= fromFrame && fromFrame < toFrame;
//TODO: If the clip QRect is not being used we should remove it
//p.setClipRect(clip);
const int w = dr.width();
const int h = dr.height();
Expand All @@ -1017,30 +1025,75 @@ void SampleBuffer::visualize(
const float ySpace = h * 0.5f;
const int nbFrames = focusOnRange ? toFrame - fromFrame : m_frames;

const int fpp = qBound<int>(1, nbFrames / w, 20);
QPointF * l = new QPointF[nbFrames / fpp + 1];
QPointF * r = new QPointF[nbFrames / fpp + 1];
int n = 0;
const int fpp = std::max(1, nbFrames / w);
// There are 2 possibilities: Either nbFrames is bigger than
// the width, so we will have width * 2 points, or nbFrames is
// smaller than the width (fpp = 1) and we will have nbFrames * 2
// points
const int totalPoints = nbFrames > w
? w * 2
: nbFrames * 2;
std::vector<QPointF> fMax(totalPoints);
std::vector<QPointF> fRms(totalPoints);
int curPixel = 0;
const int xb = dr.x();
const int first = focusOnRange ? fromFrame : 0;
const int last = focusOnRange ? toFrame - 1 : m_frames - 1;
// When the number of frames isn't perfectly divisible by the
// width, the remaining frames don't fit the last pixel and are
// past the visible area. lastVisibleFrame is the index number of
// the last visible frame.
const int visibleFrames = (fpp * w);
const int lastVisibleFrame = focusOnRange
? fromFrame + visibleFrames - 1
: visibleFrames - 1;

for (int frame = first; frame <= last; frame += fpp)
for (int frame = first; frame <= last && frame <= lastVisibleFrame; frame += fpp)
{
auto x = xb + ((frame - first) * double(w) / nbFrames);
float maxData = -1;
float minData = 1;

float rmsData[2] = {0, 0};

// Find maximum and minimum samples within range
for (int i = 0; i < fpp && frame + i <= last; ++i)
{
for (int j = 0; j < 2; ++j)
{
auto curData = m_data[frame + i][j];

if (curData > maxData) { maxData = curData; }
if (curData < minData) { minData = curData; }

rmsData[j] += curData * curData;
}
}

const float trueRmsData = (rmsData[0] + rmsData[1]) * 0.5 / fpp;
const float sqrtRmsData = sqrt(trueRmsData);
const float maxRmsData = qBound(minData, sqrtRmsData, maxData);
const float minRmsData = qBound(minData, -sqrtRmsData, maxData);

// If nbFrames >= w, we can use curPixel to calculate X
// but if nbFrames < w, we need to calculate it proportionally
// to the total number of points
auto x = nbFrames >= w
? xb + curPixel
: xb + ((double(curPixel) / nbFrames) * w);
// Partial Y calculation
auto py = ySpace * m_amplification;
l[n] = QPointF(x, (yb - (m_data[frame][0] * py)));
r[n] = QPointF(x, (yb - (m_data[frame][1] * py)));
++n;
fMax[curPixel * 2] = QPointF(x, (yb - (maxData * py)));
fMax[curPixel * 2 + 1] = QPointF(x, (yb - (minData * py)));
fRms[curPixel * 2] = QPointF(x, (yb - (maxRmsData * py)));
fRms[curPixel * 2 + 1] = QPointF(x, (yb - (minRmsData * py)));
++curPixel;
}

p.setRenderHint(QPainter::Antialiasing);
p.drawPolyline(l, nbFrames / fpp);
p.drawPolyline(r, nbFrames / fpp);
p.drawPolyline(fMax.data(), totalPoints);

p.setPen(p.pen().color().lighter(123));

delete[] l;
delete[] r;
p.drawPolyline(fRms.data(), totalPoints);
}


Expand Down
27 changes: 24 additions & 3 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,13 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )

QPainter p( &m_paintPixmap );

QLinearGradient lingrad( 0, 0, 0, height() );
QColor c = getColorForDisplay( painter.background().color() );
bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted();
bool selected = isSelected();

QLinearGradient lingrad(0, 0, 0, height());
QColor c = painter.background().color();
if (muted) { c = c.darker(150); }
if (selected) { c = c.darker(150); }

lingrad.setColorAt( 1, c.darker( 300 ) );
lingrad.setColorAt( 0, c );
Expand All @@ -593,7 +597,24 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.fillRect( rect(), c );
}

p.setPen( !muted ? painter.pen().brush().color() : mutedColor() );
auto tcoColor = m_tco->hasColor()
? (m_tco->usesCustomClipColor()
? m_tco->color()
: m_tco->getTrack()->color())
: painter.pen().brush().color();

p.setPen(tcoColor);

if (muted)
{
QColor penColor = p.pen().brush().color();
penColor.setHsv(penColor.hsvHue(), penColor.hsvSaturation() / 4, penColor.value());
p.setPen(penColor.darker(250));
}
if (selected)
{
p.setPen(p.pen().brush().color().darker(150));
}

const int spacing = TCO_BORDER_WIDTH + 1;
const float ppb = fixedTCOs() ?
Expand Down