LMMS
Loading...
Searching...
No Matches
Keymap.h
Go to the documentation of this file.
1/*
2 * Keymap.h - holds information about a key mapping
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_KEYMAP_H
26#define LMMS_KEYMAP_H
27
28#include <vector>
29#include <QObject>
30#include <QString>
31
32#include "SerializingObject.h"
33
34namespace lmms
35{
36
37class Keymap : public QObject, public SerializingObject
38{
39 Q_OBJECT
40public:
41 Keymap();
42 Keymap(
43 QString description,
44 std::vector<int> newMap,
45 int newFirst,
46 int newLast,
47 int newMiddle,
48 int newBaseKey,
49 float newBaseFreq
50 );
51
52 QString getDescription() const;
53 void setDescription(QString description);
54
55 int getMiddleKey() const {return m_middleKey;}
56 int getFirstKey() const {return m_firstKey;}
57 int getLastKey() const {return m_lastKey;}
58 int getBaseKey() const {return m_baseKey;}
59 float getBaseFreq() const {return m_baseFreq;}
60
61 std::size_t getSize() const {return m_map.size();}
62 int getDegree(int key) const;
63 int getOctave(int key) const;
64 const std::vector<int> &getMap() const {return m_map;}
65
66 void saveSettings(QDomDocument &doc, QDomElement &element) override;
67 void loadSettings(const QDomElement &element) override;
68 inline QString nodeName() const override {return "keymap";}
69
70private:
71 QString m_description;
72
73 std::vector<int> m_map;
78 float m_baseFreq;
79};
80
81} // namespace lmms
82
83#endif // LMMS_KEYMAP_H
int getBaseKey() const
Definition Keymap.h:58
std::size_t getSize() const
Definition Keymap.h:61
int getDegree(int key) const
Return scale degree for a given key, based on current map and first/middle/last notes.
Definition Keymap.cpp:72
const std::vector< int > & getMap() const
Definition Keymap.h:64
QString getDescription() const
Definition Keymap.cpp:106
int getMiddleKey() const
Definition Keymap.h:55
void loadSettings(const QDomElement &element) override
Definition Keymap.cpp:137
int getFirstKey() const
Definition Keymap.h:56
int getOctave(int key) const
Return octave offset for a given key, based on current map and the middle note.
Definition Keymap.cpp:89
Keymap()
Definition Keymap.cpp:36
int m_firstKey
first key that will be mapped
Definition Keymap.h:74
void setDescription(QString description)
Definition Keymap.cpp:112
int getLastKey() const
Definition Keymap.h:57
float getBaseFreq() const
Definition Keymap.h:59
int m_baseKey
key which is assigned the reference "base note"
Definition Keymap.h:77
float m_baseFreq
frequency of the base note (usually A4 @440 Hz)
Definition Keymap.h:78
QString nodeName() const override
Definition Keymap.h:68
int m_middleKey
first line of the map refers to this key
Definition Keymap.h:76
std::vector< int > m_map
key to scale degree mapping
Definition Keymap.h:73
int m_lastKey
last key that will be mapped
Definition Keymap.h:75
void saveSettings(QDomDocument &doc, QDomElement &element) override
Definition Keymap.cpp:118
QString m_description
name or description of the keymap
Definition Keymap.h:71
SerializingObject()
Definition SerializingObject.cpp:32
Definition AudioAlsa.cpp:35
ZCONST char * key
Definition crypt.c:587