hydrogen
1.2.3
AutomationPathSerializer.cpp
Go to the documentation of this file.
1
/*
2
* Hydrogen
3
* Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4
* Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5
*
6
* http://www.hydrogen-music.org
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (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
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see https://www.gnu.org/licenses
20
*
21
*/
22
#include <
core/AutomationPathSerializer.h
>
23
24
namespace
H2Core
25
{
26
27
28
AutomationPathSerializer::AutomationPathSerializer
()
29
{
30
}
31
32
void
AutomationPathSerializer::read_automation_path
(
const
QDomNode &node,
AutomationPath
&path)
33
{
34
auto
point = node.firstChildElement();
35
while
(! point.isNull()) {
36
if
(point.tagName() ==
"point"
) {
37
bool
hasX =
false
;
38
bool
hasY =
false
;
39
float
x = point.attribute(
"x"
).toFloat(&hasX);
40
float
y = point.attribute(
"y"
).toFloat(&hasY);
41
42
if
(hasX && hasY) {
43
path.
add_point
(x, y);
44
}
45
46
}
47
point = point.nextSiblingElement();
48
}
49
}
50
51
52
void
AutomationPathSerializer::write_automation_path
(QDomNode &node,
const
AutomationPath
&path)
53
{
54
for
(
auto
point : path) {
55
auto
element = node.ownerDocument().createElement(
"point"
);
56
element.setAttribute(
"x"
, point.first);
57
element.setAttribute(
"y"
, point.second);
58
node.appendChild(element);
59
}
60
}
61
62
63
}
AutomationPathSerializer.h
H2Core::AutomationPathSerializer::write_automation_path
void write_automation_path(QDomNode &node, const AutomationPath &path)
Definition
AutomationPathSerializer.cpp:52
H2Core::AutomationPathSerializer::AutomationPathSerializer
AutomationPathSerializer()
Definition
AutomationPathSerializer.cpp:28
H2Core::AutomationPathSerializer::read_automation_path
void read_automation_path(const QDomNode &node, AutomationPath &path)
Definition
AutomationPathSerializer.cpp:32
H2Core::AutomationPath
Definition
AutomationPath.h:38
H2Core::AutomationPath::add_point
void add_point(float x, float y)
Add a point to path.
Definition
AutomationPath.cpp:80
H2Core
Definition
ExportMidiDialog.h:31
src
core
AutomationPathSerializer.cpp
Generated by
1.10.0