Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
77d69e2
First commit
IanCaio Oct 13, 2020
fb2107d
Implements inValue/outValue on Automation Nodes
IanCaio Oct 14, 2020
28611b8
Fixes and refactor code on AutomationEditor.cpp
IanCaio Oct 15, 2020
e5c9669
Avoids unnecessary check in putValue
IanCaio Oct 15, 2020
ab0aeb0
Adds upgrade routine for the automation nodes
IanCaio Oct 15, 2020
2ed2a66
Allows dragging outValues on the Automation Editor
IanCaio Oct 16, 2020
7b6729b
Small fix inside AutomationPattern.cpp
IanCaio Oct 16, 2020
a800943
Creates separate files for AutomationNode
IanCaio Oct 16, 2020
3932106
Adds more members to AutomationNode
IanCaio Oct 16, 2020
9f55d2c
Removes unused code from AutomationEditor
IanCaio Oct 16, 2020
c42c46b
Changes to the outValues now update the tangents
IanCaio Oct 16, 2020
504143c
Keeps discrete jumps when flipping patterns
IanCaio Oct 16, 2020
d67942b
Allows reseting outValues on the AutomationEditor
IanCaio Oct 16, 2020
7c269bd
Makes so dragging nodes keep the outValue
IanCaio Oct 16, 2020
64fcec0
Fixes code style on modified code
IanCaio Oct 16, 2020
578367e
Adds a QProperty for the node outValue color
IanCaio Oct 16, 2020
c4960a1
Adds doxygen comments on methods
IanCaio Oct 16, 2020
5c94591
Refactor flipX and flipY methods
IanCaio Oct 16, 2020
939596a
Add a new edit mode to Automation Editor
IanCaio Oct 16, 2020
5a38f74
Improves the Draw OutValue edit mode
IanCaio Oct 17, 2020
7925196
Adds mutex to AutomationPattern
IanCaio Oct 17, 2020
9e325dc
Veratil's review changes
IanCaio Oct 19, 2020
61d20ff
Changes the inValue sphere to be draw first
IanCaio Oct 19, 2020
ff92b56
Merge branch 'master' into feature/automationProgression
IanCaio Oct 21, 2020
3d4be23
Changes comments and variables names
IanCaio Oct 21, 2020
caa43ad
Changes QProperty variables to use MEMBER
IanCaio Oct 22, 2020
61ef27a
Overloads some AutomationNode's operators
IanCaio Oct 22, 2020
932a46e
Improves getNodeAt method
IanCaio Oct 22, 2020
a64942a
Changes behavior of setDragValue
IanCaio Oct 22, 2020
3b6f238
Moves getNodeAt to an upper level, reducing lines
IanCaio Oct 22, 2020
53f4afa
Changes icon of Draw OutValue edit mode
IanCaio Oct 22, 2020
108323d
Merge branch 'master' into feature/automationProgression
IanCaio Oct 24, 2020
203d3b5
Removes unnecessary non-const methods
IanCaio Nov 12, 2020
1531668
Merge branch 'master' into feature/automationProgression
IanCaio Nov 12, 2020
5184d79
Fixes formatting and doxygen comments
IanCaio Nov 13, 2020
9805321
Adds helper macros for AutomationNodes
IanCaio Nov 13, 2020
055c95f
Removes tabs from ternary operator
IanCaio Nov 13, 2020
1c3502c
Update files to use AutomationNode macros
IanCaio Nov 13, 2020
3471b8f
Merge branch 'master' into feature/automationProgression
IanCaio Nov 26, 2020
7559a41
Addresses my own code review
IanCaio Nov 26, 2020
2cf33e1
Addresses Veratil's review
IanCaio Nov 26, 2020
e0c3563
Adds helper MACROs for node tangents
IanCaio Nov 26, 2020
85a0ca3
Merge branch 'master' into feature/automationProgression
IanCaio Dec 5, 2020
cbf73dc
Fixes header inclusion order
IanCaio Dec 5, 2020
de6d7c9
Removes mutex from AutomationEditor
IanCaio Dec 6, 2020
7d1f196
Locks mutex on AutomationPattern copy assignment
IanCaio Dec 6, 2020
128c723
Changes resetOutValue() so it generates tangents
IanCaio Dec 6, 2020
adc223b
Changes some methods to use for loops
IanCaio Dec 11, 2020
169cc3b
Move removeNodes/resetNodes to AutomationPattern
IanCaio Dec 11, 2020
033bfab
Optimizes loop inside putValue/putValues
IanCaio Dec 11, 2020
fe53845
Adds comment to mysterious calculation
IanCaio Dec 12, 2020
1f28a45
Merge branch 'master' into feature/automationProgression
IanCaio Dec 16, 2020
1e1e5f8
Reduces indentation on getNodeAt
IanCaio Dec 16, 2020
6bec055
Applies Veratil suggestions
IanCaio Dec 16, 2020
1d23334
Updates comment from changed code
IanCaio Dec 16, 2020
8c5f9d4
Uses lambda functions to extract code
IanCaio Dec 16, 2020
1d1d57c
Fixes behavior of AutomationPattern::flipX
IanCaio Dec 20, 2020
d9862c5
Changes pattern XML for backwards compatibility
IanCaio Dec 20, 2020
2d1fbd0
Fixes bug on AutomationPattern::resetNodes
IanCaio Dec 20, 2020
2226108
Implements fine tuning with double click
tecknixia Dec 26, 2020
4b4ac2b
Adds comment about copy-assignment
IanCaio Jan 7, 2021
93c0c65
Merge branch 'master' into feature/automationProgression
IanCaio Jan 30, 2021
5a66667
Changes flipY logic and address PhysSong review
IanCaio Jan 30, 2021
174f335
Merge branch 'feature/automationProgression' into feature/automationP…
IanCaio Feb 25, 2021
5a2a5db
Merge branch 'master' into feature/automationProgressionFineTuning
IanCaio Feb 28, 2021
5f3e69b
Fixes bug with double clicking on erase mode
IanCaio Feb 28, 2021
5290c71
Small change to the fine tuning of inValues
IanCaio Feb 28, 2021
df67e46
Addresses Spekular change requests
IanCaio Mar 26, 2021
0334021
Addresses Veratil's review
IanCaio Mar 26, 2021
7eae19c
Improves indentation on fineTuneValue
IanCaio Mar 28, 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
Prev Previous commit
Next Next commit
Addresses my own code review
	This commit addresses some fixes from a review I made from the
code on Github and also one requested change from Veratil.

	Changes:
	- Fixes code style issues.
	- Adds a helper MACRO to return the offset between the inValue
and outValue of a node and use it where getValueOffset was called.
	- Removes conditional that was not needed inside
AutomationPattern::valueAt.
	- Updates InlineAutomation.h to use the helper MACROs and
account for the outValue when deciding whether to save or discard an
inline automation.
	- Adds TODO comments on two loops present on
src/code/AutomationPattern.cpp that could be optimized.
	- Fixes some comments.
	- Uses INVAL(it) instead of valueAt(POS(it)) on the flip methods
when possible.
	- Adds a resetOutValue() method to AutomationNode and use it
where convenient.
	- Fixes a small "bug" where flipping a pattern from the TCO
context menu, when the pattern is smaller than the TCO, would use the
inValue of the last node for the node created at the end of the TCO
instead of the outValue (which is the value that the position would have
if the pattern continued).
  • Loading branch information
IanCaio committed Nov 26, 2020
commit 7559a41b354767c560ea783db73ad1c3977e66c5
9 changes: 9 additions & 0 deletions include/AutomationNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// MACROs to help handling automation nodes
#define INVAL(x) ((x).value().getInValue())
#define OUTVAL(x) ((x).value().getOutValue())
#define OFFSET(x) ((x).value().getValueOffset())
#define POS(x) ((x).key())

class AutomationPattern;
Expand Down Expand Up @@ -87,6 +88,14 @@ class AutomationNode
return m_outValue - m_inValue;
}

/**
* @brief Resets the outValue so it matches inValue
*/
inline void resetOutValue()
{
m_outValue = m_inValue;
}

/**
* @brief Gets the tangent of the left side of the node
* @return Float with the tangent from the inValue side
Expand Down
14 changes: 10 additions & 4 deletions include/InlineAutomation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define INLINE_AUTOMATION_H

#include "AutomationPattern.h"
#include "AutomationNode.h"
#include "shared_object.h"


Expand Down Expand Up @@ -53,12 +54,17 @@ class InlineAutomation : public FloatModel, public sharedObject
{
if( m_autoPattern != NULL && m_autoPattern->getTimeMap().isEmpty() == false )
{
// prevent saving inline automation if there's just one value which equals value
// of model which is going to be saved anyways
// Prevent saving inline automation if there's just one node at the beginning of
// the pattern, which has a InValue equal to the value of model (which is going
// to be saved anyways) and no offset between the InValue and OutValue
AutomationPattern::timeMap::const_iterator firstNode =
m_autoPattern->getTimeMap().begin();

if (isAtInitValue() &&
m_autoPattern->getTimeMap().size() == 1 &&
m_autoPattern->getTimeMap().begin().key() == 0 &&
m_autoPattern->getTimeMap().begin().value().getInValue() == value())
POS(firstNode) == 0 &&
INVAL(firstNode) == value() &&
OFFSET(firstNode) == 0)
{
return false;
}
Expand Down
36 changes: 20 additions & 16 deletions src/core/AutomationPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ MidiTime AutomationPattern::putValue(const MidiTime & time,
// quantization value. Control Key to override
if (!ignoreSurroundingPoints)
{
// TODO: This loop can be optimized by going through the nodes
// between the quantized times instead of calling removeValue
// for each tick even when there are no nodes there.
for (int i = newTime + 1; i < newTime + quantization(); ++i)
{
AutomationPattern::removeValue(i);
Expand Down Expand Up @@ -298,6 +301,9 @@ MidiTime AutomationPattern::putValues(const MidiTime & time,
// quantization value. Control Key to override
if (!ignoreSurroundingPoints)
{
// TODO: This loop can be optimized by going through the nodes
// between the quantized times instead of calling removeValue
// for each tick even when there are no nodes there.
for (int i = newTime + 1; i < newTime + quantization(); ++i)
{
AutomationPattern::removeValue(i);
Expand Down Expand Up @@ -388,7 +394,7 @@ MidiTime AutomationPattern::setDragValue(const MidiTime & time,
timeMap::iterator it = m_timeMap.find(newTime);
if (it != m_timeMap.end())
{
if (it.value().getValueOffset() != 0)
if (OFFSET(it) != 0)
{
m_dragKeepOutValue = true;
m_dragOutValue = OUTVAL(it);
Expand Down Expand Up @@ -445,8 +451,9 @@ float AutomationPattern::valueAt( const MidiTime & _time ) const
return m_timeMap[_time].getInValue();
}

// lowerBound returns next value with greater key, therefore we take
// the previous element to get the current value
// lowerBound returns next value with equal or greater key. Since we already
// checked if the key contains a node, we know the returned node has a greater
// key than _time. Therefore we take the previous element to calculate the current value
timeMap::const_iterator v = m_timeMap.lowerBound(_time);

if( v == m_timeMap.begin() )
Expand All @@ -466,10 +473,7 @@ float AutomationPattern::valueAt( const MidiTime & _time ) const


// This method will get the value at an offset from a node, so we use the outValue of
// that node and the inValue of the next node to the calculations. This assumes that offset
// will not be zero, because when the midi time given to AutomationPattern::valueAt(MidiTime)
// matches a node's position, that node's value will be returned and this method won't be even
// called.
// that node and the inValue of the next node for the calculations.
float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const
{
QMutexLocker m(&m_patternMutex);
Expand All @@ -481,7 +485,7 @@ float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const
return INVAL(v);
}

if( m_progressionType == DiscreteProgression || v == m_timeMap.end() )
if (m_progressionType == DiscreteProgression)
{
return OUTVAL(v);
}
Expand Down Expand Up @@ -548,7 +552,7 @@ void AutomationPattern::flipY(int min, int max)

timeMap::iterator it = m_timeMap.lowerBound(0);

if (it == m_timeMap.end()) return;
if (it == m_timeMap.end()) { return; }

float tempValue = 0;
float outValueOffset = 0;
Expand All @@ -562,7 +566,7 @@ void AutomationPattern::flipY(int min, int max)
else
{
tempValue = max - valueAt(POS(it));
outValueOffset = it.value().getValueOffset() * -1.0;
outValueOffset = OFFSET(it) * -1.0;
putValues(MidiTime(POS(it)), tempValue, tempValue + outValueOffset, false, true);
}
++it;
Expand All @@ -589,7 +593,7 @@ void AutomationPattern::flipX(int length)

timeMap::const_iterator it = m_timeMap.lowerBound(0);

if (it == m_timeMap.end()) return;
if (it == m_timeMap.end()) { return; }

// Temporary map where we will store the flipped version
// of our pattern
Expand All @@ -611,13 +615,13 @@ void AutomationPattern::flipX(int length)
{
// We are flipping an area that goes beyond the last node. So we add a node to the
// beginning of the flipped timeMap representing the value of the end of the area
tempValue = valueAt(realLength);
tempValue = valueAt(length);
tempMap[0] = AutomationNode(this, tempValue, 0);

// Now flip the nodes we have in relation to the length
do
{
tempValue = valueAt(POS(it));
tempValue = INVAL(it);
tempOutValue = OUTVAL(it);
MidiTime newTime = MidiTime(length - POS(it));

Expand All @@ -630,7 +634,7 @@ void AutomationPattern::flipX(int length)
{
do
{
tempValue = valueAt(POS(it));
tempValue = INVAL(it);
tempOutValue = OUTVAL(it);
MidiTime newTime;

Expand All @@ -647,7 +651,7 @@ void AutomationPattern::flipX(int length)
{
do
{
tempValue = valueAt(POS(it));
tempValue = INVAL(it);
tempOutValue = OUTVAL(it);

MidiTime newTime = MidiTime(realLength - POS(it));
Expand Down Expand Up @@ -832,7 +836,7 @@ bool AutomationPattern::isAutomated( const AutomatableModel * _m )


/**
* @brief returns a list of all the automation patterns everywhere that are connected to a specific model
* @brief returns a list of all the automation patterns that are connected to a specific model
* @param _m the model we want to look for
*/
QVector<AutomationPattern *> AutomationPattern::patternsForModel( const AutomatableModel * _m )
Expand Down
8 changes: 4 additions & 4 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )

m_action = ERASE_VALUES;
}
else if(m_mouseDownRight) // And right click resets outValues
else if (m_mouseDownRight) // And right click resets outValues
{
// If we clicked an outValue reset it
if (clickedNode != tm.end())
Expand Down Expand Up @@ -620,7 +620,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
// If we clicked an outValue reset it
if (clickedNode != tm.end())
{
clickedNode.value().setOutValue(INVAL(clickedNode));
clickedNode.value().resetOutValue();
Engine::getSong()->setModified();
}

Expand Down Expand Up @@ -740,7 +740,7 @@ void AutomationEditor::resetNodes(int tick0, int tick1)
{
if (POS(it) > end) { return; }

it.value().setOutValue(INVAL(it));
it.value().resetOutValue();
++it;
}
}
Expand Down Expand Up @@ -779,7 +779,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
// When we clicked the node, we might have clicked slightly off
// so we account for that offset for a smooth drag
x -= m_moveXOffset;
posTicks = (x * MidiTime::ticksPerBar()/m_ppb) + m_currentPosition;
posTicks = (x * MidiTime::ticksPerBar() / m_ppb) + m_currentPosition;

// If we moved the mouse past the beginning correct the position in ticks
posTicks = qMax(posTicks, 0);
Expand Down