lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
include
Scale.h
Go to the documentation of this file.
1
/*
2
* Scale.h - holds information about a scale and its intervals
3
*
4
* Copyright (c) 2020 Martin Pavelek <he29.HS/at/gmail.com>
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_SCALE_H
26
#define LMMS_SCALE_H
27
28
#include <cstdint>
29
#include <vector>
30
#include <QObject>
31
#include <QString>
32
33
#include "
SerializingObject.h
"
34
35
namespace
lmms
36
{
37
38
class
Interval
:
public
SerializingObject
39
{
40
public
:
41
Interval
() :
m_numerator
(1),
m_denominator
(1),
m_cents
(0),
m_ratio
(1) {};
42
explicit
Interval
(
float
cents);
43
Interval
(uint32_t numerator, uint32_t denominator);
44
45
float
getRatio
()
const
{
return
m_ratio
;}
46
47
QString
getString
()
const
48
{
49
if
(
m_denominator
) {
return
QString::number(
m_numerator
) +
"/"
+ QString::number(
m_denominator
);}
50
else
{
return
QString(
"%1"
).arg(
m_cents
, 0,
'f'
, 4);}
51
}
52
53
void
saveSettings
(QDomDocument &doc, QDomElement &element)
override
;
54
void
loadSettings
(
const
QDomElement &element)
override
;
55
inline
QString
nodeName
()
const override
{
return
"interval"
;}
56
57
private
:
58
// Scala specifies that numerators and denominators should go at least up to 2147483647 → use uint32_t.
59
uint32_t
m_numerator
;
60
uint32_t
m_denominator
;
61
float
m_cents
;
62
float
m_ratio
;
63
};
64
65
66
class
Scale
:
public
QObject,
public
SerializingObject
67
{
68
Q_OBJECT
69
public
:
70
Scale
();
71
Scale
(QString description, std::vector<Interval> intervals);
72
73
QString
getDescription
()
const
;
74
void
setDescription
(QString description);
75
76
const
std::vector<Interval> &
getIntervals
()
const
{
return
m_intervals
;}
77
void
setIntervals
(std::vector<Interval> input) {
m_intervals
= std::move(input);}
78
79
void
saveSettings
(QDomDocument &doc, QDomElement &element)
override
;
80
void
loadSettings
(
const
QDomElement &element)
override
;
81
inline
QString
nodeName
()
const override
{
return
"scale"
;}
82
83
private
:
84
QString
m_description
;
85
std::vector<Interval>
m_intervals
;
86
87
};
88
89
90
}
// namespace lmms
91
92
#endif
// LMMS_SCALE_H
SerializingObject.h
lmms::Interval::m_denominator
uint32_t m_denominator
denominator of the interval fraction
Definition
Scale.h:60
lmms::Interval::getString
QString getString() const
Definition
Scale.h:47
lmms::Interval::loadSettings
void loadSettings(const QDomElement &element) override
Definition
Scale.cpp:65
lmms::Interval::getRatio
float getRatio() const
Definition
Scale.h:45
lmms::Interval::saveSettings
void saveSettings(QDomDocument &doc, QDomElement &element) override
Definition
Scale.cpp:51
lmms::Interval::Interval
Interval()
Definition
Scale.h:41
lmms::Interval::m_ratio
float m_ratio
precomputed output value for better performance
Definition
Scale.h:62
lmms::Interval::m_cents
float m_cents
interval defined in cents (used when denominator is set to zero)
Definition
Scale.h:61
lmms::Interval::nodeName
QString nodeName() const override
Definition
Scale.h:55
lmms::Interval::m_numerator
uint32_t m_numerator
numerator of the interval fraction
Definition
Scale.h:59
lmms::Scale::m_description
QString m_description
name or description of the scale
Definition
Scale.h:84
lmms::Scale::getIntervals
const std::vector< Interval > & getIntervals() const
Definition
Scale.h:76
lmms::Scale::nodeName
QString nodeName() const override
Definition
Scale.h:81
lmms::Scale::getDescription
QString getDescription() const
Definition
Scale.cpp:88
lmms::Scale::saveSettings
void saveSettings(QDomDocument &doc, QDomElement &element) override
Definition
Scale.cpp:100
lmms::Scale::m_intervals
std::vector< Interval > m_intervals
a series of ratios that define the scale
Definition
Scale.h:85
lmms::Scale::setDescription
void setDescription(QString description)
Definition
Scale.cpp:94
lmms::Scale::setIntervals
void setIntervals(std::vector< Interval > input)
Definition
Scale.h:77
lmms::Scale::Scale
Scale()
Definition
Scale.cpp:75
lmms::Scale::loadSettings
void loadSettings(const QDomElement &element) override
Definition
Scale.cpp:112
lmms::SerializingObject::SerializingObject
SerializingObject()
Definition
SerializingObject.cpp:32
lmms
Definition
RemotePluginBase.cpp:34
Generated on
for lmms by
1.18.0