Commit 440d9b51 authored by Vincent Pinon's avatar Vincent Pinon
Browse files

fix some more warnings

parent 467dcdc2
......@@ -123,7 +123,7 @@ template <typename AssetType> bool AbstractAssetsRepository<AssetType>::parseInf
res.description = metadata->get("description") ? i18n(metadata->get("description")) + QString(" (%1)").arg(id) : id;
res.author = metadata->get("creator");
res.version_str = metadata->get("version");
res.version = int(100 * metadata->get_double("version"));
res.version = int(ceil(100 * metadata->get_double("version")));
res.id = res.mltId = assetId;
parseType(metadata, res);
// Create params
......
......@@ -192,13 +192,13 @@ void ProjectManager::newFile(QString profileName, bool showProjectSettings)
projectFolder = w->storageFolder();
projectTracks = w->tracks();
audioChannels = w->audioChannels();
documentProperties.insert(QStringLiteral("enableproxy"), QString::number((int)w->useProxy()));
documentProperties.insert(QStringLiteral("generateproxy"), QString::number((int)w->generateProxy()));
documentProperties.insert(QStringLiteral("enableproxy"), QString::number(int(w->useProxy())));
documentProperties.insert(QStringLiteral("generateproxy"), QString::number(int(w->generateProxy())));
documentProperties.insert(QStringLiteral("proxyminsize"), QString::number(w->proxyMinSize()));
documentProperties.insert(QStringLiteral("proxyparams"), w->proxyParams());
documentProperties.insert(QStringLiteral("proxyextension"), w->proxyExtension());
documentProperties.insert(QStringLiteral("audioChannels"), QString::number(w->audioChannels()));
documentProperties.insert(QStringLiteral("generateimageproxy"), QString::number((int)w->generateImageProxy()));
documentProperties.insert(QStringLiteral("generateimageproxy"), QString::number(int(w->generateImageProxy())));
QString preview = w->selectedPreview();
if (!preview.isEmpty()) {
documentProperties.insert(QStringLiteral("previewparameters"), preview.section(QLatin1Char(';'), 0, 0));
......@@ -777,7 +777,7 @@ void ProjectManager::disableBinEffects(bool disable, bool refreshMonitor)
{
if (m_project) {
if (disable) {
m_project->setDocumentProperty(QStringLiteral("disablebineffects"), QString::number((int)true));
m_project->setDocumentProperty(QStringLiteral("disablebineffects"), QString::number(true));
} else {
m_project->setDocumentProperty(QStringLiteral("disablebineffects"), QString());
}
......@@ -791,7 +791,7 @@ void ProjectManager::disableBinEffects(bool disable, bool refreshMonitor)
void ProjectManager::slotDisableTimelineEffects(bool disable)
{
if (disable) {
m_project->setDocumentProperty(QStringLiteral("disabletimelineeffects"), QString::number((int)true));
m_project->setDocumentProperty(QStringLiteral("disabletimelineeffects"), QString::number(true));
} else {
m_project->setDocumentProperty(QStringLiteral("disabletimelineeffects"), QString());
}
......@@ -1016,7 +1016,7 @@ void ProjectManager::saveWithUpdatedProfile(const QString &updatedProfile)
// Now update to new profile
auto &newProfile = ProfileRepository::get()->getProfile(updatedProfile);
QString convertedFile = currentFile.section(QLatin1Char('.'), 0, -2);
convertedFile.append(QString("-%1.kdenlive").arg((int)(newProfile->fps() * 100)));
convertedFile.append(QString("-%1.kdenlive").arg(int(newProfile->fps() * 100)));
QString saveFolder = m_project->url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile();
QTemporaryFile tmpFile(saveFolder + "/kdenlive-XXXXXX.mlt");
if (saveInTempFile) {
......
......@@ -346,7 +346,7 @@ void AbstractScopeWidget::mouseMoveEvent(QMouseEvent *event)
// Detect the movement direction here.
// This algorithm relies on the aspect ratio of dy/dx (size and signum).
if (movement.manhattanLength() > m_rescaleMinDist) {
float diff = ((float)movement.y()) / (float)movement.x();
float diff = float(movement.y()) / movement.x();
if (std::fabs(diff) > m_rescaleVerticalThreshold || movement.x() == 0) {
m_rescaleDirection = North;
......@@ -379,15 +379,15 @@ void AbstractScopeWidget::slotContextMenuRequested(const QPoint &pos)
uint AbstractScopeWidget::calculateAccelFactorHUD(uint oldMseconds, uint)
{
return std::ceil((float)oldMseconds * REALTIME_FPS / 1000);
return uint(std::ceil(float(oldMseconds) * REALTIME_FPS / 1000.f));
}
uint AbstractScopeWidget::calculateAccelFactorScope(uint oldMseconds, uint)
{
return std::ceil((float)oldMseconds * REALTIME_FPS / 1000);
return uint(std::ceil(float(oldMseconds) * REALTIME_FPS / 1000.f));
}
uint AbstractScopeWidget::calculateAccelFactorBackground(uint oldMseconds, uint)
{
return std::ceil((float)oldMseconds * REALTIME_FPS / 1000);
return uint(std::ceil(float(oldMseconds) * REALTIME_FPS / 1000.f));
}
///// Slots /////
......@@ -405,7 +405,7 @@ void AbstractScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor
if (m_aRealtime->isChecked()) {
int accel;
accel = (int)calculateAccelFactorHUD(mseconds, oldFactor);
accel = int(calculateAccelFactorHUD(mseconds, oldFactor));
if (m_accelFactorHUD < 1) {
accel = 1;
}
......@@ -439,7 +439,7 @@ void AbstractScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFact
// Calculate the acceleration factor hint to get «realtime» updates.
if (m_aRealtime->isChecked()) {
int accel;
accel = (int)calculateAccelFactorScope(mseconds, oldFactor);
accel = int(calculateAccelFactorScope(mseconds, oldFactor));
if (accel < 1) {
// If mseconds happens to be 0.
accel = 1;
......@@ -472,7 +472,7 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol
if (m_aRealtime->isChecked()) {
int accel;
accel = (int)calculateAccelFactorBackground(mseconds, oldFactor);
accel = int(calculateAccelFactorBackground(mseconds, oldFactor));
if (m_accelFactorBackground < 1) {
accel = 1;
}
......
......@@ -83,8 +83,8 @@ QImage AudioSignal::renderAudioScope(uint, const audioShortVector &audioFrame, c
// valpixel=1.0 for 127, 1.0+(1/40) for 1 short oversample, 1.0+(2/40) for longer oversample
for (int i = 0; i < numchan; ++i) {
// int maxx= (unsigned char)m_channels[i] * (horiz ? width() : height() ) / 127;
double valpixel = valueToPixel((double)(unsigned char)chanAvg[i] / 127.0);
int maxx = height() * valpixel;
double valpixel = valueToPixel(chanAvg[i] / 127.0);
int maxx = int(height() * valpixel);
int xdelta = height() / 42;
int _y2 = (showdb ? width() - dbsize : width()) / numchan - 1;
int _y1 = (showdb ? width() - dbsize : width()) * i / numchan;
......@@ -92,7 +92,7 @@ QImage AudioSignal::renderAudioScope(uint, const audioShortVector &audioFrame, c
if (horiz) {
dbsize = 9;
showdb = height() > (dbsize);
maxx = width() * valpixel;
maxx = int(width() * valpixel);
xdelta = width() / 42;
_y2 = (showdb ? height() - dbsize : height()) / numchan - 1;
_y1 = (showdb ? height() - dbsize : height()) * i / numchan;
......@@ -103,7 +103,7 @@ QImage AudioSignal::renderAudioScope(uint, const audioShortVector &audioFrame, c
int _x1 = x * xdelta;
QColor sig = Qt::green;
// value of actual painted digit
double ival = (double)_x1 / (double)xdelta / 42.0;
double ival = double(_x1) / xdelta / 42.;
if (ival > 40.0 / 42.0) {
sig = Qt::red;
} else if (ival > 37.0 / 42.0) {
......@@ -120,23 +120,23 @@ QImage AudioSignal::renderAudioScope(uint, const audioShortVector &audioFrame, c
maxx -= xdelta;
}
}
int xp = valueToPixel((double)m_peeks.at(i) / 127.0) * (horiz ? width() : height()) - 2;
int xp = int(valueToPixel(m_peeks.at(i) / 127.)) * (horiz ? width() : height()) - 2;
p.fillRect(horiz ? xp : _y1, horiz ? _y1 : height() - xdelta - xp, horiz ? 3 : _y2, horiz ? _y2 : 3, QBrush(Qt::gray, Qt::SolidPattern));
}
if (showdb) {
// draw db value at related pixel
for (int l : qAsConst(m_dbscale)) {
if (!horiz) {
double xf = pow(10.0, (double)l / 20.0) * (double)height();
p.drawText(width() - dbsize, height() - xf * 40.0 / 42.0 + 20, QString::number(l));
double xf = pow(10.0, l / 20.0) * height();
p.drawText(width() - dbsize, height() - int(xf * 40 / 42 + 20), QString::number(l));
} else {
double xf = pow(10.0, (double)l / 20.0) * (double)width();
p.drawText(xf * 40 / 42 - 10, height() - 2, QString::number(l));
double xf = pow(10.0, l / 20.0) * width();
p.drawText(int(xf * 40 / 42 - 10), height() - 2, QString::number(l));
}
}
}
p.end();
emit signalScopeRenderingFinished((uint)timer.elapsed(), 1);
emit signalScopeRenderingFinished(uint(timer.elapsed()), 1);
return image;
}
......@@ -184,11 +184,11 @@ void AudioSignal::slotReceiveAudio(audioShortVector audioSamples, int, int num_c
}
// max amplitude = 40/42, 3to10 oversamples=41, more then 10 oversamples=42
if (over2 > 0.0) {
chanSignal.append(over2);
chanSignal.append(char(over2));
} else if (over1 > 0.0) {
chanSignal.append(over1);
chanSignal.append(char(over1));
} else {
chanSignal.append(char((double)val / (double)num_samples * 40.0 / 42.0));
chanSignal.append(char(double(val) / num_samples * 40.0 / 42.0));
}
}
showAudio(chanSignal);
......
......@@ -40,7 +40,7 @@
#define MAX_FREQ_VALUE 96000
#define MIN_FREQ_VALUE 1000
#define ALPHA_MOVING_AVG 0.125
#define MAX_OVM_COLOR 0.7
#define MAX_OVM_COLOR 0.7f
AudioSpectrum::AudioSpectrum(QWidget *parent)
: AbstractAudioScopeWidget(true, parent)
......@@ -207,19 +207,19 @@ QImage AudioSpectrum::renderAudioScope(uint, const audioShortVector &audioFrame,
// Get the spectral power distribution of the input samples,
// using the given window size and function
auto *freqSpectrum = new float[(uint)fftWindow / 2];
FFTTools::WindowType windowType = (FFTTools::WindowType)m_ui->windowFunction->itemData(m_ui->windowFunction->currentIndex()).toInt();
m_fftTools.fftNormalized(audioFrame, 0, (uint)num_channels, freqSpectrum, windowType, (uint)fftWindow, 0);
auto *freqSpectrum = new float[uint(fftWindow) / 2];
FFTTools::WindowType windowType = FFTTools::WindowType(m_ui->windowFunction->itemData(m_ui->windowFunction->currentIndex()).toInt());
m_fftTools.fftNormalized(audioFrame, 0, uint(num_channels), freqSpectrum, windowType, uint(fftWindow), 0);
// Store the current FFT window (for the HUD) and run the interpolation
// for easy pixel-based dB value access
QVector<float> dbMap;
m_lastFFTLock.acquire();
m_lastFFT = QVector<float>(fftWindow / 2);
memcpy(m_lastFFT.data(), &(freqSpectrum[0]), (uint)fftWindow / 2 * sizeof(float));
memcpy(m_lastFFT.data(), &(freqSpectrum[0]), uint(fftWindow) / 2 * sizeof(float));
uint right = uint(((float)m_freqMax) / ((float)m_freq / 2.) * float(m_lastFFT.size() - 1));
dbMap = FFTTools::interpolatePeakPreserving(m_lastFFT, (uint)m_innerScopeRect.width(), 0, right, -180);
uint right = uint(m_freqMax / (m_freq / 2.) * (m_lastFFT.size() - 1));
dbMap = FFTTools::interpolatePeakPreserving(m_lastFFT, uint(m_innerScopeRect.width()), 0, right, -180);
m_lastFFTLock.release();
#ifdef DEBUG_AUDIOSPEC
......@@ -240,9 +240,11 @@ QImage AudioSpectrum::renderAudioScope(uint, const audioShortVector &audioFrame,
if (m_colorizeFactor > 0) {
QColor col = AbstractScopeWidget::colHighlightDark;
QColor spec = spectrumColor;
float f = std::sin(M_PI_2 * m_colorizeFactor);
spectrumColor = QColor((int)(f * (float)col.red() + (1. - f) * (float)spec.red()), (int)(f * (float)col.green() + (1. - f) * (float)spec.green()),
(int)(f * (float)col.blue() + (1. - f) * (float)spec.blue()), spec.alpha());
float f = std::sin(float(M_PI_2) * m_colorizeFactor);
spectrumColor = QColor(int(f * col.red() + (1.f - f) * spec.red()),
int(f * col.green() + (1.f - f) * spec.green()),
int(f * col.blue() + (1.f - f) * spec.blue()),
spec.alpha());
// Limit the maximum colorization for non-overmodulated frames to better
// recognize consecutively overmodulated frames
if (m_colorizeFactor > MAX_OVM_COLOR) {
......@@ -262,10 +264,10 @@ QImage AudioSpectrum::renderAudioScope(uint, const audioShortVector &audioFrame,
#endif
for (int i = 0; i < w; ++i) {
yMax = int((dbMap[i] - (float)m_dBmin) / (float)(m_dBmax - m_dBmin) * (float)(h - 1));
yMax = int((dbMap[i] - m_dBmin) / (m_dBmax - m_dBmin) * (h - 1));
if (yMax < 0) {
yMax = 0;
} else if (yMax >= (int)h) {
} else if (yMax >= h) {
yMax = h - 1;
}
#ifdef AUDIOSPEC_LINES
......@@ -293,12 +295,12 @@ QImage AudioSpectrum::renderAudioScope(uint, const audioShortVector &audioFrame,
}
}
int prev = 0;
m_peakMap = FFTTools::interpolatePeakPreserving(m_peaks, (uint)m_innerScopeRect.width(), 0, right, -180);
m_peakMap = FFTTools::interpolatePeakPreserving(m_peaks, uint(m_innerScopeRect.width()), 0, right, -180);
for (int i = 0; i < w; ++i) {
yMax = (m_peakMap[i] - (float)m_dBmin) / (float)(m_dBmax - m_dBmin) * (float)(h - 1);
yMax = int((m_peakMap[i] - m_dBmin) / (m_dBmax - m_dBmin) * (h - 1));
if (yMax < 0) {
yMax = 0;
} else if (yMax >= (int)h) {
} else if (yMax >= h) {
yMax = h - 1;
}
......@@ -314,7 +316,7 @@ QImage AudioSpectrum::renderAudioScope(uint, const audioShortVector &audioFrame,
qCDebug(KDENLIVE_LOG) << widgetName() << " took " << drawTime.elapsed() << " ms for drawing. Average: " << ((float)m_timeTotal / m_showTotal);
#endif
emit signalScopeRenderingFinished((uint)timer.elapsed(), 1);
emit signalScopeRenderingFinished(uint(timer.elapsed()), 1);
return spectrum;
}
......@@ -335,7 +337,7 @@ QImage AudioSpectrum::renderHUD(uint)
const int textDistY = 25;
const int topDist = m_innerScopeRect.top() - m_scopeRect.top();
const int leftDist = m_innerScopeRect.left() - m_scopeRect.left();
const int dbDiff = ceil((float)minDistY / (float)m_innerScopeRect.height() * (float)(m_dBmax - m_dBmin));
const int dbDiff = int(ceil((float(minDistY) * (m_dBmax - m_dBmin)) / m_innerScopeRect.height()));
const int mouseX = m_mousePos.x() - m_innerScopeRect.left();
const int mouseY = m_mousePos.y() - m_innerScopeRect.top();
......@@ -352,7 +354,7 @@ QImage AudioSpectrum::renderHUD(uint)
int y;
for (int db = -dbDiff; db > m_dBmin; db -= dbDiff) {
y = topDist + int(float(m_innerScopeRect.height()) * ((float)db) / float(m_dBmin - m_dBmax));
y = topDist + (m_innerScopeRect.height() * db) / (m_dBmin - m_dBmax);
if (y - topDist > m_innerScopeRect.height() - minDistY + 10) {
// Abort here, there is still a line left for min dB to paint which needs some room.
break;
......@@ -365,13 +367,13 @@ QImage AudioSpectrum::renderHUD(uint)
davinci.drawLine(leftDist, topDist + m_innerScopeRect.height() - 1, leftDist + m_innerScopeRect.width() - 1, topDist + m_innerScopeRect.height() - 1);
davinci.drawText(leftDist + m_innerScopeRect.width() + textDistX, topDist + m_innerScopeRect.height() + 6, i18n("%1 dB", m_dBmin));
const int hzDiff = ceil(((float)minDistX) / (float)m_innerScopeRect.width() * (float)m_freqMax / 1000.) * 1000;
const int hzDiff = int(ceil(float(minDistX) * m_freqMax / m_innerScopeRect.width() / 1000) * 1000);
int x = 0;
const int rightBorder = leftDist + m_innerScopeRect.width() - 1;
y = topDist + m_innerScopeRect.height() + textDistY;
for (int hz = 0; x <= rightBorder; hz += hzDiff) {
davinci.setPen(AbstractScopeWidget::penLighter);
x = leftDist + int((float)m_innerScopeRect.width() * ((float)hz) / (float)m_freqMax);
x = leftDist + int(float(m_innerScopeRect.width()) * hz / m_freqMax);
if (x <= rightBorder) {
davinci.drawLine(x, topDist, x, topDist + m_innerScopeRect.height() + 6);
......@@ -381,14 +383,14 @@ QImage AudioSpectrum::renderHUD(uint)
} else {
x = leftDist + m_innerScopeRect.width();
davinci.drawLine(x, topDist, x, topDist + m_innerScopeRect.height() + 6);
davinci.drawText(x - 10, y, i18n("%1 kHz", QString("%1").arg((double)m_freqMax / 1000, 0, 'f', 1)));
davinci.drawText(x - 10, y, i18n("%1 kHz", QString("%1").arg(m_freqMax / 1000., 0, 'f', 1)));
}
if (hz > 0) {
// Draw finer lines between the main lines
davinci.setPen(AbstractScopeWidget::penLightDots);
for (uint dHz = 3; dHz > 0; --dHz) {
x = leftDist + int((float)m_innerScopeRect.width() * ((float)hz - (float)dHz * (float)hzDiff / 4.0f) / (float)m_freqMax);
x = leftDist + int(float(m_innerScopeRect.width()) * (hz - float(dHz) * hzDiff / 4.f) / m_freqMax);
if (x > rightBorder) {
break;
}
......@@ -403,21 +405,21 @@ QImage AudioSpectrum::renderHUD(uint)
x = leftDist + mouseX;
float db = 0;
float freq = ((float)mouseX) / (float)(m_innerScopeRect.width() - 1) * (float)m_freqMax;
float freq = float(mouseX) / (m_innerScopeRect.width() - 1) * m_freqMax;
bool drawDb = false;
m_lastFFTLock.acquire();
// We need to test whether the mouse is inside the widget
// because the position could already have changed in the meantime (-> crash)
if (!m_lastFFT.isEmpty() && mouseX >= 0 && mouseX < m_innerScopeRect.width()) {
uint right = uint(((float)m_freqMax) / (m_freq / 2.) * float(m_lastFFT.size() - 1));
QVector<float> dbMap = FFTTools::interpolatePeakPreserving(m_lastFFT, (uint)m_innerScopeRect.width(), 0, right, -120);
uint right = uint(m_freqMax / (m_freq / 2.f) * (m_lastFFT.size() - 1));
QVector<float> dbMap = FFTTools::interpolatePeakPreserving(m_lastFFT, uint(m_innerScopeRect.width()), 0, right, -120);
db = dbMap[mouseX];
y = topDist + m_innerScopeRect.height() - 1 -
int((dbMap[mouseX] - (float)m_dBmin) / float(m_dBmax - m_dBmin) * float(m_innerScopeRect.height() - 1));
int((dbMap[mouseX] - m_dBmin) / (m_dBmax - m_dBmin) * (m_innerScopeRect.height() - 1));
if (y < (int)topDist + m_innerScopeRect.height() - 1) {
if (y < topDist + m_innerScopeRect.height() - 1) {
drawDb = true;
davinci.drawLine(x, y, leftDist + m_innerScopeRect.width() - 1, y);
}
......@@ -426,7 +428,7 @@ QImage AudioSpectrum::renderHUD(uint)
}
m_lastFFTLock.release();
if (y > (int)topDist + mouseY) {
if (y > topDist + mouseY) {
y = topDist + mouseY;
}
davinci.drawLine(x, y, x, topDist + m_innerScopeRect.height() - 1);
......@@ -434,7 +436,7 @@ QImage AudioSpectrum::renderHUD(uint)
if (drawDb) {
QPoint dist(20, -20);
QRect rect(leftDist + mouseX + dist.x(), topDist + mouseY + dist.y(), 100, 40);
if (rect.right() > (int)leftDist + m_innerScopeRect.width() - 1) {
if (rect.right() > leftDist + m_innerScopeRect.width() - 1) {
// Mirror the rectangle at the y axis to keep it inside the widget
rect = QRect(rect.topLeft() - QPoint(rect.width() + 2 * dist.x(), 0), rect.size());
}
......@@ -449,7 +451,7 @@ QImage AudioSpectrum::renderHUD(uint)
}
}
emit signalHUDRenderingFinished((uint)timer.elapsed(), 1);
emit signalHUDRenderingFinished(uint(timer.elapsed()), 1);
return hud;
}
#ifdef DEBUG_AUDIOSPEC
......
......@@ -196,7 +196,7 @@ QImage Spectrogram::renderHUD(uint)
if (m_aGrid->isChecked()) {
for (int frameNumber = 0; frameNumber < m_innerScopeRect.height(); frameNumber += minDistY) {
y = topDist + m_innerScopeRect.height() - 1 - frameNumber;
hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(y - mouseY) < (int)textDistY && mouseY < m_innerScopeRect.height() &&
hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(y - mouseY) < textDistY && mouseY < m_innerScopeRect.height() &&
mouseX < m_innerScopeRect.width() && mouseX >= 0;
davinci.drawLine(leftDist, y, leftDist + m_innerScopeRect.width() - 1, y);
......@@ -214,7 +214,7 @@ QImage Spectrogram::renderHUD(uint)
if (y < 0) {
y = 0;
}
if (y > (int)topDist + m_innerScopeRect.height() - 1 - 30) {
if (y > topDist + m_innerScopeRect.height() - 1 - 30) {
y = topDist + m_innerScopeRect.height() - 1 - 30;
}
davinci.drawLine(x, topDist + mouseY, leftDist + m_innerScopeRect.width() - 1, topDist + mouseY);
......@@ -223,17 +223,17 @@ QImage Spectrogram::renderHUD(uint)
}
// Frequency grid
const uint hzDiff = (uint)ceil(((float)minDistX) / (float)m_innerScopeRect.width() * (float)m_freqMax / 1000.) * 1000;
const uint hzDiff = uint(ceil(float(minDistX) / m_innerScopeRect.width() * m_freqMax / 1000.f) * 1000);
const int rightBorder = leftDist + m_innerScopeRect.width() - 1;
x = 0;
y = topDist + m_innerScopeRect.height() + textDistY;
if (m_aGrid->isChecked()) {
for (uint hz = 0; x <= rightBorder; hz += hzDiff) {
davinci.setPen(AbstractScopeWidget::penLight);
x = int((float)leftDist + (float)(m_innerScopeRect.width() - 1) * ((float)hz) / (float)m_freqMax);
x = int(leftDist + float(m_innerScopeRect.width() - 1) * hz / m_freqMax);
// Hide text if it would overlap with the text drawn at the mouse position
hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(x - (int)(leftDist + mouseX + 20)) < (int)minDistX + 16 &&
hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(x - (leftDist + mouseX + 20)) < minDistX + 16 &&
mouseX < m_innerScopeRect.width() && mouseX >= 0;
if (x <= rightBorder) {
......@@ -250,7 +250,7 @@ QImage Spectrogram::renderHUD(uint)
// Draw finer lines between the main lines
davinci.setPen(AbstractScopeWidget::penLightDots);
for (uint dHz = 3; dHz > 0; --dHz) {
x = int((float)leftDist + (float)m_innerScopeRect.width() * ((float)hz - (float)dHz * (float)hzDiff / 4.0f) / (float)m_freqMax);
x = int(leftDist + m_innerScopeRect.width() * (hz - dHz * hzDiff / 4.0f) / m_freqMax);
if (x > rightBorder) {
break;
}
......@@ -260,11 +260,11 @@ QImage Spectrogram::renderHUD(uint)
}
// Draw the line at the very right (maximum frequency)
x = leftDist + m_innerScopeRect.width() - 1;
hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && qAbs(x - (int)(leftDist + mouseX + 30)) < (int)minDistX &&
hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && qAbs(x - (leftDist + mouseX + 30)) < minDistX &&
mouseX < m_innerScopeRect.width() && mouseX >= 0;
davinci.drawLine(x, topDist, x, topDist + m_innerScopeRect.height() + 6);
if (!hideText) {
davinci.drawText(x - 10, y, i18n("%1 kHz", QString("%1").arg((double)m_freqMax / 1000, 0, 'f', 1)));
davinci.drawText(x - 10, y, i18n("%1 kHz", QString("%1").arg(m_freqMax / 1000., 0, 'f', 1)));
}
}
......@@ -280,10 +280,10 @@ QImage Spectrogram::renderHUD(uint)
// Draw the dB brightness scale
davinci.setPen(AbstractScopeWidget::penLighter);
for (y = topDist; y < (int)topDist + m_innerScopeRect.height(); ++y) {
float val = 1. - ((float)y - (float)topDist) / ((float)m_innerScopeRect.height() - 1.);
uint col = m_colorMap[(int)(val * 255)];
for (x = leftDist - 6; x >= (int)leftDist - 13; --x) {
for (y = topDist; y < topDist + m_innerScopeRect.height(); ++y) {
float val = 1 - (y - topDist) / (m_innerScopeRect.height() - 1.f);
uint col = m_colorMap[int(val * 255)];
for (x = leftDist - 6; x >= leftDist - 13; --x) {
hud.setPixel(x, y, col);
}
}
......@@ -293,7 +293,7 @@ QImage Spectrogram::renderHUD(uint)
davinci.drawText(m_scopeRect.left(), topDist, rectWidth, rectHeight, Qt::AlignRight, i18n("%1\ndB", m_dBmax));
davinci.drawText(m_scopeRect.left(), topDist + m_innerScopeRect.height() - 20, rectWidth, rectHeight, Qt::AlignRight, i18n("%1\ndB", m_dBmin));
emit signalHUDRenderingFinished((uint)timer.elapsed(), 1);
emit signalHUDRenderingFinished(uint(timer.elapsed()), 1);
return hud;
}
emit signalHUDRenderingFinished(0, 1);
......@@ -328,17 +328,17 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
if (newDataAvailable) {
auto *freqSpectrum = new float[(uint)fftWindow / 2];
auto *freqSpectrum = new float[uint(fftWindow / 2)];
// Get the spectral power distribution of the input samples,
// using the given window size and function
FFTTools::WindowType windowType = (FFTTools::WindowType)m_ui->windowFunction->itemData(m_ui->windowFunction->currentIndex()).toInt();
m_fftTools.fftNormalized(audioFrame, 0, (uint)num_channels, freqSpectrum, windowType, (uint)fftWindow, 0);
FFTTools::WindowType windowType = FFTTools::WindowType(m_ui->windowFunction->itemData(m_ui->windowFunction->currentIndex()).toInt());
m_fftTools.fftNormalized(audioFrame, 0, uint(num_channels), freqSpectrum, windowType, uint(fftWindow), 0);
// This method might be called also when a simple refresh is required.
// In this case there is no data to append to the history. Only append new data.
QVector<float> spectrumVector(fftWindow / 2);
memcpy(spectrumVector.data(), &freqSpectrum[0], (uint)fftWindow / 2 * sizeof(float));
memcpy(spectrumVector.data(), &freqSpectrum[0], uint(fftWindow) / 2 * sizeof(float));
m_fftHistory.prepend(spectrumVector);
delete[] freqSpectrum;
}
......@@ -397,23 +397,23 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
windowSize = it.size();
// Interpolate the frequency data to match the pixel coordinates
right = uint(((float)m_freqMax) / ((float)m_freq / 2.) * float(windowSize - 1));
dbMap = FFTTools::interpolatePeakPreserving(it, (uint)m_innerScopeRect.width(), 0, right, -180);
right = uint(m_freqMax / (m_freq / 2.f) * (windowSize - 1));
dbMap = FFTTools::interpolatePeakPreserving(it, uint(m_innerScopeRect.width()), 0, right, -180);
for (int i = 0; i < dbMap.size(); ++i) {
float val;
val = dbMap[i];
peak = val > (float)m_dBmax;
peak = val > m_dBmax;
// Normalize dB value to [0 1], 1 corresponding to dbMax dB and 0 to dbMin dB
val = (val - (float)m_dBmax) / (float)(m_dBmax - m_dBmin) + 1.;
val = (val - m_dBmax) / (m_dBmax - m_dBmin) + 1.f;
if (val < 0) {
val = 0;
} else if (val > 1) {
val = 1;
}
if (!peak || !m_aHighlightPeaks->isChecked()) {
spectrum.setPixel(leftDist + i, topDist + h - 1 - y, m_colorMap[(int)(val * 255)]);
spectrum.setPixel(leftDist + i, topDist + h - 1 - y, m_colorMap[int(val * 255)]);
} else {
spectrum.setPixel(leftDist + i, topDist + h - 1 - y, AbstractScopeWidget::colHighlightDark.rgba());
}
......@@ -441,7 +441,7 @@ QImage Spectrogram::renderAudioScope(uint, const audioShortVector &audioFrame, c
m_fftHistoryImg = spectrum;
emit signalScopeRenderingFinished((uint)timer.elapsed(), 1);
emit signalScopeRenderingFinished(uint(timer.elapsed()), 1);
return spectrum;
}
emit signalScopeRenderingFinished(0, 1);
......
......@@ -251,10 +251,10 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
case PaintMode_Green2:
px = scope.pixel(pt);
scope.setPixel(pt,
qRgba(qRed(px) + int((255 - qRed(px)) / (4 * avgPxPerPx)),
qRgba(qRed(px) + int(ceil((255 - qRed(px)) / (4 * avgPxPerPx))),
255,
qBlue(px) + int((255 - qBlue(px)) / (avgPxPerPx)),
qAlpha(px) + int((255 - qAlpha(px)) / (avgPxPerPx))));
qBlue(px) + int(ceil((255 - qBlue(px)) / (avgPxPerPx))),
qAlpha(px) + int(ceil((255 - qAlpha(px)) / (avgPxPerPx)))));
break;
case PaintMode_Black:
px = scope.pixel(pt);
......
......@@ -37,7 +37,7 @@ SimpleTimelineWidget::SimpleTimelineWidget(QWidget *parent)
KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window);
m_colSelected = palette().highlight().color();
m_colKeyframe = scheme.foreground(KColorScheme::NormalText).color();
m_size = QFontInfo(font()).pixelSize() * 1.8;
m_size = int(QFontInfo(font()).pixelSize() * 1.8);
m_lineHeight = m_size / 2;
setMinimumHeight(m_size);
setMaximumHeight(m_size);
......@@ -152,7 +152,7 @@ void SimpleTimelineWidget::slotGoToPrev()
void SimpleTimelineWidget::mousePressEvent(QMouseEvent *event)
{
int pos = event->x() / m_scale;
int pos = int(event->x() / m_scale);
if (event->y() < m_lineHeight && event->button() == Qt::LeftButton) {
for (const int &keyframe : qAsConst(m_keyframes)) {
if (qAbs(keyframe - pos) < 5) {
......@@ -175,7 +175,7 @@ void SimpleTimelineWidget::mousePressEvent(QMouseEvent *event)
void SimpleTimelineWidget::mouseMoveEvent(QMouseEvent *event)
{
int pos = qBound(0, (int)(event->x() / m_scale), m_duration);
int pos = qBound(0, int(event->x() / m_scale), m_duration);
if ((event->buttons() & Qt::LeftButton) != 0u) {
if (m_currentKeyframe >= 0) {
if (!m_keyframes.contains(pos)) {
......@@ -228,7 +228,7 @@ void SimpleTimelineWidget::mouseReleaseEvent(QMouseEvent *event)
void SimpleTimelineWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton && event->y() < m_lineHeight) {
int pos = qBound(0, (int)(event->x() / m_scale), m_duration);
int pos = qBound(0, int(event->x() / m_scale), m_duration);