From: fred Date: Sun, 24 Mar 2002 19:49:39 +0000 (+0000) Subject: lilypond-0.0.78 X-Git-Tag: release/1.5.59~4361 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=888a84bf5d0999265321b01d88af2946eead7c9f;p=lilypond.git lilypond-0.0.78 --- diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 2efb36aff1..4d29affb66 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -27,8 +27,9 @@ IMPLEMENT_IS_TYPE_B1(Midi_note, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_duration, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_chunk, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_header, Midi_chunk); -IMPLEMENT_IS_TYPE_B1(Midi_text, Midi_item); +IMPLEMENT_IS_TYPE_B1(Midi_instrument, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_tempo, Midi_item); +IMPLEMENT_IS_TYPE_B1(Midi_text, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_time, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_track, Midi_chunk); @@ -89,6 +90,195 @@ Midi_header::Midi_header( int format_i, int tracks_i, int clocks_per_4_i ) set( "MThd", str, "" ); } +char const* const instrument_name_sz_a_[ ] = { + + /* default is usually piano */ + /* 0 */ "piano", + + /* (1-8 piano) */ + /* 1 */ "acoustic grand", + /* 2 */ "bright acoustic", + /* 3 */ "electric grand", + /* 4 */ "honky-tonk", + /* 5 */ "electric piano 1", + /* 6 */ "electric piano 2", + /* 7 */ "harpsichord", + /* 8 */ "clav", + + /* (9-16 chrom percussion) */ + /* 9 */ "celesta", + /* 10 */ "glockenspiel", + /* 11 */ "music box", + /* 12 */ "vibraphone", + /* 13 */ "marimba", + /* 14 */ "xylophone", + /* 15 */ "tubular bells", + /* 16 */ "dulcimer", + + /* (17-24 organ) */ + /* 17 */ "drawbar organ", + /* 18 */ "percussive organ", + /* 19 */ "rock organ", + /* 20 */ "church organ", + /* 21 */ "reed organ", + /* 22 */ "accoridan", + /* 23 */ "harmonica", + /* 24 */ "tango accordian", + + /* (25-32 guitar) */ + /* 25 */ "acoustic guitar(nylon)", + /* 26 */ "acoustic guitar(steel)", + /* 27 */ "electric guitar(jazz)", + /* 28 */ "electric guitar(clean)", + /* 29 */ "electric guitar(muted)", + /* 30 */ "overdriven guitar", + /* 31 */ "distortion guitar", + /* 32 */ "guitar harmonics", + + /* (33-40 bass) */ + /* 33 */ "acoustic bass", + /* 34 */ "electric bass(finger)", + /* 35 */ "electric bass(pick)", + /* 36 */ "fretless bass", + /* 37 */ "slap bass 1", + /* 38 */ "slap bass 2", + /* 39 */ "synth bass 1", + /* 40 */ "synth bass 2", + + /* (41-48 strings) */ + /* 41 */ "violin", + /* 42 */ "viola", + /* 43 */ "cello", + /* 44 */ "contrabass", + /* 45 */ "tremolo strings", + /* 46 */ "pizzicato strings", + /* 47 */ "orchestral strings", + /* 48 */ "timpani", + + /* (49-56 ensemble) */ + /* 49 */ "string ensemble 1", + /* 50 */ "string ensemble 2", + /* 51 */ "synthstrings 1", + /* 52 */ "synthstrings 2", + /* 53 */ "choir aahs", + /* 54 */ "voice oohs", + /* 55 */ "synth voice", + /* 56 */ "orchestra hit", + + /* (57-64 brass) */ + /* 57 */ "trumpet", + /* 58 */ "trombone", + /* 59 */ "tuba", + /* 60 */ "muted trumpet", + /* 61 */ "french horn", + /* 62 */ "brass section", + /* 63 */ "synthbrass 1", + /* 64 */ "synthbrass 2", + + /* (65-72 reed) */ + /* 65 */ "soprano sax", + /* 66 */ "alto sax", + /* 67 */ "tenor sax", + /* 68 */ "baritone sax", + /* 69 */ "oboe", + /* 70 */ "english horn", + /* 71 */ "bassoon", + /* 72 */ "clarinet", + + /* (73-80 pipe) */ + /* 73 */ "piccolo", + /* 74 */ "flute", + /* 75 */ "recorder", + /* 76 */ "pan flute", + /* 77 */ "blown bottle", + /* 78 */ "skakuhachi", + /* 79 */ "whistle", + /* 80 */ "ocarina", + + /* (81-88 synth lead) */ + /* 81 */ "lead 1 (square)", + /* 82 */ "lead 2 (sawtooth)", + /* 83 */ "lead 3 (calliope)", + /* 84 */ "lead 4 (chiff)", + /* 85 */ "lead 5 (charang)", + /* 86 */ "lead 6 (voice)", + /* 87 */ "lead 7 (fifths)", + /* 88 */ "lead 8 (bass+lead)", + + /* (89-96 synth pad) */ + /* 89 */ "pad 1 (new age)", + /* 90 */ "pad 2 (warm)", + /* 91 */ "pad 3 (polysynth)", + /* 92 */ "pad 4 (choir)", + /* 93 */ "pad 5 (bowed)", + /* 94 */ "pad 6 (metallic)", + /* 95 */ "pad 7 (halo)", + /* 96 */ "pad 8 (sweep)", + + /* (97-104 synth effects) */ + /* 97 */ "fx 1 (rain)", + /* 98 */ "fx 2 (soundtrack)", + /* 99 */ "fx 3 (crystal)", + /* 100 */ "fx 4 (atmosphere)", + /* 101 */ "fx 5 (brightness)", + /* 102 */ "fx 6 (goblins)", + /* 103 */ "fx 7 (echoes)", + /* 104 */ "fx 8 (sci-fi)", + + /* (105-112 ethnic) */ + /* 105 */ "sitar", + /* 106 */ "banjo", + /* 107 */ "shamisen", + /* 108 */ "koto", + /* 109 */ "kalimba", + /* 110 */ "bagpipe", + /* 111 */ "fiddle", + /* 112 */ "shanai", + + /* (113-120 percussive) */ + /* 113 */ "tinkle bell", + /* 114 */ "agogo", + /* 115 */ "steel drums", + /* 116 */ "woodblock", + /* 117 */ "taiko drum", + /* 118 */ "melodic tom", + /* 119 */ "synth drum", + /* 120 */ "reverse cymbal", + + /* (121-128 sound effects) */ + /* 121 */ "guitar fret noise", + /* 122 */ "breath noise", + /* 123 */ "seashore", + /* 124 */ "bird tweet", + /* 125 */ "telephone ring", + /* 126 */ "helicopter", + /* 127 */ "applause", + /* 128 */ "gunshot", + 0 +}; + +Midi_instrument::Midi_instrument( int channel_i, String instrument_str ) +{ + channel_i_ = channel_i; + instrument_str.to_lower(); + for ( int i = 0; instrument_name_sz_a_[i]; i++ ) + if ( instrument_str == String(instrument_name_sz_a_[ i ] )) { + program_byte_ = (Byte)i; + break; + } +} + +String +Midi_instrument::str() const +{ + if ( program_byte_ ) { + String str = String( (char)( 0xc0 + channel_i_ ) ); + str += String( (char)program_byte_ ); + return str; + } + return String( "" ); +} + String Midi_item::i2varint_str( int i ) { @@ -263,6 +453,7 @@ Midi_track::add( Moment delta_time_moment, Midi_item* mitem_l ) // use convention of 384 clocks per 4 // use Duration_convert int delta_time_i = delta_time_moment * Moment( 384 ) / Moment( 1, 4 ); + // ? int ( delta_time_moment * 4 * 384) add( delta_time_i, mitem_l->str() ); }