source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#include "proto.hh"
#include "debug.hh"
#include "misc.hh"
#include "string.hh"
return i->str_.length_i () ? new Midi_instrument (i) : 0;
else if (Audio_note* i = dynamic_cast<Audio_note*> (a))
return new Midi_note (i);
+ else if (Audio_dynamic* i = dynamic_cast<Audio_dynamic*> (a))
+ return new Midi_dynamic (i);
+ else if (Audio_piano_pedal* i = dynamic_cast<Audio_piano_pedal*> (a))
+ return new Midi_piano_pedal (i);
else if (Audio_tempo* i = dynamic_cast<Audio_tempo*> (a))
return new Midi_tempo (i);
else if (Audio_time_signature* i = dynamic_cast<Audio_time_signature*> (a))
String
Midi_key::str () const
{
- int sharps_i = audio_l_->key_.sharps_i ();
- int flats_i = audio_l_->key_.flats_i ();
+ // fxime.
+ int sharps_i = 0; //audio_l_->key_.sharps_i ();
+ int flats_i = 0; //audio_l_->key_.flats_i ();
// midi cannot handle non-conventional keys
if (flats_i && sharps_i)
String str = "ff5902";
str += String_convert::i2hex_str (accidentals_i, 2, '0');
- str += String_convert::i2hex_str ((int)audio_l_->key_.minor_b (), 2, '0');
+
+ // (int)audio_l_->key_.minor_b ()
+ str += String_convert::i2hex_str (0, 2, '0');
return String_convert::hex2bin_str (str);
}
return str;
}
+Midi_dynamic::Midi_dynamic (Audio_dynamic* a)
+{
+ audio_l_ = a;
+}
+
+String
+Midi_dynamic::str () const
+{
+ Byte status_byte = (char) (0xB0 + channel_i_);
+ String str = to_str ((char)status_byte);
+
+ /*
+ Main volume controller (per channel):
+ 07 MSB
+ 27 LSB
+ */
+ static Real const full_scale = 127;
+
+ int volume = (int)(audio_l_->volume_*full_scale);
+ if (volume <= 0)
+ volume = 1;
+ if (volume > full_scale)
+ volume = (int)full_scale;
+
+ str += to_str ((char)0x07);
+ str += to_str ((char)volume);
+ return str;
+}
+
+Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal* a)
+{
+ audio_l_ = a;
+}
+
+String
+Midi_piano_pedal::str () const
+{
+ Byte status_byte = (char) (0xB0 + channel_i_);
+ String str = to_str ((char)status_byte);
+
+ if (audio_l_->type_str_ == "Sostenuto")
+ str += to_str ((char)0x42);
+ else if (audio_l_->type_str_ == "Sustain")
+ str += to_str ((char)0x40);
+ else if (audio_l_->type_str_ == "UnaChorda")
+ str += to_str ((char)0x43);
+
+ int pedal = ((1 - audio_l_->dir_) / 2 ) * 0x7f;
+ str += to_str ((char)pedal);
+ return str;
+}
+
Midi_tempo::Midi_tempo (Audio_tempo* a)
{
audio_l_ = a;