Move improvements to sample-exact controller handling,
also some coding style fixes
This commit is contained in:
@@ -48,7 +48,7 @@ AutomatableModel::AutomatableModel( DataType type,
|
||||
m_range( max - min ),
|
||||
m_centerValue( m_minValue ),
|
||||
m_setValueDepth( 0 ),
|
||||
m_strictStepSize( false ),
|
||||
m_hasStrictStepSize( false ),
|
||||
m_hasLinkedModels( false ),
|
||||
m_controllerConnection( NULL ),
|
||||
m_valueBuffer( static_cast<int>( engine::mixer()->framesPerPeriod() ) )
|
||||
@@ -331,7 +331,7 @@ void AutomatableModel::setAutomatedValue( const float value )
|
||||
++m_setValueDepth;
|
||||
const float oldValue = m_value;
|
||||
|
||||
const float scaled_value =
|
||||
const float scaledValue =
|
||||
( m_scaleType == Linear )
|
||||
? value
|
||||
: logToLinearScale(
|
||||
@@ -339,7 +339,7 @@ void AutomatableModel::setAutomatedValue( const float value )
|
||||
(value - minValue<float>()) / maxValue<float>()
|
||||
);
|
||||
|
||||
m_value = fittedValue( scaled_value );
|
||||
m_value = fittedValue( scaledValue );
|
||||
|
||||
if( oldValue != m_value )
|
||||
{
|
||||
@@ -405,7 +405,7 @@ float AutomatableModel::fittedValue( float value, bool forceStep ) const
|
||||
{
|
||||
value = tLimit<float>( value, m_minValue, m_maxValue );
|
||||
|
||||
if( m_step != 0 && ( m_strictStepSize || forceStep ) )
|
||||
if( m_step != 0 && ( m_hasStrictStepSize || forceStep ) )
|
||||
{
|
||||
value = nearbyintf( value / m_step ) * m_step;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ float AutomatableModel::controllerValue( int frameOffset ) const
|
||||
"lacks implementation for a scale type");
|
||||
break;
|
||||
}
|
||||
if( typeInfo<float>::isEqual( m_step, 1 ) && m_strictStepSize )
|
||||
if( typeInfo<float>::isEqual( m_step, 1 ) && m_hasStrictStepSize )
|
||||
{
|
||||
return qRound( v );
|
||||
}
|
||||
@@ -710,7 +710,7 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time )
|
||||
// fits value into [0,1]:
|
||||
(value - minValue<float>()) / maxValue<float>()
|
||||
);
|
||||
return fittedValue( scaled_value );
|
||||
return fittedValue( scaledValue );
|
||||
}
|
||||
// if we still find no pattern, the value at that time is undefined so
|
||||
// just return current value as the best we can do
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "PeakController.h"
|
||||
|
||||
|
||||
unsigned int Controller::s_periods = 0;
|
||||
long Controller::s_periods = 0;
|
||||
QVector<Controller *> Controller::s_controllers;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ Controller::Controller( ControllerTypes _type, Model * _parent,
|
||||
Model( _parent, _display_name ),
|
||||
JournallingObject(),
|
||||
m_valueBuffer( engine::mixer()->framesPerPeriod() ),
|
||||
m_bufferLastUpdated( 0 ),
|
||||
m_bufferLastUpdated( -1 ),
|
||||
m_connectionCount( 0 ),
|
||||
m_type( _type )
|
||||
{
|
||||
@@ -82,6 +82,7 @@ Controller::Controller( ControllerTypes _type, Model * _parent,
|
||||
}
|
||||
}
|
||||
}
|
||||
updateValueBuffer();
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +185,10 @@ void Controller::triggerFrameCounter()
|
||||
|
||||
void Controller::resetFrameCounter()
|
||||
{
|
||||
for( int i = 0; i < s_controllers.size(); ++i )
|
||||
{
|
||||
s_controllers.at( i )->m_bufferLastUpdated = 0;
|
||||
}
|
||||
s_periods = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ LfoController::LfoController( Model * _parent ) :
|
||||
|
||||
connect( engine::getSong(), SIGNAL( playbackStateChanged() ),
|
||||
this, SLOT( updatePhase() ) );
|
||||
connect( engine::getSong(), SIGNAL( playbackPositionChanged() ),
|
||||
this, SLOT( updatePhase() ) );
|
||||
|
||||
updateDuration();
|
||||
}
|
||||
@@ -87,11 +89,19 @@ LfoController::~LfoController()
|
||||
|
||||
void LfoController::updateValueBuffer()
|
||||
{
|
||||
m_phaseOffset = m_phaseModel.value() / 360.0;
|
||||
|
||||
float * values = m_valueBuffer.values();
|
||||
|
||||
m_phaseOffset = m_phaseModel.value() / 360.0;
|
||||
float * values = m_valueBuffer.values();
|
||||
float phase = m_currentPhase + m_phaseOffset;
|
||||
|
||||
// roll phase up until we're in sync with period counter
|
||||
m_bufferLastUpdated++;
|
||||
while( m_bufferLastUpdated != s_periods )
|
||||
{
|
||||
phase += static_cast<float>( engine::framesPerTick() ) / m_duration;
|
||||
m_bufferLastUpdated++;
|
||||
}
|
||||
|
||||
|
||||
for( int i = 0; i < m_valueBuffer.length(); i++ )
|
||||
{
|
||||
const float currentSample = m_sampleFunction != NULL
|
||||
@@ -104,13 +114,13 @@ void LfoController::updateValueBuffer()
|
||||
}
|
||||
|
||||
m_currentPhase = absFraction( phase - m_phaseOffset );
|
||||
m_bufferLastUpdated = s_periods;
|
||||
}
|
||||
|
||||
|
||||
void LfoController::updatePhase()
|
||||
{
|
||||
m_currentPhase = ( engine::getSong()->getTicks() * engine::framesPerTick() ) / m_duration;
|
||||
m_currentPhase = ( engine::getSong()->getFrames() ) / m_duration;
|
||||
m_bufferLastUpdated = s_periods - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -523,6 +523,12 @@ void song::setPlayPos( tick_t _ticks, PlayModes _play_mode )
|
||||
m_elapsedMilliSeconds += (((( _ticks - m_playPos[_play_mode].getTicks()))*60*1000/48)/getTempo());
|
||||
m_playPos[_play_mode].setTicks( _ticks );
|
||||
m_playPos[_play_mode].setCurrentFrame( 0.0f );
|
||||
|
||||
// send a signal if playposition changes during playback
|
||||
if( isPlaying() )
|
||||
{
|
||||
emit playbackPositionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user