summaryrefslogtreecommitdiff
path: root/lily
diff options
context:
space:
mode:
authorHeikki Tauriainen <g034737@welho.com>2016-01-07 22:02:07 +0200
committerJames Lowe <pkx166h@gmail.com>2016-07-27 22:54:06 +0100
commit528d28e079419b3a45098b42b8b2b4eb9f1b15b1 (patch)
tree5cef2e82a441bccc1096268602442013b3a1099a /lily
parentce8ef619243338133cb55cb9490859360d687272 (diff)
Issue 4938 (1/3) Add Audio_item and Midi_item subclasses for control changes
Diffstat (limited to 'lily')
-rw-r--r--lily/audio-item.cc6
-rw-r--r--lily/include/audio-item.hh9
-rw-r--r--lily/include/lily-proto.hh2
-rw-r--r--lily/include/midi-item.hh14
-rw-r--r--lily/midi-item.cc22
5 files changed, 53 insertions, 0 deletions
diff --git a/lily/audio-item.cc b/lily/audio-item.cc
index 8db787860f..5c713c43ed 100644
--- a/lily/audio-item.cc
+++ b/lily/audio-item.cc
@@ -222,3 +222,9 @@ Audio_control_function_value_change::context_properties_[] = {
// extra element to signify the end of the mapping, must be kept last
{ 0, NUM_CONTROLS, 0.0, 0.0 }
};
+
+Audio_control_change::Audio_control_change (int control, int value)
+ : control_ (control),
+ value_ (value)
+{
+}
diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh
index 614fdff16b..551d43f1c5 100644
--- a/lily/include/audio-item.hh
+++ b/lily/include/audio-item.hh
@@ -176,6 +176,15 @@ public:
Real value_;
};
+class Audio_control_change : public Audio_item
+{
+public:
+ Audio_control_change (int control, int value);
+
+ int control_;
+ int value_;
+};
+
int moment_to_ticks (Moment);
Real moment_to_real (Moment);
Moment remap_grace_duration (Moment);
diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh
index ee3946e0fd..f41c8f5a3f 100644
--- a/lily/include/lily-proto.hh
+++ b/lily/include/lily-proto.hh
@@ -24,6 +24,7 @@
class All_font_metrics;
class Audio_column;
+class Audio_control_change;
class Audio_control_function_value_change;
class Audio_dynamic;
class Audio_element;
@@ -90,6 +91,7 @@ class Lyric_engraver;
class Lyric_performer;
class Mensural_ligature_engraver;
class Midi_chunk;
+class Midi_control_change;
class Midi_control_function_value_change;
class Midi_duration;
class Midi_dynamic;
diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh
index dff3f4df9b..b979bca4ba 100644
--- a/lily/include/midi-item.hh
+++ b/lily/include/midi-item.hh
@@ -76,6 +76,20 @@ public:
};
/**
+ MIDI control change
+*/
+class Midi_control_change : public Midi_channel_item
+{
+public:
+ DECLARE_CLASSNAME (Midi_control_change);
+ Midi_control_change (Audio_control_change *ai);
+ virtual ~Midi_control_change ();
+ virtual string to_string () const;
+
+ Audio_control_change *audio_;
+};
+
+/**
Change instrument event
*/
class Midi_instrument : public Midi_channel_item
diff --git a/lily/midi-item.cc b/lily/midi-item.cc
index 7f064e24a8..47ccd787c3 100644
--- a/lily/midi-item.cc
+++ b/lily/midi-item.cc
@@ -54,6 +54,8 @@ Midi_item::get_midi (Audio_item *a)
else if (Audio_control_function_value_change *i
= dynamic_cast<Audio_control_function_value_change *> (a))
return new Midi_control_function_value_change (i);
+ else if (Audio_control_change *i = dynamic_cast<Audio_control_change *> (a))
+ return new Midi_control_change (i);
else
assert (0);
@@ -111,6 +113,12 @@ Midi_control_function_value_change
{
}
+Midi_control_change::Midi_control_change (Audio_control_change *ai)
+ : Midi_channel_item (ai),
+ audio_ (ai)
+{
+}
+
Midi_item::~Midi_item ()
{
}
@@ -123,6 +131,10 @@ Midi_control_function_value_change::~Midi_control_function_value_change ()
{
}
+Midi_control_change::~Midi_control_change ()
+{
+}
+
string
int2midi_varint_string (int i)
{
@@ -388,6 +400,16 @@ Midi_control_function_value_change::to_string () const
return str;
}
+string
+Midi_control_change::to_string () const
+{
+ Byte status_byte = (char) (0xB0 + channel_);
+ string str = ::to_string ((char)status_byte);
+ str += ::to_string ((char) (audio_->control_));
+ str += ::to_string ((char) (audio_->value_));
+ return str;
+}
+
char const *
Midi_item::name () const
{