|
@@ -1,6 +1,7 @@
|
|
|
#pragma once
|
|
|
#include <stdint.h>
|
|
|
#include <vector>
|
|
|
+#include <ostream>
|
|
|
|
|
|
namespace midi {
|
|
|
|
|
@@ -39,18 +40,21 @@ class NoteMessage : public ChannelMessage
|
|
|
{
|
|
|
public:
|
|
|
typedef unsigned char Pitch;
|
|
|
+ typedef unsigned char Velocity;
|
|
|
|
|
|
Pitch pitch;
|
|
|
static const Pitch pitchMaximum = (1 << 7) - 1;
|
|
|
- unsigned char velocity;
|
|
|
- static const unsigned char velocityMaximum = (2 << 7) - 1;
|
|
|
+ Velocity velocity;
|
|
|
+ static const Velocity velocityMaximum = (2 << 7) - 1;
|
|
|
|
|
|
- NoteMessage(Channel channel, Pitch pitch, unsigned char velocity)
|
|
|
+ NoteMessage(Channel channel, Pitch pitch, Velocity velocity)
|
|
|
: ChannelMessage(channel), pitch(pitch), velocity(velocity)
|
|
|
{
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+class NoteOffMessage;
|
|
|
+
|
|
|
class NoteOnMessage : public NoteMessage
|
|
|
{
|
|
|
friend class Message;
|
|
@@ -59,13 +63,14 @@ protected:
|
|
|
static const unsigned char messageType = 0x9;
|
|
|
|
|
|
public:
|
|
|
- NoteOnMessage(Channel channel, Pitch pitch, unsigned char velocity)
|
|
|
+ NoteOnMessage(Channel channel, Pitch pitch, Velocity velocity)
|
|
|
: NoteMessage(channel, pitch, velocity)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
virtual void print(std::ostream& stream) const;
|
|
|
virtual std::vector<unsigned char> getBytes() const;
|
|
|
+ NoteOffMessage toOffMessage(Velocity velocity = 0) const;
|
|
|
};
|
|
|
|
|
|
class NoteOffMessage : public NoteMessage
|
|
@@ -76,7 +81,7 @@ protected:
|
|
|
static const unsigned char messageType = 0x8;
|
|
|
|
|
|
public:
|
|
|
- NoteOffMessage(Channel channel, Pitch pitch, unsigned char velocity)
|
|
|
+ NoteOffMessage(Channel channel, Pitch pitch, Velocity velocity)
|
|
|
: NoteMessage(channel, pitch, velocity)
|
|
|
{
|
|
|
}
|