Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2012 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1997--2012 Jan Nieuwenhuizen <janneke@gnu.org> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 else if (Audio_dynamic *i = dynamic_cast<Audio_dynamic *> (a)) | 43 else if (Audio_dynamic *i = dynamic_cast<Audio_dynamic *> (a)) |
44 return new Midi_dynamic (i); | 44 return new Midi_dynamic (i); |
45 else if (Audio_piano_pedal *i = dynamic_cast<Audio_piano_pedal *> (a)) | 45 else if (Audio_piano_pedal *i = dynamic_cast<Audio_piano_pedal *> (a)) |
46 return new Midi_piano_pedal (i); | 46 return new Midi_piano_pedal (i); |
47 else if (Audio_tempo *i = dynamic_cast<Audio_tempo *> (a)) | 47 else if (Audio_tempo *i = dynamic_cast<Audio_tempo *> (a)) |
48 return new Midi_tempo (i); | 48 return new Midi_tempo (i); |
49 else if (Audio_time_signature *i = dynamic_cast<Audio_time_signature *> (a)) | 49 else if (Audio_time_signature *i = dynamic_cast<Audio_time_signature *> (a)) |
50 return new Midi_time_signature (i); | 50 return new Midi_time_signature (i); |
51 else if (Audio_text *i = dynamic_cast<Audio_text *> (a)) | 51 else if (Audio_text *i = dynamic_cast<Audio_text *> (a)) |
52 return new Midi_text (i); | 52 return new Midi_text (i); |
53 else if (Audio_control_function_value_change *i | |
54 = dynamic_cast<Audio_control_function_value_change *> (a)) | |
55 return new Midi_control_function_value_change (i); | |
53 else | 56 else |
54 assert (0); | 57 assert (0); |
55 | 58 |
56 return 0; | 59 return 0; |
57 } | 60 } |
58 | 61 |
59 Midi_duration::Midi_duration (Real seconds_f) | 62 Midi_duration::Midi_duration (Real seconds_f) |
60 { | 63 { |
61 seconds_ = seconds_f; | 64 seconds_ = seconds_f; |
62 } | 65 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 98 |
96 Midi_item::Midi_item () | 99 Midi_item::Midi_item () |
97 { | 100 { |
98 } | 101 } |
99 | 102 |
100 Midi_channel_item::Midi_channel_item (Audio_item *ai) | 103 Midi_channel_item::Midi_channel_item (Audio_item *ai) |
101 : channel_ (ai->channel_) | 104 : channel_ (ai->channel_) |
102 { | 105 { |
103 } | 106 } |
104 | 107 |
108 Midi_control_function_value_change | |
109 ::Midi_control_function_value_change (Audio_control_function_value_change *ai) | |
110 : Midi_channel_item (ai), control_ (ai->control_), value_ (ai->value_) | |
111 { | |
112 } | |
113 | |
105 Midi_item::~Midi_item () | 114 Midi_item::~Midi_item () |
106 { | 115 { |
107 } | 116 } |
108 | 117 |
118 Midi_channel_item::~Midi_channel_item () | |
119 { | |
120 } | |
121 | |
122 Midi_control_function_value_change::~Midi_control_function_value_change () | |
123 { | |
124 } | |
125 | |
109 string | 126 string |
110 int2midi_varint_string (int i) | 127 int2midi_varint_string (int i) |
111 { | 128 { |
112 int buffer = i & 0x7f; | 129 int buffer = i & 0x7f; |
113 while ((i >>= 7) > 0) | 130 while ((i >>= 7) > 0) |
114 { | 131 { |
115 buffer <<= 8; | 132 buffer <<= 8; |
116 buffer |= 0x80; | 133 buffer |= 0x80; |
117 buffer += (i & 0x7f); | 134 buffer += (i & 0x7f); |
118 } | 135 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 string | 352 string |
336 Midi_text::to_string () const | 353 Midi_text::to_string () const |
337 { | 354 { |
338 string str = "ff" + String_convert::int2hex (audio_->type_, 2, '0'); | 355 string str = "ff" + String_convert::int2hex (audio_->type_, 2, '0'); |
339 str = String_convert::hex2bin (str); | 356 str = String_convert::hex2bin (str); |
340 str += int2midi_varint_string (audio_->text_string_.length ()); | 357 str += int2midi_varint_string (audio_->text_string_.length ()); |
341 str += audio_->text_string_; | 358 str += audio_->text_string_; |
342 return str; | 359 return str; |
343 } | 360 } |
344 | 361 |
362 const Midi_control_function_value_change::Control_function | |
363 Midi_control_function_value_change::control_functions_[] = | |
364 { | |
365 // The order of the control number definitions below should always be | |
366 // kept consistent with the order of the enumeration values defined in | |
367 // Audio_control_function_value_change::Control. | |
Keith
2013/10/06 02:23:00
Is it appropriate, then, to make this array a publ
| |
368 | |
369 { 8, 40 }, // balance | |
370 { 10, 42 }, // pan position | |
371 { 91, -1 }, // reverb level (only coarse resolution available) | |
372 { 93, -1 } // chorus level (only coarse resolution available) | |
373 }; | |
374 | |
375 string | |
376 Midi_control_function_value_change::to_string () const | |
377 { | |
378 string str; | |
379 const Control_function *control_function = &control_functions_[control_]; | |
380 static const Real full_fine_scale = 0x3FFF; | |
381 static const Real full_coarse_scale = 0x7F; | |
382 bool fine_resolution = (control_function->lsb_control_number_ >= 0); | |
383 int value = lround (value_ * (fine_resolution ? | |
384 full_fine_scale : full_coarse_scale)); | |
385 Byte status_byte = (char) (0xB0 + channel_); | |
386 str += ::to_string ((char)status_byte); | |
387 str += ::to_string ((char)(control_function->msb_control_number_)); | |
388 str += ::to_string ((char)(fine_resolution ? (value >> 7) : value)); | |
389 if (fine_resolution) | |
390 { | |
391 str += ::to_string ((char)0x00); | |
392 str += ::to_string ((char)status_byte); | |
393 str += ::to_string ((char)(control_function->lsb_control_number_)); | |
394 str += ::to_string ((char)(value & 0x7F)); | |
395 } | |
396 return str; | |
397 } | |
398 | |
Keith
2013/10/06 02:23:00
Implementing fine as well as coarse seems to be mo
| |
345 char const * | 399 char const * |
346 Midi_item::name () const | 400 Midi_item::name () const |
347 { | 401 { |
348 return this->class_name (); | 402 return this->class_name (); |
349 } | 403 } |
OLD | NEW |