From 1fc7759a175ebcfcca4500d87b61e1133c318e6c Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:49:08 +0000 Subject: [PATCH] lilypond-0.0.77.jcn1 --- Documentation/mudela-man.doc | 151 ++++++++++++++++++----------------- lily/score-performer.cc | 74 ++++++++--------- 2 files changed, 113 insertions(+), 112 deletions(-) diff --git a/Documentation/mudela-man.doc b/Documentation/mudela-man.doc index f9405a5eee..c4e9c85398 100644 --- a/Documentation/mudela-man.doc +++ b/Documentation/mudela-man.doc @@ -14,22 +14,19 @@ \section{Introduction} This document describes the the GNU LilyPond input format, which is an -effective language for defining music. We call this language -(rather arrogantly) The Musical Definition Language (Mudela 0.1). - -[If anybody comes up with a better name, we'd gladly take -this. Gourlay already uses Musical Description Language, GSharp Score -Definition Language. We're not being original here] +effective language for defining music. We call this language (rather +arrogantly) The Musical Definition Language or Mudela, for +short.\footnote{If anybody comes up with a better name, we'd gladly + take this. Gourlay already uses Musical Description Language, + G-Sharp Score Definition Language. We're not being original here} The first aim of Mudela is to define a piece of music, being complete from both from a musical typesetting, as from a musical performing point of view. - -The Musical Definition Language (Mudela) version 2, has a logical -structure, making use of typing and naming (using identifiers), that -allows for flexible input, and definition reuse. See MANIFESTO for -reasons and design considerations. +The Musical Definition Language (Mudela), has a logical structure, +making use of identifiers, that allows for flexible input, and +definition reuse. See MANIFESTO for reasons and design considerations. The below included for explanatory purposes only (i.e., for a complete and up-to-date definition, see \file{lily/parser.y} and @@ -40,6 +37,8 @@ files, as this document does not cover every aspect of mudela yet, and may be out of date. +\section{Basic elements} + \subsection{Files} The de-facto extension of Mudela is \file{.ly}. Files may be included by @@ -52,8 +51,14 @@ entering \verb+include+ at the start of a line: \subsection{Comments} -Line comments are introduced by a \verb+%+. Block comments are delimited -by \verb+%{+ and \verb+%}+. They do not nest. +Line comments are introduced by a +\verb+%+. +Block comments are delimited +by +\verb+%{+ +and +\verb+%}+. +They do not nest. \subsection{Versions} @@ -75,7 +80,8 @@ alphabetic characters only. Identifiers in their normal form consist start with a backslash, a alpha character, followed by alpha-numerics. Identifiers can contain -any characters (except whitespace, \verb+$+ and \verb+%+), if you use this +any characters (except whitespace, +\verb+$+ and \verb+%+), if you use this construct: \begin{verbatim} @@ -283,7 +289,7 @@ error for this reason. \subsection{Slurs and Ties} -Ties connect the noteheads of adjecent notes. They are entered as follows: +Ties connect the noteheads of adjacent notes. They are entered as follows: \begin[fragment]{mudela} a4 ~ a4 @@ -348,7 +354,6 @@ octave, you can prevent having to type \verb+'+ all the time by using the \verb+\octave+ command: These two lines have the same pitch. \begin{verbatim} c'' d'' e'' c d e c d e - \octave c''; c d e ''c ''d ''e \octave c; c d e \end{verbatim} @@ -370,56 +375,73 @@ duration entry are bound together using an underscore He_could4 not4 \end{verbatim} -\subsection{ Music direction} +\section{Composition: forming bigger structures} -Mudela reads left to right, but you can still stack voices and -Voice\_elements which are produced in two directions: horizontal -(voice like) and vertical (chord like) +The previous examples tacitly assumed that a sequence of notes is +printed in a left to right manner. This is not entirely correct, you +will get the bigger picture in this section. -A note is a prime example of a Music-element is the note: -\begin{verbatim} -c4 -\end{verbatim} +In mathematics you can form expressions by combining expressions, +which are ultimately some kind of atom or terminal symbol. The same +goes for mudela: there are some basic building blocks, and by +combining those you create complex music. -If you enclose a sequence of Music-elements in braces ( { } ), then you form -another kind of Music-element (Voice) with those pieces +You can combine music in three ways: +\begin{itemize} +\item If you enclose a sequence of music-elements in braces ( \verb+{+ + and \verb+}+ ), then you form another kind of music called (Voice) with those pieces. + The duration of the Voice is the sum of the durations of its elements \begin{verbatim} - { c c g g a a g2 } % twinkle twinkle - { { c c g g} { a a g2 } } - - horOne = \melodic { c c g g } - horTwo = \melodic { a a g2 } - twinkle = \melodic { \horOne \horTwo } +{ c c g g a a g2 } % twinkle twinkle +{ { c c g g} { a a g2 } } \end{verbatim} - -You can stack Music-elements by enclosing a sequence Music-elements of -notes with < and >. Example: +\item You can stack music by enclosing a sequence of music elements + with \verb+<+ and \verb+>+. This is called a Chord. The duration of a Chord is + the union of the durations of its elements Example: \begin{verbatim} - % a-major chord + % a-major chord \end{verbatim} -You can also put vertical music inside horizontal music: +\item + You can form music by transposing music: \begin{verbatim} -{ c } % 4 increasing chords +\transpose + d % from c to the d that's one octave down + { e4 f4 } % the horizontal music \end{verbatim} -And vice versa +\end{itemize} + +Of course you can also combine these three mechanisms. \begin{verbatim} -< \multi 2; - {c c g g a a g2} - {r2 r2 c c g g a a g2} > % a canon +{ c } % 4 increasing chords \end{verbatim} -The duration of a chord equals the union of the durations of each of -its elements. The \verb+\multi 2+ is a construct which is explained -below. +The basic building block in Mudela is called Request. Examples of +Requests are: Timing (such as Meter), Rhythmic, Melodic, Note (which is a combination of +Rhythmic and Melodic), Musicscript (put an accent over a note or +rest), etc. For the actual up to date listing, you should consult the +LilyPond source code: the Request types form a big class hierarchy. -You can also create a Music-element by transposing a Music-element: +Normally you don't enter Requests directly, since that would be +tedious. Mudela has standard abbreviations for the most common +combination of Requests. If you enter \verb+c4+, this is an +abbreviation for: \begin{verbatim} -\transpose - d % from c to the d that's one octave down - { e4 f4 } % the horizontal music - +Request_chord{ + Note_req{ + notename: 0 acc: 0 oct: -1 + duration { 4} + } + Stem_req{ + duration { 4} + } +} \end{verbatim} +The \verb+Request_chord+ is a special kind of chord which only allows +Requests as its elements. The examples of the previous section were +processed with \verb+{+ and \verb+}+ enclosing the input. + + \subsection{Voicegroups} If more than one "voice" is in a staff, then you have the option of @@ -438,6 +460,8 @@ makes LilyPond try to form chords of all those lines. Putting different musical lines in to different voicegroups effectively makes LilyPond try to set those lines as independently as possible. +[adsolete. Has to be fixed in lily] + You can set the voicegroup of a voice with the command \verb+\group+, e.g., \begin{verbatim} oboeI = \melodic { @@ -460,6 +484,7 @@ You can set the voicegroup of a voice with the command \verb+\group+, e.g., \melodic { oboeII} } \end{verbatim} + In this example, the two oboe voices share one staff and are initially in the voicegroup called "oboes". They will share beams, dynamics etc. After two quavers, oboeI "pushes" its group: a new voicegroup is @@ -516,39 +541,19 @@ same syntax as grouping: \partial 16*3 4; \end{verbatim} -Make the piece start with a partial measure [transl?] lasting 1 3/4 -quaver. +Make the piece start with a partial measure [english translation?] +lasting 1 3/4 quaver. These commands are also "voice elements", and constitute simple mudela (consisting of stuff with duration 0). -\section{STRUCTURE} - -In concrete, a piece of Mudela has the following structure: -\begin{verbatim} -% declare pieces of music: - melody = \music{ } - accompany = \music{ } - - % instantiate (=create tex, midi output) the score: - \score{ - \melodic < - \multi 3; - \melody - \accompany - > - \midi{ } - \paper{ } -} -\end{verbatim} - \subsection{Examples} Examples are included with the GNU LilyPond distribution. For the sake of maintenance no long examples are included in this document. -\section{HISTORY} +\section{History} This language has a number of roots. First and foremost, GNU LilyPond's predecessor mpp was the inspiration of simple Mudela. Secondly, the diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 2e38539646..0ff49514e0 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -18,18 +18,15 @@ #include "source.hh" IMPLEMENT_IS_TYPE_B1(Score_performer,Performer_group_performer); -IMPLEMENT_STATIC_NAME(Score_performer); ADD_THIS_PERFORMER(Score_performer); Score_performer::Score_performer() { - midi_stream_p_ = 0; midi_l_ = 0; } Score_performer::~Score_performer() { - delete midi_stream_p_; } Translator* @@ -47,13 +44,30 @@ Score_performer::depth_i() const void Score_performer::finish() { + Performer_group_performer::do_removal_processing(); + + + Midi_stream output_stream( midi_l_->outfile_str_, midi_item_p_arr_.size() + 1, 384 ); *mlog << "MIDI output to " << midi_l_->outfile_str_ << " ..." << endl; - *mlog << "tracks: "; - header(); - Performer_group_performer::midi_output( midi_stream_p_ ); + + 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]; + + if ( it_p->is_type_b( Midi_track::static_name())) + ((Midi_track*)it_p )->number_i_ = track_i ++; + output_stream<< *it_p; + } *mlog << endl; } +void +Score_performer::play_event(Midi_item*m) +{ + midi_item_p_arr_.push(m); +} + Moment Score_performer::get_mom() const { @@ -61,10 +75,9 @@ Score_performer::get_mom() const } void -Score_performer::header() +Score_performer::header(Midi_stream &output_stream) { - int track_i = 0; - Midi_track midi_track( track_i ); + Midi_track midi_track; time_t t = time( 0 ); @@ -74,38 +87,24 @@ Score_performer::header() Midi_text creator( Midi_text::TEXT, str ); midi_track.add( Moment( 0 ), &creator ); - str = "Generated, at "; + str = "Automatically generated at "; str += ctime( &t ); str = str.left_str( str.length_i() - 1 ); - str += ",\n"; + str += "\n"; Midi_text generate( Midi_text::TEXT, str ); midi_track.add( Moment( 0 ), &generate ); str = "from musical definition: "; -#if 0 - Source_file* sourcefile_l = source_l_g->sourcefile_l( score_l_->defined_ch_C_ ); - if ( sourcefile_l ) - str += sourcefile_l->name_str(); -#elif 1 + str += score_l_->location_str(); -#else - str += score_l_-> -#endif Midi_text from( Midi_text::TEXT, str ); midi_track.add( Moment( 0 ), &from ); - // set track name - Midi_text track_name( Midi_text::TRACK_NAME, "Track " + String_convert::i2dec_str( 0, 0, '0' ) ); + Midi_text track_name( Midi_text::TRACK_NAME, "Track " + + String_convert::i2dec_str( 0, 0, '0' ) ); midi_track.add( Moment( 0 ), &track_name ); - // ugh, to please lily when reparsing mi2mu output. - // lily currently barfs when no meter present. - /* are you sure? init is to 4/4 HWN */ - Midi_time midi_time( 4, 4, 18 ); - midi_track.add( Moment( 0.0 ), &midi_time ); - - *mlog << "[" << track_i << "]"; - *midi_stream_p_ << midi_track; + output_stream << midi_track; } void @@ -122,12 +121,8 @@ Score_performer::process() } void -Score_performer::set_score( Score* score_l ) +Score_performer::set_score(Score* score_l ) { - /* - why's there no start() when there's a finish()? - let's misuse this for start() - */ Global_translator::set_score( score_l ); midi_l_ = score_l->midi_p_; } @@ -135,12 +130,13 @@ Score_performer::set_score( Score* score_l ) void Score_performer::start() { - int track_i = 1; - Performer_group_performer::set_track( midi_l_, track_i ); - if ( midi_l_->outfile_str_ == "" ) midi_l_->outfile_str_ = default_out_fn + ".midi"; - - midi_stream_p_ = new Midi_stream( midi_l_->outfile_str_, track_i, 384 ); } + +int +Score_performer::get_tempo_i()const +{ + return midi_l_->get_tempo_i(Moment( 1, 4 )); +} -- 2.39.5