Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance and quality of Sample Track display, and add RMS graph. #5927

Merged
merged 29 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from 16 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
51 changes: 39 additions & 12 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,30 +1017,57 @@ 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 = qMax<int>(1, nbFrames / w);
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved
const int totalPoints = nbFrames / fpp * 2 + 2;
IanCaio marked this conversation as resolved.
Show resolved Hide resolved
std::vector<QPointF> fMax(totalPoints);
std::vector<QPointF> fRms(totalPoints);
int curFrame = 0;
const int xb = dr.x();
const int first = focusOnRange ? fromFrame : 0;
const int last = focusOnRange ? toFrame - 1 : m_frames - 1;

for (int frame = first; frame <= last; frame += fpp)
{
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)
Veratil marked this conversation as resolved.
Show resolved Hide resolved
{
auto curData = m_data[frame + i][j];

if (curData > maxData) { maxData = m_data[frame + i][j]; }
if (curData < minData) { minData = m_data[frame + i][j]; }
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved

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

const float trueRmsData = (rmsData[0] + rmsData[1]) * 0.5 / fpp;
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved
const float sqrtRmsData = sqrt(trueRmsData);
const float maxRmsData = qBound(minData, sqrtRmsData, maxData);
const float minRmsData = qBound(minData, -sqrtRmsData, maxData);

auto x = xb + ((frame - first) * double(w) / nbFrames);
// 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[curFrame*2] = QPointF(x, (yb - (maxData * py)));
fMax[curFrame*2+1] = QPointF(x, (yb - (minData * py)));
fRms[curFrame*2] = QPointF(x, (yb - (maxRmsData * py)));
fRms[curFrame*2+1] = QPointF(x, (yb - (minRmsData * py)));
++curFrame;
}

p.setRenderHint(QPainter::Antialiasing);
p.drawPolyline(l, nbFrames / fpp);
p.drawPolyline(r, nbFrames / fpp);
//p.setRenderHint(QPainter::Antialiasing);
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved
p.drawPolyline(fMax.data(), totalPoints);
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved

p.setPen(p.pen().color().lighter(123));//
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved

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() );
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved
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 );
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved

if (muted)
{
QColor penColor = p.pen().brush().color();
penColor.setHsv( penColor.hsvHue(), penColor.hsvSaturation() / 4, penColor.value() );
LostRobotMusic marked this conversation as resolved.
Show resolved Hide resolved
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