Console Library
8.0.0
A header-only library that makes C++ simple
Toggle main menu visibility
Loading...
Searching...
No Matches
melody.h
Go to the documentation of this file.
1
11
12
/*
13
Copyright (c) 2026 MrXie1109
14
15
Permission is hereby granted, free of charge, to any person obtaining a copy
16
of this software and associated documentation files (the "Software"), to deal
17
in the Software without restriction, including without limitation the rights
18
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
copies of the Software, and to permit persons to whom the Software is
20
furnished to do so, subject to the following conditions:
21
22
The above copyright notice and this permission notice shall be included in all
23
copies or substantial portions of the Software.
24
25
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
SOFTWARE.
32
*/
33
34
#pragma once
35
36
#ifdef _WIN32
37
#ifndef CONSOLE_IGNORE_ADVICE
38
#pragma message( \
39
"Remember to link against winmm library (e.g., -lwinmm or winmm.lib)")
40
#pragma message("Define 'CONSOLE_IGNORE_ADVICE' for ignore it")
41
#endif
42
#else
43
#error "Unsupported platform - this library is for Windows only"
44
#endif
45
46
#define WIN32_LEAN_AND_MEAN
// 可以排除大量不需要的 Windows 组件
47
#define NOMINMAX 1
// 避免 min/max 宏污染
48
#define NOSERVICE
// 不需要 Windows 服务
49
#define NOMCX
// 不需要媒体中心扩展
50
#define NOHELP
// 不需要 WinHelp
51
#define NOSOUND
// 不需要波形音频
52
#define NOCOMM
// 不需要串口通信
53
#define NOKANJI
// 不需要日文字符支持
54
#define NOCLIPBOARD
// 不需要剪贴板
55
#define NOCOLOR
// 不需要颜色表
56
#define NODRAWTEXT
// 不需要 DrawText
57
#define NOGDI
// 不需要 GDI 图形接口
58
#define NOUSER
// 不需要 USER 模块(窗口管理)
59
#define NOMENUS
// 不需要菜单
60
#define NOICONS
// 不需要图标
61
#define NOSYSCOMMANDS
// 不需要系统命令
62
#define NORASTEROPS
// 不需要光栅操作
63
#define NOSHOWWINDOW
// 不需要 ShowWindow
64
#define NOATOM
// 不需要原子表
65
#define NOCTLMGR
// 不需要控件管理器
66
#define NOMETAFILE
// 不需要元文件
67
#define NOOPENFILE
// 不需要 OpenFile
68
#define NOSCROLL
// 不需要滚动条
69
#define NOSERVICE
// 不需要服务
70
#define NOTEXTMETRIC
// 不需要文本度量
71
#define NOWH
// 不需要 Windows 挂钩
72
#define NOWINOFFSETS
// 不需要窗口偏移量
73
#define NOPROFILER
// 不需要性能分析器
74
#define NODEFERWINDOWPOS
// 不需要 DeferWindowPos
75
#include <mmsystem.h>
76
#include <thread>
77
#include <windows.h>
78
79
namespace
console
{
85
enum class
Instrument
:
unsigned
char
{
86
AcousticGrandPiano
= 0,
87
BrightAcousticPiano
= 1,
88
ElectricGrandPiano
= 2,
89
HonkyTonkPiano
= 3,
90
ElectricPiano1
= 4,
91
ElectricPiano2
= 5,
92
Harpsichord
= 6,
93
Clavinet
= 7,
94
Celesta
= 8,
95
Glockenspiel
= 9,
96
MusicBox
= 10,
97
Vibraphone
= 11,
98
Marimba
= 12,
99
Xylophone
= 13,
100
TubularBells
= 14,
101
Dulcimer
= 15,
102
DrawbarOrgan
= 16,
103
PercussiveOrgan
= 17,
104
RockOrgan
= 18,
105
ChurchOrgan
= 19,
106
ReedOrgan
= 20,
107
Accordion
= 21,
108
Harmonica
= 22,
109
TangoAccordion
= 23,
110
AcousticGuitarNylon
= 24,
111
AcousticGuitarSteel
= 25,
112
ElectricGuitarJazz
= 26,
113
ElectricGuitarClean
= 27,
114
ElectricGuitarMuted
= 28,
115
OverdrivenGuitar
= 29,
116
DistortionGuitar
= 30,
117
GuitarHarmonics
= 31,
118
AcousticBass
= 32,
119
ElectricBassFinger
= 33,
120
ElectricBassPick
= 34,
121
FretlessBass
= 35,
122
SlapBass1
= 36,
123
SlapBass2
= 37,
124
SynthBass1
= 38,
125
SynthBass2
= 39,
126
Violin
= 40,
127
Viola
= 41,
128
Cello
= 42,
129
Contrabass
= 43,
130
TremoloStrings
= 44,
131
PizzicatoStrings
= 45,
132
OrchestralHarp
= 46,
133
Timpani
= 47,
134
StringEnsemble1
= 48,
135
StringEnsemble2
= 49,
136
SynthStrings1
= 50,
137
SynthStrings2
= 51,
138
ChoirAahs
= 52,
139
VoiceOohs
= 53,
140
SynthVoice
= 54,
141
OrchestraHit
= 55,
142
Trumpet
= 56,
143
Trombone
= 57,
144
Tuba
= 58,
145
MutedTrumpet
= 59,
146
FrenchHorn
= 60,
147
BrassSection
= 61,
148
SynthBrass1
= 62,
149
SynthBrass2
= 63,
150
SopranoSax
= 64,
151
AltoSax
= 65,
152
TenorSax
= 66,
153
BaritoneSax
= 67,
154
Oboe
= 68,
155
EnglishHorn
= 69,
156
Bassoon
= 70,
157
Clarinet
= 71,
158
Piccolo
= 72,
159
Flute
= 73,
160
Recorder
= 74,
161
PanFlute
= 75,
162
BlownBottle
= 76,
163
Shakuhachi
= 77,
164
Whistle
= 78,
165
Ocarina
= 79,
166
Lead1Square
= 80,
167
Lead2Sawtooth
= 81,
168
Lead3Calliope
= 82,
169
Lead4Chiff
= 83,
170
Lead5Charang
= 84,
171
Lead6Voice
= 85,
172
Lead7Fifths
= 86,
173
Lead8BassLead
= 87,
174
Pad1NewAge
= 88,
175
Pad2Warm
= 89,
176
Pad3Polysynth
= 90,
177
Pad4Choir
= 91,
178
Pad5Bowed
= 92,
179
Pad6Metallic
= 93,
180
Pad7Halo
= 94,
181
Pad8Sweep
= 95,
182
Fx1Rain
= 96,
183
Fx2Soundtrack
= 97,
184
Fx3Crystal
= 98,
185
Fx4Atmosphere
= 99,
186
Fx5Brightness
= 100,
187
Fx6Goblins
= 101,
188
Fx7Echoes
= 102,
189
Fx8SciFi
= 103,
190
Sitar
= 104,
191
Banjo
= 105,
192
Shamisen
= 106,
193
Koto
= 107,
194
Kalimba
= 108,
195
Bagpipe
= 109,
196
Fiddle
= 110,
197
Shanai
= 111,
198
TinkleBell
= 112,
199
Agogo
= 113,
200
SteelDrums
= 114,
201
Woodblock
= 115,
202
TaikoDrum
= 116,
203
MelodicTom
= 117,
204
SynthDrum
= 118,
205
ReverseCymbal
= 119,
206
GuitarFretNoise
= 120,
207
BreathNoise
= 121,
208
Seashore
= 122,
209
BirdTweet
= 123,
210
TelephoneRing
= 124,
211
Helicopter
= 125,
212
Applause
= 126,
213
Gunshot
= 127
214
};
215
221
namespace
pitches
{
224
const
int
C0
= 12,
D0
= 14,
E0
= 16,
F0
= 17,
G0
= 19,
A0
= 21,
B0
= 23;
225
const
int
C1
= 24,
D1
= 26,
E1
= 28,
F1
= 29,
G1
= 31,
A1
= 33,
B1
= 35;
226
const
int
C2
= 36,
D2
= 38,
E2
= 40,
F2
= 41,
G2
= 43,
A2
= 45,
B2
= 47;
227
const
int
C3
= 48,
D3
= 50,
E3
= 52,
F3
= 53,
G3
= 55,
A3
= 57,
B3
= 59;
228
const
int
C4
= 60,
D4
= 62,
E4
= 64,
F4
= 65,
G4
= 67,
A4
= 69,
B4
= 71;
229
const
int
C5
= 72,
D5
= 74,
E5
= 76,
F5
= 77,
G5
= 79,
A5
= 81,
B5
= 83;
230
const
int
C6
= 84,
D6
= 86,
E6
= 88,
F6
= 89,
G6
= 91,
A6
= 93,
B6
= 95;
231
const
int
C7
= 96,
D7
= 98,
E7
= 100,
F7
= 101,
G7
= 103,
A7
= 105,
232
B7
= 107;
233
const
int
C8
= 108,
D8
= 110,
E8
= 112,
F8
= 113,
G8
= 115,
A8
= 117,
234
B8
= 119;
235
const
int
C9
= 120,
D9
= 122,
E9
= 124,
F9
= 125,
G9
= 127;
237
240
const
int
Cs0
= 13,
Ds0
= 15,
Fs0
= 18,
Gs0
= 20,
As0
= 22;
241
const
int
Cs1
= 25,
Ds1
= 27,
Fs1
= 30,
Gs1
= 32,
As1
= 34;
242
const
int
Cs2
= 37,
Ds2
= 39,
Fs2
= 42,
Gs2
= 44,
As2
= 46;
243
const
int
Cs3
= 49,
Ds3
= 51,
Fs3
= 54,
Gs3
= 56,
As3
= 58;
244
const
int
Cs4
= 61,
Ds4
= 63,
Fs4
= 66,
Gs4
= 68,
As4
= 70;
245
const
int
Cs5
= 73,
Ds5
= 75,
Fs5
= 78,
Gs5
= 80,
As5
= 82;
246
const
int
Cs6
= 85,
Ds6
= 87,
Fs6
= 90,
Gs6
= 92,
As6
= 94;
247
const
int
Cs7
= 97,
Ds7
= 99,
Fs7
= 102,
Gs7
= 104,
As7
= 106;
248
const
int
Cs8
= 109,
Ds8
= 111,
Fs8
= 114,
Gs8
= 116,
As8
= 118;
249
const
int
Cs9
= 121,
Ds9
= 123,
Fs9
= 126;
251
253
const
int
REST
= -1;
254
}
255
260
struct
Note
{
261
signed
char
262
pitch
;
263
double
beats
;
264
signed
char
volume
;
265
272
Note
(
signed
char
p = 60,
double
b = 1,
signed
char
v = -1) :
273
pitch
(p),
beats
(b),
volume
(v) {}
274
};
275
287
class
MIDI
{
288
HMIDIOUT
handle
;
289
unsigned
char
bpm
;
290
unsigned
char
volume
;
291
Instrument
instrument
;
292
293
public
:
302
MIDI
(
Instrument
instrument
=
Instrument::AcousticGrandPiano
,
303
unsigned
char
bpm
= 120,
304
unsigned
char
volume
= 100,
305
unsigned
deviceID = 0) :
306
bpm
(
bpm
),
volume
(
volume
),
instrument
(
instrument
) {
307
HMIDIOUT h =
nullptr
;
308
if
(midiOutOpen(&h, deviceID, 0, 0, CALLBACK_NULL)
309
== MMSYSERR_NOERROR) {
310
handle
= h;
311
DWORD program_change
312
= 0xC0 | ((
unsigned
char)(
instrument
) << 8);
313
midiOutShortMsg(
handle
, program_change);
314
DWORD volume_change = 0xB0 | (0x07 << 8) | (
volume
<< 16);
315
midiOutShortMsg(
handle
, volume_change);
316
}
else
317
handle
=
nullptr
;
318
}
319
321
MIDI
(
const
MIDI
&) =
delete
;
323
MIDI
(
MIDI
&&midi) =
delete
;
325
const
MIDI
&
operator=
(
const
MIDI
&) =
delete
;
327
const
MIDI
&
operator=
(
MIDI
&&) =
delete
;
328
333
~MIDI
() noexcept {
334
if
(
handle
) midiOutClose(
handle
);
335
}
336
340
unsigned
char
get_bpm
()
const
{
return
bpm
; }
342
void
set_bpm
(
unsigned
char
new_bpm) {
bpm
= new_bpm; }
343
345
Instrument
get_instrument
() {
return
instrument
; }
351
void
set_instrument
(
Instrument
new_instrument) {
352
instrument
= new_instrument;
353
if
(!
handle
)
return
;
354
DWORD program_change
355
= 0xC0 | ((
unsigned
char)(new_instrument) << 8);
356
midiOutShortMsg(
handle
, program_change);
357
}
358
360
unsigned
char
get_volume
()
const
{
return
volume
; }
365
void
set_volume
(
unsigned
char
vol) {
366
volume
= vol;
367
if
(!
handle
)
return
;
368
DWORD volume_change = 0xB0 | (0x07 << 8) | (vol << 16);
369
midiOutShortMsg(
handle
, volume_change);
370
}
371
372
380
void
play
(
Note
note) {
381
if
(!
handle
)
return
;
382
if
(note.
pitch
!= -1) {
383
DWORD
note_on
384
= 0x90 | (note.
pitch
<< 8)
385
| ((note.
volume
== -1 ?
volume
: note.
volume
) << 16);
386
midiOutShortMsg(
handle
,
note_on
);
387
Sleep(60000 * note.
beats
/
bpm
);
388
DWORD
note_off
= 0x80 | (note.
pitch
<< 8) | (64 << 16);
389
midiOutShortMsg(
handle
,
note_off
);
390
}
else
391
Sleep(60000 * note.
beats
/
bpm
);
392
}
393
401
void
nplay
(
Note
note) {
402
std::thread([
this
, note]() {
play
(note); }).detach();
403
}
404
411
template
<
class
Iter>
412
void
play
(Iter begin, Iter end) {
413
for
(; begin != end; ++begin)
play
(*begin);
414
}
415
422
template
<
class
Iter>
423
void
nplay
(Iter begin, Iter end) {
424
std::thread([=]() {
play
(begin, end); }).detach();
425
}
426
431
void
note_on
(
Note
note) {
432
if
(!
handle
)
return
;
433
DWORD on = 0x90 | (note.
pitch
<< 8)
434
| ((note.
volume
== -1 ?
volume
: note.
volume
) << 16);
435
midiOutShortMsg(
handle
, on);
436
}
437
442
void
note_off
(
Note
note) {
443
if
(!
handle
)
return
;
444
DWORD off = 0x80 | (note.
pitch
<< 8) | (64 << 16);
445
midiOutShortMsg(
handle
, off);
446
}
447
};
448
}
console::MIDI::get_bpm
unsigned char get_bpm() const
Definition
melody.h:340
console::MIDI::nplay
void nplay(Note note)
异步播放一个音符(非阻塞)。
Definition
melody.h:401
console::MIDI::MIDI
MIDI(MIDI &&midi)=delete
禁止移动构造。
console::MIDI::volume
unsigned char volume
默认音量(0-127)
Definition
melody.h:290
console::MIDI::set_bpm
void set_bpm(unsigned char new_bpm)
设置 BPM。
Definition
melody.h:342
console::MIDI::play
void play(Note note)
同步播放一个音符(阻塞)。
Definition
melody.h:380
console::MIDI::play
void play(Iter begin, Iter end)
同步播放一个音符范围(阻塞)。
Definition
melody.h:412
console::MIDI::instrument
Instrument instrument
当前乐器
Definition
melody.h:291
console::MIDI::MIDI
MIDI(Instrument instrument=Instrument::AcousticGrandPiano, unsigned char bpm=120, unsigned char volume=100, unsigned deviceID=0)
构造 MIDI 对象,打开默认 MIDI 设备并设置乐器、音量和 BPM。
Definition
melody.h:302
console::MIDI::note_off
void note_off(Note note)
结束某个音符的播放。
Definition
melody.h:442
console::MIDI::nplay
void nplay(Iter begin, Iter end)
异步步播放一个音符范围(非阻塞)。
Definition
melody.h:423
console::MIDI::get_instrument
Instrument get_instrument()
获取当前乐器。
Definition
melody.h:345
console::MIDI::handle
HMIDIOUT handle
MIDI 输出设备句柄
Definition
melody.h:288
console::MIDI::get_volume
unsigned char get_volume() const
获取默认音量。
Definition
melody.h:360
console::MIDI::operator=
const MIDI & operator=(const MIDI &)=delete
禁止拷贝赋值。
console::MIDI::~MIDI
~MIDI() noexcept
析构函数,关闭 MIDI 设备。
Definition
melody.h:333
console::MIDI::note_on
void note_on(Note note)
开始播放某个音符。
Definition
melody.h:431
console::MIDI::bpm
unsigned char bpm
每分钟节拍数(beats per minute)
Definition
melody.h:289
console::MIDI::MIDI
MIDI(const MIDI &)=delete
禁止拷贝构造。
console::MIDI::set_instrument
void set_instrument(Instrument new_instrument)
切换乐器。
Definition
melody.h:351
console::MIDI::set_volume
void set_volume(unsigned char vol)
设置默认音量。
Definition
melody.h:365
console::MIDI::operator=
const MIDI & operator=(MIDI &&)=delete
禁止移动赋值。
console::pitches::D2
const int D2
Definition
melody.h:226
console::pitches::Cs7
const int Cs7
Definition
melody.h:247
console::pitches::As8
const int As8
Definition
melody.h:248
console::pitches::C9
const int C9
Definition
melody.h:235
console::pitches::D4
const int D4
Definition
melody.h:228
console::pitches::B3
const int B3
Definition
melody.h:227
console::pitches::B7
const int B7
Definition
melody.h:232
console::pitches::C7
const int C7
Definition
melody.h:231
console::pitches::A4
const int A4
Definition
melody.h:228
console::pitches::Fs7
const int Fs7
Definition
melody.h:247
console::pitches::C3
const int C3
Definition
melody.h:227
console::pitches::E5
const int E5
Definition
melody.h:229
console::pitches::B5
const int B5
Definition
melody.h:229
console::pitches::Ds2
const int Ds2
Definition
melody.h:242
console::pitches::G8
const int G8
Definition
melody.h:233
console::pitches::Gs0
const int Gs0
Definition
melody.h:240
console::pitches::F3
const int F3
Definition
melody.h:227
console::pitches::Ds3
const int Ds3
Definition
melody.h:243
console::pitches::D6
const int D6
Definition
melody.h:230
console::pitches::G5
const int G5
Definition
melody.h:229
console::pitches::As6
const int As6
Definition
melody.h:246
console::pitches::D7
const int D7
Definition
melody.h:231
console::pitches::Ds4
const int Ds4
Definition
melody.h:244
console::pitches::D1
const int D1
Definition
melody.h:225
console::pitches::Gs8
const int Gs8
Definition
melody.h:248
console::pitches::F6
const int F6
Definition
melody.h:230
console::pitches::Gs2
const int Gs2
Definition
melody.h:242
console::pitches::F2
const int F2
Definition
melody.h:226
console::pitches::As1
const int As1
Definition
melody.h:241
console::pitches::Cs2
const int Cs2
Definition
melody.h:242
console::pitches::Cs4
const int Cs4
Definition
melody.h:244
console::pitches::E2
const int E2
Definition
melody.h:226
console::pitches::D9
const int D9
Definition
melody.h:235
console::pitches::A8
const int A8
Definition
melody.h:233
console::pitches::G7
const int G7
Definition
melody.h:231
console::pitches::Ds1
const int Ds1
Definition
melody.h:241
console::pitches::E7
const int E7
Definition
melody.h:231
console::pitches::As0
const int As0
Definition
melody.h:240
console::pitches::F1
const int F1
Definition
melody.h:225
console::pitches::C2
const int C2
Definition
melody.h:226
console::pitches::E1
const int E1
Definition
melody.h:225
console::pitches::Gs1
const int Gs1
Definition
melody.h:241
console::pitches::C1
const int C1
Definition
melody.h:225
console::pitches::F8
const int F8
Definition
melody.h:233
console::pitches::Gs7
const int Gs7
Definition
melody.h:247
console::pitches::Cs8
const int Cs8
Definition
melody.h:248
console::pitches::B8
const int B8
Definition
melody.h:234
console::pitches::Cs9
const int Cs9
Definition
melody.h:249
console::pitches::G3
const int G3
Definition
melody.h:227
console::pitches::E6
const int E6
Definition
melody.h:230
console::pitches::Fs9
const int Fs9
Definition
melody.h:249
console::pitches::G4
const int G4
Definition
melody.h:228
console::pitches::A6
const int A6
Definition
melody.h:230
console::pitches::Fs4
const int Fs4
Definition
melody.h:244
console::pitches::E4
const int E4
Definition
melody.h:228
console::pitches::Fs8
const int Fs8
Definition
melody.h:248
console::pitches::Fs6
const int Fs6
Definition
melody.h:246
console::pitches::A1
const int A1
Definition
melody.h:225
console::pitches::A0
const int A0
Definition
melody.h:224
console::pitches::As7
const int As7
Definition
melody.h:247
console::pitches::Ds8
const int Ds8
Definition
melody.h:248
console::pitches::F7
const int F7
Definition
melody.h:231
console::pitches::Gs4
const int Gs4
Definition
melody.h:244
console::pitches::A2
const int A2
Definition
melody.h:226
console::pitches::Gs6
const int Gs6
Definition
melody.h:246
console::pitches::Gs5
const int Gs5
Definition
melody.h:245
console::pitches::Ds6
const int Ds6
Definition
melody.h:246
console::pitches::C8
const int C8
Definition
melody.h:233
console::pitches::Cs3
const int Cs3
Definition
melody.h:243
console::pitches::Ds0
const int Ds0
Definition
melody.h:240
console::pitches::B1
const int B1
Definition
melody.h:225
console::pitches::As2
const int As2
Definition
melody.h:242
console::pitches::Cs6
const int Cs6
Definition
melody.h:246
console::pitches::F0
const int F0
Definition
melody.h:224
console::pitches::F5
const int F5
Definition
melody.h:229
console::pitches::G9
const int G9
Definition
melody.h:235
console::pitches::C6
const int C6
Definition
melody.h:230
console::pitches::Cs0
const int Cs0
Definition
melody.h:240
console::pitches::D3
const int D3
Definition
melody.h:227
console::pitches::B4
const int B4
Definition
melody.h:228
console::pitches::Cs5
const int Cs5
Definition
melody.h:245
console::pitches::Ds5
const int Ds5
Definition
melody.h:245
console::pitches::G1
const int G1
Definition
melody.h:225
console::pitches::B2
const int B2
Definition
melody.h:226
console::pitches::G0
const int G0
Definition
melody.h:224
console::pitches::D0
const int D0
Definition
melody.h:224
console::pitches::Fs5
const int Fs5
Definition
melody.h:245
console::pitches::D8
const int D8
Definition
melody.h:233
console::pitches::G6
const int G6
Definition
melody.h:230
console::pitches::As4
const int As4
Definition
melody.h:244
console::pitches::E0
const int E0
Definition
melody.h:224
console::pitches::B0
const int B0
Definition
melody.h:224
console::pitches::F4
const int F4
Definition
melody.h:228
console::pitches::As3
const int As3
Definition
melody.h:243
console::pitches::A7
const int A7
Definition
melody.h:231
console::pitches::As5
const int As5
Definition
melody.h:245
console::pitches::Cs1
const int Cs1
Definition
melody.h:241
console::pitches::Gs3
const int Gs3
Definition
melody.h:243
console::pitches::Ds9
const int Ds9
Definition
melody.h:249
console::pitches::C0
const int C0
Definition
melody.h:224
console::pitches::E9
const int E9
Definition
melody.h:235
console::pitches::A3
const int A3
Definition
melody.h:227
console::pitches::A5
const int A5
Definition
melody.h:229
console::pitches::D5
const int D5
Definition
melody.h:229
console::pitches::E3
const int E3
Definition
melody.h:227
console::pitches::E8
const int E8
Definition
melody.h:233
console::pitches::Fs3
const int Fs3
Definition
melody.h:243
console::pitches::Fs2
const int Fs2
Definition
melody.h:242
console::pitches::B6
const int B6
Definition
melody.h:230
console::pitches::F9
const int F9
Definition
melody.h:235
console::pitches::Fs0
const int Fs0
Definition
melody.h:240
console::pitches::REST
const int REST
休止符(不发音,仅占用时值)
Definition
melody.h:253
console::pitches::C5
const int C5
Definition
melody.h:229
console::pitches::C4
const int C4
Definition
melody.h:228
console::pitches::Ds7
const int Ds7
Definition
melody.h:247
console::pitches::Fs1
const int Fs1
Definition
melody.h:241
console::pitches::G2
const int G2
Definition
melody.h:226
console
本库所有组件所在的顶层命名空间。
console::Instrument
Instrument
128 种 GM 标准乐器编号(0-127)。
Definition
melody.h:85
console::Instrument::OrchestralHarp
@ OrchestralHarp
竖琴
Definition
melody.h:132
console::Instrument::Violin
@ Violin
小提琴
Definition
melody.h:126
console::Instrument::GuitarFretNoise
@ GuitarFretNoise
吉他擦弦声
Definition
melody.h:206
console::Instrument::Lead2Sawtooth
@ Lead2Sawtooth
锯齿波领奏
Definition
melody.h:167
console::Instrument::Trombone
@ Trombone
长号
Definition
melody.h:143
console::Instrument::GuitarHarmonics
@ GuitarHarmonics
吉他泛音
Definition
melody.h:117
console::Instrument::Celesta
@ Celesta
钢片琴
Definition
melody.h:94
console::Instrument::Pad5Bowed
@ Pad5Bowed
弓弦背景
Definition
melody.h:178
console::Instrument::AcousticGrandPiano
@ AcousticGrandPiano
大钢琴 (默认)
Definition
melody.h:86
console::Instrument::StringEnsemble1
@ StringEnsemble1
弦乐合奏 1
Definition
melody.h:134
console::Instrument::Trumpet
@ Trumpet
小号
Definition
melody.h:142
console::Instrument::Flute
@ Flute
长笛
Definition
melody.h:159
console::Instrument::TelephoneRing
@ TelephoneRing
电话铃
Definition
melody.h:210
console::Instrument::Cello
@ Cello
大提琴
Definition
melody.h:128
console::Instrument::Recorder
@ Recorder
竖笛
Definition
melody.h:160
console::Instrument::PanFlute
@ PanFlute
排箫
Definition
melody.h:161
console::Instrument::Agogo
@ Agogo
阿果果铃
Definition
melody.h:199
console::Instrument::HonkyTonkPiano
@ HonkyTonkPiano
酒吧钢琴
Definition
melody.h:89
console::Instrument::Gunshot
@ Gunshot
枪声
Definition
melody.h:213
console::Instrument::ElectricBassPick
@ ElectricBassPick
拨片电贝司
Definition
melody.h:120
console::Instrument::AcousticGuitarNylon
@ AcousticGuitarNylon
尼龙弦吉他
Definition
melody.h:110
console::Instrument::ChurchOrgan
@ ChurchOrgan
教堂风琴
Definition
melody.h:105
console::Instrument::BlownBottle
@ BlownBottle
吹瓶口
Definition
melody.h:162
console::Instrument::TenorSax
@ TenorSax
次中音萨克斯
Definition
melody.h:152
console::Instrument::SynthDrum
@ SynthDrum
合成鼓
Definition
melody.h:204
console::Instrument::StringEnsemble2
@ StringEnsemble2
弦乐合奏 2
Definition
melody.h:135
console::Instrument::Helicopter
@ Helicopter
直升机
Definition
melody.h:211
console::Instrument::SynthBrass2
@ SynthBrass2
合成铜管 2
Definition
melody.h:149
console::Instrument::Fx7Echoes
@ Fx7Echoes
回声
Definition
melody.h:188
console::Instrument::Seashore
@ Seashore
海浪
Definition
melody.h:208
console::Instrument::BrassSection
@ BrassSection
铜管组
Definition
melody.h:147
console::Instrument::Bassoon
@ Bassoon
巴松管
Definition
melody.h:156
console::Instrument::Lead3Calliope
@ Lead3Calliope
汽笛风琴
Definition
melody.h:168
console::Instrument::RockOrgan
@ RockOrgan
摇滚风琴
Definition
melody.h:104
console::Instrument::SlapBass1
@ SlapBass1
击弦贝司 1
Definition
melody.h:122
console::Instrument::DrawbarOrgan
@ DrawbarOrgan
拉杆风琴
Definition
melody.h:102
console::Instrument::EnglishHorn
@ EnglishHorn
英国管
Definition
melody.h:155
console::Instrument::PercussiveOrgan
@ PercussiveOrgan
打击型风琴
Definition
melody.h:103
console::Instrument::Harpsichord
@ Harpsichord
大键琴
Definition
melody.h:92
console::Instrument::Oboe
@ Oboe
双簧管
Definition
melody.h:154
console::Instrument::ChoirAahs
@ ChoirAahs
合唱 "啊"
Definition
melody.h:138
console::Instrument::AcousticBass
@ AcousticBass
原声贝司
Definition
melody.h:118
console::Instrument::Clavinet
@ Clavinet
击弦古钢琴
Definition
melody.h:93
console::Instrument::DistortionGuitar
@ DistortionGuitar
失真吉他
Definition
melody.h:116
console::Instrument::Piccolo
@ Piccolo
短笛
Definition
melody.h:158
console::Instrument::BirdTweet
@ BirdTweet
鸟鸣
Definition
melody.h:209
console::Instrument::OverdrivenGuitar
@ OverdrivenGuitar
过载吉他
Definition
melody.h:115
console::Instrument::SynthStrings2
@ SynthStrings2
合成弦乐 2
Definition
melody.h:137
console::Instrument::TaikoDrum
@ TaikoDrum
太鼓
Definition
melody.h:202
console::Instrument::ElectricBassFinger
@ ElectricBassFinger
指拨电贝司
Definition
melody.h:119
console::Instrument::Woodblock
@ Woodblock
木鱼
Definition
melody.h:201
console::Instrument::Lead7Fifths
@ Lead7Fifths
五度领奏
Definition
melody.h:172
console::Instrument::TubularBells
@ TubularBells
管钟
Definition
melody.h:100
console::Instrument::Fx8SciFi
@ Fx8SciFi
科幻
Definition
melody.h:189
console::Instrument::MelodicTom
@ MelodicTom
旋律通鼓
Definition
melody.h:203
console::Instrument::SopranoSax
@ SopranoSax
高音萨克斯
Definition
melody.h:150
console::Instrument::Accordion
@ Accordion
手风琴
Definition
melody.h:107
console::Instrument::Lead1Square
@ Lead1Square
方波领奏
Definition
melody.h:166
console::Instrument::Glockenspiel
@ Glockenspiel
钟琴
Definition
melody.h:95
console::Instrument::TinkleBell
@ TinkleBell
铃铛
Definition
melody.h:198
console::Instrument::Banjo
@ Banjo
班卓琴
Definition
melody.h:191
console::Instrument::BrightAcousticPiano
@ BrightAcousticPiano
明亮的钢琴
Definition
melody.h:87
console::Instrument::SynthBrass1
@ SynthBrass1
合成铜管 1
Definition
melody.h:148
console::Instrument::PizzicatoStrings
@ PizzicatoStrings
弦乐拨奏
Definition
melody.h:131
console::Instrument::Pad6Metallic
@ Pad6Metallic
金属背景
Definition
melody.h:179
console::Instrument::Bagpipe
@ Bagpipe
风笛
Definition
melody.h:195
console::Instrument::Clarinet
@ Clarinet
单簧管
Definition
melody.h:157
console::Instrument::Tuba
@ Tuba
大号
Definition
melody.h:144
console::Instrument::ElectricGuitarJazz
@ ElectricGuitarJazz
爵士吉他
Definition
melody.h:112
console::Instrument::Kalimba
@ Kalimba
卡林巴
Definition
melody.h:194
console::Instrument::Pad7Halo
@ Pad7Halo
光环背景
Definition
melody.h:180
console::Instrument::Timpani
@ Timpani
定音鼓
Definition
melody.h:133
console::Instrument::Ocarina
@ Ocarina
奥卡雷纳
Definition
melody.h:165
console::Instrument::ElectricPiano1
@ ElectricPiano1
电钢琴 1
Definition
melody.h:90
console::Instrument::Lead8BassLead
@ Lead8BassLead
贝司领奏
Definition
melody.h:173
console::Instrument::Fx3Crystal
@ Fx3Crystal
水晶
Definition
melody.h:184
console::Instrument::Lead5Charang
@ Lead5Charang
炭精吉他
Definition
melody.h:170
console::Instrument::ElectricGuitarMuted
@ ElectricGuitarMuted
闷音吉他
Definition
melody.h:114
console::Instrument::SynthBass1
@ SynthBass1
合成贝司 1
Definition
melody.h:124
console::Instrument::Pad8Sweep
@ Pad8Sweep
扫弦背景
Definition
melody.h:181
console::Instrument::BreathNoise
@ BreathNoise
呼吸声
Definition
melody.h:207
console::Instrument::Dulcimer
@ Dulcimer
扬琴
Definition
melody.h:101
console::Instrument::Shakuhachi
@ Shakuhachi
尺八
Definition
melody.h:163
console::Instrument::ReedOrgan
@ ReedOrgan
簧风琴
Definition
melody.h:106
console::Instrument::AcousticGuitarSteel
@ AcousticGuitarSteel
钢弦吉他
Definition
melody.h:111
console::Instrument::Fiddle
@ Fiddle
民间提琴
Definition
melody.h:196
console::Instrument::Contrabass
@ Contrabass
低音提琴
Definition
melody.h:129
console::Instrument::MutedTrumpet
@ MutedTrumpet
弱音小号
Definition
melody.h:145
console::Instrument::Fx4Atmosphere
@ Fx4Atmosphere
大气
Definition
melody.h:185
console::Instrument::Fx1Rain
@ Fx1Rain
雨声
Definition
melody.h:182
console::Instrument::Pad2Warm
@ Pad2Warm
温暖背景
Definition
melody.h:175
console::Instrument::Vibraphone
@ Vibraphone
颤音琴
Definition
melody.h:97
console::Instrument::Pad3Polysynth
@ Pad3Polysynth
复音合成背景
Definition
melody.h:176
console::Instrument::Sitar
@ Sitar
西塔琴
Definition
melody.h:190
console::Instrument::Koto
@ Koto
古筝
Definition
melody.h:193
console::Instrument::AltoSax
@ AltoSax
中音萨克斯
Definition
melody.h:151
console::Instrument::SynthStrings1
@ SynthStrings1
合成弦乐 1
Definition
melody.h:136
console::Instrument::Shamisen
@ Shamisen
三味线
Definition
melody.h:192
console::Instrument::VoiceOohs
@ VoiceOohs
人声 "哦"
Definition
melody.h:139
console::Instrument::ElectricGrandPiano
@ ElectricGrandPiano
电子大钢琴
Definition
melody.h:88
console::Instrument::Lead6Voice
@ Lead6Voice
人声领奏
Definition
melody.h:171
console::Instrument::Marimba
@ Marimba
马林巴
Definition
melody.h:98
console::Instrument::ElectricGuitarClean
@ ElectricGuitarClean
清音电吉他
Definition
melody.h:113
console::Instrument::Whistle
@ Whistle
口哨
Definition
melody.h:164
console::Instrument::ReverseCymbal
@ ReverseCymbal
反奏钹
Definition
melody.h:205
console::Instrument::Viola
@ Viola
中提琴
Definition
melody.h:127
console::Instrument::TremoloStrings
@ TremoloStrings
弦乐颤音
Definition
melody.h:130
console::Instrument::TangoAccordion
@ TangoAccordion
探戈手风琴
Definition
melody.h:109
console::Instrument::SteelDrums
@ SteelDrums
钢鼓
Definition
melody.h:200
console::Instrument::MusicBox
@ MusicBox
八音盒
Definition
melody.h:96
console::Instrument::FretlessBass
@ FretlessBass
无品贝司
Definition
melody.h:121
console::Instrument::SynthVoice
@ SynthVoice
合成人声
Definition
melody.h:140
console::Instrument::Harmonica
@ Harmonica
口琴
Definition
melody.h:108
console::Instrument::OrchestraHit
@ OrchestraHit
乐队打击乐
Definition
melody.h:141
console::Instrument::Lead4Chiff
@ Lead4Chiff
气声领奏
Definition
melody.h:169
console::Instrument::Fx5Brightness
@ Fx5Brightness
明亮
Definition
melody.h:186
console::Instrument::Fx6Goblins
@ Fx6Goblins
小妖
Definition
melody.h:187
console::Instrument::Xylophone
@ Xylophone
木琴
Definition
melody.h:99
console::Instrument::Pad4Choir
@ Pad4Choir
合唱背景
Definition
melody.h:177
console::Instrument::Applause
@ Applause
掌声
Definition
melody.h:212
console::Instrument::SynthBass2
@ SynthBass2
合成贝司 2
Definition
melody.h:125
console::Instrument::Shanai
@ Shanai
唢呐
Definition
melody.h:197
console::Instrument::Pad1NewAge
@ Pad1NewAge
新世纪背景
Definition
melody.h:174
console::Instrument::SlapBass2
@ SlapBass2
击弦贝司 2
Definition
melody.h:123
console::Instrument::ElectricPiano2
@ ElectricPiano2
电钢琴 2
Definition
melody.h:91
console::Instrument::BaritoneSax
@ BaritoneSax
上低音萨克斯
Definition
melody.h:153
console::Instrument::Fx2Soundtrack
@ Fx2Soundtrack
电影配乐
Definition
melody.h:183
console::Instrument::FrenchHorn
@ FrenchHorn
圆号
Definition
melody.h:146
pitches
标准 MIDI 音高常量,包含中央 C4=60 的所有半音音高,以及休止符 REST。
console::Note
表示一个音符,包含音高、时值和力度。
Definition
melody.h:260
console::Note::volume
signed char volume
力度(0-127),-1 表示使用 MIDI 对象的默认音量
Definition
melody.h:264
console::Note::Note
Note(signed char p=60, double b=1, signed char v=-1)
构造一个音符。
Definition
melody.h:272
console::Note::pitch
signed char pitch
MIDI 音高编号(0-127),或 pitches::REST 表示休止符
Definition
melody.h:262
console::Note::beats
double beats
音符时值(以四分音符为单位,1 表示一拍)
Definition
melody.h:263
include
platform
win
melody.h
Generated on
for Console Library by
1.18.0