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--2019 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1997--2019 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 Midi_duration::Midi_duration (Real seconds_f) | 62 Midi_duration::Midi_duration (Real seconds_f) |
63 { | 63 { |
64 seconds_ = seconds_f; | 64 seconds_ = seconds_f; |
65 } | 65 } |
66 | 66 |
67 string | 67 string |
68 Midi_duration::to_string () const | 68 Midi_duration::to_string () const |
69 { | 69 { |
70 return string ("<duration: ") + ::to_string (seconds_) + ">"; | 70 return string ("<duration: ") + std::to_string (seconds_) + ">"; |
71 } | 71 } |
72 | 72 |
73 Midi_instrument::Midi_instrument (Audio_instrument *a) | 73 Midi_instrument::Midi_instrument (Audio_instrument *a) |
74 : Midi_channel_item (a), | 74 : Midi_channel_item (a), |
75 audio_ (a) | 75 audio_ (a) |
76 { | 76 { |
77 audio_->str_ = String_convert::to_lower (audio_->str_); | 77 audio_->str_ = String_convert::to_lower (audio_->str_); |
78 } | 78 } |
79 | 79 |
80 string | 80 string |
81 Midi_instrument::to_string () const | 81 Midi_instrument::to_string () const |
82 { | 82 { |
83 Byte program_byte = 0; | 83 Byte program_byte = 0; |
84 bool found = false; | 84 bool found = false; |
85 | 85 |
86 SCM program = Lily::midi_program (ly_symbol2scm (audio_->str_.c_str ())); | 86 SCM program = Lily::midi_program (ly_symbol2scm (audio_->str_.c_str ())); |
87 found = (scm_is_true (program)); | 87 found = (scm_is_true (program)); |
88 if (found) | 88 if (found) |
89 program_byte = (Byte) scm_to_int (program); | 89 program_byte = (Byte) scm_to_int (program); |
90 else | 90 else |
91 warning (_f ("no such MIDI instrument: `%s'", audio_->str_.c_str ())); | 91 warning (_f ("no such MIDI instrument: `%s'", audio_->str_.c_str ())); |
92 | 92 |
93 string str = ::to_string ((char) (0xc0 + channel_)); //YIKES! FIXME : Should b
e track. -rz | 93 string str (1, static_cast<char> (0xc0 + channel_)); //YIKES! FIXME : Should b
e track. -rz |
94 str += ::to_string ((char)program_byte); | 94 str += program_byte; |
95 return str; | 95 return str; |
96 } | 96 } |
97 | 97 |
98 Midi_item::Midi_item () | 98 Midi_item::Midi_item () |
99 { | 99 { |
100 } | 100 } |
101 | 101 |
102 Midi_channel_item::Midi_channel_item (Audio_item *ai) | 102 Midi_channel_item::Midi_channel_item (Audio_item *ai) |
103 : channel_ (ai->channel_) | 103 : channel_ (ai->channel_) |
104 { | 104 { |
(...skipping 24 matching lines...) Expand all Loading... |
129 while ((i >>= 7) > 0) | 129 while ((i >>= 7) > 0) |
130 { | 130 { |
131 buffer <<= 8; | 131 buffer <<= 8; |
132 buffer |= 0x80; | 132 buffer |= 0x80; |
133 buffer += (i & 0x7f); | 133 buffer += (i & 0x7f); |
134 } | 134 } |
135 | 135 |
136 string str; | 136 string str; |
137 while (1) | 137 while (1) |
138 { | 138 { |
139 str += ::to_string ((char)buffer); | 139 str += static_cast<char> (buffer); |
140 if (buffer & 0x80) | 140 if (buffer & 0x80) |
141 buffer >>= 8; | 141 buffer >>= 8; |
142 else | 142 else |
143 break; | 143 break; |
144 } | 144 } |
145 return str; | 145 return str; |
146 } | 146 } |
147 | 147 |
148 Midi_key::Midi_key (Audio_key *a) | 148 Midi_key::Midi_key (Audio_key *a) |
149 : audio_ (a) | 149 : audio_ (a) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 { | 222 { |
223 Byte status_byte = (char) (0x90 + channel_); | 223 Byte status_byte = (char) (0x90 + channel_); |
224 string str = ""; | 224 string str = ""; |
225 int finetune; | 225 int finetune; |
226 | 226 |
227 // print warning if fine tuning was needed, HJJ | 227 // print warning if fine tuning was needed, HJJ |
228 if (get_fine_tuning () != 0) | 228 if (get_fine_tuning () != 0) |
229 { | 229 { |
230 finetune = PITCH_WHEEL_CENTER + get_fine_tuning (); | 230 finetune = PITCH_WHEEL_CENTER + get_fine_tuning (); |
231 | 231 |
232 str += ::to_string ((char) (0xE0 + channel_)); | 232 str += static_cast<char> (0xE0 + channel_); |
233 str += ::to_string ((char) (finetune & 0x7F)); | 233 str += static_cast<char> (finetune & 0x7F); |
234 str += ::to_string ((char) (finetune >> 7)); | 234 str += static_cast<char> (finetune >> 7); |
235 str += ::to_string ((char) (0x00)); | 235 str += static_cast<char> (0x00); |
236 } | 236 } |
237 | 237 |
238 str += ::to_string ((char) status_byte); | 238 str += status_byte; |
239 str += ::to_string ((char) (get_semitone_pitch () + c0_pitch_)); | 239 str += static_cast<char> (get_semitone_pitch () + c0_pitch_); |
240 str += ::to_string ((char) dynamic_byte_); | 240 str += dynamic_byte_; |
241 | 241 |
242 return str; | 242 return str; |
243 } | 243 } |
244 | 244 |
245 Midi_note_off::Midi_note_off (Midi_note *n) | 245 Midi_note_off::Midi_note_off (Midi_note *n) |
246 : Midi_note (n->audio_) | 246 : Midi_note (n->audio_) |
247 { | 247 { |
248 on_ = n; | 248 on_ = n; |
249 channel_ = n->channel_; | 249 channel_ = n->channel_; |
250 | 250 |
251 // use note_on with velocity=0 instead of note_off | 251 // use note_on with velocity=0 instead of note_off |
252 aftertouch_byte_ = 0; | 252 aftertouch_byte_ = 0; |
253 } | 253 } |
254 | 254 |
255 string | 255 string |
256 Midi_note_off::to_string () const | 256 Midi_note_off::to_string () const |
257 { | 257 { |
258 Byte status_byte = (char) (0x90 + channel_); | 258 Byte status_byte = (char) (0x90 + channel_); |
259 | 259 |
260 string str = ::to_string ((char)status_byte); | 260 string str (1, status_byte); |
261 str += ::to_string ((char) (get_semitone_pitch () + Midi_note::c0_pitch_)); | 261 str += static_cast<char> (get_semitone_pitch () + Midi_note::c0_pitch_); |
262 str += ::to_string ((char)aftertouch_byte_); | 262 str += aftertouch_byte_; |
263 | 263 |
264 if (get_fine_tuning () != 0) | 264 if (get_fine_tuning () != 0) |
265 { | 265 { |
266 // Move pitch wheel back to the central position. | 266 // Move pitch wheel back to the central position. |
267 str += ::to_string ((char) 0x00); | 267 str += static_cast<char> (0x00); |
268 str += ::to_string ((char) (0xE0 + channel_)); | 268 str += static_cast<char> (0xE0 + channel_); |
269 str += ::to_string ((char) (PITCH_WHEEL_CENTER & 0x7F)); | 269 str += static_cast<char> (PITCH_WHEEL_CENTER & 0x7F); |
270 str += ::to_string ((char) (PITCH_WHEEL_CENTER >> 7)); | 270 str += static_cast<char> (PITCH_WHEEL_CENTER >> 7); |
271 } | 271 } |
272 | 272 |
273 return str; | 273 return str; |
274 } | 274 } |
275 | 275 |
276 Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal *a) | 276 Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal *a) |
277 : Midi_channel_item (a), | 277 : Midi_channel_item (a), |
278 audio_ (a) | 278 audio_ (a) |
279 { | 279 { |
280 } | 280 } |
281 | 281 |
282 string | 282 string |
283 Midi_piano_pedal::to_string () const | 283 Midi_piano_pedal::to_string () const |
284 { | 284 { |
285 Byte status_byte = (char) (0xB0 + channel_); | 285 Byte status_byte = (char) (0xB0 + channel_); |
286 string str = ::to_string ((char)status_byte); | 286 string str (1, status_byte); |
287 | 287 |
288 if (audio_->type_string_ == "Sostenuto") | 288 if (audio_->type_string_ == "Sostenuto") |
289 str += ::to_string ((char)0x42); | 289 str += static_cast<char> (0x42); |
290 else if (audio_->type_string_ == "Sustain") | 290 else if (audio_->type_string_ == "Sustain") |
291 str += ::to_string ((char)0x40); | 291 str += static_cast<char> (0x40); |
292 else if (audio_->type_string_ == "UnaCorda") | 292 else if (audio_->type_string_ == "UnaCorda") |
293 str += ::to_string ((char)0x43); | 293 str += static_cast<char> (0x43); |
294 | 294 |
295 int pedal = ((1 - audio_->dir_) / 2) * 0x7f; | 295 int pedal = ((1 - audio_->dir_) / 2) * 0x7f; |
296 str += ::to_string ((char)pedal); | 296 str += static_cast<char> (pedal); |
297 return str; | 297 return str; |
298 } | 298 } |
299 | 299 |
300 Midi_tempo::Midi_tempo (Audio_tempo *a) | 300 Midi_tempo::Midi_tempo (Audio_tempo *a) |
301 : audio_ (a) | 301 : audio_ (a) |
302 { | 302 { |
303 } | 303 } |
304 | 304 |
305 string | 305 string |
306 Midi_tempo::to_string () const | 306 Midi_tempo::to_string () const |
(...skipping 16 matching lines...) Expand all Loading... |
323 str = String_convert::hex2bin (str); | 323 str = String_convert::hex2bin (str); |
324 str += int2midi_varint_string (audio_->text_string_.length ()); | 324 str += int2midi_varint_string (audio_->text_string_.length ()); |
325 str += audio_->text_string_; | 325 str += audio_->text_string_; |
326 return str; | 326 return str; |
327 } | 327 } |
328 | 328 |
329 string | 329 string |
330 Midi_control_change::to_string () const | 330 Midi_control_change::to_string () const |
331 { | 331 { |
332 Byte status_byte = (char) (0xB0 + channel_); | 332 Byte status_byte = (char) (0xB0 + channel_); |
333 string str = ::to_string ((char)status_byte); | 333 string str (1, status_byte); |
334 str += ::to_string ((char) (audio_->control_)); | 334 str += static_cast<char> (audio_->control_); |
335 str += ::to_string ((char) (audio_->value_)); | 335 str += static_cast<char> (audio_->value_); |
336 return str; | 336 return str; |
337 } | 337 } |
338 | 338 |
339 char const * | 339 char const * |
340 Midi_item::name () const | 340 Midi_item::name () const |
341 { | 341 { |
342 return class_name (); | 342 return class_name (); |
343 } | 343 } |
OLD | NEW |