]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 0.0.74pre.jcn1: pats
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 10 Jul 1997 06:56:40 +0000 (08:56 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 10 Jul 1997 06:56:40 +0000 (08:56 +0200)
pl 74pre.jcn1
- oversimplified midi output thru performer hierarchy
- bf: Spanner::doprint

pl 72pre.jcn1
- naming fixes; some iter*() explicitations
        - removed acceptor.hh
- *performer*: second draft of midi (audio/...)

46 files changed:
.dstreamrc
.version
BUGS
NEWS
flower/include/iterate.hh
init/midi.ini [new file with mode: 0644]
init/performer.ini [new file with mode: 0644]
init/symbol.ini
lily/.version
lily/engraver-group.cc
lily/engraver.cc
lily/global-performers.cc [new file with mode: 0644]
lily/identifier.cc
lily/include/acceptor.hh
lily/include/engraver-group.hh
lily/include/global-performers.hh [new file with mode: 0644]
lily/include/global-translator.hh
lily/include/identifier.hh
lily/include/input-translator.hh
lily/include/lily-proto.hh
lily/include/lyric-performer.hh [new file with mode: 0644]
lily/include/midi-def.hh
lily/include/my-lily-parser.hh
lily/include/note-performer.hh [new file with mode: 0644]
lily/include/performer-group-performer.hh [new file with mode: 0644]
lily/include/performer.hh [new file with mode: 0644]
lily/include/score-performer.hh [new file with mode: 0644]
lily/include/score.hh
lily/include/staff-performer.hh [new file with mode: 0644]
lily/include/voice-group-performer.hh [new file with mode: 0644]
lily/input-translator.cc
lily/lyric-performer.cc [new file with mode: 0644]
lily/midi-def.cc
lily/music-iterator.cc
lily/my-lily-lexer.cc
lily/note-performer.cc [new file with mode: 0644]
lily/parser.y
lily/performer-group-performer.cc [new file with mode: 0644]
lily/performer.cc [new file with mode: 0644]
lily/score-grav.cc
lily/score-performer.cc [new file with mode: 0644]
lily/score.cc
lily/spanner.cc
lily/staff-performer.cc [new file with mode: 0644]
lily/template6.cc
lily/voice-group-performer.cc [new file with mode: 0644]

index 321a61888aca5312c08531b26b459bc58ebdeaf9..cb3e8bbcbe8e85080e0cd277db9f7635baf42ad0 100644 (file)
@@ -3,53 +3,87 @@ Dstream                       1
 
 File_path              1
 My_lily_lexer          1
-PCol                   0
-Score_column           0
-Ineq_constrained_qp    0
-Spacing_problem        0
-Colinfo                        0
-Mixed_qp               0
-PScore                 0
-Idealspacing           0
+PCol                   1
+Score_column           1
+Script_column          1
+# E l b e ment? search/replace typo
+Elbement_group         1
+Ineq_constrained_qp    1
+Spacing_problem        1
+Colinfo                        1
+Mixed_qp               1
+PScore                 1
+Idealspacing           1
 
 # yydebug
-InitParser             0
-Parser                 0
-InitDeclarations       0
+InitParser             1
+Parser                 1
+InitDeclarations       1
 Declarations           1
 # FlexLexer debug
 InitLexer              1
 Lexer                  1
+Matrix                 1
 
-parse_duration         0
-parse_pitchmod         0
-Col_configuration      0
-Request                        0
-Note_req               0
-Rhythmic_req           0
-Rest_req               0
-delete_identifiers     0
-Command                        0
-Staff_commands         0
-Stem                   0
-Staff                  0
-Score                  0
-Voice                  0
-Voice_element          0
-Input_cursor           0
-Commands_at            0
-Input_command          0
-Time_description       0
-Melodic_req            0
-Midi_walker            0
-Stem_req               0
-Group_change_req       0
-Script_req             0
-Colinfo                        0
-Word_wrap              0
-Text_req               0
-Script_def             0
-Text_def               0
-Paperdef               0
+parse_duration         1
+parse_pitchmod         1
+Col_configuration      1
+Request                        1
+Note_req               1
+Rhythmic_req           1
+Rest_req               1
+delete_identifiers     1
+Command                        1
+Staff_commands         1
+Stem                   1
+Staff                  1
+Score                  1
+Voice                  1
+Voice_element          1
+Spanner                        1
+Atom                   1
+Change_iterator                1
+Chord_iterator         1
+Music_iterator         1
+Request_iterator       1
+Score_performer                0
+Voice_element_iterator  1
+Voice_iterator         1
+Chord                  1
+Collision              1
+Rest_collision         1
+Stem                   1
+Key_item               1
+Clef_item              1
+Bar                    1
+Slur                   1
+Music                  1
+Paper_def              1
+Lookup                 1
+Input_translator       1
+Score_elem             1
+Item                   1
+Note_head              1
+Engraver               1
+Score_engraver         1
+Staff_engravers                1
+Engraver_group_engraver 1
+Input_cursor           1
+Commands_at            1
+Input_command          1
+Time_description       1
+Melodic_req            1
+Midi_walker            1
+Note_performer         0
+Performer              0
+Stem_req               1
+Group_change_req       1
+Script_req             1
+Colinfo                        1
+Word_wrap              1
+Text_req               1
+Script_def             1
+Text_def               1
+Paperdef               1
 Symtable               1
 Symtables              1
index 62907006a88eca04a3b92ef54806dea3a9ccc9e6..ef1a72985016861f51f2b263420d1535de40c832 100644 (file)
--- a/.version
+++ b/.version
@@ -4,4 +4,4 @@ TOPLEVEL_PATCH_LEVEL = 74
 # use to send patches, always empty for released version:
 # include separator: ".postfix", "-pl" makes rpm barf
 
-TOPLEVEL_MY_PATCH_LEVEL = pre
+TOPLEVEL_MY_PATCH_LEVEL = pre.jcn1
diff --git a/BUGS b/BUGS
index ab3880a17e2102a0a1db11fa314d0b31e2a2c0a8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1,11 +0,0 @@
-This file documents bugs which were "re-introduced" in various pl's
-
-pl69
-       * slurs.ly
-
-pl68:
-       * opening rests wohltemperirt
-       
-       * lyrics broken,
-
-       * midi broken
diff --git a/NEWS b/NEWS
index 802481261242cd82d023f055e4d443c0eb2352b3..cd728f5bdfa0759f7f96960d99e56c38c44fec0e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+pl 74pre.jcn1
+       - oversimplified midi output thru performer hierarchy
+       - bf: Spanner::doprint
+
+pl 72pre.jcn1
+       - naming fixes; some iter*() explicitations
+        - removed acceptor.hh
+       - *performer*: second draft of midi (audio/...)
+
 pl 74pre
        - Input_engraver -> Input_translator
        - bf: span start/stop is now a "used" col.
index 9aee1ec550641c7ca1ed0b7f08e0398bf28e5c58..74e6ff202c7ed09e4051bc7594a3d941a707ccf6 100644 (file)
 #ifndef ITERATE_HH
 #define ITERATE_HH
 
-
+/*
+ ugh.
+ jcn: kjoet.
+      if we wouldn't have had this, things might have been 
+      just a little bit easier to read, imho.
+      (it does save quite some disk space, though)
+ */
 
 #define iterator(set)          typeof((set).top())
 #define iterator_bot(set)              typeof((set).bottom())
diff --git a/init/midi.ini b/init/midi.ini
new file mode 100644 (file)
index 0000000..29f4c2d
--- /dev/null
@@ -0,0 +1,5 @@
+
+default_midi = \midi {
+        \tempo 4:60;
+       \include "performer.ini"
+}
diff --git a/init/performer.ini b/init/performer.ini
new file mode 100644 (file)
index 0000000..6c77837
--- /dev/null
@@ -0,0 +1,28 @@
+%
+% setup for Request->Element conversion. Guru-only
+%
+
+% nice to have, but let's first get some output
+
+\requesttranslator {
+       Performer "Score_performer"
+       \alias "Score";
+%      \consists "Clef_performer";
+%      \consists "Key_performer";
+%      \consists "Meter_performer";
+%      \consists "Tempo_performer";
+
+       \contains\requesttranslator {
+               Performer "Staff_performer"
+               \alias "Midi";
+               \contains\requesttranslator{
+                       Performer "Voice_group_performer"
+                       \alias "Voice_group";
+                       \contains\requesttranslator{
+                               Performer "Performer_group_performer"
+                               \consists "Lyric_performer";
+                               \consists "Note_performer";
+                       }
+               }
+       }
+}
index 2c26af1cc53aba18ccd875b79ac377b68a8a46e8..77f7fdd5f6c2b9e671a40ae8e671bc7607039b25 100644 (file)
@@ -5,6 +5,9 @@
 \include "script.ini"
 \include "paper16.ini"
 
+% ugh
+\include "midi.ini"
+
 left = -1
 right = 1
 up = 1
index e6694dfa00e4edf6453cdb44d7a7f94a176ba240..3175b2b620cc2c01cd09e0bd992d92f427bb4c68 100644 (file)
@@ -4,4 +4,4 @@ PATCH_LEVEL = 74
 # use to send patches, always empty for released version:
 # include separator: ".postfix", "-pl" makes rpm barf
 
-MY_PATCH_LEVEL = pre
+MY_PATCH_LEVEL = pre.jcn1
index f876bf2605f5928fa60a220e866d1c45b644109d..224a86ac4fd13dfbc55ff99b5a164c27fe996211 100644 (file)
@@ -48,7 +48,8 @@ Engraver_group_engraver::Engraver_group_engraver()
 void
 Engraver_group_engraver::set_feature(Feature d)
 {
-    iter_top(grav_list_, i);
+    PCursor<Engraver*> i(grav_list_.top());
+    // why the while construct?
     while (i.ok()) {
        // this construction to ensure clean deletion
        Engraver *grav_l = i++; 
@@ -59,9 +60,8 @@ Engraver_group_engraver::set_feature(Feature d)
 void
 Engraver_group_engraver::sync_features()
 {
-    iter_top(grav_list_, i);
+    PCursor<Engraver*> i(grav_list_.top());
     while (i.ok()) {
-
        Engraver *grav_l = i++; 
        grav_l->sync_features();
     }
@@ -70,9 +70,8 @@ Engraver_group_engraver::sync_features()
 void
 Engraver_group_engraver::do_pre_move_processing()
 {
-    iter_top(grav_list_, i);
+    PCursor<Engraver*> i(grav_list_.top());
     while (i.ok()) {
-       
        Engraver *grav_l = i++; 
        grav_l->pre_move_processing();
     }
@@ -81,9 +80,8 @@ Engraver_group_engraver::do_pre_move_processing()
 void
 Engraver_group_engraver::do_process_requests()
 {
-    iter_top(grav_list_, i);
+    PCursor<Engraver*> i(grav_list_.top());
     while (i.ok()) {
-       
        Engraver *grav_l = i++; 
        grav_l->process_requests();
     }
@@ -93,7 +91,7 @@ Engraver_group_engraver::do_process_requests()
 void
 Engraver_group_engraver::do_post_move_processing()
 {
-    iter_top(grav_list_, i);
+    PCursor<Engraver*> i(grav_list_.top());
     while (i.ok()) {
                // this construction to ensure clean deletion
        Engraver *grav_l = i++; 
@@ -109,8 +107,8 @@ Engraver_group_engraver::contains_b(Engraver* grav_l)const
     
     if (parent_b)
        return true;
-    for (iter_top(grav_list_, j); j.ok(); j++)
-       if (j->contains_b(grav_l))
+    for (PCursor<Engraver*> i(grav_list_.top()); i.ok(); i++)
+       if (i->contains_b(grav_l))
            return true;
     return false;
 }
@@ -153,7 +151,7 @@ Engraver_group_engraver::remove_engraver_p(Engraver*grav_l)
 {
     group_l_arr_.substitute((Engraver_group_engraver*)grav_l,0);
     nongroup_l_arr_.substitute(grav_l,0);
-    iterator(grav_list_) grav_cur= grav_list_.find(grav_l);
+    PCursor<Engraver*> grav_cur( grav_list_.find(grav_l) );
     
     return grav_cur.remove_p();
 }
@@ -177,7 +175,7 @@ Engraver_group_engraver::do_print()const
 {
 #ifndef NPRINT
     mtor << "ID: " << id_str_ << "\n";
-    for (iter_top(grav_list_, i); i.ok(); i++) 
+    for (PCursor<Engraver*> i(grav_list_.top()); i.ok(); i++)
        i->print();
 #endif
 }
@@ -273,7 +271,7 @@ Engraver_group_engraver::do_announces()
 void
 Engraver_group_engraver::do_removal_processing()
 {
-    for (iter( grav_list_.top(), i); i.ok(); i++)
+    for (PCursor<Engraver*> i(grav_list_.top()); i.ok(); i++)
        i->do_removal_processing();
 }
 
index 29027f4deace92fe15b9053b28d4fd3db93c886a..d524de63d5d5b7529b750a7631d450a67e15afa7 100644 (file)
@@ -130,8 +130,7 @@ IMPLEMENT_STATIC_NAME(Engraver);
 IMPLEMENT_IS_TYPE_B(Engraver);
 
 void
-Engraver::do_print()const
+Engraver::do_print() const
 {
 }
 
-
diff --git a/lily/global-performers.cc b/lily/global-performers.cc
new file mode 100644 (file)
index 0000000..274a0d7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+  global-translators.cc -- implement 
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+           Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#include "proto.hh"
+#include "plist.hh"
+#include "input-translator.hh"
+#include "debug.hh"
+#include "performer.hh"
+
+struct Performer_table_entry {
+    String name_str_;
+    Perf_ctor ctor_l_;
+    Performer_table_entry(String s, Perf_ctor f) {
+       name_str_ =s;
+       ctor_l_ = f;
+    }
+    Performer_table_entry()
+    {
+       ctor_l_ =0;
+    }
+};
+
+static Array<Performer_table_entry> *perf_table=0;
+
+void
+add_Performer(String s, Perf_ctor f)
+{
+    if (!perf_table)
+       perf_table = new Array<Performer_table_entry>;
+    
+    perf_table->push(Performer_table_entry(s, f));
+}
+
+
+Performer*
+get_performer_p(String s)
+{
+    for (int i=0; i < perf_table->size(); i++) {
+       if ((*perf_table)[i].name_str_ == s)
+           return (*(*perf_table)[i].ctor_l_)();
+    }
+    error("Unknown performer `" + s +"\'");
+    return 0;
+}
index 40c7e543e86c8dde801ac94034fe5112a099319c..b3b61794873c68db999f44b6a788a76f9f2f4c05 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include <assert.h>
+#include "midi-def.hh"
 #include "paper-def.hh"
 #include "score.hh"
 #include "identifier.hh"
@@ -67,6 +68,7 @@ DEFAULT_PRINT(Music_id,Music , music);
 DEFAULT_PRINT(Request_id, Request, request);
 DEFAULT_PRINT(Score_id, Score, score);
 DEFAULT_PRINT(Input_trans_id, Input_translator, itrans);
+DEFAULT_PRINT(Midi_def_id,Midi_def, mididef);
 DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef);
 
 void
@@ -120,6 +122,7 @@ implement_id_class(Music_id, Music, music);
 implement_id_class(Score_id, Score, score);
 implement_id_class(Request_id, Request, request);
 implement_id_class(Input_trans_id, Input_translator, itrans);
+implement_id_class(Midi_def_id, Midi_def, mididef);
 implement_id_class(Paper_def_id, Paper_def, paperdef);
 
 Identifier::Identifier(Identifier const&)
@@ -136,4 +139,5 @@ virtual_accessor(Music_id, Music, music);
 default_accessor(Score_id, Score, score);
 virtual_accessor(Request_id, Request, request);
 default_accessor(Input_trans_id, Input_translator, itrans);
+default_accessor(Midi_def_id, Midi_def, mididef);
 default_accessor(Paper_def_id, Paper_def, paperdef);
index 872f374aee2478554c9491d4837f3759d8b8a04b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,41 +0,0 @@
-/*
-  acceptor.hh -- declare Translator
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef ACCEPTOR_HH
-#define ACCEPTOR_HH
-#error
-
-#include "string.hh"
-#include "lily-proto.hh"
-#include "interpreter.hh"
-#include "virtual-methods.hh"
-
-class Translator {
-public:
-    String id_str_;
-    
-    int iterator_count_;
-    
-    virtual Interpreter * interpreter_l() { return 0; }
-
-    /// Score_engraver = 0, Staff_engravers = 1, etc)
-    virtual int depth_i()const=0;
-    virtual Translator *find_get_translator_l(String name, String id)=0;
-    virtual Translator *ancestor_l(int l=1)=0;
-    virtual ~Translator(){}
-    NAME_MEMBERS();
-    Translator();
-    virtual Translator *get_default_interpreter()=0;
-};
-
-class Interpreter : public virtual Translator {
-public:
-    virtual bool interpret_request_b(Request*) { return false;}
-};
-#endif // ACCEPTOR_HH
index 8710ff53adbe73a1dbcc6c48f75e5753503b0a6f..4e468e9efd93ec1dfc89a6dc22ec8deea29b0fd8 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef ENGRAVERGROUP_HH
 #define ENGRAVERGROUP_HH
 
+#include "lily-proto.hh"
 #include "parray.hh"
 #include "plist.hh"
 #include "score-elem-info.hh"
diff --git a/lily/include/global-performers.hh b/lily/include/global-performers.hh
new file mode 100644 (file)
index 0000000..b3e6574
--- /dev/null
@@ -0,0 +1,33 @@
+
+/*
+  global-performers.hh -- declare global performer stuff
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#ifndef GLOBAL_PERFORMER_HH
+#define GLOBAL_PERFORMER_HH
+
+/**
+  A macro to automate administration of performers
+ */
+#define ADD_THIS_PERFORMER( c ) \
+struct c ## init { \
+    static Performer* globalctor () \
+    { \
+       return new c;\
+    } \
+    c ## init () \
+    { \
+       add_Performer( c::static_name(), globalctor ); \
+    } \
+} _ ## c ## init;
+
+// typedef Performer*(*Perf_ctor)(void); c++ ?
+typedef Performer*(*Perf_ctor)();
+void add_Performer(String s, Perf_ctor f);
+
+#endif // GLOBAL_PERFORMER_HH 
index 877020b10d462a0b5c7b7cb187338222e96ccd24..8344d3d898f9e4214690c2277e97800b4582c99e 100644 (file)
@@ -36,4 +36,4 @@ protected:
 
 
 
-#endif // Global_translator_HH
+#endif // GLOBAL_TRANSLATOR_HH
index 5a0d8d53955af681a66c801b54c86b1c8a7cfba2..ddcc32ccb4e640f114247597c8a63f21adc45335 100644 (file)
@@ -34,6 +34,7 @@ struct Identifier : public Input {
     IDACCESSOR(Input_translator, itrans)       
     IDACCESSOR(General_script_def, script)
     IDACCESSOR(Symtables, symtables)
+    IDACCESSOR(Midi_def, mididef)
     IDACCESSOR(Paper_def, paperdef)
     IDACCESSOR(Lookup,lookup)
     IDACCESSOR(Real,real)
@@ -68,4 +69,5 @@ declare_id_class(Score_id, Score, score);
 declare_id_class(Request_id, Request, request);
 declare_id_class(Input_trans_id, Input_translator, itrans);
 declare_id_class(Paper_def_id,Paper_def, paperdef);
+declare_id_class(Midi_def_id,Midi_def, mididef);
 #endif // IDENTIFIER_
index fa4790cbe83effdb81297a5161ceee4222d07b95..2ee65f0d8f3aa53176ad85ca51a35135e56d90f9 100644 (file)
@@ -37,7 +37,7 @@ struct Input_translator : Input {
     bool accepts_b(String);
     void print() const;
     Engraver_group_engraver * get_group_engraver_p();
-    //  Performer_group_performer * get_group_performer_p();
+    Performer_group_performer * get_group_performer_p();
     Input_translator * get_default_itrans_l();
     Input_translator * recursive_find(String nm);
     Input_translator * find_itrans_l(String nm);    
index 0dbc8f086392fb3dbb77138f1e90499d24b7544c..86573e000143fdf140809ee900cef06de501d5ac 100644 (file)
@@ -31,6 +31,7 @@ struct Chord;
 struct Clef_change_req;
 struct Clef_item;
 struct Clef_engraver;
+struct Clef_performer;
 struct Col_hpositions;
 struct Chord;
 struct Colinfo;
@@ -61,13 +62,14 @@ struct Idealspacing;
 struct Identifier;
 struct Interpreter;
 struct Input_file;
-struct Input_translator;
 struct Input_score;
+struct Input_translator;
 struct Item;
 struct Key;
 struct Key_change_req;
 struct Key_item;
 struct Key_engraver;
+struct Key_performer;
 struct Keyword;
 struct Keyword_table;
 struct Lily_stream;
@@ -85,6 +87,7 @@ struct Melodic_req;
 struct Meter;
 struct Meter_change_req;
 struct Meter_engraver;
+struct Meter_performer;
 struct Midi_def;
 struct Midi_duration;
 struct Midi_header;
@@ -105,6 +108,7 @@ struct Music_list;
 struct My_lily_parser;
 struct Note_column;
 struct Note_column_engraver;
+struct Note_performer;
 struct Note_req;
 struct Note_head;
 struct Note_head_engraver;
@@ -121,6 +125,8 @@ struct Pulk_voice;
 struct Pulk_voices;
 struct Rational;
 struct Engraver_group_engraver;
+struct Performer;
+struct Performer_group_performer;
 struct Request;
 struct Request_column;
 struct Engraver;
@@ -136,6 +142,7 @@ struct Score;
 struct Score_column;
 struct Score_elem;
 struct Score_elem_info;
+struct Score_performer;
 struct Script;
 struct Script_column;
 struct Script_def;
@@ -150,6 +157,7 @@ struct Spacing_req ;
 struct Span_dynamic_req;
 struct Span_req;
 struct Spanner;
+struct Staff_performer;
 struct Staff_side;
 struct Staff_symbol;
 struct Stem;
@@ -182,6 +190,7 @@ struct Vertical_align_element;
 struct Voice;
 struct Voice_element;
 struct Voice_group_engravers;
+struct Voice_group_performer;
 struct Voice_list;
 struct Voice_engravers;
 struct Voicegroup;
diff --git a/lily/include/lyric-performer.hh b/lily/include/lyric-performer.hh
new file mode 100644 (file)
index 0000000..3abb55b
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+  lyric-performer.hh -- declare Lyric_performer
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+           Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+
+#ifndef LYRIC_PERFOMER_HH
+#define LYRIC_PERFOMER_HH
+
+#include "lily-proto.hh"
+#include "performer.hh"
+#include "varray.hh"
+
+class Lyric_performer : public Performer {
+public:
+    NAME_MEMBERS();
+    Lyric_performer();
+    ~Lyric_performer();
+
+private:
+    Array<Lyric_req*> lreq_arr_;
+    virtual bool do_try_request(Request*);
+    virtual void do_process_requests();
+    virtual void do_post_move_processing();
+};
+
+#endif // LYRIC_PERFOMER_HH
index 9673783d25fed2cecd240c36ebd37f197d172e6d..13073251abf910b5fe3f45c70d38595134d9cfa6 100644 (file)
@@ -7,8 +7,8 @@
 */
 
 
-#ifndef MIDIDEF_HH
-#define MIDIDEF_HH
+#ifndef MIDI_DEF_HH
+#define MIDI_DEF_HH
 #include "lily-proto.hh"
 #include "real.hh"
 #include "string.hh"
@@ -25,18 +25,25 @@ struct Midi_def {
     /// output file name
     String outfile_str_;
 
+    Assoc<String, Real> *real_vars_p_;
+    Input_translator* itrans_p_;
+
     /// duration of whole note
     Real whole_seconds_f_;
 
     Midi_def();
-    Midi_def(Midi_def const& midi_c_r);
+    Midi_def( Midi_def const& midi_c_r );
     ~Midi_def();
 
     Real duration_to_seconds_f(Moment);
+    Global_translator* get_global_translator_p() const;
+    Real get_var( String s ) const;
     int get_tempo_i( Moment moment );
-    void set_tempo( Moment moment, int count_per_minute_i );
     void print() const;
+    void set( Input_translator* itrans_p );
+    void set_var( String s, Real r );
+    void set_tempo( Moment moment, int count_per_minute_i );
 };
 
-#endif // MIDIDEF_HH //
+#endif // MIDI_DEF_HH
 
index 5ecfd7d62c94577adfd6ba69e628b16415b35cc1..6c963824985e3b868182389a589325c1d309bf74 100644 (file)
@@ -55,6 +55,7 @@ public:
     Input pop_spot();
     
     Paper_def*default_paper();
+    Midi_def*default_midi();
     void do_yyparse();
     void parser_error(String);
     void clear_notenames();
diff --git a/lily/include/note-performer.hh b/lily/include/note-performer.hh
new file mode 100644 (file)
index 0000000..267deb1
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+  note-performer.hh -- declare Note_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#ifndef NOTE_PERFORMER_HH
+#define NOTE_PERFORMER_HH
+
+#include "performer.hh"
+
+/**
+*/
+
+class Note_performer : public Performer {
+public:
+    NAME_MEMBERS();
+
+    Note_performer();
+    ~Note_performer();
+
+    virtual void process_requests();
+    virtual bool /*do_*/try_request( Request *req_l ) ;
+
+protected:
+    virtual void do_print() const;
+
+#if 0
+    virtual void /*do_*/process_requests();
+    virtual void /*do_*/pre_move_processing();
+    virtual void /*do_*/post_move_processing();
+#endif
+
+private:
+    Melodic_req * note_req_l_;
+//    Rhythmic_req * note_req_l_;
+
+//    Melodic_req* current_l_;
+//    Moment off_mom_;
+//    Moment on_mom_;
+};
+
+#endif // NOTE_PERFORMER_HH
diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh
new file mode 100644 (file)
index 0000000..7219de0
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+  performer-group-performer.hh -- declare Performer_group_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#ifndef PERFORMER_GROUP_PERFORMER_HH
+#define PERFORMER_GROUP_PERFORMER_HH
+
+#include "lily-proto.hh"
+#include "parray.hh"
+#include "plist.hh"
+#include "performer.hh"
+#include "translator.hh"
+
+/**
+  Group a number of performers. Usually delegates everything to its contents.
+*/
+
+class Performer_group_performer : public Performer, public virtual Translator {
+public:
+    NAME_MEMBERS();
+    Input_translator* itrans_l_;
+
+    Performer_group_performer();
+    ~Performer_group_performer();
+
+    bool is_bottom_performer_b() const;
+    virtual Performer_group_performer* find_performer_l( String name, String id );
+    
+    virtual void add( Performer* perf_p );
+    virtual bool try_request( Request* req_l );
+
+    virtual Translator* find_get_translator_l( String name, String id );
+    virtual Translator* get_default_interpreter();
+
+    Translator * ancestor_l( int l = 1 );
+    int depth_i() const;
+
+    void process_requests();
+
+private:
+    Pointer_list<Performer*> perf_p_list_;
+    
+    Link_array<Performer_group_performer> group_l_arr_;
+    Link_array<Performer> nongroup_l_arr_;
+};
+
+#endif // PERFORMER_GROUP_PERFORMER_HH
+
diff --git a/lily/include/performer.hh b/lily/include/performer.hh
new file mode 100644 (file)
index 0000000..356b0c9
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+  performer.hh -- declare Performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#ifndef PERFORMER_HH
+#define PERFORMER_HH
+
+#include "lily-proto.hh"
+#include "varray.hh"
+#include "request.hh"
+#include "score-elem-info.hh"
+#include "staff-info.hh"
+
+class Performer {
+public:
+    NAME_MEMBERS();
+    Performer_group_performer* daddy_perf_l_;
+
+    Performer();
+    virtual ~Performer();
+
+    void print() const;
+    virtual void process_requests();
+    virtual bool try_request( Request* req_l );
+
+protected:
+    virtual void do_print() const;
+    virtual void play_event( Midi_item* l );
+};
+
+#include "global-performers.hh"
+
+#endif // PERFORMER_HH
diff --git a/lily/include/score-performer.hh b/lily/include/score-performer.hh
new file mode 100644 (file)
index 0000000..980bbaa
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+  score-performer.hh -- declare Score_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#ifndef SCORE_PERFORMER_HH
+#define SCORE_PERFORMER_HH
+
+#include "performer-group-performer.hh"
+#include "global-translator.hh"
+
+class Score_performer: 
+    public Performer_group_performer, public Global_translator 
+{
+public:
+    NAME_MEMBERS();
+    Score_performer();
+    ~Score_performer();
+
+protected:
+    virtual Translator* ancestor_l( int l );
+    virtual int depth_i() const;
+
+    virtual void play_event( Midi_item* l );
+    virtual void prepare( Moment mom );
+    virtual void process();
+
+private:
+    Midi_stream* midi_stream_p_;
+    Moment prev_mom_;
+    Moment now_mom_;
+};
+
+#endif // SCORE_PERFORMER_HH
index b11118f17fc43bd2271fa68c79a0e37296f67a8e..15486e2aaaf333e0e044cba11110825659eb1064 100644 (file)
@@ -62,7 +62,9 @@ public:
 
 private:
     void run_translator(Global_translator*);
+    void midi_output();
     void paper_output();
+
     /// do midi stuff
     void midi();
 
diff --git a/lily/include/staff-performer.hh b/lily/include/staff-performer.hh
new file mode 100644 (file)
index 0000000..cf1eb20
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+  staff-performer.hh -- declare Staff_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#ifndef STAFF_PERFORMER_HH
+#define STAFF_PERFORMER_HH
+
+#include "performer-group-performer.hh"
+
+class Staff_performer : public Performer_group_performer 
+{
+public:
+    NAME_MEMBERS();
+
+    Staff_performer();
+    ~Staff_performer();
+
+    String instrument_str();
+
+protected:
+    virtual void play_event( Midi_item* l );
+
+private:
+    int midi_track_i_;
+};
+
+#endif // STAFF_PERFORMER_HH
diff --git a/lily/include/voice-group-performer.hh b/lily/include/voice-group-performer.hh
new file mode 100644 (file)
index 0000000..1a7efee
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+  voice-group-performer.hh -- declare Voice_group_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#ifndef VOICE_GROUP_PERFORMER_HH
+#define VOICE_GROUP_PERFORMER_HH
+
+#include "performer-group-performer.hh"
+
+#if 0
+class Voice_performer_group_performer : public Performer_group_performer {
+public:
+    Voice_performer_
+
+};
+
+#endif
+
+class Voice_group_performer : public Performer_group_performer {
+public:
+    NAME_MEMBERS();
+
+    Voice_group_performer();
+    ~Voice_group_performer();
+
+private:
+};
+
+
+#if 0
+class Voice_performer : 
+       public Performer_group_performer, public Interpreter 
+{
+    
+};
+#endif
+
+#endif // VOICE_GROUP_PERFORMER_HH
index a90325bd5e0a387d8b7ce92c44e530afc87f56b2..1a652794a8f502b412cf326477b3f7c844c1df98 100644 (file)
@@ -13,6 +13,7 @@
 #include "parray.hh"
 #include "input-translator.hh"
 #include "engraver-group.hh"
+#include "performer-group-performer.hh"
 
 bool
 Input_translator::is_name_b(String n)
@@ -33,7 +34,7 @@ Input_translator::print() const
        mtor << consists_str_arr_[i] << ',';
     if (contains_itrans_p_list_.size())
        mtor << "\nContains " ;
-    for (iter(contains_itrans_p_list_.top(), i); i.ok(); i++) 
+    for (PCursor<Input_translator*> i(contains_itrans_p_list_.top()); i.ok(); i++) 
        i->print();
     mtor << "}\n";
 #endif 
@@ -48,7 +49,8 @@ Input_translator::recursive_find(String nm)
        return this;
 
     Input_translator * r =0;
-    iter(contains_itrans_p_list_.top(), i);
+    // what bout for() ?
+    PCursor<Input_translator*> i(contains_itrans_p_list_.top());
     for (; !r &&i.ok(); i++) {
        if (i->recursive_find(nm))
            r = i.ptr();
@@ -60,7 +62,7 @@ Input_translator::recursive_find(String nm)
 Input_translator *
 Input_translator::find_itrans_l(String nm)
 {
-    for (iter(contains_itrans_p_list_.top(), i); i.ok(); i++)
+    for (PCursor<Input_translator*> i(contains_itrans_p_list_.top()); i.ok(); i++) 
        if (i->is_name_b( nm))
            return i;
 
@@ -83,22 +85,20 @@ Input_translator::get_group_engraver_p()
     return grav_p;
 }
 
-#if 0
 Performer_group_performer*
 Input_translator::get_group_performer_p()
 {    
     assert (base_str_ == "Performer");
-    Performer_group_performer * grav_p = (Performer_group_performer*)
+    Performer_group_performer * perf_p = (Performer_group_performer*)
        get_performer_p(type_str_);
 
     for (int i=0; i < consists_str_arr_.size(); i++) {
-       grav_p->add( get_performer_p( consists_str_arr_[i]) );
+       perf_p->add( get_performer_p( consists_str_arr_[i]) );
     }
-    grav_p->itrans_l_ = this;
-    grav_p->id_str_ = default_id_str_;
-    return grav_p;
+    perf_p->itrans_l_ = this;
+    perf_p->id_str_ = default_id_str_;
+    return perf_p;
 }
-#endif    
 
 bool
 Input_translator::accept_req_b()
diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc
new file mode 100644 (file)
index 0000000..aa24dca
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+  lyric-performer.cc -- implement Lyric_performer
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+           Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#include "lyric-performer.hh"
+#include "musical-request.hh"
+//#include "text-item.hh"
+//#include "paper-def.hh"
+//#include "lookup.hh"
+
+
+IMPLEMENT_STATIC_NAME(Lyric_performer);
+IMPLEMENT_IS_TYPE_B1(Lyric_performer,Performer);
+ADD_THIS_PERFORMER(Lyric_performer);
+
+Lyric_performer::Lyric_performer()
+{
+}
+
+Lyric_performer::~Lyric_performer()
+{
+}
+
+bool
+Lyric_performer::do_try_request( Request* req_l )
+{
+    Musical_req* m_l = req_l->musical();
+    if ( !m_l || ! m_l->lreq_l() ) 
+       return false;
+    lreq_arr_.push( m_l->lreq_l() );
+
+    return true;
+}
+
+void
+Lyric_performer::do_process_requests()
+{
+#if 0
+    Text_item * last_item_l =0;
+    for (int i=0; i < lreq_arr_.size(); i++) {
+       Text_item *lp = new Text_item(lreq_arr_[i]->tdef_p_ );
+       lp->dir_i_ = -1;
+       lp->fat_b_ = true;
+       if (last_item_l)
+           lp->add_support(last_item_l);
+       last_item_l = lp;
+       typeset_element(lp);
+    }
+#endif
+}
+
+void
+Lyric_performer::do_post_move_processing()
+{
+    lreq_arr_.set_size(0);
+}
+
index 2f703f01f8f3478bb9bc08f98de562544fd29f20..5e76d11805bda19dd57052a0f57671f0e779e7dd 100644 (file)
@@ -8,6 +8,10 @@
 #include <math.h>
 #include "misc.hh"
 #include "midi-def.hh"
+#include "input-translator.hh"
+#include "performer-group-performer.hh"
+#include "assoc-iter.hh"
+
 #include "debug.hh"
 
 // classes, alphasorted
@@ -23,27 +27,48 @@ int Midi_def::num_i_s = 4;
 
 Midi_def::Midi_def()
 {
-    set_tempo( Moment( 1, 4 ), 60 );
     outfile_str_ = "lelie.midi"; 
+    itrans_p_ = 0;
+    real_vars_p_ = new Assoc<String,Real>;
+    // ugh
+    set_tempo( Moment( 1, 4 ), 60 );
 }
 
-Midi_def::Midi_def( Midi_def const& midi_c_r )
+Midi_def::Midi_def( Midi_def const& s )
 {
-    whole_seconds_f_ = midi_c_r.whole_seconds_f_;
-    outfile_str_ = midi_c_r.outfile_str_;
+    whole_seconds_f_ = s.whole_seconds_f_;
+    itrans_p_ = s.itrans_p_ ? new Input_translator( *s.itrans_p_ ) : 0;
+    real_vars_p_ = new Assoc<String,Real> ( *s.real_vars_p_ );
+    outfile_str_ = s.outfile_str_;
 }
 
 Midi_def::~Midi_def()
 {
+    delete itrans_p_;
+    delete real_vars_p_;
 }
 
 Real
-Midi_def::duration_to_seconds_f( Moment moment )
+Midi_def::duration_to_seconds_f( Moment mom )
 {
-    if (!moment)
+    if ( !mom )
        return 0;
     
-    return Moment( whole_seconds_f_ ) * moment;
+    return Moment( whole_seconds_f_ ) * mom;
+}
+
+Global_translator*
+Midi_def::get_global_translator_p() const
+{
+    return  itrans_p_->get_group_performer_p()->global_l();
+}
+
+Real
+Midi_def::get_var( String s ) const
+{
+    if ( !real_vars_p_->elt_b( s ) )
+       error ( "unknown midi variable `"  + s + "'" );
+    return real_vars_p_->elem( s );
 }
 
 int
@@ -56,14 +81,32 @@ void
 Midi_def::print() const
 {
 #ifndef NPRINT
-    mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
+    mtor << "Midi {";
+    mtor << "4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
     mtor << "out: " << outfile_str_;
+    for (Assoc_iter<String,Real> i( *real_vars_p_ ); i.ok(); i++) {
+       mtor << i.key() << "= " << i.val() << "\n";
+    }
     mtor << "}\n";
 #endif
 }
 
+void
+Midi_def::set( Input_translator* itrans_p )
+{
+    delete itrans_p_;
+    itrans_p_ = itrans_p;
+}
+
 void
 Midi_def::set_tempo( Moment moment, int count_per_minute_i )
 {
     whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment;
 }
+
+void
+Midi_def::set_var( String s, Real r )
+{
+   real_vars_p_->elem( s ) = r;
+}
+
index 38cfd02349f56266dc6f92b483a2f5883bb6875e..33e6b2cdb60ed8c4230997f6dde5b11a42db488a 100644 (file)
@@ -167,9 +167,9 @@ Chord_iterator::Chord_iterator(Chord const *chord_C)
 void
 Chord_iterator::construct_children()
 {
-    int j =0;
-    for(iter(chord_C_->music_p_list_.top(), i); i.ok(); j++, i++) {
-       
+    int j = 0;
+    for(PCursor<Music*> i(chord_C_->music_p_list_.top());  //, int j = 0; 
+       i.ok(); j++, i++) {
        Music_iterator * mi =  get_iterator_p( i.ptr());
        set_translator(mi->report_to_l()->ancestor_l( chord_C_->multi_level_i_ ));
        if ( mi->ok() )
@@ -182,16 +182,16 @@ void
 Chord_iterator::do_print() const
 {
 #ifndef NPRINT
-     for (iter(children_p_list_.top(), i); i.ok(); i++ ) {
+    for (PCursor<Music_iterator*> i(children_p_list_.top()); i.ok(); i++) {
        i->print();
-     }
+    }
 #endif
 }
 
 void
 Chord_iterator::process_and_next(Moment until)
 {
-    for (iter(children_p_list_.top(), i); i.ok(); ) {
+    for (PCursor<Music_iterator*> i(children_p_list_.top()); i.ok(); ) {
        if  (i->next_moment() == until) {
            i->process_and_next(until);
        }
@@ -212,7 +212,7 @@ Moment
 Chord_iterator::next_moment()const
 {
     Moment next_ = INFTY;
-    for (iter(children_p_list_.top(), i); i.ok(); i++) 
+    for (PCursor<Music_iterator*> i(children_p_list_.top()); i.ok(); i++)
        next_ = next_ <? i->next_moment() ;
     return next_;
 }
index 9792102b5a3a7c96c9975f983b22a8bd180debb4..a67aac8a7608b9b5d42ab64afb2de3071eefba59 100644 (file)
@@ -38,7 +38,7 @@ static Keyword_ent the_key_tab[]={
     {"id", ID},
     {"in", IN_T},
     {"init_end", INIT_END},
-    {"requesttranslator", REQUESTENGRAVER},
+    {"requesttranslator", REQUESTTRANSLATOR},
     {"lyric", LYRIC},
     {"key", KEY},
     {"melodic" , MELODIC},
diff --git a/lily/note-performer.cc b/lily/note-performer.cc
new file mode 100644 (file)
index 0000000..03d53b1
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+  note-performer.cc -- implement Note_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#include "note-performer.hh"
+#include "translator.hh"
+#include "input-translator.hh"
+#include "musical-request.hh"
+#include "midi-item.hh"
+#include "debug.hh"
+
+IMPLEMENT_IS_TYPE_B1(Note_performer,Performer);
+IMPLEMENT_STATIC_NAME(Note_performer);
+ADD_THIS_PERFORMER(Note_performer);
+
+Note_performer::Note_performer()
+{
+    // is this what we want? 
+    // or do we need to cache/keep note until it has ended?
+    note_req_l_ = 0;
+}
+
+Note_performer::~Note_performer()
+{
+}
+
+void 
+Note_performer::do_print() const
+{
+#ifndef NPRINT
+    if ( note_req_l_ )
+       note_req_l_->print();
+#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() ) {
+       Midi_note n( note_req_l_->melodic(), 0, true  );
+       play_event( &n );
+    }
+    note_req_l_ = 0;
+}
+
+bool 
+Note_performer::try_request( Request* req_l )
+{
+    if ( note_req_l_ )
+       return false;
+    
+ // huh?
+//    if (req_l->musical() && (req_l->musical()->note() || req_l->musical()->rest()))
+//     note_req_l_ = req_l->musical()->rhythmic();
+    if ( req_l->musical() && req_l->musical()->note() )
+       note_req_l_ = req_l->musical()->melodic();
+    else
+       return false;
+
+    return true;
+}
+
index 27472489aff222c5da83b0460c3ccc901cdcb0af..2607a2ed089d0257fd3308ed8785aada8832c8b1 100644 (file)
@@ -1,6 +1,17 @@
 %{ // -*-Fundamental-*-
+
+/*
+  parser.y -- lily parser
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+           Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
 #include <iostream.h>
 
+// mmm
 #define MUDELA_VERSION "0.0.61"
 
 #include "script-def.hh"
@@ -47,7 +58,7 @@
     Chord * chord;
     Duration *duration;
     Identifier *id;    
-    Input_translator * iregs;
+    Input_translator* itrans;
     Music *music;
     Music_list *musiclist;
     Score *score;
@@ -106,7 +117,7 @@ yylex(YYSTYPE *s,  void * v_l)
 %token GEOMETRIC
 %token GROUPING
 %token GROUP
-%token REQUESTENGRAVER
+%token REQUESTTRANSLATOR
 %token HSHIFT
 %token IN_T
 %token ID
@@ -114,9 +125,9 @@ yylex(YYSTYPE *s,  void * v_l)
 %token LYRIC
 %token KEY
 %token MELODIC
+%token MIDI
 %token MELODIC_REQUEST
 %token METER
-%token MIDI
 %token MM_T
 %token MULTI
 %token NOTE
@@ -161,6 +172,7 @@ yylex(YYSTYPE *s,  void * v_l)
 %token <id>    REAL_IDENTIFIER
 %token <id>    INT_IDENTIFIER
 %token <id>    SCORE_IDENTIFIER
+%token <id>    MIDI_IDENTIFIER
 %token <id>    PAPER_IDENTIFIER
 %token <id>    REQUEST_IDENTIFIER
 %token <real>  REAL 
@@ -203,7 +215,7 @@ yylex(YYSTYPE *s,  void * v_l)
 %type <id>     old_identifier
 %type <symbol> symboldef
 %type <symtable>       symtable symtable_body
-%type <iregs>  input_translator_spec input_translator_spec_body
+%type <itrans> input_translator_spec input_translator_spec_body
 
 %left PRIORITY
 
@@ -288,6 +300,10 @@ declaration:
                $$ = new Paper_def_id(*$1, $3, PAPER_IDENTIFIER);
                delete $1;
        }
+       | declarable_identifier '=' midi_block {
+               $$ = new Midi_def_id(*$1, $3, MIDI_IDENTIFIER);
+               delete $1;
+       }
        | declarable_identifier '=' script_definition {
                $$ = new Script_id(*$1, $3, SCRIPT_IDENTIFIER);
                delete $1;
@@ -321,7 +337,7 @@ declaration:
 
 
 input_translator_spec:
-       REQUESTENGRAVER '{' input_translator_spec_body '}'
+       REQUESTTRANSLATOR '{' input_translator_spec_body '}'
                { $$ = $3; }
        ;
 
@@ -350,6 +366,7 @@ input_translator_spec_body:
                $$->add($3);
        }
        ;
+
 /*
        SCORE
 */
@@ -405,7 +422,7 @@ paper_block:
 
 paper_body:
        /* empty */                     {
-               $$ = THIS->default_paper();
+               $$ = THIS->default_paper(); // paper / video / engrave
        }
        | paper_body OUTPUT STRING ';'  { $$->outfile_str_ = *$3;
                delete $3;
@@ -434,8 +451,8 @@ midi_block:
        '{' midi_body '}'       { $$ = $3; }
        ;
 
-midi_body: 
-               $$ = new Midi_def; 
+midi_body: /* empty */                 {
+               $$ = THIS->default_midi(); // midi / audio / perform
        }
        | midi_body OUTPUT STRING ';'   { 
                $$->outfile_str_ = *$3; 
@@ -444,14 +461,14 @@ midi_body: {
        | midi_body TEMPO notemode_duration ':' int ';' {
                $$->set_tempo( $3->length(), $5 );
        }
+       | midi_body input_translator_spec       {
+               $$->set( $2 );
+       }
        | midi_body error {
 
        }
        ;
 
-
-
-
 /*
        MUSIC
 */
@@ -1068,3 +1085,10 @@ My_lily_parser::default_paper()
        return id ? id->paperdef(true) : new Paper_def ;
 }
 
+Midi_def*
+My_lily_parser::default_midi()
+{
+       Identifier *id = lexer_p_->lookup_identifier( "default_midi" );
+       return id ? id->mididef(true) : new Midi_def ;
+}
+
diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc
new file mode 100644 (file)
index 0000000..1f09116
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+  performer-group-performer.cc -- implement Performer_group_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#include "performer-group-performer.hh"
+#include "input-translator.hh"
+#include "debug.hh"
+
+IMPLEMENT_IS_TYPE_B2(Performer_group_performer,Performer, Translator);
+IMPLEMENT_STATIC_NAME(Performer_group_performer);
+ADD_THIS_PERFORMER(Performer_group_performer);
+
+Performer_group_performer::Performer_group_performer()
+{
+}
+
+Performer_group_performer::~Performer_group_performer()
+{
+}
+
+void
+Performer_group_performer::add( Performer *perf_p )
+{
+    perf_p_list_.bottom().add(perf_p);
+    perf_p->daddy_perf_l_ = this;
+
+    if (perf_p->is_type_b(Performer_group_performer::static_name())) {
+       group_l_arr_.push((Performer_group_performer*)perf_p);
+    } else {
+       nongroup_l_arr_ .push(perf_p);
+    }
+}
+
+Translator*
+Performer_group_performer::ancestor_l( int l )
+{
+    if (!l || !daddy_perf_l_)
+       return this;
+    
+    return daddy_perf_l_->ancestor_l( l - 1 );
+}
+
+int
+Performer_group_performer::depth_i() const
+{
+    return daddy_perf_l_->depth_i() + 1;
+}
+
+Translator*
+Performer_group_performer::find_get_translator_l( String n,String id )
+{
+    Translator * ret=0;
+    Input_translator* itrans_l= itrans_l_-> recursive_find ( n );
+    if (itrans_l ) {
+       ret = find_performer_l(n,id);
+       if (!ret) {
+           Performer_group_performer * group = 
+               itrans_l-> get_group_performer_p();
+           
+           add(group);
+           ret = group;
+           
+           if (group->itrans_l_->is_name_b( n ) )
+               ret ->id_str_ = id;
+           else
+               return ret->find_get_translator_l(n,id);
+
+       }
+    } else if (daddy_perf_l_)
+       ret =daddy_perf_l_->find_get_translator_l(n,id);
+    else {
+       warning("Can't find or create `" + n + "' called `" + id + "'\n");
+       ret =0;
+    }
+    return ret;
+}
+
+Performer_group_performer*
+Performer_group_performer::find_performer_l( String n, String id )
+{
+    if (name() == n && id_str_ == id)
+       return this;
+    Performer_group_performer * r = 0;
+    for (int i =0; !r && i<  group_l_arr_.size(); i++) {
+       r = group_l_arr_[i]->find_performer_l(n,id);
+    }
+    
+    return r;
+}
+
+Translator*
+Performer_group_performer::get_default_interpreter()
+{
+    // ? 
+    if ( is_bottom_performer_b() )
+       return daddy_perf_l_->get_default_interpreter();
+
+    Performer_group_performer *perf_p= itrans_l_->
+       get_default_itrans_l()->get_group_performer_p();
+    add(perf_p );
+    if (perf_p->is_bottom_performer_b())
+       return perf_p;
+    else
+       return perf_p->get_default_interpreter();
+}
+
+bool
+Performer_group_performer::is_bottom_performer_b() const
+{
+    return !itrans_l_->get_default_itrans_l();
+}
+
+void
+Performer_group_performer::process_requests()
+{
+    PCursor<Performer*> i( perf_p_list_.top() );
+    while( i.ok() ) {
+       Performer* perf_l = i++; 
+       perf_l->process_requests();
+    }
+}
+
+bool
+Performer_group_performer::try_request( Request* req_l )
+{
+//    return Performer::try_request( req_l );
+    bool hebbes_b =false;
+    for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++)
+       hebbes_b =nongroup_l_arr_[i]->try_request(req_l);
+//    if (!hebbes_b)
+    if ( !hebbes_b && daddy_perf_l_ )
+       hebbes_b = daddy_perf_l_->try_request(req_l);
+    return hebbes_b ;
+}
diff --git a/lily/performer.cc b/lily/performer.cc
new file mode 100644 (file)
index 0000000..9523fc3
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+  performer.cc -- declare Performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+
+#include "performer-group-performer.hh"
+#include "debug.hh"
+
+IMPLEMENT_STATIC_NAME(Performer);
+IMPLEMENT_IS_TYPE_B(Performer);
+
+Performer::Performer()
+{
+    daddy_perf_l_ = 0;
+}
+
+Performer::~Performer()
+{
+}
+
+void
+Performer::do_print() const
+{
+}
+
+void 
+Performer::play_event( Midi_item* l ) 
+{ 
+    daddy_perf_l_->play_event( l ); 
+}
+
+void
+Performer::print() const
+{
+#ifndef NPRINT
+    mtor << "\n" << name() << " {";
+//    do_print();
+    mtor << "}";
+#endif
+}
+
+void
+Performer::process_requests()
+{
+}
+
+bool 
+Performer::try_request( Request* req_l )
+{
+// huh?
+//    return daddy_perf_l_->try_request( req_l_ );
+    return false;
+}
+
index ee3b325a00b77fa2278e0591e06db7957fddf4a4..f837dba557e00f413b15ad71d6342bdbfa4b8c73 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  score-reg.cc -- implement Score_engraver
+  score-grav.cc -- implement Score_engraver
 
   source file of the GNU LilyPond music typesetter
 
diff --git a/lily/score-performer.cc b/lily/score-performer.cc
new file mode 100644 (file)
index 0000000..944f44e
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+  score-performer.cc -- implement Score_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+#include "score-performer.hh"
+#include "input-translator.hh"
+#include "midi-item.hh"
+#include "midi-stream.hh"
+#include "string-convert.hh"
+#include "debug.hh"
+
+IMPLEMENT_IS_TYPE_B1(Score_performer,Performer_group_performer);
+IMPLEMENT_STATIC_NAME(Score_performer);
+ADD_THIS_PERFORMER(Score_performer);
+
+Score_performer::Score_performer()
+{
+    // not so much ugh, as [todo]
+    *mlog << "MIDI output to " << "lelie.midi" << " ...\n";    
+    midi_stream_p_ = new Midi_stream( "lelie.midi", 
+        // don-t forget: extra track 0 for tempo/copyright stuff...
+       //score_l_->staffs_.size() + 1, 
+       1, 
+       384 );
+}
+
+Score_performer::~Score_performer()
+{
+    delete midi_stream_p_;
+}
+
+Translator* 
+Score_performer::ancestor_l( int l ) 
+{ 
+    return Global_translator::ancestor_l( l );
+}
+
+int 
+Score_performer::depth_i() const 
+{ 
+    return Global_translator::depth_i();
+}
+
+void 
+Score_performer::play_event( Midi_item* l )
+{
+//    file_p_->output( l );
+//    cerr << String_convert::bin2hex_str( l->str() );
+    // this should be done at staff level, 
+    // cached per staff probably.
+    // but it generates output...
+    *midi_stream_p_ << *l;
+}
+
+void 
+Score_performer::prepare( Moment m )
+{
+    now_mom_ = m;
+}
+
+void 
+Score_performer::process()
+{
+    process_requests();
+    prev_mom_ = now_mom_;
+}
+
index fd23b08522d8d1f82fcacc1eb38ddb51004002e5..320c752caf55a4c858be1df303ca53410a52824f 100644 (file)
@@ -60,8 +60,35 @@ void
 Score::process()
 {
     paper();
+    midi();
 }
 
+void
+Score::midi()
+{
+    if (!midi_p_)
+       return;
+    
+    *mlog << "\nCreating elements ..." << endl; //flush;
+//    pscore_p_ = new PScore(paper_p_);
+    
+    Global_translator* score_trans=  midi_p_->get_global_translator_p();
+    run_translator( score_trans );
+    delete score_trans;
+    
+    if( errorlevel_i_){
+       // should we? hampers debugging. 
+       warning("Errors found, /*not processing score*/");
+//     return;
+    }
+    print();
+    *mlog << endl;
+//    pscore_p_->process();
+
+    // output
+    midi_output();
+}
+    
 void
 Score::paper()
 {
@@ -93,7 +120,6 @@ Score::paper()
 
     // output
     paper_output();
-    
 }
 
 /**
@@ -219,7 +245,7 @@ Score::paper_output()
 }
 
 void
-Score::midi()
+Score::midi_output()
 {
 #if 0
     if (!midi_p_)
index f66aa494975353acd92fa4a379d11ac214e135a5..5cc28a1bd94d81301481d708ae2432d925482894 100644 (file)
@@ -18,8 +18,19 @@ void
 Spanner::do_print()const
 {
 #ifndef NPRINT
-    mtor << "Between col " << 
-       left_col_l_->rank_i() << ", " << right_col_l_->rank_i() ;
+    mtor << "Between col ";
+// huh? this does not work 
+//    mtor << ( left_col_l_ ? left_col_l_->rank_i() : "nop" );
+    if ( left_col_l_ )
+       mtor << left_col_l_->rank_i();
+    else 
+       mtor << "nop";
+    mtor << ", ";
+//    mtor << ( right_col_l_ ? right_col_l_->rank_i() : "nop" );
+    if ( right_col_l_ )
+       mtor << right_col_l_->rank_i();
+    else 
+       mtor << "nop";
     if (broken_into_l_arr_.size())
        mtor << "with broken pieces\n";
 #endif
diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc
new file mode 100644 (file)
index 0000000..1609a57
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+  staff-performer.cc -- implement Staff_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+
+#include "staff-performer.hh"
+#include "translator.hh"
+#include "input-translator.hh"
+#include "debug.hh"
+
+IMPLEMENT_STATIC_NAME(Staff_performer);
+IMPLEMENT_IS_TYPE_B1(Staff_performer,Performer_group_performer);
+ADD_THIS_PERFORMER(Staff_performer);
+
+Staff_performer::Staff_performer()
+{
+}
+
+Staff_performer::~Staff_performer()
+{
+}
+
+String 
+Staff_performer::instrument_str() 
+{ 
+    return Translator::id_str_; 
+}
+
+void 
+Staff_performer::play_event( Midi_item* l )
+{
+//    l.track_i_ = midi_track_i_;
+    Performer::play_event( l );
+}
+
index 2fbc12167998bf931c3c5aedb2fc4cc38e649753..38344df6000db2fb012485e3df97d87ddd6402ef 100644 (file)
@@ -1,5 +1,7 @@
 #include "proto.hh"
 #include "plist.tcc"
 #include "engraver.hh"
+#include "performer.hh"
 
 IPL_instantiate(Engraver);
+IPL_instantiate(Performer);
diff --git a/lily/voice-group-performer.cc b/lily/voice-group-performer.cc
new file mode 100644 (file)
index 0000000..ac5c6cb
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+  voice-group-performer.cc -- implement Voice_group_performer
+
+  (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+                 Jan Nieuwenhuizen <jan@digicash.com>
+ */
+
+
+#include "voice-group-performer.hh"
+#include "translator.hh"
+#include "input-translator.hh"
+#include "debug.hh"
+
+//IMPLEMENT_IS_TYPE_B2(Voice_group_performer,Performer, Translator);
+IMPLEMENT_IS_TYPE_B1(Voice_group_performer,Performer_group_performer);
+IMPLEMENT_STATIC_NAME(Voice_group_performer);
+ADD_THIS_PERFORMER(Voice_group_performer);
+
+Voice_group_performer::Voice_group_performer()
+{
+}
+
+Voice_group_performer::~Voice_group_performer()
+{
+}
+