LMMS
Loading...
Searching...
No Matches
InlineAutomation.h
Go to the documentation of this file.
1/*
2 * InlineAutomation.h - class for automating something "inline"
3 *
4 * Copyright (c) 2008-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_INLINE_AUTOMATION_H
26#define LMMS_INLINE_AUTOMATION_H
27
28#include "AutomationNode.h"
29#include "AutomationClip.h"
30
31namespace lmms
32{
33
35{
36public:
39 {
40 }
41
43 FloatModel(_copy.value(), _copy.minValue(), _copy.maxValue(), _copy.step<float>()),
45 {
46 m_autoClip->clearObjects();
47 m_autoClip->addObject(this);
48 }
49
51 {
52 }
53
54 virtual float defaultValue() const = 0;
55
56 bool hasAutomation() const
57 {
58 if( m_autoClip != nullptr && m_autoClip->getTimeMap().isEmpty() == false )
59 {
60 // Prevent saving inline automation if there's just one node at the beginning of
61 // the clip, which has a InValue equal to the value of model (which is going
62 // to be saved anyways) and no offset between the InValue and OutValue
63 AutomationClip::timeMap::const_iterator firstNode =
64 m_autoClip->getTimeMap().begin();
65
66 if (isAtInitValue()
67 && m_autoClip->getTimeMap().size() == 1
68 && POS(firstNode) == 0
69 && INVAL(firstNode) == value()
70 && OFFSET(firstNode) == 0)
71 {
72 return false;
73 }
74
75 return true;
76 }
77
78 return false;
79 }
80
82 {
83 if( m_autoClip == nullptr )
84 {
85 m_autoClip = std::make_unique<AutomationClip>(nullptr);
86 m_autoClip->addObject( this );
87 }
88 return m_autoClip.get();
89 }
90
91 void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
92 void loadSettings( const QDomElement & _this ) override;
93
94
95private:
96 std::unique_ptr<AutomationClip> m_autoClip;
97
98} ;
99
100
101} // namespace lmms
102
103#endif // LMMS_INLINE_AUTOMATION_H
bool isAtInitValue() const
Definition AutomatableModel.h:186
T step() const
Definition AutomatableModel.h:204
Definition AutomationClip.h:52
FloatModel(float val=0, float min=0, float max=0, float step=0, Model *parent=nullptr, const QString &displayName=QString(), bool defaultConstructed=false)
Definition AutomatableModel.h:467
bool hasAutomation() const
Definition InlineAutomation.h:56
void loadSettings(const QDomElement &_this) override
Definition InlineAutomation.cpp:50
InlineAutomation(const InlineAutomation &_copy)
Definition InlineAutomation.h:42
void saveSettings(QDomDocument &_doc, QDomElement &_parent) override
Definition InlineAutomation.cpp:33
AutomationClip * automationClip()
Definition InlineAutomation.h:81
virtual float defaultValue() const =0
InlineAutomation()
Definition InlineAutomation.h:37
std::unique_ptr< AutomationClip > m_autoClip
Definition InlineAutomation.h:96
~InlineAutomation() override
Definition InlineAutomation.h:50
float minValue() const
Definition AutomatableModel.h:448
float maxValue() const
Definition AutomatableModel.h:453
float value(int frameOffset=0) const
Definition AutomatableModel.h:438
static PuglViewHint int value
Definition pugl.h:1708
CARLA_PLUGIN_EXPORT int clone(int(*)(void *), void *, int, void *,...)
Definition interposer-safe.cpp:46
Definition AudioAlsa.cpp:35
float INVAL(AutomationClip::TimemapIterator it)
Definition AutomationClip.h:264
int POS(AutomationClip::TimemapIterator it)
Definition AutomationClip.h:294
float OFFSET(AutomationClip::TimemapIterator it)
Definition AutomationClip.h:274