Sequencer - New points are inserted with the right value
This commit is contained in:
parent
702bf2bee8
commit
b9cb427ae4
3 changed files with 15 additions and 2 deletions
11
c-sync.cc
11
c-sync.cc
|
@ -180,6 +180,17 @@ void T_SyncTime::setDuration(
|
||||||
|
|
||||||
/*= T_SyncSegment ============================================================*/
|
/*= T_SyncSegment ============================================================*/
|
||||||
|
|
||||||
|
uint32_t T_SyncSegment::findTimeOfPoint(
|
||||||
|
const uint32_t index ) const noexcept
|
||||||
|
{
|
||||||
|
assert( index <= durations.size( ) );
|
||||||
|
uint32_t t{ 0 };
|
||||||
|
for ( auto i = 0u ; i < index ; i ++ ) {
|
||||||
|
t += durations[ i ];
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
float T_SyncSegment::computeValue(
|
float T_SyncSegment::computeValue(
|
||||||
const float relTimeUnits ) const noexcept
|
const float relTimeUnits ) const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,9 @@ struct T_SyncSegment
|
||||||
T_Array< float > values;
|
T_Array< float > values;
|
||||||
T_Array< uint32_t > durations; // n(values) - 1 items
|
T_Array< uint32_t > durations; // n(values) - 1 items
|
||||||
|
|
||||||
|
// Find the amount of time units before point
|
||||||
|
uint32_t findTimeOfPoint( uint32_t index ) const noexcept;
|
||||||
|
|
||||||
// Compute the value for the specified position, which is relative
|
// Compute the value for the specified position, which is relative
|
||||||
// to the start of the segment.
|
// to the start of the segment.
|
||||||
float computeValue( float relTimeUnits ) const noexcept;
|
float computeValue( float relTimeUnits ) const noexcept;
|
||||||
|
|
|
@ -325,8 +325,7 @@ void SyncEditor::InsertPoint(
|
||||||
auto& ns{ c.segments[ segmentIndex ] };
|
auto& ns{ c.segments[ segmentIndex ] };
|
||||||
|
|
||||||
const auto hd{ ns.durations[ pointIndex - 1 ] / 2 };
|
const auto hd{ ns.durations[ pointIndex - 1 ] / 2 };
|
||||||
// FIXME: this should use the actual value
|
const float hv{ ns.computeValue( ns.findTimeOfPoint( pointIndex - 1 ) + hd ) };
|
||||||
const float hv{ ( ns.values[ pointIndex ] + ns.values[ pointIndex - 1 ] ) * .5f };
|
|
||||||
|
|
||||||
ns.durations[ pointIndex - 1 ] -= hd;
|
ns.durations[ pointIndex - 1 ] -= hd;
|
||||||
ns.durations.insert( pointIndex - 1 , hd );
|
ns.durations.insert( pointIndex - 1 , hd );
|
||||||
|
|
Loading…
Reference in a new issue