From bdabe71a2bdda41b64c0000da6023771701f4def Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 7 Aug 1997 09:23:05 +0200 Subject: [PATCH] patch::: 0.1.1.jcn1: zachte pats pl 0.1.1.jcn1 - Audio{column,score,item,...}, more generic audio - bf: Makefiles - added empty flower/aclocal.m4? - bf: mi2mu mudela version --- .dstreamrc | 37 +++---- NEWS | 6 ++ VERSION | 2 +- flower/Makefile | 2 +- lily/Makefile | 8 +- lily/audio-column.cc | 43 ++++++++ lily/audio-item.cc | 84 ++++++++++++++++ lily/audio-score.cc | 73 ++++++++++++++ lily/global-performers.cc | 2 +- lily/include/audio-column.hh | 38 +++++++ lily/include/audio-item.hh | 84 ++++++++++++++++ lily/include/audio-score.hh | 35 +++++++ lily/include/lily-proto.hh | 12 ++- lily/include/midi-item.hh | 69 +++++-------- lily/include/performer.hh | 5 +- lily/include/score-performer.hh | 7 +- lily/include/score.hh | 6 +- lily/include/staff-performer.hh | 5 +- lily/key-performer.cc | 15 +-- lily/lyric-performer.cc | 9 +- lily/meter-performer.cc | 10 +- lily/midi-item.cc | 160 +++++++++++++++++------------- lily/midi-stream.cc | 7 +- lily/note-performer.cc | 25 ++--- lily/performer-group-performer.cc | 2 + lily/performer.cc | 14 ++- lily/score-performer.cc | 33 ++++-- lily/score.cc | 4 + lily/staff-performer.cc | 52 +++++++--- lily/template8.cc | 18 +++- mi2mu/Makefile | 10 +- mi2mu/lily-stream.cc | 2 +- 32 files changed, 660 insertions(+), 219 deletions(-) create mode 100644 lily/audio-column.cc create mode 100644 lily/audio-item.cc create mode 100644 lily/audio-score.cc create mode 100644 lily/include/audio-column.hh create mode 100644 lily/include/audio-item.hh create mode 100644 lily/include/audio-score.hh diff --git a/.dstreamrc b/.dstreamrc index bb39c57afd..2ec9f75879 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -36,43 +36,46 @@ Engraver_group_engraver 1 File_path 1 Group_change_req 1 Head_column 1 -Idealspacing 0 +Idealspacing 1 Ineq_constrained_qp 1 -Input_translator 0 +Input_translator 1 Item 1 Key_item 1 Lookup 1 +Line_spacer 1 Melodic_req 0 Midi_def 1 Mixed_qp 1 -Music 0 +Music 1 Music_iterator 1 My_lily_lexer 1 Note_head 1 -Note_performer 0 +Note_performer 1 Note_req 0 -PCol 0 +PCol 1 PScore 1 Paper_def 1 Paperdef 1 -Performer 0 -Request 0 +Performer 1 +Performer_group_performer 1 +Request 1 Request_iterator 1 Rest_collision 1 Rest_collision_engraver 1 Rest_req 1 Rhythmic_req 0 Score 1 -Score_column 0 +Score_column 1 Score_elem 1 -Score_engraver 0 -Score_performer 0 -Script_column 0 -Script_def 0 -Script_req 0 +Score_engraver 1 +Score_performer 1 +Script_column 1 +Script_def 1 +Script_req 1 Slur 1 Spacing_problem 1 Spanner 1 +Spring_spacer 1 Staff 1 Staff_commands 1 Stem 1 @@ -80,11 +83,11 @@ Stem 1 Stem_req 1 Symtable 1 Symtables 1 -Text_def 0 -Text_req 0 +Text_def 1 +Text_req 1 Time_description 1 -Voice 0 -Voice_element 0 +Voice 1 +Voice_element 1 Voice_element_iterator 1 Voice_iterator 1 Word_wrap 1 diff --git a/NEWS b/NEWS index 6f889e2664..140b08c42a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +pl 0.1.1.jcn1 + - Audio{column,score,item,...}, more generic audio + - bf: Makefiles + - added empty flower/aclocal.m4? + - bf: mi2mu mudela version + pl 0.1.1 - {Horizontal, Vertical}_group. A score_element may be in at most one. - This means Horizontal_group_item and Vertical_group_spanner need special support. diff --git a/VERSION b/VERSION index 4f48ae745f..1a78f879c5 100644 --- a/VERSION +++ b/VERSION @@ -3,4 +3,4 @@ TOPLEVEL_MINOR_VERSION = 1 TOPLEVEL_PATCH_LEVEL = 1 # use to send patches, always empty for released version: -TOPLEVEL_MY_PATCH_LEVEL = +TOPLEVEL_MY_PATCH_LEVEL = .jcn1 diff --git a/flower/Makefile b/flower/Makefile index 1089809e21..750c101458 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -40,7 +40,7 @@ SUBDIRS = include test # SCRIPTS = README_FILES = ONEWS NEWS README TODO -EXTRA_DISTFILES= configure config.hh.in configure.in VERSION $(README_FILES) $(SCRIPTS) Flower-flags.make.in +EXTRA_DISTFILES= configure config.hh.in configure.in aclocal.m4 VERSION $(README_FILES) $(SCRIPTS) Flower-flags.make.in # diff --git a/lily/Makefile b/lily/Makefile index 785fb9e0e4..1cee326a74 100644 --- a/lily/Makefile +++ b/lily/Makefile @@ -12,7 +12,10 @@ depth = .. # +# identify module: +# NAME = lilypond +# # generic variables: # @@ -21,11 +24,6 @@ include ./$(depth)/make/Variables.make include VERSION # -# identify module: -# - -# - # descent order into subdirectories: # SUBDIRS = include diff --git a/lily/audio-column.cc b/lily/audio-column.cc new file mode 100644 index 0000000000..0bda45c592 --- /dev/null +++ b/lily/audio-column.cc @@ -0,0 +1,43 @@ +/* + audio-column.cc -- implement Audio_column + + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen + */ + +#include "audio-column.hh" +#include "audio-item.hh" +#include "audio-score.hh" + +#include "debug.hh" + +Audio_column::Audio_column( Moment at_mom ) +{ + at_mom_ = at_mom; + audio_score_l_ = 0; +} + +void +Audio_column::add( Audio_item* l ) +{ + audio_item_l_list_.bottom().add( l ); + l->audio_column_l_ = this; +} + +Moment +Audio_column::at_mom() const +{ + return at_mom_; +} + +void +Audio_column::print() const +{ +#ifndef NPRINT + mtor << "Audio_column {"; + mtor << "at: " << at_mom_ << "\n"; + mtor << "}\n"; +#endif +} + diff --git a/lily/audio-item.cc b/lily/audio-item.cc new file mode 100644 index 0000000000..689c34af38 --- /dev/null +++ b/lily/audio-item.cc @@ -0,0 +1,84 @@ +/* + audio-item.cc -- implement Audio items. + + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + +#include "audio-item.hh" +#include "midi-item.hh" + +#if 0 +Audio_instrument::Audio_instrument( String instrument_str ) + : Audio_item( 0 ) +{ +} +#endif + +Audio_item::Audio_item( Request* req_l ) +{ + audio_column_l_ = 0; + req_l_ = req_l; +} + +Audio_key::Audio_key( Request* req_l ) + : Audio_item( req_l ) +{ +} + +Midi_item* +Audio_key::midi_item_p() +{ + return new Midi_key( this ); +} + + +Audio_note::Audio_note( Request* req_l, bool on_b ) + : Audio_item( req_l ) +{ + on_b_ = on_b; +} + +Midi_item* +Audio_note::midi_item_p() +{ + return new Midi_note( this ); +} + +Audio_tempo::Audio_tempo( int per_minute_4_i ) + : Audio_item( 0 ) +{ + per_minute_4_i_ = per_minute_4_i; +} + +Midi_item* +Audio_tempo::midi_item_p() +{ + return new Midi_tempo( this ); +} + +Audio_meter::Audio_meter( Request* req_l ) + : Audio_item( req_l ) +{ +} + +Midi_item* +Audio_meter::midi_item_p() +{ + return new Midi_meter( this ); +} + +Audio_text::Audio_text( Audio_text::Type type, String text_str ) + : Audio_item( 0 ) +{ + text_str_ = text_str; + type_ = type; +} + +Midi_item* +Audio_text::midi_item_p() +{ + return new Midi_text( this ); +} + diff --git a/lily/audio-score.cc b/lily/audio-score.cc new file mode 100644 index 0000000000..8094b3e369 --- /dev/null +++ b/lily/audio-score.cc @@ -0,0 +1,73 @@ +/* + audio-score.cc -- implement Audio_score + + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + +#include "debug.hh" +#include "midi-def.hh" +#include "audio-column.hh" +#include "audio-score.hh" + +Audio_score::Audio_score( Midi_def* l ) +{ + midi_l_ = l; +} + +void +Audio_score::play( Audio_item* i, Audio_column* c ) +{ + assert( c ); + assert( i ); + + c->add( i ); +// typeset_element( i ); +} + +void +Audio_score::add( Audio_column* p ) +{ + p->audio_score_l_ = this; + audio_column_p_list_.bottom().add(p); +} + +#if 0 +void +Audio_score::output(Tex_stream &ts) +{ + ts << "\n "<< midi_l_->lookup_l()->texsetting << "%(Tex id)\n"; + ts<< super_elem_l_->TeX_string(); + ts << "\n\\EndLilyPondOutput"; +} +#endif + +void +Audio_score::print() const +{ +#ifndef NPRINT + mtor << "Audio_score { "; + midi_l_->print(); + mtor << "\ncolumns: "; + for ( PCursor i( audio_column_p_list_ ); i.ok(); i++ ) + i->print(); + mtor << "}\n"; +#endif +} + +void +Audio_score::process() +{ +#if 0 + clean_cols(); + print(); + *mlog << "Preprocessing elements... " < + */ + +#ifndef AUDIO_COLUMN_HH +#define AUDIO_COLUMN_HH + +#include "proto.hh" +#include "plist.hh" +#include "lily-proto.hh" +#include "moment.hh" + + +/** + generic audio grouped vertically. + */ + +class Audio_column { +public: + Audio_column( Moment at_mom ); + + void add( Audio_item* i_l ); + Moment at_mom() const; + void print() const; + + Link_list audio_item_l_list_; + Audio_score * audio_score_l_; + +private: + Audio_column( Audio_column const& ); + + Moment at_mom_; +}; + + +#endif // AUDIO_COLUMN_HH diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh new file mode 100644 index 0000000000..e6104dcb7f --- /dev/null +++ b/lily/include/audio-item.hh @@ -0,0 +1,84 @@ +/* + audio-item.hh -- declare Audio_items + + (c) 1996, 1997 Jan Nieuwenhuizen + */ + +#ifndef AUDIO_ITEM_HH +#define AUDIO_ITEM_HH + +#include "lily-proto.hh" +#include "string.hh" + +/** + Any piece of audio information. + We need virtual constructors, + let's try decentralised factory for specific audio implemenations. + */ +struct Audio_item { + Audio_item( Request* req_l ); + + /// Create a midi-item from myself. + virtual Midi_item* midi_item_p() = 0; + +#if 0 + /// Not implemented. Anyone? + virtual Niff_item* niff_item_p() = 0; + + /// Not implemented. Anyone? + virtual Cscore_item* score_item_p() = 0; +#endif + + Audio_column* audio_column_l_; + Request* req_l_; + +private: + Audio_item( Audio_item const& ); + Audio_item& operator=( Audio_item const& ); +}; + +struct Audio_key : public Audio_item { + Audio_key( Request* req_l ); + + virtual Midi_item* midi_item_p(); +}; + +#if 0 +struct Audio_instrument : public Audio_item { + Audio_instrument( Request* req_l ); +}; +#endif + +struct Audio_note : public Audio_item { + Audio_note( Request* req_l, bool on_b ); + virtual Midi_item* midi_item_p(); + bool on_b_; +}; + +struct Audio_text : Audio_item { + enum Type { + TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, + MARKER, CUE_POINT + }; + + Audio_text( Audio_text::Type type, String text_str ); + virtual Midi_item* midi_item_p(); + + Type type_; + String text_str_; +}; + +struct Audio_tempo : Audio_item { + Audio_tempo( int per_minute_4_i ); + virtual Midi_item* midi_item_p(); + + int per_minute_4_i_; +}; + +struct Audio_meter : Audio_item { + Audio_meter( Request* req_l ); + virtual Midi_item* midi_item_p(); +}; + +#endif // AUDIO_ITEM_HH + diff --git a/lily/include/audio-score.hh b/lily/include/audio-score.hh new file mode 100644 index 0000000000..845b598e47 --- /dev/null +++ b/lily/include/audio-score.hh @@ -0,0 +1,35 @@ +/* + audio-score.hh -- declare Audio_score + + (c) 1997 Jan Nieuwenhuizen + */ + +#ifndef AUDIO_SCORE_HH +#define AUDIO_SCORE_HH + +#include "proto.hh" +#include "parray.hh" +#include "plist.hh" + +/** all stuff which goes onto midi. notes, signs, symbols in a score + #Audio_score# contains the items, the columns. + + */ + +class Audio_score { +public: + Audio_score( Midi_def* ); + + void add( Audio_column* ); + +// void output(Tex_stream &ts); + + void play( Audio_item* i, Audio_column* c ); + void print() const; + void process(); + + Pointer_list audio_column_p_list_; + Midi_def *midi_l_; +}; + +#endif // AUDIO_SCORE_HH diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 8760b560b1..5619bf021a 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -13,6 +13,13 @@ struct My_lily_lexer; struct Absolute_dynamic_req; struct Translator; +struct Audio_column; +struct Audio_item; +struct Audio_key; +struct Audio_meter; +struct Audio_note; +struct Audio_score; +struct Audio_tempo; struct Atom; struct Bar; struct Bar_engraver; @@ -95,10 +102,13 @@ struct Midi_def; struct Midi_duration; struct Midi_header; struct Midi_item; +struct Midi_key; +struct Midi_meter; +struct Midi_note; struct Midi_output; -struct Midi_pitch; struct Midi_score; struct Midi_stream; +struct Midi_tempo; struct Midi_track; struct Mixed_qp; struct Molecule; diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh index ed5cf51a59..369d4a4886 100644 --- a/lily/include/midi-item.hh +++ b/lily/include/midi-item.hh @@ -1,14 +1,14 @@ -// -// midiitem.hh -- part of GNU LilyPond -// -// copyright 1997 Jan Nieuwenhuizen +/* + midi-item.hh -- declare Midi items + + (c) 1997 Jan Nieuwenhuizen + */ #ifndef MIDI_ITEM_HH #define MIDI_ITEM_HH #include "string.hh" #include "lily-proto.hh" -#include "virtual-methods.hh" /** Any piece of midi information. @@ -16,24 +16,23 @@ Maybe use base classes for RIFF files? */ struct Midi_item { - Midi_item() { } - DECLARE_MY_RUNTIME_TYPEINFO; + Midi_item( Audio_item* audio_item_l ); static String i2varint_str( int i ); - virtual void output_midi( Midi_stream& midi_stream_r ) const; + void output( Midi_stream* midi_stream_l ) const; virtual String str() const = 0; + + Audio_item* audio_item_l_; + int channel_i_; + private: - Midi_item(Midi_item const&){} - void operator=(Midi_item const&){} + Midi_item( Midi_item const& ); + Midi_item& operator =( Midi_item const& ); }; struct Midi_key : public Midi_item { - Midi_key( int accidentals_i, int minor_i ); - DECLARE_MY_RUNTIME_TYPEINFO; + Midi_key( Audio_item* audio_item_l ); virtual String str() const; - /* *************** */ - int accidentals_i_; - int minor_i_; }; /** @@ -41,12 +40,9 @@ struct Midi_key : public Midi_item { */ struct Midi_instrument : public Midi_item { Midi_instrument( int channel_i, String instrument_str ); - DECLARE_MY_RUNTIME_TYPEINFO; virtual String str() const; - - int channel_i_; - Byte program_byte_; + String instrument_str_; }; struct Midi_note : public Midi_item { @@ -55,23 +51,18 @@ struct Midi_note : public Midi_item { @param #melreq_l# is the pitch. */ - Midi_note( Melodic_req* melreq_l, int channel_i, bool on_b ); - DECLARE_MY_RUNTIME_TYPEINFO; + Midi_note( Audio_item* audio_item_l ); virtual String str() const; /* *************** */ int const c0_pitch_i_c_ = 60; + bool on_b_; Byte dynamic_byte_; - - int channel_i_; - int on_b_; - int pitch_i_; }; struct Midi_duration : public Midi_item { Midi_duration( Real seconds_f ); - DECLARE_MY_RUNTIME_TYPEINFO; virtual String str() const; /* *************** */ @@ -80,7 +71,6 @@ struct Midi_duration : public Midi_item { struct Midi_chunk : Midi_item { Midi_chunk(); - DECLARE_MY_RUNTIME_TYPEINFO; void add( String str ); void set( String header_str, String data_str, String footer_str ); @@ -94,45 +84,36 @@ private: struct Midi_header : Midi_chunk { /* *************** */ Midi_header( int format_i, int tracks_i, int clocks_per_4_i ); - DECLARE_MY_RUNTIME_TYPEINFO; }; struct Midi_text : Midi_item { - enum Type { TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, MARKER, CUE_POINT }; + + Midi_text( Audio_item* audio_item_l ); Midi_text( Midi_text::Type type, String text_str ); - DECLARE_MY_RUNTIME_TYPEINFO; virtual String str() const; - /* *************** */ + Type type_; String text_str_; - }; struct Midi_tempo : Midi_item { + Midi_tempo( Audio_item* audio_item_l ); Midi_tempo( int per_minute_4_i ); - DECLARE_MY_RUNTIME_TYPEINFO; virtual String str() const; - /* *************** */ int per_minute_4_i_; }; -struct Midi_time : Midi_item { - - Midi_time( int num_i, int den_i, int clocks_per_1_i ); - DECLARE_MY_RUNTIME_TYPEINFO; +struct Midi_meter : Midi_item { + Midi_meter( Audio_item* audio_item_l ); virtual String str() const; - - /* *************** */ - int num_i_; - int den_i_; int clocks_per_1_i_; }; @@ -140,11 +121,9 @@ struct Midi_track : Midi_chunk { int number_i_; /* *************** */ Midi_track(); - DECLARE_MY_RUNTIME_TYPEINFO; void add( int delta_time_i, String event ); void add( Moment delta_time_moment, Midi_item* mitem_l ); }; -#endif // MIDI_ITEM_HH // - +#endif // MIDI_ITEM_HH diff --git a/lily/include/performer.hh b/lily/include/performer.hh index 353f1f9b13..eda9b784f3 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -41,6 +41,7 @@ public: virtual void do_removal_processing(); void creation_processing(); + protected: virtual void do_creation_processing(); @@ -48,8 +49,8 @@ protected: virtual int get_tempo_i() const; virtual void do_print() const; virtual Moment get_mom() const; - virtual void play_event( Midi_item* l ); - + virtual void play( Audio_item* p ); + virtual void play( Midi_item* l ); }; #include "global-performers.hh" diff --git a/lily/include/score-performer.hh b/lily/include/score-performer.hh index 4a79cb1fb4..b4030800b4 100644 --- a/lily/include/score-performer.hh +++ b/lily/include/score-performer.hh @@ -30,7 +30,9 @@ protected: virtual void set_score( Score* score_l ); virtual void start(); virtual int get_tempo_i() const; - virtual void play_event(Midi_item*); + virtual void play(Audio_item*); + virtual void play(Midi_item*); + private: void header(Midi_stream&); @@ -38,8 +40,9 @@ private: Moment prev_mom_; Moment now_mom_; + Audio_column* audio_column_l_; - Link_array midi_item_p_arr_; + Link_array midi_item_l_arr_; }; #endif // SCORE_PERFORMER_HH diff --git a/lily/include/score.hh b/lily/include/score.hh index dea8806243..ecd4f8cc10 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -27,6 +27,7 @@ public: Midi_def *midi_p_; Music * music_p_; PScore *pscore_p_; + Audio_score* audio_score_p_; int errorlevel_i_; @@ -34,6 +35,7 @@ public: /// construction Score(); + Score(Score const&); ~Score(); /// do everything except outputting to file @@ -50,11 +52,7 @@ public: void print() const; - Score(Score const&); private: - - - void run_translator(Global_translator*); void midi_output(); void paper_output(); diff --git a/lily/include/staff-performer.hh b/lily/include/staff-performer.hh index 95c8721da8..8d6a45d92f 100644 --- a/lily/include/staff-performer.hh +++ b/lily/include/staff-performer.hh @@ -21,7 +21,8 @@ public: String instrument_str(); protected: - virtual void play_event( Midi_item* l ); + virtual void play( Midi_item* l ); + virtual void play( Audio_item* l ); virtual void do_removal_processing(); virtual void do_creation_processing(); // @@ -34,7 +35,7 @@ private: Moment midi_mom_; Midi_track* midi_track_p_; - + Pointer_list audio_item_p_list_; int track_i_; }; diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 5e620ff7c9..5affa0c1f3 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -8,7 +8,7 @@ #include "key-performer.hh" #include "command-request.hh" -#include "midi-item.hh" +#include "audio-item.hh" @@ -36,16 +36,9 @@ Key_performer::do_print() const void Key_performer::process_requests() { - if ( key_req_l_ ) { - int sharps_i = key_req_l_->sharps_i(); - int flats_i = key_req_l_->flats_i(); - // midi cannot handle non-conventional keys - if ( !( flats_i && sharps_i ) ) { - Midi_key k( sharps_i - flats_i, key_req_l_->minor_b() ); - play_event( &k ); - } - key_req_l_ = 0; - } + if ( key_req_l_ ) + play( new Audio_key( key_req_l_ ) ); + key_req_l_ = 0; } bool diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index e623e5881c..08fa4c14e9 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -9,7 +9,7 @@ #include "lyric-performer.hh" #include "text-def.hh" #include "musical-request.hh" -#include "midi-item.hh" +#include "audio-item.hh" @@ -36,11 +36,8 @@ Lyric_performer::do_print() const void Lyric_performer::process_requests() { - if ( lreq_arr_.size() ) { - Midi_text t( Midi_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_ ); - play_event( &t ); - } - + if ( lreq_arr_.size() ) + play( new Audio_text( Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_ ) ); lreq_arr_.clear(); } diff --git a/lily/meter-performer.cc b/lily/meter-performer.cc index 812163e04a..9a3d75c83c 100644 --- a/lily/meter-performer.cc +++ b/lily/meter-performer.cc @@ -8,7 +8,7 @@ #include "meter-performer.hh" #include "command-request.hh" -#include "midi-item.hh" +#include "audio-item.hh" IMPLEMENT_IS_TYPE_B1(Meter_performer,Performer); ADD_THIS_PERFORMER(Meter_performer); @@ -34,11 +34,9 @@ Meter_performer::do_print() const void Meter_performer::process_requests() { - if ( meter_req_l_ ) { - Midi_time m( meter_req_l_->beats_i_, meter_req_l_->one_beat_i_, 18 ); - play_event( &m ); - meter_req_l_ = 0; - } + if ( meter_req_l_ ) + play( new Audio_meter( meter_req_l_ ) ); + meter_req_l_ = 0; } bool diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 4d29affb66..d520eac8fb 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -1,39 +1,25 @@ /* - midi-item.cc -- implement various midi items. + midi-item.cc -- implement Midi items. source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys -*/ + (c) 1997 Jan Nieuwenhuizen + */ -#include #include "proto.hh" #include "plist.hh" -#include "p-col.hh" #include "debug.hh" #include "misc.hh" #include "string.hh" #include "string-convert.hh" -#include "request.hh" +#include "command-request.hh" #include "musical-request.hh" -#include "music-list.hh" #include "midi-item.hh" #include "midi-stream.hh" - - -IMPLEMENT_IS_TYPE_B(Midi_item); -IMPLEMENT_IS_TYPE_B1(Midi_key,Midi_item); -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_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); +#include "audio-item.hh" Midi_chunk::Midi_chunk() + : Midi_item( 0 ) { } @@ -64,6 +50,7 @@ Midi_chunk::str() const } Midi_duration::Midi_duration( Real seconds_f ) + : Midi_item( 0 ) { seconds_f_ = seconds_f; } @@ -75,6 +62,7 @@ Midi_duration::str() const } Midi_header::Midi_header( int format_i, int tracks_i, int clocks_per_4_i ) + : Midi_chunk() { String str; @@ -258,27 +246,44 @@ char const* const instrument_name_sz_a_[ ] = { }; Midi_instrument::Midi_instrument( int channel_i, String instrument_str ) + : Midi_item( 0 ) { + instrument_str_ = instrument_str; + instrument_str_.to_lower(); 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_ ) { + // ugh, does not work... + return String( "" ); + Byte program_byte = 0; + for ( int i = 0; instrument_name_sz_a_[i]; i++ ) + if ( instrument_str_ == String(instrument_name_sz_a_[ i ] )) { + program_byte = (Byte)i; + break; + } + if ( program_byte ) { String str = String( (char)( 0xc0 + channel_i_ ) ); - str += String( (char)program_byte_ ); + str += String( (char)program_byte ); return str; } return String( "" ); } +Midi_item::Midi_item( Audio_item* audio_item_l ) +{ + audio_item_l_ = audio_item_l; + channel_i_ = 0; +} + +void +Midi_item::output( Midi_stream* midi_stream_l ) const +{ + *midi_stream_l << str(); +} + String Midi_item::i2varint_str( int i ) { @@ -300,36 +305,36 @@ Midi_item::i2varint_str( int i ) return str; } -void -Midi_item::output_midi( Midi_stream& midi_stream_r ) const +Midi_key::Midi_key( Audio_item* audio_item_l ) + : Midi_item( audio_item_l ) { - midi_stream_r << str(); -} - -Midi_key::Midi_key( int accidentals_i, int minor_i ) -{ - accidentals_i_ = accidentals_i; - minor_i_ = minor_i; } String Midi_key::str() const { + Key_change_req* k = audio_item_l_->req_l_->command()->keychange(); + int sharps_i = k->sharps_i(); + int flats_i = k->flats_i(); + + // midi cannot handle non-conventional keys + if ( flats_i && sharps_i ) + return ""; + int accidentals_i = sharps_i - flats_i; + String str = "ff5902"; - str += String_convert::i2hex_str( accidentals_i_, 2, '0' ); - str += String_convert::i2hex_str( minor_i_, 2, '0' ); + str += String_convert::i2hex_str( accidentals_i, 2, '0' ); + int minor_i = k->minor_b(); + str += String_convert::i2hex_str( minor_i, 2, '0' ); return String_convert::hex2bin_str( str ); } -Midi_note::Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo ) +Midi_note::Midi_note( Audio_item* audio_item_l ) + : Midi_item( audio_item_l ) { - assert(melreq_l); - pitch_i_ = melreq_l->pitch() + c0_pitch_i_c_; - channel_i_ = channel_i; - - on_b_ = on_bo; - + // ugh dynamic_byte_ = 0x64; + on_b_ = ( (Audio_note*)audio_item_l_ )->on_b_; if ( on_b_ ) // poor man-s staff dynamics: dynamic_byte_ -= 0x10 * channel_i_; else @@ -339,10 +344,12 @@ Midi_note::Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo ) String Midi_note::str() const { - if ( pitch_i_ != INT_MAX ) { + Note_req* n = audio_item_l_->req_l_->musical()->melodic()->note(); + int pitch_i = n->pitch() + c0_pitch_i_c_; + if ( pitch_i != INT_MAX ) { Byte status_byte = ( on_b_ ? 0x90 : 0x80 ) + channel_i_; String str = String( (char)status_byte ); - str += (char)pitch_i_; + str += (char)pitch_i; // poor man-s staff dynamics: str += (char)dynamic_byte_; return str; @@ -350,7 +357,14 @@ Midi_note::str() const return String( "" ); } +Midi_tempo::Midi_tempo( Audio_item* audio_item_l ) + : Midi_item( audio_item_l ) +{ + per_minute_4_i_ = ( (Audio_tempo*)audio_item_l_ )->per_minute_4_i_; +} + Midi_tempo::Midi_tempo( int per_minute_4_i ) + : Midi_item( 0 ) { per_minute_4_i_ = per_minute_4_i; } @@ -364,41 +378,53 @@ Midi_tempo::str() const return String_convert::hex2bin_str( str ); } -Midi_time::Midi_time( int num_i, int den_i, int clocks_per_1_i ) +Midi_meter::Midi_meter( Audio_item* audio_item_l ) + : Midi_item( audio_item_l ) { - num_i_ = num_i; - den_i_ = den_i; - clocks_per_1_i_ = clocks_per_1_i; + clocks_per_1_i_ = 18; } String -Midi_time::str() const +Midi_meter::str() const +{ + Meter_change_req* m = audio_item_l_->req_l_->command()->meterchange(); + int num_i = m->beats_i_; + int den_i = m->one_beat_i_; + + String str = "ff5804"; + str += String_convert::i2hex_str( num_i, 2, '0' ); + str += String_convert::i2hex_str( intlog2( den_i ) , 2, '0' ); + str += String_convert::i2hex_str( clocks_per_1_i_, 2, '0' ); + str += String_convert::i2hex_str( 8, 2, '0' ); + return String_convert::hex2bin_str( str ); +} + +Midi_text::Midi_text( Audio_item* audio_item_l ) + : Midi_item( audio_item_l ) { - String str = "ff5804"; - str += String_convert::i2hex_str( num_i_, 2, '0' ); - str += String_convert::i2hex_str( intlog2( den_i_ ) , 2, '0' ); - str += String_convert::i2hex_str( clocks_per_1_i_, 2, '0' ); - str += String_convert::i2hex_str( 8, 2, '0' ); - return String_convert::hex2bin_str( str ); + text_str_ = ( (Audio_text*)audio_item_l_ )->text_str_; + type_ = (Type)( (Audio_text*)audio_item_l_ )->type_; } Midi_text::Midi_text( Midi_text::Type type, String text_str ) + : Midi_item( 0 ) { - type_ = type; - text_str_ = text_str; + text_str_ = text_str; + type_ = type; } String Midi_text::str() const { - String str = "ff" + String_convert::i2hex_str( type_, 2, '0' ); - str = String_convert::hex2bin_str( str ); - str += i2varint_str( text_str_.length_i() ); - str += text_str_; - return str; + String str = "ff" + String_convert::i2hex_str( type_, 2, '0' ); + str = String_convert::hex2bin_str( str ); + str += i2varint_str( text_str_.length_i() ); + str += text_str_; + return str; } -Midi_track::Midi_track( ) +Midi_track::Midi_track() + : Midi_chunk() { // 4D 54 72 6B MTrk // 00 00 00 3B chunk length (59) diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index 83d8b7aa6c..38f462d760 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -37,13 +37,18 @@ Midi_stream::operator <<( String str ) str = String_convert::bin2hex_str( str ); *os_p_ << str; + + if ( check_debug ) + *os_p_ << "\n"; + return *this; } Midi_stream& Midi_stream::operator <<( Midi_item const& mitem_c_r ) { - mitem_c_r.output_midi( *this ); +// *this << mitem_c_r.str(); + mitem_c_r.output( this ); if ( check_debug ) *os_p_ << "\n"; return *this; diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 430e33c7c7..be234fcdd1 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -1,6 +1,8 @@ /* note-performer.cc -- implement Note_performer + source file of the GNU LilyPond music typesetter + (c) 1996, 1997 Jan Nieuwenhuizen */ @@ -8,7 +10,7 @@ #include "translator.hh" #include "input-translator.hh" #include "musical-request.hh" -#include "midi-item.hh" +#include "audio-item.hh" #include "debug.hh" IMPLEMENT_IS_TYPE_B1(Note_performer,Performer); @@ -29,34 +31,28 @@ void Note_performer::do_print() const { #ifndef NPRINT - if ( note_req_l_ ) + if ( note_req_l_ ) { note_req_l_->print(); + mtor << ( off_mom_ ? "on" : "off" ) << "\n"; + } #endif } void Note_performer::process_requests() { -// if ( when() == off_mom_ ) -// play_event( Note_event( current_l_->pitch() ) ); - -//Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo ) - // this is _really_ braindead, but it generates some output if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic() ) return; - // ugh, need to know channel (===track===staff) too - int channel_i = get_track_i(); + // ugh! Midi specific Moment mom = get_mom(); if ( !off_mom_ ) { // start note off_mom_ = mom + note_req_l_->duration(); - Midi_note n( note_req_l_->melodic(), channel_i, true ); - play_event( &n ); + play( new Audio_note( note_req_l_, true ) ); } - else if ( mom == off_mom_ ) { - Midi_note n( note_req_l_->melodic(), channel_i, false ); - play_event( &n ); + else if ( mom == off_mom_ ) { // stop note + play( new Audio_note( note_req_l_, false ) ); note_req_l_ = 0; off_mom_ = 0; } @@ -79,4 +75,3 @@ Note_performer::do_try_request( Request* req_l ) return true; } - diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index 55c5e18994..f465139920 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -1,6 +1,8 @@ /* performer-group-performer.cc -- implement Performer_group_performer + source file of the GNU LilyPond music typesetter + (c) 1996, 1997 Han-Wen Nienhuys Jan Nieuwenhuizen */ diff --git a/lily/performer.cc b/lily/performer.cc index 5e15fc53d6..246fc603e2 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -1,5 +1,7 @@ /* - performer.cc -- declare Performer + performer.cc -- implement Performer + + source file of the GNU LilyPond music typesetter (c) 1996, 1997 Han-Wen Nienhuys Jan Nieuwenhuizen @@ -34,9 +36,15 @@ Performer::get_mom() const } void -Performer::play_event( Midi_item* l ) +Performer::play( Audio_item* p ) +{ + daddy_perf_l_->play( p ); +} + +void +Performer::play( Midi_item* l ) { - daddy_perf_l_->play_event( l ); + daddy_perf_l_->play( l ); } int diff --git a/lily/score-performer.cc b/lily/score-performer.cc index df8ff16747..bb05c0f16a 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -1,6 +1,8 @@ /* score-performer.cc -- implement Score_performer + source file of the GNU LilyPond music typesetter + (c) 1996, 1997 Jan Nieuwenhuizen */ @@ -8,6 +10,9 @@ #include "score-performer.hh" #include "input-translator.hh" #include "midi-def.hh" +#include "audio-item.hh" +#include "audio-column.hh" +#include "audio-score.hh" #include "midi-item.hh" #include "midi-stream.hh" #include "string-convert.hh" @@ -47,16 +52,16 @@ Score_performer::finish() Performer_group_performer::do_removal_processing(); - Midi_stream output_stream( midi_l_->outfile_str_, midi_item_p_arr_.size() + 1, 384 ); + Midi_stream output_stream( midi_l_->outfile_str_, midi_item_l_arr_.size() + 1, 384 ); *mlog << "MIDI output to " << midi_l_->outfile_str_ << " ..." << endl; header( output_stream); - int track_i = 1; - for (int i=0; i< midi_item_p_arr_.size(); i++) { - Midi_item * it_p = midi_item_p_arr_[i]; +// int track_i = 1; + for (int i=0; i< midi_item_l_arr_.size(); i++) { + Midi_item * it_p = midi_item_l_arr_[i]; - if ( it_p->is_type_b( Midi_track::static_name())) - ((Midi_track*)it_p )->number_i_ = track_i ++; +// if ( it_p->is_type_b( Midi_track::static_name())) +// ((Midi_track*)it_p )->number_i_ = track_i ++; output_stream<< *it_p; } *output_stream.os_p_ << flush; @@ -64,9 +69,16 @@ Score_performer::finish() } void -Score_performer::play_event(Midi_item*m) +Score_performer::play( Audio_item* l ) +{ + l->audio_column_l_ = audio_column_l_; + audio_column_l_->add( l ); +} + +void +Score_performer::play( Midi_item* l ) { - midi_item_p_arr_.push(m); + midi_item_l_arr_.push( l ); } Moment @@ -105,7 +117,7 @@ Score_performer::header(Midi_stream &output_stream) + String_convert::i2dec_str( 0, 0, '0' ) ); midi_track.add( Moment( 0 ), &track_name ); - Midi_tempo tempo ( get_tempo_i()); + Midi_tempo tempo ( get_tempo_i() ); midi_track.add( Moment(0), &tempo); output_stream << midi_track; @@ -115,6 +127,9 @@ void Score_performer::prepare( Moment m ) { now_mom_ = m; + audio_column_l_ = new Audio_column( m ); + + score_l_->audio_score_p_->add( audio_column_l_ ); } void diff --git a/lily/score.cc b/lily/score.cc index 861bf4b00f..729df8e020 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -17,6 +17,7 @@ #include "source-file.hh" #include "midi-output.hh" #include "midi-def.hh" +#include "audio-score.hh" #include "p-col.hh" #include "music-iterator.hh" #include "music.hh" @@ -27,6 +28,7 @@ extern String default_out_fn; Score::Score() { pscore_p_=0; + audio_score_p_ = 0; paper_p_ = 0; midi_p_ = 0; errorlevel_i_ = 0; @@ -44,6 +46,7 @@ Score::~Score() { delete music_p_; delete pscore_p_; + delete audio_score_p_; delete paper_p_; delete midi_p_; } @@ -89,6 +92,7 @@ Score::midi() return; *mlog << "\nCreating MIDI elements ..." << flush; + audio_score_p_ = new Audio_score( midi_p_ ); Global_translator* score_trans= midi_p_->get_global_translator_p(); run_translator( score_trans ); diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 0d94d87ae7..a1efbfcebc 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -1,7 +1,9 @@ /* staff-performer.cc -- implement Staff_performer - (c) 1996, 1997 Jan Nieuwenhuizen + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen */ @@ -10,6 +12,8 @@ #include "input-translator.hh" #include "debug.hh" #include "midi-def.hh" +#include "audio-column.hh" +#include "audio-item.hh" #include "midi-item.hh" #include "midi-stream.hh" #include "string.hh" @@ -21,31 +25,44 @@ ADD_THIS_PERFORMER(Staff_performer); Staff_performer::Staff_performer() { - midi_mom_ = 0; midi_track_p_ = new Midi_track; } + +Staff_performer::~Staff_performer() +{ + delete midi_track_p_; +} + void Staff_performer::do_creation_processing() { - header(); } void Staff_performer::do_removal_processing() { - Performer::play_event( midi_track_p_); -} + header(); -Staff_performer::~Staff_performer() -{ - delete midi_track_p_; + Moment midi_mom = 0; + for ( PCursor i( audio_item_p_list_ ); i.ok(); i++ ) { + Audio_item* l = *i; + Moment mom = l->audio_column_l_->at_mom(); + Moment delta_t = mom - midi_mom_ ; + midi_mom_ += delta_t; + Midi_item* p = l->midi_item_p(); + p->channel_i_ = track_i_; + midi_track_p_->add( delta_t, p ); + delete p; + } + + Performer::play( midi_track_p_ ); } void Staff_performer::header() { // set track name - Midi_text track_name( Midi_text::TRACK_NAME, instrument_str()); + Midi_text track_name( Midi_text::TRACK_NAME, instrument_str() ); midi_track_p_->add( Moment( 0 ), &track_name ); // set instrument description @@ -60,7 +77,7 @@ Staff_performer::header() Midi_instrument instrument( channel_i, instrument_str() ); midi_track_p_->add( Moment( 0 ), &instrument ); - Midi_tempo midi_tempo( get_tempo_i( ) ); + Midi_tempo midi_tempo( get_tempo_i() ); midi_track_p_->add( Moment( 0 ), &midi_tempo ); } @@ -71,12 +88,17 @@ Staff_performer::instrument_str() } void -Staff_performer::play_event( Midi_item* l ) +Staff_performer::play( Audio_item* p ) +{ + audio_item_p_list_.bottom().add( p ); + Performer::play( p ); +} + +// huh? +void +Staff_performer::play( Midi_item* p ) { - Moment mom = get_mom(); - Moment delta_t = mom - midi_mom_ ; - midi_mom_ += delta_t; - midi_track_p_->add( delta_t, l); + Performer::play( p ); } diff --git a/lily/template8.cc b/lily/template8.cc index bd33a49eb3..effc9ec539 100644 --- a/lily/template8.cc +++ b/lily/template8.cc @@ -1,5 +1,21 @@ +/* + template8.cc -- instantiate audio List classes + + source file of the GNU LilyPond music typesetter + + (c) 1996,1997 Han-Wen Nienhuys +*/ #include "proto.hh" #include "plist.hh" -#include "plist.tcc" +#include "audio-column.hh" +#include "audio-item.hh" +#include "cursor.tcc" +#include "list.tcc" #include "pcursor.tcc" +#include "plist.tcc" + + +IPL_instantiate(Audio_item); +IPL_instantiate(Audio_column); + diff --git a/mi2mu/Makefile b/mi2mu/Makefile index 84286dc182..bd430b8aa7 100644 --- a/mi2mu/Makefile +++ b/mi2mu/Makefile @@ -13,16 +13,20 @@ depth = .. # +# identify module: +# +NAME = mi2mu +MODULE_NAME = mi2mu +# + # generic variables: # include ./$(depth)/make/Variables.make include ./$(depth)/make/Files.make # -# identify module: +# versioning # -NAME = mi2mu -MODULE_NAME = mi2mu include $(mi2mu-dir)/VERSION build = $(mi2mu-dir)/$(outdir)/.build # diff --git a/mi2mu/lily-stream.cc b/mi2mu/lily-stream.cc index eeb3c14189..97fdcaab56 100644 --- a/mi2mu/lily-stream.cc +++ b/mi2mu/lily-stream.cc @@ -108,7 +108,7 @@ Lily_stream::header() *os_p_ << midi_parser_l_g->filename_str_; *os_p_ << "\n\n"; // ugh - *os_p_ << "\\version \"0.0.61\";\n"; + *os_p_ << "\\version \"0.1.0\";\n"; } /* snapnie: dit kan toch automaties? Zie ook dstream. -- 2.39.5