lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
include
Piano.h
Go to the documentation of this file.
1
/*
2
* Piano.h - declaration of class Piano
3
*
4
* Copyright (c) 2004-2014 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_PIANO_H
26
#define LMMS_PIANO_H
27
28
#include <array>
29
30
#include "
Model.h
"
31
#include "
Note.h
"
32
33
namespace
lmms
34
{
35
36
37
class
InstrumentTrack
;
38
class
MidiEventProcessor
;
39
40
class
Piano
final :
public
Model
41
{
42
public
:
43
enum class
KeyType
44
{
45
White,
46
Black
47
} ;
48
52
Piano
(
InstrumentTrack
* track);
53
58
void
setKeyState
(
int
key,
bool
state);
59
60
bool
isKeyPressed
(
int
key)
const
61
{
62
return
m_pressedKeys
[key];
63
}
64
69
void
handleKeyPress
(
int
key,
int
midiVelocity = -1);
70
74
void
handleKeyRelease
(
int
key);
75
76
InstrumentTrack
*
instrumentTrack
()
const
77
{
78
return
m_instrumentTrack
;
79
}
80
81
MidiEventProcessor
*
midiEventProcessor
()
const
82
{
83
return
m_midiEvProc
;
84
}
85
86
static
bool
isWhiteKey
(
int
key);
87
static
bool
isBlackKey
(
int
key);
88
89
static
const
unsigned
int
WhiteKeysPerOctave
= 7;
90
static
const
unsigned
int
BlackKeysPerOctave
= 5;
91
static
const
unsigned
int
NumWhiteKeys
= 75;
92
static
const
unsigned
int
NumBlackKeys
= 53;
93
94
private
:
95
static
bool
isValidKey
(
int
key)
96
{
97
return
key >= 0 && key <
NumKeys
;
98
}
99
100
InstrumentTrack
*
m_instrumentTrack
;
101
MidiEventProcessor
*
m_midiEvProc
;
102
std::array<bool, NumKeys>
m_pressedKeys
= {};
103
104
} ;
105
106
107
}
// namespace lmms
108
109
#endif
// LMMS_PIANO_H
Model.h
Note.h
lmms::InstrumentTrack
Definition
InstrumentTrack.h:62
lmms::MidiEventProcessor
Definition
MidiEventProcessor.h:36
lmms::Model::Model
Model(Model *parent, QString displayName=QString(), bool defaultConstructed=false)
Definition
Model.cpp:30
lmms::Piano::NumBlackKeys
static const unsigned int NumBlackKeys
Definition
Piano.h:92
lmms::Piano::m_midiEvProc
MidiEventProcessor * m_midiEvProc
Definition
Piano.h:101
lmms::Piano::handleKeyRelease
void handleKeyRelease(int key)
Handle a note being released on our keyboard display.
Definition
Piano.cpp:92
lmms::Piano::WhiteKeysPerOctave
static const unsigned int WhiteKeysPerOctave
Definition
Piano.h:89
lmms::Piano::NumWhiteKeys
static const unsigned int NumWhiteKeys
Definition
Piano.h:91
lmms::Piano::m_instrumentTrack
InstrumentTrack * m_instrumentTrack
Definition
Piano.h:100
lmms::Piano::m_pressedKeys
std::array< bool, NumKeys > m_pressedKeys
Definition
Piano.h:102
lmms::Piano::Piano
Piano(InstrumentTrack *track)
Create a new keyboard display.
Definition
Piano.cpp:60
lmms::Piano::isBlackKey
static bool isBlackKey(int key)
Definition
Piano.cpp:103
lmms::Piano::isValidKey
static bool isValidKey(int key)
Definition
Piano.h:95
lmms::Piano::instrumentTrack
InstrumentTrack * instrumentTrack() const
Definition
Piano.h:76
lmms::Piano::KeyType
KeyType
Definition
Piano.h:44
lmms::Piano::isWhiteKey
static bool isWhiteKey(int key)
Definition
Piano.cpp:111
lmms::Piano::isKeyPressed
bool isKeyPressed(int key) const
Definition
Piano.h:60
lmms::Piano::BlackKeysPerOctave
static const unsigned int BlackKeysPerOctave
Definition
Piano.h:90
lmms::Piano::handleKeyPress
void handleKeyPress(int key, int midiVelocity=-1)
Handle a note being pressed on our keyboard display.
Definition
Piano.cpp:78
lmms::Piano::setKeyState
void setKeyState(int key, bool state)
Turn a key on or off.
Definition
Piano.cpp:67
lmms::Piano::midiEventProcessor
MidiEventProcessor * midiEventProcessor() const
Definition
Piano.h:81
lmms
Definition
RemotePluginBase.cpp:34
lmms::NumKeys
const int NumKeys
Number of physical keys, limited to MIDI range (valid for both MIDI 1.0 and 2.0).
Definition
Note.h:90
Generated on
for lmms by
1.18.0