Merge branch 'master' into cpp20
This commit is contained in:
@@ -74,6 +74,7 @@ static thread_local bool s_renderingThread = false;
|
||||
AudioEngine::AudioEngine( bool renderOnly ) :
|
||||
m_renderOnly( renderOnly ),
|
||||
m_framesPerPeriod( DEFAULT_BUFFER_SIZE ),
|
||||
m_baseSampleRate(std::max(ConfigManager::inst()->value("audioengine", "samplerate").toInt(), 44100)),
|
||||
m_inputBufferRead( 0 ),
|
||||
m_inputBufferWrite( 1 ),
|
||||
m_outputBufferRead(nullptr),
|
||||
@@ -241,34 +242,6 @@ void AudioEngine::stopProcessing()
|
||||
|
||||
|
||||
|
||||
sample_rate_t AudioEngine::baseSampleRate() const
|
||||
{
|
||||
sample_rate_t sr = ConfigManager::inst()->value( "audioengine", "samplerate" ).toInt();
|
||||
if( sr < 44100 )
|
||||
{
|
||||
sr = 44100;
|
||||
}
|
||||
return sr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sample_rate_t AudioEngine::outputSampleRate() const
|
||||
{
|
||||
return m_audioDev != nullptr ? m_audioDev->sampleRate() :
|
||||
baseSampleRate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sample_rate_t AudioEngine::inputSampleRate() const
|
||||
{
|
||||
return m_audioDev != nullptr ? m_audioDev->sampleRate() :
|
||||
baseSampleRate();
|
||||
}
|
||||
|
||||
bool AudioEngine::criticalXRuns() const
|
||||
{
|
||||
return cpuLoad() >= 99 && Engine::getSong()->isExporting() == false;
|
||||
|
||||
@@ -29,20 +29,17 @@
|
||||
namespace lmms
|
||||
{
|
||||
|
||||
using std::unique_ptr;
|
||||
using std::move;
|
||||
|
||||
void ComboBoxModel::addItem( QString item, unique_ptr<PixmapLoader> loader )
|
||||
void ComboBoxModel::addItem(QString item, std::unique_ptr<PixmapLoader> loader)
|
||||
{
|
||||
m_items.emplace_back( move(item), move(loader) );
|
||||
m_items.emplace_back(std::move(item), std::move(loader));
|
||||
setRange( 0, m_items.size() - 1 );
|
||||
}
|
||||
|
||||
|
||||
void ComboBoxModel::replaceItem(std::size_t index, QString item, unique_ptr<PixmapLoader> loader)
|
||||
void ComboBoxModel::replaceItem(std::size_t index, QString item, std::unique_ptr<PixmapLoader> loader)
|
||||
{
|
||||
assert(index < m_items.size());
|
||||
m_items[index] = Item(move(item), move(loader));
|
||||
m_items[index] = Item(std::move(item), std::move(loader));
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void Keymap::loadSettings(const QDomElement &element)
|
||||
QDomNode node = element.firstChild();
|
||||
m_map.clear();
|
||||
|
||||
for (int i = 0; !node.isNull(); i++)
|
||||
while (!node.isNull())
|
||||
{
|
||||
m_map.push_back(node.toElement().attribute("value").toInt());
|
||||
node = node.nextSibling();
|
||||
|
||||
@@ -80,9 +80,7 @@ void PeakController::updateValueBuffer()
|
||||
{
|
||||
if( m_coeffNeedsUpdate )
|
||||
{
|
||||
const float ratio = 44100.0f / Engine::audioEngine()->outputSampleRate();
|
||||
m_attackCoeff = 1.0f - powf( 2.0f, -0.3f * ( 1.0f - m_peakEffect->attackModel()->value() ) * ratio );
|
||||
m_decayCoeff = 1.0f - powf( 2.0f, -0.3f * ( 1.0f - m_peakEffect->decayModel()->value() ) * ratio );
|
||||
m_coeff = 100.0f / Engine::audioEngine()->outputSampleRate();
|
||||
m_coeffNeedsUpdate = false;
|
||||
}
|
||||
|
||||
@@ -97,14 +95,7 @@ void PeakController::updateValueBuffer()
|
||||
for( f_cnt_t f = 0; f < frames; ++f )
|
||||
{
|
||||
const float diff = ( targetSample - m_currentSample );
|
||||
if( m_currentSample < targetSample ) // going up...
|
||||
{
|
||||
m_currentSample += diff * m_attackCoeff;
|
||||
}
|
||||
else if( m_currentSample > targetSample ) // going down
|
||||
{
|
||||
m_currentSample += diff * m_decayCoeff;
|
||||
}
|
||||
m_currentSample += diff * m_coeff;
|
||||
values[f] = m_currentSample;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ void ProjectRenderer::abortProcessing()
|
||||
|
||||
void ProjectRenderer::updateConsoleProgress()
|
||||
{
|
||||
const int cols = 50;
|
||||
constexpr int cols = 50;
|
||||
static int rot = 0;
|
||||
auto buf = std::array<char, 80>{};
|
||||
auto prog = std::array<char, cols + 1>{};
|
||||
@@ -221,9 +221,9 @@ void ProjectRenderer::updateConsoleProgress()
|
||||
}
|
||||
prog[cols] = 0;
|
||||
|
||||
const auto activity = (const char*)"|/-\\";
|
||||
const auto activity = "|/-\\";
|
||||
std::fill(buf.begin(), buf.end(), 0);
|
||||
sprintf(buf.data(), "\r|%s| %3d%% %c ", prog.data(), m_progress,
|
||||
std::snprintf(buf.data(), buf.size(), "\r|%s| %3d%% %c ", prog.data(), m_progress,
|
||||
activity[rot] );
|
||||
rot = ( rot+1 ) % 4;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ void Scale::loadSettings(const QDomElement &element)
|
||||
QDomNode node = element.firstChild();
|
||||
m_intervals.clear();
|
||||
|
||||
for (int i = 0; !node.isNull(); i++)
|
||||
while (!node.isNull())
|
||||
{
|
||||
Interval temp;
|
||||
temp.restoreState(node.toElement());
|
||||
|
||||
@@ -43,20 +43,6 @@ TimeSig::TimeSig( const MeterModel &model ) :
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int TimeSig::numerator() const
|
||||
{
|
||||
return m_num;
|
||||
}
|
||||
|
||||
int TimeSig::denominator() const
|
||||
{
|
||||
return m_denom;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TimePos::TimePos( const bar_t bar, const tick_t ticks ) :
|
||||
m_ticks( bar * s_ticksPerBar + ticks )
|
||||
{
|
||||
@@ -86,140 +72,4 @@ TimePos TimePos::quantize(float bars) const
|
||||
return (lowPos + snapUp) * interval;
|
||||
}
|
||||
|
||||
|
||||
TimePos TimePos::toAbsoluteBar() const
|
||||
{
|
||||
return getBar() * s_ticksPerBar;
|
||||
}
|
||||
|
||||
|
||||
TimePos& TimePos::operator+=( const TimePos& time )
|
||||
{
|
||||
m_ticks += time.m_ticks;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TimePos& TimePos::operator-=( const TimePos& time )
|
||||
{
|
||||
m_ticks -= time.m_ticks;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bar_t TimePos::getBar() const
|
||||
{
|
||||
return m_ticks / s_ticksPerBar;
|
||||
}
|
||||
|
||||
|
||||
bar_t TimePos::nextFullBar() const
|
||||
{
|
||||
return ( m_ticks + ( s_ticksPerBar - 1 ) ) / s_ticksPerBar;
|
||||
}
|
||||
|
||||
|
||||
void TimePos::setTicks( tick_t ticks )
|
||||
{
|
||||
m_ticks = ticks;
|
||||
}
|
||||
|
||||
|
||||
tick_t TimePos::getTicks() const
|
||||
{
|
||||
return m_ticks;
|
||||
}
|
||||
|
||||
|
||||
TimePos::operator int() const
|
||||
{
|
||||
return m_ticks;
|
||||
}
|
||||
|
||||
|
||||
tick_t TimePos::ticksPerBeat( const TimeSig &sig ) const
|
||||
{
|
||||
// (number of ticks per bar) divided by (number of beats per bar)
|
||||
return ticksPerBar(sig) / sig.numerator();
|
||||
}
|
||||
|
||||
|
||||
tick_t TimePos::getTickWithinBar( const TimeSig &sig ) const
|
||||
{
|
||||
return m_ticks % ticksPerBar( sig );
|
||||
}
|
||||
|
||||
tick_t TimePos::getBeatWithinBar( const TimeSig &sig ) const
|
||||
{
|
||||
return getTickWithinBar( sig ) / ticksPerBeat( sig );
|
||||
}
|
||||
|
||||
tick_t TimePos::getTickWithinBeat( const TimeSig &sig ) const
|
||||
{
|
||||
return getTickWithinBar( sig ) % ticksPerBeat( sig );
|
||||
}
|
||||
|
||||
|
||||
f_cnt_t TimePos::frames( const float framesPerTick ) const
|
||||
{
|
||||
// Before, step notes used to have negative length. This
|
||||
// assert is a safeguard against negative length being
|
||||
// introduced again (now using Note Types instead #5902)
|
||||
assert(m_ticks >= 0);
|
||||
return static_cast<f_cnt_t>(m_ticks * framesPerTick);
|
||||
}
|
||||
|
||||
double TimePos::getTimeInMilliseconds( bpm_t beatsPerMinute ) const
|
||||
{
|
||||
return ticksToMilliseconds( getTicks(), beatsPerMinute );
|
||||
}
|
||||
|
||||
TimePos TimePos::fromFrames( const f_cnt_t frames, const float framesPerTick )
|
||||
{
|
||||
return TimePos( static_cast<int>( frames / framesPerTick ) );
|
||||
}
|
||||
|
||||
|
||||
tick_t TimePos::ticksPerBar()
|
||||
{
|
||||
return s_ticksPerBar;
|
||||
}
|
||||
|
||||
|
||||
tick_t TimePos::ticksPerBar( const TimeSig &sig )
|
||||
{
|
||||
return DefaultTicksPerBar * sig.numerator() / sig.denominator();
|
||||
}
|
||||
|
||||
|
||||
int TimePos::stepsPerBar()
|
||||
{
|
||||
int steps = ticksPerBar() / DefaultBeatsPerBar;
|
||||
return std::max(1, steps);
|
||||
}
|
||||
|
||||
|
||||
void TimePos::setTicksPerBar( tick_t tpb )
|
||||
{
|
||||
s_ticksPerBar = tpb;
|
||||
}
|
||||
|
||||
|
||||
TimePos TimePos::stepPosition( int step )
|
||||
{
|
||||
return step * ticksPerBar() / stepsPerBar();
|
||||
}
|
||||
|
||||
double TimePos::ticksToMilliseconds( tick_t ticks, bpm_t beatsPerMinute )
|
||||
{
|
||||
return TimePos::ticksToMilliseconds( static_cast<double>(ticks), beatsPerMinute );
|
||||
}
|
||||
|
||||
double TimePos::ticksToMilliseconds(double ticks, bpm_t beatsPerMinute)
|
||||
{
|
||||
// 60 * 1000 / 48 = 1250
|
||||
return ( ticks * 1250 ) / beatsPerMinute;
|
||||
}
|
||||
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
@@ -159,7 +159,7 @@ void MidiApple::removePort( MidiPort* port )
|
||||
|
||||
QString MidiApple::sourcePortName( const MidiEvent& event ) const
|
||||
{
|
||||
qDebug("sourcePortName return '%s'?\n", event.sourcePort());
|
||||
qDebug("sourcePortName");
|
||||
/*
|
||||
if( event.sourcePort() )
|
||||
{
|
||||
@@ -501,7 +501,7 @@ void MidiApple::openDevices()
|
||||
void MidiApple::openMidiReference( MIDIEndpointRef reference, QString refName, bool isIn )
|
||||
{
|
||||
char * registeredName = (char*) malloc(refName.length()+1);
|
||||
sprintf(registeredName, "%s",refName.toLatin1().constData());
|
||||
std::snprintf(registeredName, refName.length() + 1, "%s",refName.toLatin1().constData());
|
||||
qDebug("openMidiReference refName '%s'",refName.toLatin1().constData());
|
||||
|
||||
MIDIClientRef mClient = getMidiClientRef();
|
||||
@@ -623,7 +623,7 @@ char * MidiApple::getFullName(MIDIEndpointRef &endpoint_ref)
|
||||
size_t deviceNameLen = deviceName == nullptr ? 0 : strlen(deviceName);
|
||||
size_t endPointNameLen = endPointName == nullptr ? 0 : strlen(endPointName);
|
||||
char * fullName = (char *)malloc(deviceNameLen + endPointNameLen + 2);
|
||||
sprintf(fullName, "%s:%s", deviceName,endPointName);
|
||||
std::snprintf(fullName, deviceNameLen + endPointNameLen + 2, "%s:%s", deviceName,endPointName);
|
||||
if (deviceName != nullptr) { free(deviceName); }
|
||||
if (endPointName != nullptr) { free(endPointName); }
|
||||
return fullName;
|
||||
|
||||
@@ -186,21 +186,18 @@ void MixerChannelView::contextMenuEvent(QContextMenuEvent*)
|
||||
delete contextMenu;
|
||||
}
|
||||
|
||||
void MixerChannelView::paintEvent(QPaintEvent* event)
|
||||
void MixerChannelView::paintEvent(QPaintEvent*)
|
||||
{
|
||||
static constexpr auto innerBorderSize = 3;
|
||||
static constexpr auto outerBorderSize = 1;
|
||||
|
||||
const auto channel = mixerChannel();
|
||||
const bool muted = channel->m_muteModel.value();
|
||||
const auto name = channel->m_name;
|
||||
const auto elidedName = elideName(name);
|
||||
const auto isActive = m_mixerView->currentMixerChannel() == this;
|
||||
|
||||
if (!m_inRename && m_renameLineEdit->text() != elidedName) { m_renameLineEdit->setText(elidedName); }
|
||||
|
||||
const auto width = rect().width();
|
||||
const auto height = rect().height();
|
||||
auto painter = QPainter{this};
|
||||
|
||||
if (channel->color().has_value() && !muted)
|
||||
if (channel->color().has_value() && !channel->m_muteModel.value())
|
||||
{
|
||||
painter.fillRect(rect(), channel->color()->darker(isActive ? 120 : 150));
|
||||
}
|
||||
@@ -208,13 +205,11 @@ void MixerChannelView::paintEvent(QPaintEvent* event)
|
||||
|
||||
// inner border
|
||||
painter.setPen(isActive ? strokeInnerActive() : strokeInnerInactive());
|
||||
painter.drawRect(1, 1, width - MIXER_CHANNEL_INNER_BORDER_SIZE, height - MIXER_CHANNEL_INNER_BORDER_SIZE);
|
||||
painter.drawRect(1, 1, width - innerBorderSize, height - innerBorderSize);
|
||||
|
||||
// outer border
|
||||
painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive());
|
||||
painter.drawRect(0, 0, width - MIXER_CHANNEL_OUTER_BORDER_SIZE, height - MIXER_CHANNEL_OUTER_BORDER_SIZE);
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
painter.drawRect(0, 0, width - outerBorderSize, height - outerBorderSize);
|
||||
}
|
||||
|
||||
void MixerChannelView::mousePressEvent(QMouseEvent*)
|
||||
@@ -227,7 +222,7 @@ void MixerChannelView::mouseDoubleClickEvent(QMouseEvent*)
|
||||
renameChannel();
|
||||
}
|
||||
|
||||
bool MixerChannelView::eventFilter(QObject* dist, QEvent* event)
|
||||
bool MixerChannelView::eventFilter(QObject*, QEvent* event)
|
||||
{
|
||||
// If we are in a rename, capture the enter/return events and handle them
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
@@ -246,11 +241,6 @@ bool MixerChannelView::eventFilter(QObject* dist, QEvent* event)
|
||||
return false;
|
||||
}
|
||||
|
||||
int MixerChannelView::channelIndex() const
|
||||
{
|
||||
return m_channelIndex;
|
||||
}
|
||||
|
||||
void MixerChannelView::setChannelIndex(int index)
|
||||
{
|
||||
MixerChannel* mixerChannel = Engine::mixer()->mixerChannel(index);
|
||||
@@ -259,64 +249,10 @@ void MixerChannelView::setChannelIndex(int index)
|
||||
m_soloButton->setModel(&mixerChannel->m_soloModel);
|
||||
m_effectRackView->setModel(&mixerChannel->m_fxChain);
|
||||
m_channelNumberLcd->setValue(index);
|
||||
m_renameLineEdit->setText(elideName(mixerChannel->m_name));
|
||||
m_channelIndex = index;
|
||||
}
|
||||
|
||||
QBrush MixerChannelView::backgroundActive() const
|
||||
{
|
||||
return m_backgroundActive;
|
||||
}
|
||||
|
||||
void MixerChannelView::setBackgroundActive(const QBrush& c)
|
||||
{
|
||||
m_backgroundActive = c;
|
||||
}
|
||||
|
||||
QColor MixerChannelView::strokeOuterActive() const
|
||||
{
|
||||
return m_strokeOuterActive;
|
||||
}
|
||||
|
||||
void MixerChannelView::setStrokeOuterActive(const QColor& c)
|
||||
{
|
||||
m_strokeOuterActive = c;
|
||||
}
|
||||
|
||||
QColor MixerChannelView::strokeOuterInactive() const
|
||||
{
|
||||
return m_strokeOuterInactive;
|
||||
}
|
||||
|
||||
void MixerChannelView::setStrokeOuterInactive(const QColor& c)
|
||||
{
|
||||
m_strokeOuterInactive = c;
|
||||
}
|
||||
|
||||
QColor MixerChannelView::strokeInnerActive() const
|
||||
{
|
||||
return m_strokeInnerActive;
|
||||
}
|
||||
|
||||
void MixerChannelView::setStrokeInnerActive(const QColor& c)
|
||||
{
|
||||
m_strokeInnerActive = c;
|
||||
}
|
||||
|
||||
QColor MixerChannelView::strokeInnerInactive() const
|
||||
{
|
||||
return m_strokeInnerInactive;
|
||||
}
|
||||
|
||||
void MixerChannelView::setStrokeInnerInactive(const QColor& c)
|
||||
{
|
||||
m_strokeInnerInactive = c;
|
||||
}
|
||||
|
||||
void MixerChannelView::reset()
|
||||
{
|
||||
m_peakIndicator->resetPeakToMinusInf();
|
||||
}
|
||||
|
||||
void MixerChannelView::renameChannel()
|
||||
{
|
||||
m_inRename = true;
|
||||
@@ -459,4 +395,9 @@ MixerChannel* MixerChannelView::mixerChannel() const
|
||||
return Engine::mixer()->mixerChannel(m_channelIndex);
|
||||
}
|
||||
|
||||
void MixerChannelView::reset()
|
||||
{
|
||||
m_peakIndicator->resetPeakToMinusInf();
|
||||
}
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
@@ -282,20 +282,17 @@ void Fader::paintEvent(QPaintEvent* ev)
|
||||
|
||||
void Fader::paintLevels(QPaintEvent* ev, QPainter& painter, bool linear)
|
||||
{
|
||||
std::function<float(float value)> mapper = [this](float value) { return ampToDbfs(qMax(0.0001f, value)); };
|
||||
const auto mapper = linear
|
||||
? +[](float value) -> float { return value; }
|
||||
: +[](float value) -> float { return ampToDbfs(qMax(0.0001f, value)); };
|
||||
|
||||
if (linear)
|
||||
{
|
||||
mapper = [this](float value) { return value; };
|
||||
}
|
||||
|
||||
const float mappedMinPeak(mapper(m_fMinPeak));
|
||||
const float mappedMaxPeak(mapper(m_fMaxPeak));
|
||||
const float mappedPeakL(mapper(m_fPeakValue_L));
|
||||
const float mappedPeakR(mapper(m_fPeakValue_R));
|
||||
const float mappedPersistentPeakL(mapper(m_persistentPeak_L));
|
||||
const float mappedPersistentPeakR(mapper(m_persistentPeak_R));
|
||||
const float mappedUnity(mapper(1.f));
|
||||
const float mappedMinPeak = mapper(m_fMinPeak);
|
||||
const float mappedMaxPeak = mapper(m_fMaxPeak);
|
||||
const float mappedPeakL = mapper(m_fPeakValue_L);
|
||||
const float mappedPeakR = mapper(m_fPeakValue_R);
|
||||
const float mappedPersistentPeakL = mapper(m_persistentPeak_L);
|
||||
const float mappedPersistentPeakR = mapper(m_persistentPeak_R);
|
||||
const float mappedUnity = mapper(1.f);
|
||||
|
||||
painter.save();
|
||||
|
||||
@@ -375,10 +372,10 @@ void Fader::paintLevels(QPaintEvent* ev, QPainter& painter, bool linear)
|
||||
// Please ensure that "clip starts" is the maximum value and that "ok ends"
|
||||
// is the minimum value and that all other values lie inbetween. Otherwise
|
||||
// there will be warnings when the gradient is defined.
|
||||
const float mappedClipStarts(mapper(dbfsToAmp(0.f)));
|
||||
const float mappedWarnEnd(mapper(dbfsToAmp(-0.01f)));
|
||||
const float mappedWarnStart(mapper(dbfsToAmp(-6.f)));
|
||||
const float mappedOkEnd(mapper(dbfsToAmp(-12.f)));
|
||||
const float mappedClipStarts = mapper(dbfsToAmp(0.f));
|
||||
const float mappedWarnEnd = mapper(dbfsToAmp(-0.01f));
|
||||
const float mappedWarnStart = mapper(dbfsToAmp(-6.f));
|
||||
const float mappedOkEnd = mapper(dbfsToAmp(-12.f));
|
||||
|
||||
// Prepare the gradient for the meters
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user