+++ /dev/null
-#!/usr/bin/perl -w
-sub
- set_hrefs
-{
- while (<HTMLIN>) {
- s#href=([A-Za-z.]+)#href=$base/$1#g;
- print HTMLOUT $_;
- }
-}
-
-local $base="lilypond/";
-local @examples=("wohltemperirt");
-
-system 'pod2html';
-
-print "resetting refs.\n";
-
-foreach $a (<*.html>)
-{
- rename $a, "$a~";
- open HTMLIN, "$a~";
- open HTMLOUT, ">$a";
- set_hrefs;
-}
-
-foreach $a (@examples) {
- $texfile="test";
- system "ln ../input/$a.ly ./$a.ly.txt";
- system "cd ..; lilypond input/$a; tex $texfile;".
- "dvips -o $texfile.ps $texfile;";
-
- # generate the pixmap at twice the size, then rescale (for antialiasing)
- if ( ! -f "$a.gif" ) {
- system "mv ../$texfile.ps $a.ps; ".
- "mv ../lelie.midi $a.midi; ".
- "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif";
- }
-}
-
-system "tar hcf website.tar *.html *.gif lelie_logo.png *.ps *.ly.txt *.midi docxx/;" .
- "gzip -f9 website.tar;"
+++ /dev/null
-DISTFILES=Makefile dummy.dep
-
-
-
-dummy.dep:
- touch dummy.dep
-
-
-dist: $(DISTFILES)
- ln $(DISTFILES) $(DDIR)/$(SUBDIR)
-
-clean:
- true
+++ /dev/null
-default:
- $(MAKE) -C ..
-DISTFILES=Makefile $(allhdr)
-dist:
- ln $(DISTFILES) $(DDIR)/$(SUBDIR)
-
-
-TAGS: $(hdr)
- $(TAGSACTION) $^
-
-clean:
- rm -f parser.hh
- rm -f midi-parser.hh
+++ /dev/null
-/*
- bar-reg.hh -- declare Bar_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef BARREG_HH
-#define BARREG_HH
-#include "register.hh"
-
-/**
- generate bars. Either user ("|:"), or default (new measure)
- */
-class Bar_register : public Request_register {
- void split_bar(Bar *& pre, Bar * no, Bar * &post);
-public:
- Bar_req * bar_req_l_;
- Bar * bar_p_;
-
- virtual bool try_request(Request *req_l);
- virtual void process_requests();
- virtual void pre_move_processing();
- virtual void post_move_processing();
- Bar_register();
- NAME_MEMBERS(Bar_register);
-};
-
-#endif // BARREG_HH
+++ /dev/null
-/*
- bar.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef BAR_HH
-#define BAR_HH
-#include "item.hh"
-
-struct Bar: Item {
- String type;
-
- Bar(String type);
-NAME_MEMBERS(Bar);
- void do_print() const;
- Molecule*brew_molecule_p()const;
-};
-#endif // BAR_HH
-
+++ /dev/null
-/*
- beam.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef BEAM_HH
-#define BEAM_HH
-#include "proto.hh"
-#include "directional-spanner.hh"
-#include "plist.hh"
-
-/** a beam connects multiple stems Beam adjusts the stems its owns to
- make sure that they reach the beam and that point in the correct
- direction */
-struct Beam: public Directional_spanner {
- PointerList<Stem*> stems;
- /// the slope of the beam in posns / point (dimension)
- Real slope;
-
- /// position of leftmost end of beam
- Real left_pos;
-
-
- /* *************** */
-NAME_MEMBERS(Beam);
-
- virtual Interval width()const;
- Offset center() const;
- Spanner *do_break_at(PCol *, PCol *) const;
- Beam();
- void add(Stem*);
-
-
- void set_default_dir();
- void do_pre_processing();
- void do_post_processing();
-
- void do_print() const;
- void set_grouping(Rhythmic_grouping def, Rhythmic_grouping current);
- void set_stemlens();
- ~Beam();
-
-private:
- Molecule stem_beams(Stem *here, Stem *next, Stem *prev)const;
- void solve_slope();
- Molecule*brew_molecule_p()const;
-};
-
-#endif // BEAM_HH
-
+++ /dev/null
-//
-// binary-source-file.hh -- declare Binary_source_file
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef BINARY_SOURCE_FILE_HH
-#define BINARY_SOURCE_FILE_HH
-
-class Binary_source_file : public Source_file {
-public:
- Binary_source_file( String& filename_str );
- virtual ~Binary_source_file();
-
- virtual String error_str( char const* pos_ch_c_l );
- virtual int line_i( char const* pos_ch_c_l );
-};
-
-#endif // BINARY_SOURCE_FILE_HH //
+++ /dev/null
-/*
- some 2D geometrical concepts
-*/
-
-#ifndef BOXES_HH
-#define BOXES_HH
-
-#include "fproto.hh"
-#include "real.hh"
-#include "interval.hh"
-#include "offset.hh"
-
-/// a square subset of Real^2
-struct Box {
- Interval x, y;
-
- void translate(Offset o) {
- x.translate(o.x);
- y.translate(o.y);
- }
- /// smallest box enclosing #b#
- void unite(Box b) {
- x.unite(b.x);
- y.unite(b.y);
- }
- Box();
- Box(Interval ix, Interval iy);
-};
-
-
-#endif
+++ /dev/null
-/*
- break.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef BREAK_HH
-#define BREAK_HH
-#include "varray.hh"
-#include "proto.hh"
-#include "colhpos.hh"
-
-/** Class representation of an algorithm which decides where to put
- the column, and where to break lines. */
-struct Break_algorithm {
- PScore &pscore_;
- Real linelength;
-
- /* *************** */
-
- Break_algorithm(PScore&);
-
- /// check if the spacing/breaking problem is well-stated
- void problem_OK()const;
-
- /// search all pcols which are breakable.
- Line_of_cols find_breaks() const;
-
- /// helper: solve for the columns in #curline#.
- Col_hpositions solve_line(Line_of_cols) const;
-
- /// does curline fit on the paper?
- bool feasible(Line_of_cols)const;
-
- virtual Array<Col_hpositions> solve()=0;
-};
-
-/// wordwrap type algorithm: move to next line if current is optimal.
-struct Word_wrap : Break_algorithm {
- virtual Array<Col_hpositions> solve();
- Word_wrap(PScore&);
-};
-#endif // BREAK_HH
-
+++ /dev/null
-/*
- class-name.hh -- declare
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef CLASS_NAME_HH
-#define CLASS_NAME_HH
-
-/// a macro to declare the classes name as a static and virtual function.
-#define NAME_MEMBERS(c) \
-static const char *static_name(){ return #c; }\
-virtual const char *name() const{ return c::static_name(); } \
-int a_stupid_nonexistent_function_to_allow_the_semicolon_come_out()
-
-#endif // CLASS-NAME_HH
+++ /dev/null
-
-/*
- clef-item.hh -- declare Clef_item
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef CLEFITEM_HH
-#define CLEFITEM_HH
-#include "item.hh"
-
-
-struct Clef_item : Item {
- String type;
- int y_off;
-
- /// is this a change clef (smaller size)?
- bool change;
-
-
- /* *************** */
-NAME_MEMBERS(Clef_item);
- Clef_item();
- void read(Clef_register const&);
- void read(String);
- Molecule* brew_molecule_p()const;
-};
-
-#endif // CLEFITEM_HH
-
-
+++ /dev/null
-/*
- clef.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef CLEF_HH
-#define CLEF_HH
-
-#include "scalar.hh"
-#include "varray.hh"
-#include "register.hh"
-
-/// where is c-0 in the staff?
-class Clef_register : public Request_register {
- Clef_item *clef_p_;
- Clef_change_req * clef_req_l_;
-
-public:
- int c0_position_i_;
- String clef_type_str_;
-
- /* ************** */
- virtual void process_requests();
- virtual void pre_move_processing();
- virtual void post_move_processing();
- virtual bool try_request(Request*);
- Clef_register();
- NAME_MEMBERS(Clef_register);
- void read_req(Clef_change_req*);
- bool set_type(String);
-};
-#endif // CLEF_HH
-
+++ /dev/null
-/*
- colhpos.hh -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef COLHPOS_HH
-#define COLHPOS_HH
-#include "varray.hh"
-#include "proto.hh"
-
-typedef Array<PCol*> Line_of_cols;
-
-struct Col_hpositions {
- Line_of_cols cols;
- Array<Real> config;
- Real energy;
-
- /* ************** */
- void OK()const;
-
- Col_hpositions();
- void add( PCol*c);
- void print() const;
-};
-
-
-#endif // COLHPOS_HH
-
+++ /dev/null
-/*
- commandrequest.hh -- declare Non musical requests
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef COMMANDREQUEST_HH
-#define COMMANDREQUEST_HH
-
-#include "request.hh"
-#include "varray.hh"
-
-/** Request which are assumed to be "happening" before the
- musical requests. */
-struct Command_req : virtual Request {
- REQUESTMETHODS(Command_req, command);
-
- virtual Measure_grouping_req * measuregrouping() { return 0; }
- virtual Clef_change_req * clefchange() { return 0; }
- virtual Key_change_req * keychange() { return 0; }
- virtual Partial_measure_req * partial() { return 0; }
- virtual Meter_change_req * meterchange() { return 0; }
- virtual Bar_req *bar() { return 0; }
- virtual Cadenza_req *cadenza() { return 0; }
- virtual Timing_req*timing() { return 0; }
-};
-
-
-/** Baseclass for meter/partial req. It has to be handled by
- Staff_{walker,column} baseclass. */
-struct Timing_req : Command_req {
- REQUESTMETHODS(Timing_req, timing);
-};
-
-
-struct Partial_measure_req : Timing_req {
- Moment duration_;
-
- Partial_measure_req(Moment);
- REQUESTMETHODS(Partial_measure_req, partial);
-};
-
-/**
- todo: allow C meter
- */
-struct Meter_change_req : Timing_req {
- int beats_i_, one_beat_i_;
-
- Meter_change_req();
- void set(int,int);
- REQUESTMETHODS(Meter_change_req, meterchange);
-};
-
-/// toggle Cadenza mode
-struct Cadenza_req : Timing_req {
- /// turn on?
- bool on_b_;
- Cadenza_req(bool);
- REQUESTMETHODS(Cadenza_req,cadenza);
-};
-
-/// check if we're at start of a measure.
-struct Barcheck_req : Timing_req {
-
- REQUESTMETHODS(Barcheck_req,barcheck);
-};
-
-struct Measure_grouping_req: Timing_req {
- Array<int> beat_i_arr_;
- Array<Moment> elt_length_arr_;
-
- REQUESTMETHODS(Measure_grouping_req, measuregrouping);
-};
-
-struct Group_change_req : Command_req {
- String newgroup_str_;
- REQUESTMETHODS(Group_change_req, groupchange);
-};
-
-/** draw a (repeat)-bar. This something different than #Barcheck_req#,
- the latter should only happen at the start of a measure. */
-struct Bar_req : Command_req {
- String type_str_;
- Bar_req(String);
- int compare(const Bar_req&)const;
- REQUESTMETHODS(Bar_req,bar);
-};
-struct Terminate_voice_req : Command_req {
- REQUESTMETHODS(Terminate_voice_req,terminate);
-};
-
-struct Group_feature_req : Command_req {
- int stemdir_i_;
- Group_feature_req();
- REQUESTMETHODS(Group_feature_req, groupfeature);
-};
-
-
-struct Key_change_req : Command_req {
- Array<Melodic_req*> melodic_p_arr_;
-
- Key_change_req();
- Key_change_req(Key_change_req const&);
- ~Key_change_req();
- REQUESTMETHODS(Key_change_req, keychange);
-};
-
-struct Clef_change_req : Command_req {
- String clef_str_;
- Clef_change_req(String);
- REQUESTMETHODS(Clef_change_req, clefchange);
-};
-
-#endif // COMMANDREQUEST_HH
+++ /dev/null
-/*
- complex-staff.hh -- declare Complex_staff
-
- (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef COMPLEXSTAF_HH
-#define COMPLEXSTAF_HH
-
-
-#include "key.hh"
-#include "staff.hh"
-#include "staff-walker.hh"
-
-///
-struct Complex_staff : Staff {
-
- /* *************** */
-
- virtual void set_output(PScore *);
- virtual Staff_walker *get_walker_p();
-};
-
-#endif // COMPLEXSTAF_HH
-
+++ /dev/null
-/*
- complex-walker.hh -- declare Complex_walker
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef COMPLEXWALKER_HH
-#define COMPLEXWALKER_HH
-
-#include "proto.hh"
-#include "staff-walker.hh"
-#include "staff-elem-info.hh"
-
-/**
- A staff walker which uses registers to decide what to print
- */
-class Complex_walker: public Staff_walker {
- bool try_command_request(Command_req *req_l);
- void do_announces();
- void try_request(Request*req);
-
-
-
-public:
- int c0_position_i_;
- Walker_registers *walk_regs_p_;
-
- /* *************** */
-
- void regs_process_requests();
- void typeset_element(Staff_elem *elem_p);
- void announce_element(Staff_elem_info);
- virtual void process_requests();
- virtual void do_post_move();
- virtual void do_pre_move();
-
- Complex_walker(Complex_staff*);
- ~Complex_walker();
-
- Complex_staff *staff();
-private:
-};
-
-
-#endif // COMPLEXWALKER_HH
-
-
+++ /dev/null
-/*
- global constants
- */
-#ifndef CONST_HH
-#define CONST_HH
-#include <math.h>
-#include "real.hh"
-
-const Real EPS=1e-7; // qlpsolve.hh
-const int MAXITER=100; // qlpsolve.hh
-const Real INFTY=HUGE_VAL;
-#endif
+++ /dev/null
-#ifndef DEBUG_HH
-#define DEBUG_HH
-
-#include <assert.h>
-#include <iostream.h>
-#include "dstream.hh"
-#include "real.hh"
-#include "proto.hh"
-
-void message( String message_str, char const* context_ch_c_l );
-void warning( String message_str, char const* context_ch_c_l );
-void error( String message_str, char const* context_ch_c_l );
-void error(String s); // errors
-void error_t(const String& s, Time_description const & t_tdes);
-void error_t(String const &s, const Moment &when);
-// warnings
-//void warning(String s);
-#define WARN warnout << "warning: "<<__FUNCTION__ << "(): "
-extern ostream &warnout ;
-
-// progress
-extern ostream *mlog;
-
-// debugging
-extern Dstream *monitor; // monitor
-
-#ifdef NPRINT
-#define mtor if (0) *monitor // clever hack
-#else
-#define mtor if (check_debug) monitor->identify_as(__PRETTY_FUNCTION__)
-#endif
-
-extern bool check_debug;
-
-#endif
+++ /dev/null
-#ifndef DIMEN_HH
-#define DIMEN_HH
-
-#include "real.hh"
-#include "string.hh"
-
-const Real INCH_TO_PT=72.0;
-const Real CM_TO_PT=INCH_TO_PT/2.54;
-const Real MM_TO_PT=CM_TO_PT/10;
-const Real PT_TO_PT =1.0;
-
-#define PT *PT_TO_PT
-#define MM *MM_TO_PT
-#define CM *CM_TO_PT
-#define INCH *INCH_TO_PT
-
-Real parse_dimen(String);
-String print_dimen(Real);
-Real convert_dimen(Real, String);
-#endif
-
+++ /dev/null
-/*
- directional-spanner.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef DIRECTIONALSPANNER_HH
-#define DIRECTIONALSPANNER_HH
-
-#include "spanner.hh"
-
-/// a spanner which can be pointing "up" or "down"
-struct Directional_spanner : Spanner{
-
- /// -1 below heads, +1 above heads.
- int dir_i_;
-
- /// offset of "center" relative to left-column/0-pos of staff
- virtual Offset center() const=0;
- virtual void set_default_dir()=0;
- Directional_spanner();
-
-};
-
-#endif // DIRECTIONALSPANNER_HH
-
+++ /dev/null
-//
-// duration.hh -- declare Duration, Plet, Duration_convert Duration_iterator
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-// split into 4?
-
-#ifndef DURATION_HH
-#define DURATION_HH
-
-/// (dur)
-struct Duration {
- // actually i hate it when other people use default arguments,
- // because it makes you easily loose track of what-s really
- // happening; in the routine-s implementation you-re not aware
- // of this defaultness (who sets this stupid value?).
- Duration( int type_i = 1, int dots_i = 0, Plet* plet_p = 0 );
- Duration( Duration const& dur_c_r );
- ~Duration();
-
- Duration const& operator =( Duration const& dur_c_r );
-
- void set_plet( Plet* plet_l ); // handiger: newt zelf
-
-// int i_; // balltype -> type!
- int type_i_;
- int dots_i_;
- Plet* plet_p_;
-};
-
-/// (plet)
-struct Plet {
- Plet( int replace_i, int type_i );
- Plet( Plet const& plet_c_r );
-
-// int i_;
- int iso_i_; // 2/3; 2 is not duration, maar of count!
- int type_i_;
-};
-
-/**
- Duration_convert handles all conversions to -n fro Duration (dur).
- That is including (integer + division) representation for MIDI,
- and conversion from unexact time representation (best guess :-).
-
- A Moment (mom) is a Rational that holds the time fraction
- compared to a whole note (before also called wholes).
-
- SUGGESTION: currently a moment in time is called moment too;
- let-s typedef Rational When too, so that we get
- When Staff_column::when(), Moment Voice_element::mom().
-*/
-struct Duration_convert {
- /// Most used division in MIDI, all fine with me.
- static int const division_1_c_i = 384;
-
- /// Return (integer, division) representation.
- static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
-
- /// Return Moment representation (fraction of whole note).
- static Moment dur2_mom( Duration dur );
-
- /// Return Mudela string representation.
- static String dur2_str( Duration dur );
-
- /// Return Moment from (integer, division) representation.
- static Moment i2_mom( int i, int division_1_i = division_1_c_i );
-
- /// Return Moment (fraction of whole) representation, best guess.
- static Duration mom2_dur( Moment mom );
-
- /// Return plet factor (not a Moment: should use Rational?).
- static Moment plet_factor_mom( Duration dur );
-
- /** Return synchronisation factor for mom, so that
- mom2_dur( mom / sync_f ) will return the duration dur.
- */
- static Real sync_f( Duration dur, Moment mom );
-};
-
-/// (iter_dur)
-struct Duration_iterator {
- /// start at shortest: 128:2/3
- Duration_iterator();
-
- // **** what about these three here ?
- /// return forward_dur();
- Duration operator ++(int);
-
- /// return ok()
- operator bool();
-
- /// return dur()
- Duration operator ()();
- // ****
-
- /// return current dur
- Duration dur();
-
- /// return dur(), step to next
- Duration forward_dur();
-
- /// durations left?
- bool ok();
-
-private:
- Duration cursor_dur_;
-};
-
-#endif // DURATION_HH
-
+++ /dev/null
-#ifndef GLOB_HH
-#define GLOB_HH
-#include <assert.h>
-#include <math.h>
-#include "real.hh"
-
-#include "proto.hh"
-#include "const.hh"
-#endif
+++ /dev/null
-/*
- grouping.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef GROUPING_HH
-#define GROUPING_HH
-
-#include "moment.hh"
-#include "interval.hh"
-#include "varray.hh"
-
-typedef Interval_t<Moment> MInterval;
-
-/** data structure which represents rhythmic units this is a tree. It groupes notes according to rules
- */
-struct Rhythmic_grouping {
- Array<Rhythmic_grouping*> children;
- MInterval *interval_;
-
- /* *************** */
-
- Array<MInterval> intervals();
- MInterval interval()const;
- Moment length() const;
- void intersect(MInterval);
-
- void operator=(Rhythmic_grouping const&);
- Rhythmic_grouping(Rhythmic_grouping const&);
- Rhythmic_grouping(MInterval, int n=1);
- Rhythmic_grouping();
- Rhythmic_grouping(Array<Rhythmic_grouping*>);
- ~Rhythmic_grouping();
-
- void add_child(Moment start, Moment len);
- bool child_fit_query(Moment start);
- void split(Rhythmic_grouping r);
- void split(Array<MInterval>);
- void split(int n);
-
- void print() const;
- void OK() const;
-
- Array<int> generate_beams(Array<int>, int&);
-
- /** multiply self to span #i#.
- In implementation, this isn't really const, but conceptually it is.
- */
- void extend(MInterval i) const;
- void translate(Moment);
-private:
- void init();
- void junk();
- void copy(Rhythmic_grouping const&);
-};
-
-
-Rhythmic_grouping parse_grouping(Array<int> beat_i_arr, Array<Moment> elt_length_arr);
-
-
-#endif
+++ /dev/null
-/*
- headreg.hh -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef HEADREG_HH
-#define HEADREG_HH
-#include "register.hh"
-
-struct Notehead_register : Request_register {
- Item* note_p_;
- Rhythmic_req * note_req_l_;
- int dir_i_;
-
- /* *************** */
- Notehead_register();
- virtual bool try_request(Request *req_l) ;
- virtual void process_requests();
- virtual void pre_move_processing();
- virtual void post_move_processing();
- void set_feature(Features);
- NAME_MEMBERS(Notehead_register);
-};
-
-
-#endif // HEADREG_HH
+++ /dev/null
-/*
- idealspacing.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef IDEALSPACING_HH
-#define IDEALSPACING_HH
-#include "proto.hh"
-
-/// ideal spacing between two columns
-struct Idealspacing {
-
- /// the ideal distance
- Real space;
-
- /// Hooke's constant: how strong are the "springs" attached to columns
- Real hooke;
-
- /// the two columns
- const PCol *left, *right;
-
- void print()const;
- void OK() const ;
- Idealspacing(const PCol *left,const PCol *right);
-};
-
-
-#endif // IDEALSPACING_HH
-
+++ /dev/null
-
-/*
- identifier.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef IDENTIFIER_HH
-#define IDENTIFIER_HH
-#include "identparent.hh"
-#include "symtable.hh"
-#include "input-staff.hh"
-#include "input-music.hh"
-#include "notename.hh"
-#include "lookup.hh"
-#include "script-def.hh"
-
-#define make_id_class(Idclass, Class, accessor) \
-struct Idclass : Identifier {\
- virtual const char *classname() { return #Class; }\
- Idclass(String s, Class*st):Identifier(s) { data = st; }\
- virtual Class* accessor(bool copy) {\
- if (copy)\
- return new Class(* (Class*) data);\
- else\
- return (Class*) data;\
- }\
- ~Idclass() { delete accessor(false); }\
- virtual void do_print()const; \
-}\
-
-make_id_class(Real_id, Real, real);
-make_id_class(Script_id, Script_def, script);
-make_id_class(Lookup_id, Lookup, lookup);
-make_id_class(Symtables_id, Symtables, symtables);
-make_id_class(Staff_id, Input_staff, staff);
-make_id_class(M_chord_id, Music_general_chord, mchord);
-make_id_class(M_voice_id, Music_voice, mvoice);
-make_id_class(Notetab_id, Notename_tab, notename_tab);
-
-#endif // IDENTIFIER_HH
-
+++ /dev/null
-/*
- identparent.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef IDENTPARENT_HH
-#define IDENTPARENT_HH
-
-#include "proto.hh"
-#include "string.hh"
-
-/* boolean argument to accesor is copy_b..*/
-#define IDACCESSOR( Input_staff, staff)\
- virtual Input_staff * staff(bool) { error(#Input_staff); return 0; }
-
-struct Identifier {
- void *data;
- String name;
-
- Identifier(String n) : name(n) { }
- virtual ~Identifier() {}
-
- void print()const;
- virtual const char*classname() { return "new Identifier"; }
- void error(String);
- IDACCESSOR(Input_staff, staff)
- IDACCESSOR(Input_music, music)
- IDACCESSOR(Music_voice, mvoice)
- IDACCESSOR(Script_def, script)
- IDACCESSOR(Symtables, symtables)
- IDACCESSOR(Music_general_chord, mchord)
- IDACCESSOR(Lookup,lookup)
- IDACCESSOR(Real,real)
- IDACCESSOR(Notename_tab, notename_tab)
-protected:
- virtual void do_print()const=0;
-private:
- Identifier(Identifier const&){}
-
-};
-#endif // IDENTPARENT_HH
-
-
-
+++ /dev/null
-/*
- input-file.hh -- declare Input_file
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef INPUT_FILE_HH
-#define INPUT_FILE_HH
-#include <FlexLexer.h>
-#include "proto.hh"
-#include "fproto.hh"
-#include "varray.hh"
-#include "string.hh"
-
-struct Input_file {
- istream* is;
- char const* defined_ch_c_l_;
- Source_file* sourcefile_l_;
- int line;
- String name;
-
- Input_file(String);
- ~Input_file();
-};
-
-#endif // INPUT_FILE_HH
+++ /dev/null
-/*
- input-music.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef INPUTMUSIC_HH
-#define INPUTMUSIC_HH
-
-#include "plist.hh"
-#include "proto.hh"
-#include "voice.hh"
-#include "moment.hh"
-
-struct Voice_list : public PointerList<Voice*> {
- void translate_time(Moment dt);
-};
-
-/**
-
- A set voices.
- Input_music is anything that can simply be regarded as/converted to
- a set of voices "cooperating" or independant. It has some basic
- characteristics that real music has too:
-
- - it is rhythmic (it has a length, and can be translated horizontally)
- - a pitch (it can be transposed)
-
- */
-struct Input_music {
- virtual Voice_list convert()const=0;
- void check_plet(Voice_element* velt_l);
- virtual Moment length()const=0;
- virtual void translate_time(Moment dt)=0;
- virtual ~Input_music(){}
- virtual void print() const =0;
- virtual void set_default_group(String)=0;
- virtual bool find_plet_start_bo(char c, Moment& moment_r) = 0;
- virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) = 0;
- // virtual void transpose(...) const =0;
-
-
- virtual Input_music *clone() const = 0;
- virtual Simple_music *simple() { return 0; }
-};
-
-/// Simple music consists of one voice
-struct Simple_music : Input_music {
- Voice voice_;
-
- /* *** */
- virtual Simple_music*simple() { return this; }
- void add(Voice_element*);
- virtual void set_default_group(String g) { voice_.set_default_group(g); }
- virtual Moment length()const;
- virtual Voice_list convert()const;
- virtual void translate_time(Moment dt);
- virtual void print() const;
- virtual bool find_plet_start_bo(char c, Moment& moment_r);
- virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
- virtual Input_music *clone() const {
- return new Simple_music(*this);
- }
-
-};
-
-/// Complex_music consists of multiple voices
-struct Complex_music : Input_music {
- IPointerList<Input_music*> elts;
- /* *************** */
- virtual void set_default_group(String g);
- void add(Input_music*);
- Complex_music();
- Complex_music(Complex_music const &);
- virtual void print() const ;
- void concatenate(Complex_music*);
- virtual bool find_plet_start_bo(char c, Moment& moment_r);
- virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
-
-};
-
-
-/**
- A voice like list of music.
-
- different music forms which start after each other ( concatenated,
- stacked "horizontally )
-
- */
-
-struct Music_voice : Complex_music {
-
-
- /* *************** */
- Moment length()const;
- virtual void translate_time(Moment dt);
- virtual Voice_list convert()const;
- void add_elt(Voice_element*);
- virtual Input_music *clone() const {
- return new Music_voice(*this);
- }
- virtual void print() const ;
-};
-
-/**
- Multiple musicstuff stacked on top of each other
- chord like :
-
- - different music forms which start at the same time ( stacked "vertically" )
-
- */
-struct Music_general_chord : Complex_music {
-
-
- /* *************** */
-
- virtual Moment length()const;
- virtual Voice_list convert()const;
- virtual void translate_time(Moment dt);
- void add_elt(Voice_element*);
- virtual Input_music *clone() const {
- return new Music_general_chord(*this);
- }
-
- virtual void print() const ;
-};
-
-struct Multi_voice_chord : Music_general_chord {
- void set_default_group(String);
- virtual Input_music *clone() const {
- return new Multi_voice_chord(*this);
- }
-};
-struct Voice_group_chord : Music_general_chord {
-
- virtual Input_music *clone() const {
- return new Voice_group_chord(*this);
- }
-};
-#endif // INPUTMUSIC_HH
+++ /dev/null
-/*
- input-score.hh -- declare
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef INPUTSCORE_HH
-#define INPUTSCORE_HH
-
-#include "varray.hh"
-#include "proto.hh"
-#include "plist.hh"
-#include "string.hh"
-
-
-/// the total music def of one movement
-struct Input_score {
- /// defined where?
- const char* defined_ch_c_l_;
- int errorlevel_i_;
-
- /// paper_, staffs_ and commands_ form the problem definition.
- Paper_def *paper_p_;
- Midi_def* midi_p_;
- IPointerList<Input_staff*> staffs_;
-
- Input_music * score_wide_music_p_;
-
- /* *************************************************************** */
- Input_score();
- Input_score(Input_score const&);
-
- void add(Input_staff*);
- ~Input_score();
- /// construction
- void set(Paper_def*);
- void set(Midi_def* midi_p);
- void print() const;
- Score*parse();
- void set(Input_music*);
-};
-
-#endif
+++ /dev/null
-/*
- input-staff.hh -- declare Input_staff
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef INPUTSTAFF_HH
-#define INPUTSTAFF_HH
-
-#include "string.hh"
-#include "plist.hh"
-#include "varray.hh"
-#include "proto.hh"
-
-struct Input_staff {
-
- const char * defined_ch_c_l_;
- String type;
-
- IPointerList<Input_music*> music_;
- Input_music * score_wide_music_p_;
-
- /* *************** */
- ~Input_staff();
- void add(Input_music*m);
- Input_staff(Input_staff const&);
- Input_staff(String);
- void set_score_wide(Input_music*m);
- Staff* parse(Score*, Input_music *score_wide);
- void print() const;
-};
-
-
-#endif // INPUTSTAFF_HH
-
+++ /dev/null
-#ifndef ITEM_HH
-#define ITEM_HH
-
-#include "glob.hh"
-#include "boxes.hh"
-#include "string.hh"
-#include "staff-elem.hh"
-
-/**
- a horizontally fixed size element of the score
-
- Item is the datastructure for printables whose width is known
- before the spacing is calculated
-
- NB. This doesn't mean an Item has to initialize the output field before
- spacing calculation.
-
-*/
-struct Item : Staff_elem {
- /// indirection to the column it is in
- PCol * pcol_l_;
-
- /* *************** */
- virtual Item *item() { return this; }
- Item();
- void do_print()const;
-
- NAME_MEMBERS(Item);
-};
-
-
-#endif
+++ /dev/null
-/*
- key-item.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef KEYITEM_HH
-#define KEYITEM_HH
-
-#include "item.hh"
-#include "varray.hh"
-
-
-/// An item which places accidentals at the start of the line
-struct Key_item : Item {
- Array<int> pitch;
- Array<int> acc;
- int c_position;
-
-
- /* *************** */
-NAME_MEMBERS(Key_item);
- Key_item(int cposition);
- void add(int pitch, int acc);
- void read(const Key_register&);
- void set_c_position(int);
- void preprocess();
- Molecule* brew_molecule_p()const;
-};
-
-#endif // KEYITEM_HH
+++ /dev/null
-/*
- key-reg.hh -- declare Key_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef KEYREG_HH
-#define KEYREG_HH
-
-#include "register.hh"
-#include "key.hh"
-
-struct Key_register : Request_register {
- Key key_;
- Key_change_req * keyreq_l_;
- Key_item * kit_p_;
- Array<int> accidental_idx_arr_;
- bool default_key_b_;
-
- virtual bool try_request(Request *req_l);
- virtual void process_requests();
- virtual void pre_move_processing();
- virtual void post_move_processing();
- virtual void acknowledge_element(Staff_elem_info);
- Key_register();
- NAME_MEMBERS(Key_register);
-private:
-
- void read_req(Key_change_req * r);
-};
-
-#endif // KEYREG_HH
+++ /dev/null
-/*
- key.hh -- declare Key
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef KEY_HH
-#define KEY_HH
-
-#include "varray.hh"
-#include "scalar.hh"
-
-/// administration of current key
-class Key {
- Array<int> accidental_i_arr_;
-
- /* *************** */
-
-public:
-
- Key();
- void set(int i, int acc);
- int acc(int i)const { return accidental_i_arr_[i]; }
-};
-
-/// administration of accidentals
-struct Local_key
-{
- void reset(Key);
- Key& oct(int);
- Local_key();
-
-private:
- Array<Key> octaves;
-};
-
-#endif // KEY_HH
-
-
+++ /dev/null
-/*
- keyword.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef KEYWORD_HH
-#define KEYWORD_HH
-
-/* for the keyword table */
-struct Keyword_ent
-{
- const char *name;
- int tokcode;
-};
-
-struct Keyword_table
-{
- Keyword_ent *table;
- int maxkey;
- Keyword_table(Keyword_ent *);
- int lookup(const char *s) const;
-};
-
-
-#endif // KEYWORD_HH
-
+++ /dev/null
-/*
- leastsquare.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef LEASTSQUARE_HH
-#define LEASTSQUARE_HH
-#include "varray.hh"
-#include "offset.hh"
-
-
-/**
- Least squares minimisation in 2 variables.
- */
-struct Least_squares {
- Array<Offset> input;
- void minimise(Real &coef, Real &offset);
- void OK() const;
-};
-
-
-#endif // LEASTSQUARE_HH
-
+++ /dev/null
-/*
- lexer.hh -- declare My_flex_lexer
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef LEXER_HH
-#define LEXER_HH
-#include <FlexLexer.h>
-#include "proto.hh"
-#include "fproto.hh"
-#include "varray.hh"
-#include "string.hh"
-
-int yylex();
-void yyerror(const char *s);
-bool busy_parsing();
-void kill_lexer();
-void set_lexer();
-
-/// lexer with provisions for include files.
-struct My_flex_lexer : yyFlexLexer {
-
- Array<Input_file*> include_stack;
- Assoc<String, Identifier*> *the_id_tab;
- Keyword_table * keytable;
- Notename_tab * defaulttab;
- int errorlevel_i_;
- /* *************** */
- int ret_notename(int *p, String text, int octave_mod);
- char const* here_ch_c_l();
- void set(Notename_tab *n);
- int lookup_keyword(String);
- void lookup_notename(int &large, int &small, String s);
- void LexerError(const char *);
- String spot() const;
- Identifier*lookup_identifier(String s);
- My_flex_lexer();
- void add_identifier(Identifier*i);
- ~My_flex_lexer();
- void new_input(String s);
- bool close_input();
- int yylex();
- void print_declarations() const;
-};
-
-extern My_flex_lexer *lexer;
-
-#endif
+++ /dev/null
-//
-// lily-stream.hh -- part of LilyPond
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-// should i be named Mudela_stream?
-
-#ifndef LILY_STREAM_HH
-#define LILY_STREAM_HH
-
-/// Lily output
-struct Lily_stream {
- ostream* os_p_;
- String filename_str_;
-
- Lily_stream( String filename_str );
- ~Lily_stream();
-
- Lily_stream& operator <<( String str );
- Lily_stream& operator <<( Midi_event& midi_event_r );
-
- void header();
- void open();
-};
-
-#endif // LILY_STREAM_HH
-
+++ /dev/null
-#ifndef PROBLEM_HH
-#define PROBLEM_HH
-
-#include "glob.hh"
-#include "plist.hh"
-#include "varray.hh"
-#include "vector.hh"
-#include "interval.hh"
-
-/// helper struct for #Spacing_problem#
-struct Colinfo {
- const PCol *pcol_;
- const Real* fixpos;
- Interval width;
-
- /* *************** */
- Colinfo();
- void operator=(Colinfo const&);
- Colinfo(Colinfo const&);
- ~Colinfo();
- Colinfo(const PCol*,const Real*);
- void print() const;
- bool fixed() const { return fixpos;}
- Real fixed_position()const { return *fixpos; }
- Real minright() const { return width.right; }
- Real minleft() const { return -width.left; }
-};
-
-
-/** the problem, given by the columns (which include constraints) and
- intercolumn spacing. The problem is:
-
- Generate a spacing which
- \begin{itemize}
- \item
- Satisfies spacing constraints (notes can't be printed through each other)
- \item
- Looks good, ie tries to conform to an ideal spacing as much as possible.
- \end{itemize}
- This is converted by regarding idealspacing as "springs" attached
- to columns. The equilibrium of one spring is the ideal
- distance. The columns have a size, this imposes "hard" constraints
- on the distances. This transforms the problem into a quadratic
- programming problem with linear constraints.
-
- The quality is given by the total potential energy in the
- springs. The lower the energy, the better the configuration.
-*/
-class Spacing_problem {
- Array<const Idealspacing*> ideals;
- Array<Colinfo> cols;
-
- /// the index of #c# in #cols#
- int col_id(const PCol *c) const;
-
- /// generate an (nonoptimal) solution
- Vector find_initial_solution() const;
-
- /// check if problem is too tight
- bool check_feasible() const;
-
- /// does #this# contain the column #w#?
- bool contains(const PCol *w);
-
- /// make the energy function
- void make_matrices(Matrix &quad, Vector &lin,Real&) const;
-
- /// generate the LP constraints
- void make_constraints(Mixed_qp& lp) const;
-
-public:
- /** solve the spacing problem
-
- @return the column positions, and the energy (last element)
-
- */
- Array<Real> solve() const;
-
-
- /**
- add a idealspacing to the problem.
-
- One pair of columns can have no, one or more idealspacings,
- since they can be "summed" if the columns to which #i# refers are
- not in this problem, the spacing is ignored.
- */
- void add_ideal(const Idealspacing *i);
-
-
- /** add a col to the problem. columns have to be added left to right. The column contains
- info on it's minimum width.
- */
- void add_column(const PCol *, bool fixed=false, Real fixpos=0.0);
-
-
-
- bool check_constraints(Vector v) const;
-
- Vector try_initial_solution() const;
- void OK() const;
- void print() const;
- void print_ideal(const Idealspacing*)const;
-};
-
-
-#endif
+++ /dev/null
-/*
- local-key-item.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef LOCALKEYITEM_HH
-#define LOCALKEYITEM_HH
-#include "item.hh"
-#include "varray.hh"
-
-struct Local_acc {
- int name , acc, octave;
- static int compare(Local_acc&, Local_acc&);
-};
-
-struct Local_key_item : Item {
-NAME_MEMBERS(Local_key_item);
- Array<Local_acc> accs;
- Array<Item*> support_items_;
- int c0_position;
-
- /* *************** */
-
- Local_key_item(int c0position);
- void add(Item*);
- void add(int oct, int pitch, int acc);
- void add(Melodic_req*);
- void do_pre_processing();
- Molecule* brew_molecule_p()const;
-};
-#endif // LOCALKEYITEM_HH
-
+++ /dev/null
-/*
- local-key-reg.hh -- declare Local_key_register
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef LOCALKEYREG_HH
-#define LOCALKEYREG_HH
-#include "register.hh"
-#include "key.hh"
-
-struct Local_key_register : Request_register {
- Local_key local_key_;
- Local_key_item* key_item_p_;
- const Key *key_c_l_;
- /* *************** */
- virtual void process_requests();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void pre_move_processing();
- Local_key_register();
- NAME_MEMBERS(Local_key_register);
-};
-
-#endif // LOCALKEYREG_HH
+++ /dev/null
-/*
- lilypond, (c) 1996,97 Han-Wen Nienhuys
-*/
-#ifndef LOOKUPSYMS_HH
-#define LOOKUPSYMS_HH
-
-#include "symbol.hh"
-#include "fproto.hh"
-#include "scalar.hh"
-
-/// intuitive interface to symbol table
-struct Lookup {
- Symtables *symtables_;
- String texsetting;
- /* *************** */
- void add(String, Symtable*);
- void print()const;
- Real internote();
-
- Symbol linestaff(int n, Real w);
- Symbol fill(Box b);
- Symbol beam_element(int,int,Real=0);
-
- /// round slope to closest TeXslope
- Symbol beam(Real&,Real);
-
- /**
- pos == 3 : 3 lines above staff (extending below note)
-
- pos == -3: below staff
- */
- Symbol streepjes(int pos);
-
- Symbol meter(Array<Scalar>);
- Symbol stem(Real y1_pos, Real y2_pos);
- Symbol rule_symbol(Real height, Real width);
- Symbol accidental(int);
- Symbol ball(int);
- Symbol flag(int);
- Symbol rest(int);
- Symbol clef(String);
- Symbol bar(String);
- Symbol dots(int);
- Symbol slur(int dy, Real &dx, int dir);
- Symbol half_slur(int dy, Real &dx, int dir, int xpart);
- Symbol half_slur_middlepart(Real &dx, int dir);
- Symbol big_slur(int dy, Real &dx, int dir);
- Symbol text(String style, String text, int align = 1);
- Symbol script(String idx);
- Symbol hairpin(Real & width, bool decresc);
-
- Lookup();
- Lookup(Lookup const &);
- ~Lookup();
-};
-
-#endif
+++ /dev/null
-//
-// lyric-item.hh -- part of LilyPond
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef LYRIC_ITEM_HH
-#define LYRIC_ITEM_HH
-
-#include "textitem.hh"
-
-struct Lyric_item : Text_item {
- /* *************** */
- Lyric_item(Lyric_req* lreq_l, int voice_count_i);
- virtual void do_pre_processing();
-};
-
-
-#endif // LYRIC_ITEM_HH //
-
+++ /dev/null
-/*
- lyricstaff.hh -- part of LilyPond
-
- copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
- */
-
-#ifndef LYRICSTAFF_HH
-#define LYRICSTAFF_HH
-
-#include "staff.hh"
-
-/**
- Hungarian prefix lstaff
- */
-struct Lyric_staff : Staff {
- virtual void set_output(PScore *);
- virtual Staff_walker *get_walker_p();
-};
-
-#endif // LYRICSTAFF_HH
-
-
-
-
+++ /dev/null
-//
-// lyricwalker.hh -- declare Lyric_walker
-//
-// (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen <jan@digicash.com>
-//
-
-#ifndef LYRICWALKER_HH
-#define LYRICWALKER_HH
-
-#include "proto.hh"
-#include "grouping.hh"
-#include "staff-walker.hh"
-
-/// a simple walker which collects words, and then print them, first on top
-struct Lyric_walker: Staff_walker {
- Array<Lyric_item*> litem_l_array_;
-
- /* *************** */
- virtual void process_requests();
-
- Lyric_walker(Lyric_staff* lstaff_l);
- Lyric_staff* lstaff_l();
-};
-
-
-#endif // LYRICWALKER_HH
-
-
+++ /dev/null
-#ifndef MAIN_HH
-#define MAIN_HH
-#include "proto.hh"
-
-void debug_init();
-void set_debug(bool);
-void do_scores();
-void add_score(Input_score * s);
-void set_default_output(String s);
-Input_score* current_iscore_l();
-String find_file(String);
-const char *get_version();
-extern Source* source_l_g;
-extern bool only_midi;
-
-extern String default_out_fn;
-
-#endif
+++ /dev/null
-/*
- meter-reg.hh -- declare Meter_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef METERREG_HH
-#define METERREG_HH
-#include "register.hh"
-
-/**
- generate meters.
- */
-class Meter_register : public Request_register {
-public:
- Meter_change_req * meter_req_l_;
- Meter * meter_p_;
-
- virtual bool try_request(Request *req_l);
- virtual void process_requests();
- virtual void pre_move_processing();
- virtual void post_move_processing();
- Meter_register();
- NAME_MEMBERS(Meter_register);
-};
-#endif // METERREG_HH
+++ /dev/null
-/*
- meter.hh -- declare Meter
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef METER_HH
-#define METER_HH
-#include "item.hh"
-#include "varray.hh"
-#include "scalar.hh"
-
-struct Meter: Item {
- Array<Scalar> args;
- /* *************** */
-NAME_MEMBERS(Meter);
-
- Meter(Array<Scalar> args) ;
- Molecule*brew_molecule_p() const;
-};
-#endif // METER_HH
-
+++ /dev/null
-/*
- midi-def.hh -- declare
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-*/
-
-
-#ifndef MIDIDEF_HH
-#define MIDIDEF_HH
-#include "proto.hh"
-#include "real.hh"
-#include "string.hh"
-#include "moment.hh"
-
-
-/**
- */
-struct Midi_def {
- /// output file name
- String outfile_str_;
-
- /// duration of whole note
- Real whole_seconds_f_;
-
- Midi_def();
- Midi_def(Midi_def const& midi_c_r);
- ~Midi_def();
-
- Real duration_to_seconds_f(Moment);
- int get_tempo_i( Moment moment );
- void set_tempo( Moment moment, int count_per_minute_i );
- void print() const;
-};
-
-#endif // MIDIDEF_HH //
-
+++ /dev/null
-//
-// midi-event.hh -- declare midi_event
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MIDI_EVENT_HH
-#define MIDI_EVENT_HH
-
-
-// should these:
-// * be Midi_items
-// * be Voice_elements/requests
-// * get a name-change
-// ?
-
-/// (midi_event)
-class Midi_event {
-public:
- Midi_event();
- virtual ~Midi_event();
-
- virtual String mudela_str(); // = 0;
- virtual void output_mudela( Lily_stream& lily_stream_r );
- virtual Moment mom();
-
-protected:
- String mudela_str_;
-};
-
-class Midi_key : public Midi_event {
-public:
- Midi_key( int accidentals_i, int minor );
- virtual ~Midi_key();
-
- String notename_str( int pitch_i );
-
-private:
- int accidentals_i_;
- int minor_i_;
- int key_i_;
-};
-
-class Midi_note : public Midi_event {
- public:
- int const c0_pitch_i_c_ = 60;
-
- Midi_note( Midi_key* midi_key_l, Midi_time* midi_time_l, int division_1_i, int pitch_i, int time_i );
- virtual ~Midi_note();
-
- virtual Moment mom();
-
-private:
- Duration dur_;
-};
-
-class Midi_tempo : public Midi_event {
-public:
- Midi_tempo( int useconds_per_4_i );
- virtual ~Midi_tempo();
-
- int get_tempo_i( Moment moment );
-
-private:
- int useconds_per_4_i_;
- Real seconds_per_1_f_;
-};
-
-class Midi_time : public Midi_event {
-public:
- Midi_time( int num_i, int den_i, int division_4_i, int count_32_i );
- virtual ~Midi_time();
-
- Duration i2_dur( int time_i, int division_1_i );
- int clocks_1_i();
-
-private:
- Real sync_f_;
- Duration sync_dur_;
- int clocks_1_i_;
- int num_i_;
- int den_i_;
-};
-
-#endif // MIDI_EVENT_HH
-
+++ /dev/null
-//
-// midi-item.hh -- part of LilyPond
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MIDI_ITEM_HH
-#define MIDI_ITEM_HH
-#include "string.hh"
-#include "proto.hh"
-
-struct Midi_item {
- /* *************** */
- static String i2varint_str( int i );
- virtual void output_midi( Midi_stream& midi_stream_r );
- virtual String str() = 0;
-};
-
-struct Midi_note : public Midi_item {
- /* *************** */
- int const c0_pitch_i_c_ = 60;
- Byte dynamic_byte_;
-
- /**
- Generate a note-event on a channel pitch.
-
- @param #melreq_l# is the pitch.
- */
- Midi_note( Melodic_req* melreq_l, int channel_i, bool on_b );
-
- virtual String str();
-
- int channel_i_;
- int on_b_;
- int pitch_i_;
-};
-
-struct Midi_duration : public Midi_item {
- /* *************** */
- Midi_duration( Real seconds_f );
-
- virtual String str();
-
- Real seconds_f_;
-};
-
-struct Midi_chunk : Midi_item {
- /* *************** */
- Midi_chunk();
-
- void add( String str );
- void set( String header_str, String data_str, String footer_str );
- virtual String str();
-
-private:
- String data_str_;
- String footer_str_;
- String header_str_;
-};
-
-struct Midi_header : Midi_chunk {
- /* *************** */
- Midi_header( int format_i, int tracks_i, int clocks_per_4_i );
-};
-
-struct Midi_tempo : Midi_item {
- /* *************** */
- Midi_tempo( int tempo_i );
-
- virtual String str();
-
- int tempo_i_;
-};
-
-struct Midi_track : Midi_chunk {
- /* *************** */
- int number_i_;
- Midi_track( int number_i );
-
- void add( int delta_time_i, String event );
-// void add( Moment delta_time_moment, Midi_item& mitem_r );
- void add( Moment delta_time_moment, Midi_item* mitem_l );
-};
-
-#endif // MIDI_ITEM_HH //
-
+++ /dev/null
-//
-// midi-main.hh -- global (sic) m2m stuff
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-#include "string.hh"
-
-#define monitor_p_g &cout
-enum Verbose { QUIET_ver, BRIEF_ver, NORMAL_ver, VERBOSE_ver, DEBUG_ver };
-extern Verbose level_ver;
-#ifdef NPRINT
-#define dtor if ( 0 ) *monitor_p_g
-#define mtor if ( 0 ) *monitor_p_g
-#else
-#define dtor if ( level_ver >= DEBUG_ver ) *monitor_p_g
-#define vtor if ( level_ver >= VERBOSE_ver ) *monitor_p_g
-#define mtor if ( level_ver >= NORMAL_ver ) *monitor_p_g
-#define btor if ( level_ver >= BRIEF_ver ) *monitor_p_g
-#define qtor if ( level_ver >= QUIET_ver ) *monitor_p_g
-#endif
-
-extern Source* source_l_g;
-extern bool no_triplets_bo_g;
-void message( String message_str, char const* context_ch_c_l );
-void warning( String message_str, char const* context_ch_c_l );
-void error( String message_str, char const* context_ch_c_l );
-
-String version_str();
+++ /dev/null
-/*
- midi-output.hh -- declare Midi_output
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef MIDIOUTPUT_HH
-#define MIDIOUTPUT_HH
-#include "pscore.hh"
-
-struct Midi_output {
- Midi_stream* midi_stream_l_;
- Midi_output(Score* score_l, Midi_def* );
- void do_staff(Staff*st_l, int count);
-
- Midi_def* midi_l_;
-};
-#endif // MIDIOUTPUT_HH
+++ /dev/null
-//
-// midi-score.hh -- declare midi_score
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MIDI_SCORE_HH
-#define MIDI_SCORE_HH
-
-/// (midi_score)
-class Midi_score {
-public:
- Midi_score( int format_i, int tracks_i, int tempo_i );
- ~Midi_score();
-
- void add_track( Midi_track* midi_track_p );
-
- int output_mudela( String filename_str );
-
-private:
- IPointerList<Midi_track*> midi_track_p_list_;
- int format_i_;
- int tracks_i_;
- int tempo_i_;
-};
-
-#endif // MIDI_SCORE_HH
-
+++ /dev/null
-//
-// midi-stream.hh -- part of LilyPond
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MIDI_STREAM_HH
-#define MIDI_STREAM_HH
-
-#include <iostream.h>
-#include "string.hh"
-
-/// Midi output
-struct Midi_stream {
- ostream* os_p_;
- String filename_str_;
- int clocks_per_4_i_;
- int tracks_i_;
-
- Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i_ );
- ~Midi_stream();
-
- Midi_stream& operator <<( String str );
- Midi_stream& operator <<( Midi_item& mitem_r );
- Midi_stream& operator <<( int i );
-
- void header();
- void open();
-
-//private:
-// Midi_stream(Midi_stream const&);
-};
-#endif // MIDI_STREAM_HH //
+++ /dev/null
-//
-// midi-track.hh -- declare midi_track
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MIDI_TRACK_HH
-#define MIDI_TRACK_HH
-
-/// (midi_track)
-class Midi_track {
-public:
- Midi_track( int track_i );
- ~Midi_track();
-
- void add_event( Moment mom, Midi_event* midi_event_p );
- String name_str();
- void output_mudela( Lily_stream& lily_stream_r );
- Track_column* tcol_l( Moment mom );
-
-private:
- IPointerList<Track_column*> tcol_p_list_;
- String name_str_;
-};
-
-#endif // MIDI_TRACK_HH
-
+++ /dev/null
-/*
- midi-walker.hh -- declare Midi_walker
-
- (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen <jan@digicash.com>
- */
-
-#ifndef MIDIWALKER_HH
-#define MIDIWALKER_HH
-
-#include "proto.hh"
-#include "grouping.hh"
-#include "staff-walker.hh"
-#include "pcursor.hh"
-#include "pqueue.hh"
-
-
-/**
- a simple walker which collects midi stuff, and then outputs.
-
- Should derive from Staff_walker
- */
-class Midi_walker : public PCursor<Staff_column*> {
- Midi_track *track_l_;
- PQueue<Melodic_req*, Moment> stop_notes;
- Moment last_moment_;
-
- /* *************** */
- void do_stop_notes(Moment);
-
- void output_event(Midi_item&, Moment);
-public:
-
- Midi_walker(Staff*, Midi_track*);
- void process_requests();
- ~Midi_walker();
-};
-
-
-#endif // MIDIWALKER_HH
-
-
+++ /dev/null
-#ifndef MISC_HH
-#define MISC_HH
-
-#include "proto.hh"
-#include "real.hh"
-#include "moment.hh"
-#include "scalar.hh"
-#include "grouping.hh"
-
-Moment wholes(int dur, int dots);
-double log_2(double x) ;
-int intlog2(int d);
-inline int
-abs(int i){
- return (i < 0)?-i:i;
-}
-inline int
-sign(int i) {
- if (i<0) return -1;
- else if (i) return 1;
- else return 0;
-}
-
-Interval itemlist_width(const Array<Item*> &its);
-
-#endif
+++ /dev/null
-#ifndef MOLECULE_HH
-#define MOLECULE_HH
-
-#include "proto.hh"
-#include "plist.hh"
-#include "boxes.hh"
-#include "symbol.hh"
-
-/// a symbol which can be translated, and freely copied
-struct Atom {
- Offset off;
- Symbol sym;
-
- /* *************** */
-
- void translate(Offset o) {
- off += o;
- }
-
- /// how big is #this#?
- Box extent() const;
- Atom(Symbol s);
-
- void print() const;
-
- String TeXstring() const;
-};
-
-
-/** a group of individually translated symbols. You can add molecules
- to the top, to the right, etc. */
-struct Molecule {
- IPointerList<Atom*> ats; // change to List<Atom>?
-
- /* *************** */
-
- Molecule() { }
- Molecule(Atom a) { add(a) ; }
-
- void add_right(const Molecule &m);
- void add_left(const Molecule &m);
- void add_top(const Molecule &m);
- void add_bottom(const Molecule &m);
- void add(Molecule const &m);
- void translate(Offset);
- void add(Atom a) { ats.bottom().add(new Atom(a)); }
- /// how big is #this#?
- Box extent() const;
-
- String TeXstring() const;
-
- Molecule(const Molecule&s);
- void print() const;
-private:
- void operator=(const Molecule&);
-};
-#endif
+++ /dev/null
-/*
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef MOMENT_HH
-#define MOMENT_HH
-
-#include "rational.hh"
-class String;
-typedef Rational Moment;
-
-
-#endif //
-
+++ /dev/null
-/*
- musicalrequests.hh -- declare Musical requests
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef MUSICALREQUESTS_HH
-#define MUSICALREQUESTS_HH
-
-#include "request.hh"
-
-
-/**
- A request which is coupled to a #Voice_element# with nonzero duration.
- Base class only
- */
-struct Musical_req : virtual Request {
- virtual Skip_req* skip() { return 0; }
- REQUESTMETHODS(Musical_req, musical);
-};
-
-
-struct Skip_req : Musical_req {
- Moment duration_;
-
- virtual Moment duration() const;
- REQUESTMETHODS(Skip_req, skip);
-};
-/** a request with a duration.
- This request is used only a base class.
- */
-struct Rhythmic_req : virtual Musical_req {
- int balltype;
- int dots;
- Moment plet_factor;
- /* *************** */
- static int compare(const Rhythmic_req &, const Rhythmic_req &);
- virtual Moment duration() const;
- Rhythmic_req();
- Rhythmic_req(int,int);
- REQUESTMETHODS(Rhythmic_req, rhythmic);
-};
-
-struct Spacing_req :virtual Request {
- Moment next;
- Real distance;
- Real strength;
- /* *************** */
- Spacing_req();
- REQUESTMETHODS(Spacing_req, spacing);
-};
-
-struct Blank_req : Spacing_req, Rhythmic_req {
- REQUESTMETHODS(Spacing_req, spacing);
-
-};
-
-/// Put a text above or below (?) this staff.
-struct Text_req : virtual Musical_req {
- /// preferred position (above/below)
- int dir_i_;
- /// the characteristics of the text
- Text_def *tdef_p_;
- /* *************** */
- Text_req(int d, Text_def*);
- ~Text_req();
- Text_req(Text_req const&);
- static int compare(const Text_req&,const Text_req&);
- REQUESTMETHODS(Text_req,text);
-};
-
-/** Put a text in lyric_staff
- @see Lyric_staff
- */
-struct Lyric_req : public Rhythmic_req, Text_req {
- Lyric_req(Text_def* t_p);
- REQUESTMETHODS(Lyric_req, lreq_l);
-};
-
-/// request which has some kind of pitch
-struct Melodic_req :virtual Musical_req
-{
- /// 0 is c, 6 is b
- int notename_i_;
- /// 0 is central c
- int octave_i_;
-
- /// 0 natural, 1 sharp, etc
- int accidental_i_;
-
- /// force/supress printing of accidental.
- bool forceacc_b_;
-
- /// return height from central c (in halflines)
- int height()const;
- /// return pitch from central c (in halfnotes)
- int pitch()const;
- Melodic_req();
-
- REQUESTMETHODS(Melodic_req,melodic);
-};
-
-/// Put a note of specified type, height, and with accidental on the staff.
-struct Note_req : Rhythmic_req, virtual Melodic_req {
-
-
- Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); }
- REQUESTMETHODS(Note_req, note);
- };
-
-/**
-Put a rest on the staff. Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
-*/
-class Rest_req : public Rhythmic_req {
-public:
- REQUESTMETHODS(Rest_req,rest);
-};
-
-/**
- attach a stem to the noteball.
- Rhythmic_req parent needed to determine if it will fit inside a beam.
- */
-struct Stem_req : Rhythmic_req {
- /// preferred direction for the stem
- int dir_i_;
- Stem_req(int s, int dots);
- REQUESTMETHODS(Stem_req,stem);
-};
-
-/**
- Requests to start or stop something.
- This type of request typically results in the creation of a #Spanner#
-*/
-struct Span_req : Musical_req {
- /// should the spanner start or stop, or is it unwanted?
- enum {
- NOSPAN, START, STOP
- } spantype ;
- static int compare(const Span_req &r1, const Span_req &r2);
- REQUESTMETHODS(Span_req,span);
-
- Span_req();
-
-};
-
-/// request for backward plet generation
-struct Plet_req : Request {
- char type_c_;
- int dur_i_;
- int type_i_;
- Plet_req();
-
- REQUESTMETHODS(Plet_req,plet);
-};
-/**
-*/
-
-/** Start / stop a beam at this note. if #nplet# is set, the staff will try to put an
-appropriate number over the beam
- */
-struct Beam_req : Span_req {
- int nplet;
-
- /* *************** */
- REQUESTMETHODS(Beam_req,beam);
-
- Beam_req();
-};
-
-/// a slur
-struct Slur_req : Span_req {
- REQUESTMETHODS(Slur_req,slur);
-
-};
-
-
-/**Put a script above or below this ``note''. eg upbow, downbow. Why a
-request? These symbols may conflict with slurs and brackets, so this
-also a request */
-struct Script_req : Musical_req {
- int dir_i_;
- Script_def *scriptdef_p_;
-
- /* *************** */
- static int compare(const Script_req &, const Script_req &);
- Script_req(int d, Script_def*);
- REQUESTMETHODS(Script_req,script);
- ~Script_req();
- Script_req(Script_req const&);
-};
-
-
-
-
-#endif // MUSICALREQUESTS_HH
+++ /dev/null
-//
-// my-midi-lexer.hh -- declare My_midi_lexer
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MY_MIDI_LEXER_HH
-#define MY_MIDI_LEXER_HH
-
-#include <FlexLexer.h>
-#include "proto.hh"
-// #include "fproto.hh"
-#include "varray.hh"
-#include "string.hh"
-
-int yylex();
-void yyerror(const char *s);
-// bool busy_parsing();
-// void kill_lexer();
-// void set_lexer();
-
-/// (midi_lexer)
-class My_midi_lexer : yyFlexLexer {
-public:
- My_midi_lexer( String filename_str );
- ~My_midi_lexer();
-
- int close_i();
- void error( char const* sz_l );
- char const* here_ch_c_l();
- static int varint2_i( String str );
- int yylex();
-
-private:
- Input_file* input_file_p_;
-
-public: // ugh
- int errorlevel_i_;
-};
-
-extern My_midi_lexer* midi_lexer_l_g;
-
-#endif // MY_MIDI_LEXER_HH
-
+++ /dev/null
-//
-// my-midi-parser.hh -- declare My_midi_parser
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef MY_MIDI_PARSER_HH
-#define MY_MIDI_PARSER_HH
-
-// #include "proto.hh"
-// #include "string.hh"
-
-int yyparse();
-
-/// (midi_parser)
-class My_midi_parser {
-public:
- My_midi_parser( String filename_str );
- ~My_midi_parser();
- void add_score( Midi_score* midi_score_p );
- void error( char const* sz_l );
- int parse();
- void forward( int i );
- Moment mom();
- void note_begin( int channel_i, int pitch_i, int dyn_i );
- Midi_event* note_end_midi_event_p( int channel_i, int pitch_i, int dyn_i );
- int output_mudela( String filename_str );
- void reset();
- void set_division_4( int division_4_i );
- void set_key( int accidentals_i, int minor_i );
- void set_tempo( int useconds_i );
- void set_time( int num_i, int den_i, int clocks_i, int count_32_i );
-
-private:
- Int64 now_i64_; // 31 bits yields tipically about 1000 bars
-
- static int const CHANNELS_i = 16;
- static int const PITCHES_i = 128;
- Int64 running_i64_i64_a_[ CHANNELS_i ][ PITCHES_i ];
-
- Midi_score* midi_score_p_;
- int division_1_i_;
- Midi_key* midi_key_p_;
- Midi_tempo* midi_tempo_p_;
- Midi_time* midi_time_p_;
-
- char const* defined_ch_c_l_;
- int fatal_error_i_;
- My_midi_lexer* midi_lexer_p_;
-};
-
-extern My_midi_parser* midi_parser_l_g;
-
-#endif // MY_MIDI_PARSER_HH
-
+++ /dev/null
-/*
- notehead.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef NOTEHEAD_HH
-#define NOTEHEAD_HH
-#include "item.hh"
-
-/**
- ball at the end of the stem
-takes care of:
-
- * help lines
- * proper placing of dots
-
- */
-
-struct Notehead : Item {
- NAME_MEMBERS(Notehead);
-
- int position;
- /// -1 = lowest, 0 = inside, 1 = top
- int extremal;
- /// needed for the help-lines
- int staff_size;
- int dots;
- int balltype;
- int x_dir;
-
- /* *************** */
-
- void set_rhythmic(Rhythmic_req *);
-
- /**
- position of top line (5 linestaff: 8)
- */
- Notehead(int staff_size);
- void do_print()const;
- static int compare(Notehead * const &a, Notehead *const &b) ;
- Molecule* brew_molecule_p()const;
-};
-#endif // NOTEHEAD_HH
-
+++ /dev/null
-/*
- notename.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef NOTENAME_HH
-#define NOTENAME_HH
-
-#include "string.hh"
-
-struct Notename_tab {
- String notetab[7*5];
-
- void set(int l, int s, String nm);
- void lookup(int &large, int &small, String s);
-};
-
-void set_notename_tab(Notename_tab*n);
-void lookup_notename(int &large, int &small, String s);
-
-
-#endif // NOTENAME_HH
-
+++ /dev/null
-/*
- offset.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef OFFSET_HH
-#define OFFSET_HH
-#include "real.hh"
-
-/// 2d vector
-struct Offset {
- Real x,y;
-
- Offset operator+(Offset o)const {
- Offset r(*this);
- r+=o;
- return r;
- }
-
- Offset operator+=(Offset o) {
- x+=o.x;
- y+=o.y;
- return *this;
- }
- Offset(Real ix , Real iy) {
- x=ix;
- y=iy;
- }
- Offset() {
- x=0.0;
- y=0.0;
- }
-};
-
-#endif // OFFSET_HH
-
-
+++ /dev/null
-/*
- paper-def.hh -- declare
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef Paper_def_HH
-#define Paper_def_HH
-#include "proto.hh"
-#include "real.hh"
-#include "string.hh"
-#include "moment.hh"
-
-
-/** symbols, dimensions and constants
-
- This struct takes care of all kinds of symbols, dimensions and
- constants. Most of them are related to the point-size of the fonts,
- so therefore, the lookup table for symbols is also in here.
-
- see TODO
- */
-struct Paper_def {
- Lookup *lookup_p_;
- String outfile;
-
- Real linewidth;
-
- /// how much space does a whole note take (ideally?)
- Real whole_width;
-
- /// ideal = geometric_ ^ log2(duration)
- Real geometric_;
-
- /* *************** */
- void reinit();
- Paper_def(Lookup*);
- void set(Lookup*);
- ~Paper_def();
- Paper_def(Paper_def const&);
- Real interline()const;
- Real internote()const;
- Real rule_thickness()const;
- Real standard_height()const;
- Real note_width() const;
- void print() const;
- Real duration_to_dist(Moment);
-};
-
-#endif // Paper_def_HH
-
+++ /dev/null
-/*
- parseconstruct.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef PARSECONSTRUCT_HH
-#define PARSECONSTRUCT_HH
-
-#include "proto.hh"
-
-extern char const* defined_ch_c_l;
-extern char const* req_defined_ch_c_l;
-void set_default_duration(int *);
-void last_duration(int n);
-void set_duration_mode(String s);
-void get_default_duration(int *);
-void set_default_octave(String);
-void set_plet(int,int);
-Voice_element * get_note_element(String,int * ,int *);
-Voice_element* get_rest_element(String,int *);
-Voice_element* get_word_element(Text_def*, int*);
-void add_requests( Voice_element*v, Array<Request*>&req);
-Request* get_request(char);
-void set_text_style(String);
-Script_def* get_scriptdef(char);
-Text_def*get_text(String s);
-Request* get_plet_request( char c, int dur_i, int type_i );
-Request*get_script_req(int d , Script_def*def);
-Request*get_text_req(int d , Text_def*def);
-Request* get_stemdir_req(int);
-
-
-
-
-Request*get_grouping_req(Array<int> i_arr);
-
-#endif // PARSECONSTRUCT_HH
-
+++ /dev/null
-#ifndef COLS_HH
-#define COLS_HH
-
-#include "glob.hh"
-#include "boxes.hh"
-#include "plist.hh"
-#include "item.hh"
-
-
-/**
- stuff grouped vertically.
- This is a class to address items vertically. It contains the data for:
- \begin{itemize}
- \item
- unbroken score
- \item
- broken score
- \item
- the linespacing problem
- \end{itemize}
- */
-
-struct PCol {
- PointerList<const Item*> its;
- PointerList<const Spanner*> stoppers, starters;
-
-
-
- /** prebreak is put before end of line.
- if broken here, then (*this) column is discarded, and prebreak
- is put at end of line, owned by Col
- */
- PCol *prebreak_p_;
-
- /// postbreak at beginning of the new line
- PCol *postbreak_p_;
-
- /** if this column is pre or postbreak, then this field points to
- the parent. */
- PCol *daddy_l_;
-
- /// if lines are broken then this column is in #line#
- const Line_of_score *line_l_;
-
- /// if lines are broken then this column x-coord #hpos#
- Real hpos;
-
- PScore * pscore_l_;
-
- /* *************** */
- /// which one (left =0)
- int rank() const;
-
- /// does this column have items
- bool used_b() const;
-
- void add(Item *i);
-
- /// Can this be broken? true eg. for bars.
- bool breakable_b()const;
-
- Interval width() const;
- ~PCol();
- PCol(PCol * parent);
-
- /**
- which col comes first?.
- signed compare on columns.
-
- @return < 0 if c1 < c2.
- */static int compare(const PCol &c1, const PCol &c2);
-
-
- void OK() const;
- void set_breakable();
- void print()const;
-private:
- PCol(PCol const&){}
-};
-
-
-#include "compare.hh"
-instantiate_compare(PCol &, PCol::compare);
-
-
-#endif
+++ /dev/null
-/*
- proto.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef PROTO_HH
-#define PROTO_HH
-
-#include "fproto.hh"
-#include "real.hh"
-
-/// (i64)
-typedef long long Int64;
-
-struct Absdynamic_req;
-struct Accidental;
-struct Atom;
-struct Bar;
-struct Bar_register;
-struct Barcheck_req;
-struct Bar_req;
-struct Beam;
-struct Beam_req;
-struct Box;
-struct Bracket_req;
-struct Cadenza_req;
-struct Chord;
-struct Clef_change_req;
-struct Clef_register;
-struct Clef_item;
-struct Col_hpositions;
-struct Colinfo;
-struct Complex_music;
-struct Complex_staff;
-struct Complex_walker;
-struct Cresc_req;
-struct Directional_spanner;
-struct Decresc_req;
-struct Duration;
-struct Duration_iterator;
-struct Durational_req;
-struct Dynamic;
-struct Group_change_req;
-struct Group_feature_req;
-struct Idealspacing;
-struct Identifier;
-struct Input_file;
-struct Input_music;
-struct Input_score;
-struct Input_staff;
-struct Item;
-struct Key;
-struct Key_register;
-struct Key_change_req;
-struct Key_item;
-struct Keyword;
-struct Keyword_table;
-struct Lily_stream;
-struct Line_of_score;
-struct Line_of_staff;
-struct Linestaff;
-struct Local_key;
-struct Local_key_register;
-struct Local_key_item;
-struct Lookup;
-struct Lyric_item;
-struct Lyric_req;
-struct Melodic_req;
-struct Measure_grouping_req;
-struct Meter_change_req;
-struct Meter;
-struct Meter_register;
-struct Midi_def;
-struct Midi_duration;
-struct Midi_event;
-struct Midi_header;
-struct Midi_item;
-struct Midi_key;
-struct Midi_note;
-struct Midi_output;
-struct Midi_pitch;
-struct Midi_staff;
-struct Midi_stream;
-struct Midi_tempo;
-struct Midi_time;
-struct Midi_track;
-struct Midi_walker;
-struct Mixed_qp;
-class My_midi_lexer;
-class My_midi_parser;
-class Midi_event;
-class Midi_score;
-class Midi_track;
-struct Molecule;
-struct Musical_req;
-struct Music_general_chord;
-struct Music_voice;
-struct Command_req;
-struct Note_req;
-struct Notehead;
-struct Notehead_register;
-struct Notename_tab;
-struct Offset;
-struct Output;
-struct PCol;
-struct Plet_req;
-struct Plet;
-struct PScore;
-struct PStaff;
-struct Paper_def;
-struct Partial_measure_req;
-struct Rational;
-struct Register_group_register;
-struct Request;
-struct Request_register;
-struct Rest;
-struct Rest_req;
-struct Rhythmic_grouping;
-struct Rhythmic_grouping_req;
-struct Rhythmic_req;
-struct Score;
-struct Score_column;
-struct Score_walker;
-struct Script_def;
-struct Script;
-struct Script_register;
-struct Script_req;
-struct Simple_music;
-struct Skip_req;
-struct Slur;
-struct Slur_register;
-struct Slur_req;
-struct Source;
-struct Source_file;
-struct Spacing_req ;
-struct Span_req;
-struct Spanner;
-struct Blank_req;
-struct Staff;
-struct Staff_column;
-struct Staff_elem;
-struct Staff_elem_info;
-struct Staff_symbol;
-struct Staff_walker;
-struct Stem;
-struct Stem_req;
-struct Stem_beam_register;
-struct String;
-struct Symbol;
-struct Symtable;
-struct Symtables;
-struct Tex_stream;
-struct Terminate_voice_req;
-struct Text_item ;
-struct Text_def;
-struct Text_gob;
-struct Text_register;
-struct Text_req;
-struct Timing_req;
-struct Time_description;
-struct Track_column;
-struct Voice;
-struct Voice_element;
-struct Voice_group_registers;
-struct Voice_list;
-struct Voice_registers;
-struct Voicegroup;
-struct Walker_registers;
-typedef Rational Moment;
-#endif // PROTO_HH
+++ /dev/null
-// the breaking problem for a score.
-
-#ifndef PSCORE_HH
-#define PSCORE_HH
-
-#include "colhpos.hh"
-#include "varray.hh"
-#include "pcol.hh"
-#include "pstaff.hh"
-
-
-/** all stuff which goes onto paper. notes, signs, symbols in a score can be grouped in two ways:
- horizontally (staffwise), and vertically (columns). #PScore#
- contains the items, the columns and the staffs.
- */
-
-struct PScore {
- Paper_def *paper_l_;
-
- /// the columns, ordered left to right
- IPointerList<PCol *> cols;
-
- /// the idealspacings, no particular order
- IPointerList<Idealspacing*> suz;
-
- /// the staffs ordered top to bottom
- IPointerList<PStaff*> staffs;
-
- /// all symbols in score. No particular order.
- IPointerList<Item*> its;
-
- /// if broken, the different lines
- IPointerList<Line_of_score*> lines;
-
- /// crescs etc; no particular order
- IPointerList<Spanner *> spanners;
-
- /// broken spanners
- IPointerList<Spanner*> broken_spans;
-
- /* *************** */
- /* CONSTRUCTION */
-
- PScore(Paper_def*);
- /// add a line to the broken stuff. Positions given in #config#
- void set_breaking(Array<Col_hpositions>);
-
- void add(PStaff *);
-
-
- /** add an item.
- add the item in specified containers. If breakstatus is set
- properly, add it to the {pre,post}break of the pcol.
- */
- void typeset_item(Item *item_p, PCol *pcol_l,PStaff*pstaf_l,int breakstatus=1);
-
- /// add a Spanner
- void typeset_spanner(Spanner*, PStaff*);
-
- /// add to bottom of pcols
- void add(PCol*);
- void add_broken(Spanner*);
-
- /* INSPECTION */
- Array<Item*> select_items(PStaff*, PCol*);
-
- /**
- @return argument as a cursor of the list
- */
- PCursor<PCol *> find_col(const PCol *)const;
-
- /* MAIN ROUTINES */
- void process();
-
- /// last deed of this struct
- void output(Tex_stream &ts);
-
- /* UTILITY ROUTINES */
-
- /// get the spacing between c1 and c2, create one if necessary.
- Idealspacing* get_spacing(PCol *c1, PCol *c2);
-
- /// connect c1 and c2
- void do_connect(PCol *c1, PCol *c2, Real distance_f, Real strength_f);
-
- /// connect c1 and c2 and any children of c1 and c2
- void connect(PCol* c1, PCol *c2, Real distance_f,Real strength_f= 1.0);
-
- /* STANDARD ROUTINES */
- void OK()const;
- void print() const;
-private:
- /// before calc_breaking
- void preprocess();
-
- /// calculate where the lines are to be broken, and use results
- void calc_breaking();
-
- /// after calc_breaking
- void postprocess();
-
- /// delete unused columns
- void clean_cols();
-};
-
-#endif
+++ /dev/null
-#ifndef PSTAFF_HH
-#define PSTAFF_HH
-
-#include "proto.hh"
-#include "plist.hh"
-#include "item.hh"
-#include "symbol.hh"
-
-/// items grouped horizontally
-struct PStaff {
- PScore * pscore_l_;
-
-
- PointerList<const Spanner*> spans;
- PointerList<Item*> its;
-
- /* *************** */
- void add(Item*i);
- PStaff(PScore*);
-
-private:
- PStaff(PStaff const&);
-};
-
-#endif
+++ /dev/null
-/*
- qlp.hh -- declare Ineq_constrained_qp, Mixed_qp
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef QLP_HH
-#define QLP_HH
-
-#include "matrix.hh"
-
-/// inequality constrained quadratic program
-class Ineq_constrained_qp {
- friend class Active_constraints;
-
- Array<Vector> cons;
- Array<Real> consrhs;
-public:
- Matrix quad;
- Vector lin;
- Real const_term;
-
-
- /**
- use a KKT method to assert optimality of sol
- */
- void assert_solution(Vector sol) const;
- /// solve the problem using a projected gradient method
- Vector solve(Vector start) const;
-
- /**
- @return the number of variables in the problem
- */
- int dim() const{
- return lin.dim();
- }
-
- /**
- add a constraint
-
-
- c*vars >= r
-
- PRE
- c.dim() == dim();
-
- */
- void add_inequality_cons(Vector c, double r);
-
- /** set up matrices to go with the problem. */
- Ineq_constrained_qp(int novars);
-
- /**
- evaluate the quadratic function for input #v#
- */
- Real eval(Vector v);
-
- void eliminate_var(int idx, Real value);
- void OK()const;
- void print() const;
-
-};
-
-
-/**
- Quadratic programming with mixed linear constraints.
- problem definition of a quadratic optimisation problem with linear
- inequality and equality constraints
-
-
- x^T QUAD x /2 + b^T x
-*/
-class Mixed_qp :public Ineq_constrained_qp {
- Array<int> eq_cons;
- Array<Real> eq_consrhs;
-public:
- Mixed_qp(int n);
- void OK() const;
- void print() const;
-
- Vector solve(Vector start) const;
- void add_fixed_var(int i , Real value);
-
-
- /**
- add a constraint,
-
- c*vars == r
-
- PRE
- c.dim()==dim();
- */
- void add_equality_cons(Vector c, double r);
-};
-#endif
+++ /dev/null
-/*
- qlpsolve.hh -- declare Active_constraints, Inactive_iter
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef QLPSOLVE_HH
-#define QLPSOLVE_HH
-#include "qlp.hh"
-#include "matrix.hh"
-
-
-/**
- This class represents the set of active (binding) constraints
- which can be active while the QLP algorithm is in a feasible
- point. The active constraints are numbered.
- If the constraints are of the form
-
- A^T*x >= b
-
- then the binding constraints are those where the >= is equality.
-
- */
-
-class Active_constraints {
- friend class Inactive_iter;
-
-
- Matrix A,H;
- Array<int> active;
- Array<int> inactive; // actually this is a set, not an array.
- const Ineq_constrained_qp *opt;
-
-public:
- String status()const;
-
- Vector vec(int k) const { return opt->cons[k]; }
- Real rhs(int k) const { return opt->consrhs[k]; }
-
-
- /** drop constraint. drop constraint k from the active set. k is the index of the
- constraint in #active#
-
- */
- void drop (int k);
-
-
- /** add constraint j.
- add constraint j to the active set j is the index of the
- constraint in #inactive#
- */
- void add(int j);
-
- /// exchange in and out.
- void exchange(int in, int out) { add(in); drop (out); }
-
-
- Vector find_active_optimum(Vector g);
-
- /// get lagrange multipliers.
- Vector get_lagrange(Vector v);
-
- Active_constraints(Ineq_constrained_qp const *op);
- /** construct: no constraints active, n vars. Put the equalities
- into the constraints. */
-
- /// check invariants
- void OK();
-};
-
-
-/**
- loop through the inactive constraints.
- */
-class Inactive_iter {
- int j;
- Active_constraints const* ac;
-public:
- Inactive_iter(Active_constraints const &c) { ac=&c; j=0; }
- int idx() const { return j; }
- void operator ++(int) { j++; }
- int constraint_id() const { return ac->inactive[j]; }
- Vector vec() const { return ac->vec(constraint_id()); }
- Real rhs() const { return ac->rhs(constraint_id()); }
- bool ok() const { return j < ac->inactive.size(); }
-};
-
-#endif // QLPSOLVE_HH
+++ /dev/null
-/*
- register.hh -- part of LilyPond
-
- (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef REGISTER_HH
-#define REGISTER_HH
-
-#include "proto.hh"
-#include "varray.hh"
-#include "request.hh"
-#include "staff-elem-info.hh"
-
-/**
- a struct which processes requests, and creates the #Staff_elem#s.
- It may use derived classes. Hungarian postfix: register
- */
-class Request_register {
- friend class Register_group_register;
- /**
- You cannot copy a Request_register
- */
- Request_register(const Request_register&){}
-protected:
-
- /// utility
- virtual Paper_def * paper() const;
-
- /**
- try to fit the request in this register
-
- @return
- false: not noted, not taken.
-
- true: request swallowed. Don't try to put the request elsewhere.
-
-
- Default: always return false
- */
- virtual bool try_request(Request *req_l);
-
- /// make items/spanners with the requests you got
- virtual void process_requests(){}
-
- /** typeset any items/spanners. Default: do nothing
- */
- virtual void pre_move_processing(){}
- /** reset any appropriate data. Default: do nothing
- */
- virtual void post_move_processing(){}
-
- /**
- Is this request eligible to be processed? Default: return false.
- */
- virtual bool acceptable_request_b(Request*) const;
-
- /**
- typeset a "command" item. Default: pass on to daddy.
- If the column is not breakable, #pre_p# and #post_p# are junked
- */
- virtual void typeset_breakable_item(Item * pre_p ,
- Item * nobreak_p, Item * post_p);
- /**
- Invoke walker method to typeset element. Default: pass on to daddy.
- */
- virtual void typeset_element(Staff_elem*elem_p);
-
- /**
- take note of item/spanner
- put item in spanner. Adjust local key; etc.
-
- Default: ignore the info
- */
- virtual void acknowledge_element(Staff_elem_info) {}
- /**
- Announce element. Default: pass on to daddy. Utility
- */
- virtual void announce_element(Staff_elem_info);
- /**
- Set features of the register(s). Default: ignore features.
- */
- virtual void set_feature(Features){}
- /**
- Does this equal or contain a certain register?
- */
- virtual bool contains_b(Request_register*reg_l);
- /**
- Get information on the staff. Default: ask daddy.
- */
- virtual Staff_info get_staff_info();
-
- virtual void do_print()const;
-public:
- /** Every Request_register (except for the 'top' which is directly
- inside the Staff_walker, is a element of a group. */
- Register_group_register * daddy_reg_l_;
-
- Request_register();
- virtual ~Request_register(){}
- NAME_MEMBERS(Request_register);
- void print() const;
-};
-
-
-#endif // REGISTER_HH
-
+++ /dev/null
-/*
- registergroup.hh -- declare
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef REGISTERGROUP_HH
-#define REGISTERGROUP_HH
-
-
-#include "plist.hh"
-#include "staff-elem-info.hh"
-#include "register.hh"
-
-/**
- Group a number of registers. Usually delegates everything to its contents.
- Postfix: group
- */
-class Register_group_register : public Request_register {
-protected:
- IPointerList<Request_register*> reg_list_;
- virtual void do_print()const;
-public:
-
- /**
- Junk #reg_l#.
-
- Pre:
- #reg_l# is in #reg_list_#
- */
- virtual void terminate_register(Request_register * reg_l);
-
- /**
- Remove #reg_l# from the list, and return it.
- */
- Request_register * get_register_p(Request_register*reg_l);
- virtual void set_feature(Features i);
- virtual bool acceptable_request_b(Request*);
- virtual void pre_move_processing();
- virtual void post_move_processing();
- virtual void acknowledge_element(Staff_elem_info info);
- virtual bool try_request(Request*);
- virtual void process_requests();
- virtual ~Register_group_register();
- virtual void add(Request_register* reg_p);
- virtual bool contains_b(Request_register*);
-};
-
-#endif // REGISTERGROUP_HH
-
-
+++ /dev/null
-#if 0
-
-
-
-/**Draw a (Guitar) chord above or below this ``note''.
-Why a request?
-Because everything else is done in requests.
-*/
-struct Chord : Request {
- // don't know how this looks.
-};
-
-
-/// for absolute dynamics
-enum Loudness {
- FFF, FF, F, MF, MP, P, PP, PPP
-} ;
-
-
-/**
-Start/stop a bracket at this note. if #nplet# is set, the staff will
-try to put an appropriate number over the bracket
-*/
-struct Bracket_req : Span_req {
- int nplet; // print a number over the beam.
-};
-
-struct Subtle_req {
- Moment subtime;
-};
-
-
-/** helper in the hierarchy. Each dynamic is bound to one note ( a
- crescendo spanning multiple notes is thought to be made of two
- "dynamics": a start and a stop). Dynamic changes can occur in a
- smaller time than the length of its note, therefore fore each
- Dynamic request carries a time, measured from the start of its
- note.
-
- This subfield would come in handy, if mpp96 was adapted for midi
- support.
-
- Dynamic should have been derived from request, but I don't want to
- fuss with virtual baseclasses. */
-
-struct Dynamic:Subtle_req {
-
-};
-/// do a crescendo
-struct Cresc_req : Span_req, Dynamic {
-
-};
-
-/// do a decrescendo
-struct Decresc_req : Span_req, Dynamic {
-
-};
-
-/// do a dynamic like "fff" or "mp"
-struct Absdynamic_req : Request, Dynamic {
- Loudness loudness;
-};
-
-struct Grace_req : Subtle_req {
-
-};
-
-struct Grace_turn_req : Grace_turn {
-
-};
-
-struct Grace_note : Melodic_req {
-
-};
-
-struct Grace_notes {
-
-};
-
-struct Glissando_req : Span_req {
-
-};
-#endif
+++ /dev/null
-/*
- request.hh -- declare Request baseclasses.
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef REQUEST_HH
-#define REQUEST_HH
-// LilyPond's second egg of columbus!
-
-#include "glob.hh"
-#include "string.hh"
-#include "moment.hh"
-#include "class-name.hh"
-
-/**
- a voice element wants something printed.
- Hungarian postfix: req
- @see lilygut manpage
- */
-class Request {
-public:
- Voice_element*elt_l_;
- char const* defined_ch_c_l_;
-
- /* *************** */
- Voice * voice_l();
- Request();
- Request(Request const&);
- virtual ~Request(){}
-
- NAME_MEMBERS(Request);
- virtual Request* clone() const { return new Request(*this); }
- void print()const ;
-
- virtual Moment duration() const { return 0; }
-
- /* accessors for children
- maybe checkout RTTI
- */
- virtual Barcheck_req *barcheck() { return 0; }
- virtual Note_req *note() { return 0;}
- virtual Script_req *script() { return 0;}
- virtual Stem_req *stem() { return 0;}
- virtual Text_req*text() { return 0; }
- virtual Rest_req *rest() { return 0; }
- virtual Span_req *span() { return 0; }
- virtual Beam_req *beam() { return 0 ; }
- virtual Plet_req* plet() { return 0; }
- virtual Slur_req *slur() { return 0 ; }
- virtual Rhythmic_req*rhythmic() { return 0; }
- virtual Lyric_req* lreq_l() { return 0; }
- virtual Melodic_req *melodic() { return 0; }
- virtual Terminate_voice_req *terminate() {return 0;}
- virtual Group_change_req * groupchange() { return 0;}
- virtual Group_feature_req * groupfeature() { return 0; }
- virtual Spacing_req * spacing() { return 0; }
- virtual Blank_req * blank() { return 0; }
- virtual Musical_req *musical() { return 0; }
- virtual Command_req * command() { return 0; }
-protected:
- virtual void do_print()const ;
-};
-
-#define REQUESTMETHODS(T,accessor) \
-virtual T * accessor() { return this;}\
-NAME_MEMBERS(T);\
-virtual Request *clone() const { return new T(*this); } \
-virtual void do_print() const
-
-#endif
+++ /dev/null
-/*
- rest.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef REST_HH
-#define REST_HH
-#include "item.hh"
-
-struct Rest : Item {
-
- int dots;
- int balltype;
-
- /* *************** */
-
-
- Rest(int dur,int dots);
- void do_print()const;
-NAME_MEMBERS(Rest);
- Molecule* brew_molecule_p()const;
-};
-#endif
-
+++ /dev/null
-/*
- sccol.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SCCOL_HH
-#define SCCOL_HH
-#include "proto.hh"
-#include "varray.hh"
-#include "moment.hh"
-
-
-/**
-
- When typesetting hasn't started on PScore yet, the columns which
- contain data have a rhythmical position. Score_column is the type
- with a rhythmical time attached to it. The calculation of
- idealspacing is done with data in these columns. (notably: the
- #durations# field)
-
- */
-
-class Score_column {
- friend class Score;
- friend class Score_walker;
-
- bool musical_b_;
- Moment when_;
- void set_breakable();
-public:
- /// indirection to column
- PCol * pcol_l_;
-
- /// length of notes/rests in this column
- Array<Moment> durations;
-
- /* *************** */
-
- Moment when() { return when_; }
- Score_column(Moment when);
- static int compare(Score_column & c1, Score_column &c2);
- void add_duration(Moment );
- void preprocess();
- bool breakable_b();
- bool musical_b() { return musical_b_; }
- bool used_b();
- void print() const;
-
-
-};
-
-instantiate_compare(Score_column&, Score_column::compare);
-
-#endif // SCCOL_HH
-
-
-
-
+++ /dev/null
-/*
- score-walker.hh -- declare Score_walker
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef SCOREWALKER_HH
-#define SCOREWALKER_HH
-#include "pcursor.hh"
-#include "proto.hh"
-#include "varray.hh"
-
-
-/**
- walk through the score_columns, and while doing so, walk all staffs in a score.
- */
-class Score_walker : public PCursor<Score_column *>
-{
- Score* score_l_;
- /// walkers for the individual staves.
- Array<Staff_walker *> walker_p_arr_;
- Array<Staff_walker *> disallow_break_walk_l_arr;
- int disallow_break_count_;
- void reinit();
-public:
- void allow_break(Staff_walker*w);
- Score_walker(Score*);
- ~Score_walker();
- Moment when();
- void operator++(int);
- /// process staff walkers.
- void process();
-};
-#endif // SCOREWALKER_HH
+++ /dev/null
-/*
- score.hh -- declare Score
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef SCORE_HH
-#define SCORE_HH
-
-#include "varray.hh"
-#include "proto.hh"
-#include "plist.hh"
-#include "moment.hh"
-#include "assoc.hh"
-#include "string.hh"
-
-/// the total music def of one movement
-struct Score {
- /// paper_, staffs_ and commands_ form the problem definition.
- Paper_def *paper_p_;
- Midi_def *midi_p_;
- IPointerList<Staff*> staffs_;
-
- /// "runtime" fields for setting up spacing
- IPointerList<Score_column*> cols_;
- PScore *pscore_p_;
-
- const char *defined_ch_c_l_;
- int errorlevel_i_;
-
- /* *************************************************************** */
-
- /// construction
- Score();
- ~Score();
- void add(Staff*);
-
- /// do everything except outputting to file
- void process();
-
- /// output to file
- void output(String fn);
-
-
- ///
- void set(Midi_def* midi_p);
- ///
- void set(Paper_def* midi_p);
-
- // standard
- void OK() const;
- void print() const;
-
- /// find a column.
- PCursor<Score_column *> find_col(Moment,bool);
-
- /// when does the last *musical* element finish?
- Moment last() const;
-
-private:
- void paper_output();
- void setup_music();
- void process_music();
- /// do midi stuff
- void midi();
-
- /// do paper stuff
- void paper();
-
- // utils:
- PCursor<Score_column*> create_cols(Moment);
-
- Score(Score const&){}
-
- /**
- make the pcol_l_ fields of each Score_column point to the correct PCol,
- remove any unnecessary Score_column's
- */
- void do_cols();
-
- /// remove unused cols
- void clean_cols();
-
- /// add #Idealspacings# to #pscore_#
- void calc_idealspacing();
-};
-#endif
+++ /dev/null
-/*
- scoreline.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SCORELINE_HH
-#define SCORELINE_HH
-#include "proto.hh"
-#include "plist.hh"
-#include "varray.hh"
-
-/// the columns of a score that form one line.
-struct
-Line_of_score {
- PointerList<PCol *> cols;
-
- // need to store height of each staff.
- IPointerList<Line_of_staff*> staffs;
- PScore * pscore_l_; // needed to generate staffs
-
- /* *************** */
- void process() ;
- Line_of_score(Array<PCol *> sv, PScore *);
-
- String TeXstring() const;
-
- // is #c# contained in #*this#?
- bool element(const PCol *c);
-};
-
-#endif
-
+++ /dev/null
-/*
- script-def.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SCRIPTDEF_HH
-#define SCRIPTDEF_HH
-#include "string.hh"
-struct Script_def{
- int stemdir;
- int staffdir;
-
- bool invertsym;
- String symidx;
-
- /* *************** */
- int compare(Script_def const &);
- void print() const;
- Script_def(String, int, int ,bool);
-};
-
-
-#endif // SCRIPTDEF_HH
-
+++ /dev/null
-/*
- script-reg.hh -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef SCRIPTREG_HH
-#define SCRIPTREG_HH
-
-#include "register.hh"
-
-
-struct Script_register : Request_register {
- Script * script_p_;
- Script_req * script_req_l_;
- int dir_i_;
- /* *************** */
- void set_feature(Features dir_i_);
- Script_register();
- virtual bool try_request(Request*);
- virtual void process_requests();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void pre_move_processing();
- virtual void post_move_processing();
- NAME_MEMBERS(Script_register);
-};
-
-#endif // SCRIPTREG_HH
+++ /dev/null
-/*
- script.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SCRIPT_HH
-#define SCRIPT_HH
-
-#include "script-def.hh"
-#include "item.hh"
-
-struct Script : Item {
- int dir;
- int symdir;
- int pos;
- int staffsize;
- Script_def *specs_l_;
- Stem *stem_l_;
- Array<Item *> support;
-
- /* *************** */
- NAME_MEMBERS(Script);
- Molecule *brew_molecule_p()const;
- virtual void do_post_processing();
- virtual void do_pre_processing();
- Script(Script_req*, int staffsize);
- void set_support(Item*);
- void set_stem(Stem*);
- Interval support_height()const;
- virtual Interval width() const;
-private:
- void set_symdir();
- void set_default_dir();
- void set_default_index();
- Symbol symbol()const;
-};
-
-
-#endif // SCRIPT_HH
-
+++ /dev/null
-/*
- slur-reg.hh -- declare Slur_register
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef SLURREG_HH
-#define SLURREG_HH
-
-#include "register.hh"
-
-struct Slur_register : Request_register {
- Array<Slur_req*> requests_arr_;
- Array<Slur_req*> new_slur_req_l_arr_;
- Array<Slur *> slur_l_stack_;
- Array<Slur*> end_slur_l_arr_;
-
- int dir_i_;
-
- /* *************** */
- ~Slur_register();
- Slur_register();
- virtual bool try_request(Request*);
- virtual void process_requests();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void pre_move_processing();
- virtual void post_move_processing();
- virtual void set_feature(Features);
- NAME_MEMBERS(Slur_register);
-};
-
-#endif // SLURREG_HH
+++ /dev/null
-/*
- slur.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SLUR_HH
-#define SLUR_HH
-
-#include "directional-spanner.hh"
-#include "fproto.hh"
-#include "varray.hh"
-
-struct Slur : Directional_spanner {
-
- Array<Notehead*> encompass;
-
- bool open_left, open_right;
-
- /* *************** */
- Offset center() const;
- Slur();
- void do_post_processing();
- void do_pre_processing();
- void add(Notehead*);
- void set_default_dir();
-
- Spanner* do_break_at( PCol*, PCol*) const;
- void process();
-private:
- Molecule*brew_molecule_p()const;
- NAME_MEMBERS(Slur);
-};
-
-#endif // SLUR_HH
-
-
+++ /dev/null
-//
-// source-file.hh -- declare Source_file
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef SOURCE_FILE_HH
-#define SOURCE_FILE_HH
-
-/// class for reading and mapping a file.
-class Source_file
-{
-public:
- /** Ugh! filename gets changed! The path to the opened file may
- change, since it might be searched in multiple directories. */
- Source_file( String& filename_str_r );
- virtual ~Source_file();
-
- char const* ch_c_l();
- virtual String error_str( char const* pos_ch_c_l );
- istream* istream_l();
- bool in_b( char const* pos_ch_c_l );
- off_t length_off();
- virtual int line_i( char const* pos_ch_c_l );
- String name_str();
- String file_line_no_str( char const* ch_c_l );
-
-private:
- void close();
- void map();
- void open();
- void unmap();
-
- istream* istream_p_;
- int fildes_i_;
- String name_str_;
- off_t size_off_;
- caddr_t data_caddr_;
-};
-
-#endif // SOURCE_FILE_HH //
+++ /dev/null
-//
-// source.hh -- part of LilyPond
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef SOURCE_HH
-#define SOURCE_HH
-
-class Source
-{
-public:
- Source();
- ~Source();
-
- void add( Source_file* sourcefile_p );
- Source_file* sourcefile_l( char const* ch_c_l );
-
-private:
- IPointerList<Source_file*> sourcefile_p_iplist_;
-};
-
-
-// ugh
-extern Source* source_l_g;
-
-#endif // SOURCE_HH //
+++ /dev/null
-/*
- spanner.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SPANNER_HH
-#define SPANNER_HH
-
-#include "proto.hh"
-#include "staff-elem.hh"
-
-
-/** a symbol which is attached between two columns. A spanner is a symbol which spans across several columns, so its
- final appearance can only be calculated after the breaking problem
- is solved.
-
- Examples
-
- - (de)crescendo
- - slur
- - beam
- - bracket
-
-
- Spanner should know about the items which it should consider:
- e.g. slurs should be steep enough to "enclose" all those items. This
- is absolutely necessary for beams, since they have to adjust the
- length of stems of notes they encompass.
-
- */
-struct Spanner:Staff_elem {
- PCol *left, *right;
-
-
- /* *************** */
-
- Spanner();
- virtual Interval width()const;
- void do_print()const;
-
- Spanner *broken_at(PCol *c1, PCol *c2) const;
- virtual Spanner* spanner() { return this; }
-protected:
-
- /**
- clone a piece of this spanner.
- PRE
- c1 >= start, c2 <= stop
- */
- virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0;
- NAME_MEMBERS(Spanner);
-};
-#endif
+++ /dev/null
-/*
- staff-column.hh -- declare Staff_column
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef STAFFCOLUMN_HH
-#define STAFFCOLUMN_HH
-#include "proto.hh"
-#include "varray.hh"
-#include "moment.hh"
-
-/// store simultaneous requests
-class Staff_column {
-
- Staff_column(Staff_column const&);
-
-public:
- Array<Request*> creationreq_l_arr_;
- Array<Request*> musicalreq_l_arr_;
- Array<Request*> commandreq_l_arr_;
- Staff * staff_l_;
-
- /// fields to collect timing data vertically.
- Array<Timing_req*> timing_req_l_arr_;
- Score_column *musical_column_l_, *command_column_l_;
-
- /* *************** */
-
- Staff_column();
-
- Moment when() const;
- void set_cols(Score_column *c1, Score_column *c2);
- void add(Voice_element*ve);
- void OK() const;
- ~Staff_column();
- void typeset_breakable_items(Array<Item *> &pre_p_arr,
- Array<Item *> &nobreak_p_arr,
- Array<Item *> &post_p_arr);
- void typeset_musical_item(Item *i);
-protected:
- void setup_one_request(Request*);
-};
-
-
-
-#endif // STAFFCOLUMN_HH
-
+++ /dev/null
-/*
- staff-elem-info.hh -- declare Staff_elem_info
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef STAFFELEMINFO_HH
-#define STAFFELEMINFO_HH
-
-#include "proto.hh"
-#include "varray.hh"
-/// data container.
-struct Staff_elem_info {
- Staff_elem * elem_p_;
- Request*req_l_;
- const Voice * voice_l_;
- Array<Request_register*> origin_reg_l_arr_;
-
-
- /* *** */
- Staff_elem_info(Staff_elem*, Request*);
- Staff_elem_info();
-};
-
-struct Staff_info {
- int *c0_position_i_;
- Staff_walker *walk_l_;
- const Time_description *time_c_l_;
- const Rhythmic_grouping *rhythmic_c_l_;
-};
-
-
-struct Features {
- bool initialiser_b_;
- int direction_i_;
-
- Features();
- static Features dir(int);
-};
-#endif // STAFFELEMINFO_HH
+++ /dev/null
-/*
- staff-elem.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef STAFFELEM_HH
-#define STAFFELEM_HH
-#include "varray.hh"
-#include "proto.hh"
-#include "offset.hh"
-#include "molecule.hh"
-#include "class-name.hh"
-
-
-/** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend
- on other Staff_elem's, eg, Beam needs to know and set direction of
- Stem. So the Beam has to be calculated *before* Stem. This is
- accomplished with the dependencies field of struct Staff_elem.
-
- */
-struct Staff_elem {
- enum Status {
- ORPHAN, // not yet added to pstaff
- VIRGIN, // added to pstaff
- PRECALCING,
- PRECALCED, // calcs before spacing done
- POSTCALCING,
- POSTCALCED, // after spacing calcs done
- OUTPUT, // molecule has been output
- } status;
-
- /// the pstaff it is in
- PStaff *pstaff_l_;
-
- /* *************** */
- Staff_elem(Staff_elem const&);
- String TeXstring () const ;
- virtual void print() const;
- virtual Interval width() const;
- virtual Interval height() const;
- Paper_def *paper() const;
- virtual ~Staff_elem();
- Staff_elem();
- NAME_MEMBERS(Staff_elem);
- void translate(Offset);
- void add_processing();
- void pre_processing();
- void post_processing();
- void molecule_processing();
-
- virtual Spanner* spanner() { return 0; }
- virtual Item * item() { return 0; }
- void add_dependency(Staff_elem* );
- void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
-
-protected:
-
- /// do printing of derived info.
- virtual void do_print() const=0;
- /// generate the molecule
- virtual Molecule* brew_molecule_p()const=0;
- ///executed directly after the item is added to the PScore
- virtual void do_add_processing();
- /// do calculations before determining horizontal spacing
- virtual void do_pre_processing();
-
- /// do calculations after determining horizontal spacing
- virtual void do_post_processing();
-
- Array<Staff_elem*> dependants;
-
-private:
- /// member: the symbols
- Molecule *output; // should scrap, and use temp var?
-
-
- /**
- This is needed, because #output# may still be
- NULL.
- */
- Offset offset_;
- Array<Staff_elem*> dependencies;
-};
-
-
-#endif // STAFFELEM_HH
-
+++ /dev/null
-/*
- staff-walker.hh -- declare Staff_walker
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef STAFFWALKER_HH
-#define STAFFWALKER_HH
-
-#include "proto.hh"
-#include "time-description.hh"
-#include "pcursor.hh"
-
-/**
- manage run-time info when walking staffcolumns such as: key,
- meter, pending beams & slurs
- */
-struct Staff_walker : public PCursor<Staff_column*> {
- Staff * staff_l_;
- PScore * pscore_l_;
- Score_walker *score_walk_l_;
- Time_description time_;
- Rhythmic_grouping *default_grouping;
-
- /* *************** */
-
- Moment when() const;
- virtual ~Staff_walker();
- Staff_walker(Staff*, PScore*);
- void process() ;
-
- void operator++(int);
- void allow_break();
-
-protected:
- /// every time before ++ is called
- virtual void do_pre_move(){}
- /// every time after ++ is called
- virtual void do_post_move(){}
- virtual void process_requests()=0;
-private:
- void process_timing_reqs();
- Staff_walker(Staff_walker const&);
-};
-
-#endif // STAFFWALKER_HH
-
+++ /dev/null
-/*
- staff.hh -- declare Staff
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#ifndef STAFF_HH
-#define STAFF_HH
-
-#include "plist.hh"
-#include "proto.hh"
-#include "moment.hh"
-
-/// base class for a collection of voices.
-class Staff {
- Staff(const Staff&src);
-
- /// synchronous horizontal stuff
- IPointerList<Voice*> voice_list_;
- Staff_column *get_col(Moment, PCursor<Staff_column*> * last= 0);
-
-public:
-
- /// runtime field
- IPointerList<Staff_column*> cols_;
-
- Score *score_l_;
- PScore *pscore_l_;
- PStaff *pstaff_l_;
-
- /* *************************************************************** */
-
- void add(const PointerList<Voice*> &s);
-
- void add_voice(Voice *v);
- Paper_def*paper()const;
-
- void setup_staffcols();
-
- void OK() const;
- void print() const;
-
- /// when does the last *musical* element finish?
- Moment last() const;
-
-// /// extract midi info
-// Midi_track* midi_track_p();
-
- /// remove unused cols
- void clean_cols() ;
- Staff();
-
- virtual void set_output(PScore * destination)=0;
- virtual Staff_walker *get_walker_p()=0;
- virtual ~Staff() { }
-protected:
-
-};
-#endif
+++ /dev/null
-/*
- staffline.hh -- horizontal structures for broken scores.
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef STAFFLINE_HH
-#define STAFFLINE_HH
-
-#include "proto.hh"
-#include "real.hh"
-#include "plist.hh"
-#include "varray.hh"
-#include "glob.hh"
-#include "pstaff.hh"
-
-/// one broken line of staff.
-struct Line_of_staff {
-
- Line_of_score * line_of_score_l_;
- PStaff *pstaff_l_;
-
- /* *************** */
-
- String TeXstring() const;
- Line_of_staff(Line_of_score*, PStaff *);
- Interval height() const;
- void process();
-};
-
-#endif
+++ /dev/null
-/*
- staffsym.hh -- declare Staff_symbol
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef STAFFSYM_HH
-#define STAFFSYM_HH
-#include "spanner.hh"
-/**
- This spanner draws the lines of a pstaff.
- The bottom line is position 0.
- */
-class Staff_symbol : public Spanner
-{
-public:
- /// this many lines.
- int no_lines_i_;
-
- NAME_MEMBERS(Staff_symbol);
- Staff_symbol(int lines);
- virtual Molecule* brew_molecule_p() const;
- void set_extent(PCol* p1, PCol* p2);
- virtual void do_print()const;
- virtual Spanner *do_break_at( PCol *c1, PCol *c2) const;
-};
-#endif // STAFFSYM_HH
+++ /dev/null
-/*
- stem-beam-reg.hh -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef STEMBEAMREG_HH
-#define STEMBEAMREG_HH
-#include "register.hh"
-
-struct Stem_beam_register : Request_register {
- Stem * stem_p_;
- Beam * beam_p_;
- Beam_req * beam_req_l_;
- Stem_req * stem_req_l_;
- Beam_req * start_req_l_;
- bool end_beam_b_;
- Rhythmic_grouping *current_grouping;
- int default_dir_i_;
-
- /* *************** */
- Stem_beam_register();
- ~Stem_beam_register();
- virtual void set_feature(Features dir_i_);
- virtual bool try_request(Request*);
- virtual void process_requests();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void pre_move_processing();
- virtual void post_move_processing();
- NAME_MEMBERS(Stem_beam_register);
-};
-#endif // STEMBEAMREG_HH
+++ /dev/null
-/*
- stem.hh -- declare Stem
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef STEM_HH
-#define STEM_HH
-#include "item.hh"
-#include "varray.hh"
-#include "moment.hh"
-
-
-/**the rule attached to the ball.
- takes care of:
-
- \begin{itemize}
- \item the rule
- \item the flag
- \item up/down position.
- \end{itemize}
- */
-
-struct Stem : Item {
- /// heads that the stem encompasses (positions)
- int minnote, maxnote;
-
- /// false if in beam
- bool print_flag;
-
- int beams_left;
- int beams_right;
-
- /// needed for determining direction/length
- int staff_center;
-
-
- /**extent of the stem (positions).
- fractional, since Beam has to adapt them.
- */
-
- Real bot, top;
- Real stemlen;
-
- /// flagtype? 4 none, 8 8th flag, 0 = beam.
- int flag;
-
-
- /**
- geen gedonder, jij gaat onder.
- -1 stem points down, +1: stem points up
- */
-
- int dir;
- Real stem_xoffset;
-
- Array<Notehead*> heads;
-
- /* *************** */
- Stem(int center); //, Moment duration);
-
- /// ensure that this Stem also encompasses the Notehead #n#
- void add(Notehead*n);
-
- NAME_MEMBERS(Stem);
-
- Real hindex()const;
- void do_print() const;
- void set_stemend(Real);
- int get_default_dir();
- void set_default_dir();
- void set_default_stemlen();
- void set_default_extents();
- void set_noteheads();
- void do_pre_processing();
-
- Interval width() const;
-
- Molecule* brew_molecule_p() const;
-};
-#endif
+++ /dev/null
-#ifndef SYMBOL_HH
-#define SYMBOL_HH
-
-#include "string.hh"
-#include "boxes.hh"
-#include "proto.hh"
-
-struct Symbol {
- String tex;
- Box dim;
-
- Symbol (String, Box);
- Symbol();
- String str()const; // for printing.
-};
-
-#endif
+++ /dev/null
-/*
- lilypond, (c) 1996,97 Han-Wen Nienhuys
-*/
-#ifndef SYMTABLE_HH
-#define SYMTABLE_HH
-#include "assoc.hh"
-#include "string.hh"
-#include "symbol.hh"
-
-struct Symtable : public Assoc<String, Symbol> {
- Symbol lookup(String)const;
- void print()const;
-};
-
-
-struct Symtables : private Assoc<String, Symtable*> {
-
- Symtable* operator()(String s);
- ~Symtables();
- Symtables();
- Symtables(Symtables const&);
- Assoc<String, Symtable*>::add;
- void print()const;
-};
-
-
-#endif
-
+++ /dev/null
-#ifndef TSTREAM__HH
-#define TSTREAM__HH
-
-#include <iostream.h>
-#include "string.hh"
-
-
-/** TeX output.
- Use this class for writing to a TeX file.
- It counts braces to prevent nesting errors, and
- it will add a comment sign before each newline.
- */
-struct Tex_stream {
- bool outputting_comment;
- ostream *os;
- int nest_level;
-
- /// open a file for writing
- Tex_stream(String filename);
- void header();
- /// delegate conversion to string class.
- Tex_stream &operator<<(String);
-
- /// close the file
- ~Tex_stream();
-private:
- Tex_stream(Tex_stream const&);
-};
-#endif
+++ /dev/null
-#ifndef TEX_HH
-#define TEX_HH
-
-#include "string.hh"
-#include "boxes.hh"
-#include "scalar.hh"
-
-/** parameter substitution in TeXstrings.
- this function provides a simple macro mechanism:
-
- if source == "tex%bla%", then
- substitute_args(source, {"X","Y"}) == "texXblaY"
- */
-String
-substitute_args(String source, Array<String> args);
-
-/// parameter substitution in TeXstrings
-String
-substitute_args(String source, Array<Scalar> args);
-
-/// #h# is in points
-String vstrut(Real h);
-
-
-#endif
+++ /dev/null
-/*
- text-def.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef TEXTDEF_HH
-#define TEXTDEF_HH
-
-#include "string.hh"
-#include "proto.hh"
-
-struct Text_def {
- int align_i_;
- String text_str_;
- String style_str_;
- char const* defined_ch_c_l_;
-
-
- /* ****************/
- virtual ~Text_def() {};
- bool compare(const Text_def&);
- Text_def();
- virtual void print() const;
- virtual Atom create_atom(Paper_def*) const;
-};
-
-#endif // TEXTDEF_HH
-
+++ /dev/null
-/*
- text-reg.hh -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef TEXTREG_HH
-#define TEXTREG_HH
-#include "register.hh"
-
-struct Text_register : Request_register{
- Text_item * text_p_;
- Text_req * text_req_l_;
- int dir_i_;
- /* *************** */
- virtual void set_feature(Features );
- Text_register();
- virtual bool try_request(Request*);
- virtual void process_requests();
- virtual void pre_move_processing();
- virtual void post_move_processing();
- NAME_MEMBERS(Text_register);
-};
-
-#endif // TEXTREG_HH
+++ /dev/null
-/*
- text.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef TEXT_ITEM_HH
-#define TEXT_ITEM_HH
-
-#include "text-def.hh"
-#include "item.hh"
-
-struct Text_item : Item {
- int pos_i_;
- int staffsize_i_;
- int dir_i_;
- Text_def* tdef_l_;
-
- /* ***************/
- NAME_MEMBERS(Text_item);
- virtual void set_default_index();
- Molecule* brew_molecule_p() const;
- void do_pre_processing();
-
- Text_item(Text_req*,int);
-};
-
-
-#endif // TEXT_HH
-
+++ /dev/null
-/*
- textspanner.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef TEXTSPANNER_HH
-#define TEXTSPANNER_HH
-
-#include "string.hh"
-#include "directional-spanner.hh"
-#include "text-def.hh"
-
-/** a spanner which puts texts on top of other spanners. Use for
- triplets, eentweetjes, ottava, etc. */
-struct Text_spanner : Spanner {
- Text_def spec;
- Offset text_off_;
- Directional_spanner*support;
-
- /* *************** */
-
- NAME_MEMBERS(Text_spanner);
- virtual void do_pre_processing();
- virtual void do_post_processing();
- virtual Interval height() const ;
- virtual Molecule* brew_molecule_p()const;
- virtual void do_print() const;
- virtual Spanner* do_break_at(PCol*,PCol*)const;
- Text_spanner();
- void set_support(Directional_spanner*);
-};
-#endif // TEXTSPANNER_HH
-
+++ /dev/null
-/*
- moment.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef tdes_HH
-#define tdes_HH
-
-#include "moment.hh"
-
-/// full info on where we are
-struct Time_description {
- Moment when_;
-
- /// if true, no bars needed, no reduction of whole_in_measure
- bool cadenza_b_;
-
- /// current measure info
- Moment whole_per_measure_;
-
- /// where am i
- Moment whole_in_measure_;
-
- /// how long is one beat?
- Moment one_beat_;
-
- /// idem
- int bars_i_;
-
- /* *************** */
- void set_cadenza(bool);
- void OK() const;
- Time_description();
- void add(Moment dt);
- String str()const;
- void print() const;
- void setpartial(Moment p);
- Moment barleft();
- void set_meter(int,int);
- static int compare (Time_description&, Time_description&);
-};
-
-#include "compare.hh"
-
-
-instantiate_compare(Time_description&,Time_description::compare);
-
-#endif // Time_description_HH
-
+++ /dev/null
-//
-// track-column.hh -- declare Track_column
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#ifndef TRACK_COLUMN_HH
-#define TRACK_COLUMN_HH
-
-/// (tcol)
-class Track_column {
-public:
- Track_column( Moment mom );
- ~Track_column();
-
- void add_event( Midi_event* midi_event_p );
- Moment mom();
-
-//private:
- IPointerList<Midi_event*> midi_event_p_list_;
- Moment mom_;
-};
-
-#endif // TRACK_COLUMN_HH
-
+++ /dev/null
-/*
- voice-element.hh -- declare Voice_element
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef VOICE_ELEMENT_HH
-#define VOICE_ELEMENT_HH
-
-#include "proto.hh"
-#include "plist.hh"
-#include "moment.hh"
-
-/** one horizontal bit. Voice_element is nothing but a container for
- *the requests, */
-struct Voice_element {
- Moment duration;
- char const* defined_ch_c_l_;
- const Voice *voice_l_;
- IPointerList<Request*> reqs;
-
- /* *************** */
-
- Voice_element();
- Voice_element(Voice_element const & src );
-
- void add(Request*);
- bool find_plet_start_bo(char c, Moment& moment_r);
- void print ()const;
- void set_default_group(String id);
- void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
-};
-
-#endif // VOICE-ELEMENT_HH
+++ /dev/null
-/*
- voice-group-regs.hh -- declare Voice_group_registers
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef VOICEGROUPREGS_HH
-#define VOICEGROUPREGS_HH
-
-#include "registergroup.hh"
-
-struct Voice_group_registers : Register_group_register {
- String group_id_str_;
- Array<Voice_registers*> voice_regs_l_;
-
- /* *************** */
-
- NAME_MEMBERS(Voice_group_registers);
- static bool static_acceptable_request_b(Request*);
- virtual void terminate_register(Request_register*);
- virtual void do_print() const;
- virtual void add(Request_register*);
- Voice_group_registers(String id);
- virtual bool try_request(Request*);
-};
-#endif // VOICEGROUPREGS_HH
+++ /dev/null
-/*
- voice-regs.hh -- declare Voice_registers
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef VOICEREGS_HH
-#define VOICEREGS_HH
-
-#include "registergroup.hh"
-
-class Voice_registers : public Register_group_register {
-
-
-public:
- Voice *voice_l_;
- /* *************** */
-
- NAME_MEMBERS(Voice_registers);
- virtual bool acceptable_request_b(Request*);
- virtual void acknowledge_element(Staff_elem_info info);
- virtual bool try_request(Request*);
- Voice_registers(Voice*);
- virtual void do_print() const;
-};
-
-
-#endif // VOICEREGS_HH
+++ /dev/null
-#ifndef VOICE_HH
-#define VOICE_HH
-
-#include "proto.hh"
-#include "plist.hh"
-#include "moment.hh"
-
-/** class for horizontal stuff.
-
- Voice is a ordered row of Voice_elements. It is strictly
- horizontal: you cannot have two rhythmic elements running parallel
- in a Voice. For proper processing, each Voice should have
- Group_change_req as a first element.
-
- */
-
-struct Voice {
- IPointerList<Voice_element *> elts;
- Moment start;
-
- /* *************** */
- Voice();
- Voice(Voice const&);
-
- Moment when(const Voice_element*)const;
- Moment last() const;
-
- void add(Voice_element*);
- bool find_plet_start_bo(char c, Moment& moment_r);
- void print() const;
- void set_default_group(String id);
- void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
-};
-
-#endif
+++ /dev/null
-/*
- walkregs.hh -- declare Walker_registers
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
-#ifndef WALKREGS_HH
-#define WALKREGS_HH
-
-
-#include "registergroup.hh"
-
-/**
- Top level registers: the interface to Complex_walker.
-
- [sigh. Sometimes I wish C++ could do better late binding.]
- */
-struct Walker_registers : Register_group_register {
- Array<Item*> prebreak_item_p_arr_;
- Array<Item*> nobreak_item_p_arr_;
- Array<Item*> postbreak_item_p_arr_;
- Array<Staff_elem_info> announce_info_arr_;
- Array<Voice_group_registers*> group_l_arr_;
- Complex_walker * walk_l_;
-
- /* *************** */
- void change_group(Group_change_req * greq_l,
- Voice_registers *voice_regs_l,
- Voice_group_registers * old_group);
- Voice_group_registers * get_group(String id);
- void typeset_musical_item(Staff_elem * elem_p);
- Walker_registers(Complex_walker*);
- void do_announces();
- void terminate_register(Request_register * reg);
- virtual bool try_request(Request * r);
- virtual Staff_info get_staff_info();
-
- virtual void announce_element(Staff_elem_info);
- virtual void acknowledge_element(Staff_elem_info);
- virtual void typeset_breakable_item(Item * pre_p , Item * nobreak_p, Item * post_p);
- virtual void typeset_element(Staff_elem*elem_p);
- virtual void pre_move_processing();
- virtual void post_move_processing();
- virtual Paper_def * paper() const;
-};
-
-#endif // WALKREGS_HH
+++ /dev/null
-DISTFILES=Makefile
-dist:
- ln $(DISTFILES) $(DDIR)/$(SUBDIR)
-
-clean:
- rm *.o
\ No newline at end of file
+++ /dev/null
-default:
- $(MAKE) -C ..
-
-win32:
- $(MAKE) -C .. Windows_NT
-
-DISTFILES=Makefile $(allcc) $(othersrc)
-dist:
- ln $(DISTFILES) $(DDIR)/$(SUBDIR)
-
-TAGS: $(allcc)
- $(TAGSACTION) $^
-
-clean:
- rm -f $(gencc)
+++ /dev/null
-/*
- bar-reg.cc -- implement Bar_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "bar-reg.hh"
-#include "bar.hh"
-#include "commandrequest.hh"
-#include "score-column.hh"
-#include "time-description.hh"
-
-Bar_register::Bar_register()
-{
- post_move_processing();
-}
-
-bool
-Bar_register::try_request(Request*r_l)
-{
- Command_req* c_l = r_l->command();
- if (!c_l|| !c_l->bar())
- return false;
-
- assert(!bar_req_l_);
- bar_req_l_ = c_l->bar();
-
- return true;
-}
-
-void
-Bar_register::process_requests()
-{
- if (bar_req_l_ ) {
- bar_p_ = new Bar(bar_req_l_->type_str_);
- } else if (!get_staff_info().time_c_l_->whole_in_measure_) {
- bar_p_ = new Bar("|");
- }
-
- if (bar_p_){
- announce_element(Staff_elem_info(bar_p_, bar_req_l_) );
- }
-}
-
-void
-Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post)
-{
- String s= no->type;
- if (s == ":|:") {
- pre = new Bar(":|");
- post = new Bar("|:");
- }else if (s=="|:") {
- post = new Bar(s);
- } else {
- pre = new Bar(*no);
- }
-}
-
-void
-Bar_register::pre_move_processing()
-{
- if (bar_p_) {
- Bar * post_p =0;
- Bar * pre_p =0;
- split_bar(pre_p, bar_p_, post_p);
-
- typeset_breakable_item(pre_p, bar_p_, post_p);
- bar_p_ =0;
- }
-}
-
-void
-Bar_register::post_move_processing()
-{
- bar_req_l_ = 0;
- bar_p_ =0;
-}
+++ /dev/null
-#include "bar.hh"
-#include "string.hh"
-#include "molecule.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "debug.hh"
-
-
-
-Bar::Bar( String t)
-{
- type = t;
-}
-
-void
-Bar::do_print()const
-{
- mtor << type;
-}
-
-Molecule*
-Bar::brew_molecule_p()const
-{
- Symbol s = paper()->lookup_p_->bar(type);
- Molecule*output = new Molecule(Atom(s));
- return output;
-}
-
+++ /dev/null
-#include "varray.hh"
-
-#include "dimen.hh"
-#include "beam.hh"
-#include "misc.hh"
-#include "debug.hh"
-#include "symbol.hh"
-#include "molecule.hh"
-#include "leastsquares.hh"
-#include "pcol.hh"
-#include "stem.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "grouping.hh"
-
-
-
-struct Stem_info {
- Real x;
- Real idealy;
- Real miny;
- int no_beams;
-
-
- Stem_info(){}
- Stem_info(const Stem*);
-};
-
-Stem_info::Stem_info(const Stem*s)
-{
- x = s->hindex();
- int dir = s->dir;
- idealy = max(dir*s->top, dir*s->bot);
- miny = max(dir*s->minnote, dir*s-> maxnote);
- assert(miny <= idealy);
-
-}
-
-/* *************** */
-
-Offset
-Beam::center()const
-{
- assert(status >= POSTCALCED);
-
- Real w=(paper()->note_width() + width().length())/2.0;
- return Offset(w, (left_pos + w* slope)*paper()->internote());
-}
-
-
-Beam::Beam()
-{
- slope = 0;
- left_pos = 0.0;
-}
-
-void
-Beam::add(Stem*s)
-{
- stems.bottom().add(s);
- s->add_dependency(this);
- s->print_flag = false;
-}
-
-void
-Beam::set_default_dir()
-{
- int dirs[2];
- dirs[0]=0; dirs[1] =0;
- for (iter_top(stems,i); i.ok(); i++) {
- int d = i->get_default_dir();
- dirs[(d+1)/2] ++;
- }
- dir_i_ = (dirs[0] > dirs[1]) ? -1 : 1;
- for (iter_top(stems,i); i.ok(); i++) {
- i->dir = dir_i_;
- }
-}
-
-/*
- should use minimum energy formulation (cf linespacing)
- */
-void
-Beam::solve_slope()
-{
- Array<Stem_info> sinfo;
- for (iter_top(stems,i); i.ok(); i++) {
- i->set_default_extents();
- Stem_info info(i);
- sinfo.push(info);
- }
- Real leftx = sinfo[0].x;
- Least_squares l;
- for (int i=0; i < sinfo.size(); i++) {
- sinfo[i].x -= leftx;
- l.input.push(Offset(sinfo[i].x, sinfo[i].idealy));
- }
-
- l.minimise(slope, left_pos);
- Real dy = 0.0;
- for (int i=0; i < sinfo.size(); i++) {
- Real y = sinfo[i].x * slope + left_pos;
- Real my = sinfo[i].miny;
-
- if (my - y > dy)
- dy = my -y;
- }
- left_pos += dy;
- left_pos *= dir_i_;
- slope *= dir_i_;
-
- // URG
- Real sl = slope*paper()->internote();
- paper()->lookup_p_->beam(sl, 20 PT);
- slope = sl /paper()->internote();
-}
-
-void
-Beam::set_stemlens()
-{
- iter_top(stems,s);
- Real x0 = s->hindex();
- for (; s.ok() ; s++) {
- Real x = s->hindex()-x0;
- s->set_stemend(left_pos + slope * x);
- }
-}
-
-
-void
-Beam::do_post_processing()
-{
- solve_slope();
- set_stemlens();
-}
-
-void
-Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur)
-{
- def.OK();
- cur.OK();
- assert(cur.children.size() == stems.size());
-
- cur.split(def);
-
- Array<int> b;
- {
- iter_top(stems,s);
- Array<int> flags;
- for (; s.ok(); s++) {
- int f = intlog2(abs(s->flag))-2;
- assert(f>0);
- flags.push(f);
- }
- int fi =0;
- b= cur.generate_beams(flags, fi);
- b.insert(0,0);
- b.push(0);
- assert(stems.size() == b.size()/2);
- }
-
- iter_top(stems,s);
- for (int i=0; i < b.size() && s.ok(); i+=2, s++) {
- s->beams_left = b[i];
- s->beams_right = b[i+1];
- }
-}
-
-
-// todo.
-Spanner *
-Beam::do_break_at( PCol *, PCol *) const
-{
- Beam *beam_p= new Beam(*this);
-
- return beam_p;
-}
-
-void
-Beam::do_pre_processing()
-{
- left = (*stems.top()) ->pcol_l_;
- right = (*stems.bottom())->pcol_l_;
- assert(stems.size()>1);
- if (!dir_i_)
- set_default_dir();
-
-}
-
-
-Interval
-Beam::width() const
-{
- Beam * me = (Beam*) this; // ugh
- return Interval( (*me->stems.top()) ->hindex(),
- (*me->stems.bottom()) ->hindex() );
-}
-
-/*
- beams to go with one stem.
- */
-Molecule
-Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const
-{
- assert( !next || next->hindex() > here->hindex() );
- assert( !prev || prev->hindex() < here->hindex() );
- Real dy=paper()->internote()*2;
- Real stemdx = paper()->rule_thickness();
- Real sl = slope*paper()->internote();
- paper()->lookup_p_->beam(sl, 20 PT);
-
- Molecule leftbeams;
- Molecule rightbeams;
-
- /* half beams extending to the left. */
- if (prev) {
- int lhalfs= lhalfs = here->beams_left - prev->beams_right ;
- int lwholebeams= here->beams_left <? prev->beams_right ;
- Real w = (here->hindex() - prev->hindex())/4;
- Symbol dummy;
- Atom a(dummy);
- if (lhalfs) // generates warnings if not
- a = paper()->lookup_p_->beam(sl, w);
- a.translate(Offset (-w, -w * sl));
- for (int j = 0; j < lhalfs; j++) {
- Atom b(a);
- b.translate(Offset(0, -dir_i_ * dy * (lwholebeams+j)));
- leftbeams.add( b );
- }
- }
-
- if (next){
- int rhalfs = here->beams_right - next->beams_left;
- int rwholebeams = here->beams_right <? next->beams_left;
-
- Real w = next->hindex() - here->hindex();
- Atom a = paper()->lookup_p_->beam(sl, w + stemdx);
-
- int j = 0;
- for (; j < rwholebeams; j++) {
- Atom b(a);
- b.translate(Offset(0, -dir_i_ * dy * j));
- rightbeams.add( b );
- }
-
- w /= 4;
- if (rhalfs)
- a = paper()->lookup_p_->beam(sl, w);
-
- for (; j < rwholebeams + rhalfs; j++) {
- Atom b(a);
- b.translate(Offset(0, -dir_i_ * dy * j));
- rightbeams.add(b );
- }
-
- }
- leftbeams.add(rightbeams);
- return leftbeams;
-}
-
-
-Molecule*
-Beam::brew_molecule_p() const return out;
-{
- Real inter=paper()->internote();
- out = new Molecule;
- Real x0 = stems.top()->hindex();
-
- for (iter_top(stems,i); i.ok(); i++) {
- PCursor<Stem*> p(i-1);
- PCursor<Stem*> n(i+1);
- Stem * prev = p.ok() ? p.ptr() : 0;
- Stem * next = n.ok() ? n.ptr() : 0;
-
- Molecule sb = stem_beams(i, next, prev);
- Real x = i->hindex()-x0;
- sb.translate(Offset(x, (x * slope + left_pos)* inter));
- out->add(sb);
- }
- out->translate(Offset(x0 - left->hpos,0));
-}
-
-void
-Beam::do_print()const
-{
-#ifndef NPRINT
- mtor << "slope " <<slope << "left ypos " << left_pos;
- Spanner::print();
-#endif
-}
-
-Beam::~Beam()
-{
-
-}
+++ /dev/null
-/*
- binary-source-file.cc -- implement Binary_source_file
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Jan Nieuwenhuizen
-*/
-
-
-#include <limits.h> // INT_MAX
-#include <assert.h>
-
-#include "proto.hh"
-#include "plist.hh"
-#include "string.hh"
-#include "debug.hh"
-#include "source-file.hh"
-#include "binary-source-file.hh"
-#include "string-convert.hh"
-
-Binary_source_file::Binary_source_file( String& filename_str )
- : Source_file( filename_str )
-{
-}
-
-Binary_source_file::~Binary_source_file()
-{
-}
-
-String
-Binary_source_file::error_str( char const* pos_ch_c_l )
-{
- assert( this );
- if ( !in_b( pos_ch_c_l ) )
- return "";
-
- char const* begin_ch_c_l = pos_ch_c_l - 8 >? ch_c_l();
- char const* end_ch_c_l = pos_ch_c_l + 7 <? ch_c_l() + length_off();
-
- String pre_str( (Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l );
- pre_str = String_convert::bin2hex_str( pre_str );
- for ( int i = 2; i < pre_str.length_i(); i += 3 )
- pre_str = pre_str.left_str( i ) + " " + pre_str.mid_str( i + 1, INT_MAX );
- String post_str( (Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l );
- post_str = String_convert::bin2hex_str( post_str );
- for ( int i = 2; i < post_str.length_i(); i += 3 )
- post_str = post_str.left_str( i ) + " " + post_str.mid_str( i + 1, INT_MAX );
-
- String str = pre_str
- + String( '\n' )
- + String( ' ', pre_str.length_i() + 1 )
- + post_str;
- return str;
-}
-
-int
-Binary_source_file::line_i( char const* pos_ch_c_l )
-{
- if ( !in_b( pos_ch_c_l ) )
- return 0;
-
- return pos_ch_c_l - ch_c_l();
-}
-
+++ /dev/null
-#include "boxes.hh"
-#include "const.hh"
-#include "varray.hh"
-
-
-Box::Box()
-{
-}
-
-Box::Box(Interval ix, Interval iy)
-{
- x = ix;
- y = iy;
-}
-
+++ /dev/null
-/*
- do calculations for breaking problem
- */
-#include "break.hh"
-#include "paper-def.hh"
-#include "linespace.hh"
-#include "debug.hh"
-#include "scoreline.hh"
-#include "pscore.hh"
-
-
-/*
- return all breakable columns
- */
-Line_of_cols
-Break_algorithm::find_breaks() const
-{
- Line_of_cols retval;
- for (iter_top(pscore_.cols,c); c.ok(); c++)
- if (c->breakable_b())
- retval.push(c);
- assert(retval.top() == pscore_.cols.bottom().ptr());
- return retval;
-}
-
-// construct an appropriate Spacing_problem and solve it.
-Col_hpositions
-Break_algorithm::solve_line(Line_of_cols curline) const
-{
- Spacing_problem sp;
-
- sp.add_column(curline[0], true, 0.0);
- for (int i=1; i< curline.size()-1; i++)
- sp.add_column(curline[i]);
- sp.add_column(curline.top(), true, linelength);
-
- // misschien moeven uit Spacing_problem?
- for (iter_top(pscore_.suz,i); i.ok(); i++) {
- sp.add_ideal(i);
- }
- Array<Real> the_sol=sp.solve();
- Col_hpositions col_hpos;
- col_hpos.cols = curline;
- col_hpos.energy = the_sol.pop();
- col_hpos.config = the_sol;
- col_hpos.OK();
- return col_hpos;
-}
-
-Break_algorithm::Break_algorithm(PScore&s)
- :pscore_(s)
-{
- linelength = s.paper_l_->linewidth;
-}
-
-bool
-Break_algorithm::feasible(Line_of_cols curline) const
-{
- Real l =0;
- for (int i=0; i < curline.size(); i++)
- l +=curline[i]->width().length();
- return l < linelength;
-}
-
-void
-Break_algorithm::problem_OK() const
-{
- if (!pscore_.cols.size())
- error("Score does not have any columns");
-#ifndef NDEBUG
- iter_top(pscore_.cols,start);
- PCursor<PCol *> end (pscore_.cols.bottom());
-
- assert(start->breakable_b());
- assert(end->breakable_b());
-#endif
-}
+++ /dev/null
-#include "idealspacing.hh"
-#include "score.hh"
-#include "pscore.hh"
-#include "paper-def.hh"
-#include "score-column.hh"
-#include "dimen.hh"
-
-
-/**
- this needs A LOT of rethinking.
-
- generate springs between columns.
-
- */
-void
-Score::calc_idealspacing()
-{
- iter_top(cols_,i);
-
- for (; i.ok(); i++) {
- assert(i->used_b());
- PCursor<Score_column*> j(i+1);
- if (i->musical_b()) {
- assert(j.ok());
- for (int n=0; n < i->durations.size(); n++) {
- Moment d = i->durations[n];
- Real dist = paper_p_->duration_to_dist(d);
- Real strength = i->durations[0]/i->durations[n];
- assert(strength <= 1.0);
-
- while (j->when() < d + i->when())
- j++;
- Moment delta_desired = j->when() - (d+i->when());
- dist += paper_p_->duration_to_dist(delta_desired);
-
- pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, strength);
- }
- } else if (j.ok()) {
-
- /* attach i to the next column in use. This exists, since
- the last col is breakable, and therefore in use
- */
-
- Moment d = j->when() - i->when();
- Real dist = (d) ? paper_p_->duration_to_dist(d) : 2 PT; // todo
-
- pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, (d) ? 1.0:1.0);
- }
- // !j.ok() might hold if we're at the last col.
- }
-}
-
-
+++ /dev/null
-/*
- clef-item.cc -- implement Clef_item
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "clef-item.hh"
-#include "string.hh"
-#include "molecule.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "clef-reg.hh"
-
-
-
-Clef_item::Clef_item()
-{
- change = true;
- read("violin");
-}
-
-void
-Clef_item::read(String t)
-{
- type = t;
- if (type == "violin")
- y_off = 2;
- if (type == "alto")
- y_off = 4;
- if (type == "tenor")
- y_off = 6;
- if (type == "bass")
- y_off = 6;
-}
-void
-Clef_item::read(Clef_register const &k)
-{
- read(k.clef_type_str_);
-}
-
-Molecule*
-Clef_item::brew_molecule_p()const
-{
- String t = type;
- if (change)
- t += "_change";
- Symbol s = paper()->lookup_p_->clef(t);
- Molecule*output = new Molecule(Atom(s));
- output->translate(Offset(0, paper()->internote() * y_off));
- return output;
-}
-
+++ /dev/null
-/*
- clef.cc -- implement Clef_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>,
- Mats Bengtsson <matsb@s3.kth.se>
-*/
-
-#include "clef-reg.hh"
-#include "clef-item.hh"
-#include "debug.hh"
-#include "commandrequest.hh"
-#include "time-description.hh"
-#include "staff-column.hh"
-
-Clef_register::Clef_register()
-{
- clef_p_ = 0;
-
- /* ugly hack to prevent segfault (daddy_reg_l_ == 0 at construction) */
- clef_type_str_ = "";
-}
-
-bool
-Clef_register::set_type(String s)
-{
- clef_type_str_ = s;
- if (clef_type_str_ == "violin") {
- c0_position_i_= -2;
- } else if (clef_type_str_ == "alto") {
- c0_position_i_= 4;
- } else if (clef_type_str_ == "tenor") {
- c0_position_i_= 6;
- } else if (clef_type_str_ == "bass") {
- c0_position_i_= 10;
- }else
- return false;
- *get_staff_info().c0_position_i_ = c0_position_i_;
-
- return true;
-}
-
-void
-Clef_register::read_req(Clef_change_req*c_l)
-{
- if (!set_type(c_l->clef_str_))
- error("unknown clef type ", c_l->defined_ch_c_l_);
-}
-
-bool
-Clef_register::try_request(Request * r_l)
-{
- Command_req* creq_l= r_l->command();
- if (!creq_l || !creq_l->clefchange())
- return false;
-
- clef_req_l_ = creq_l->clefchange();
-
- // do it now! Others have to read c0_pos.
- read_req(creq_l->clefchange());
- return true;
-}
-
-void
-Clef_register::process_requests()
-{
- const Time_description *time_l = get_staff_info().time_c_l_;
- if (!clef_req_l_ && (!time_l->whole_in_measure_|| !time_l->when_)) {
- clef_p_ = new Clef_item;
- clef_p_->change = false;
- } else if (clef_req_l_) {
- clef_p_ = new Clef_item;
- clef_p_->change = true;
- }
- if (clef_p_) {
- clef_p_->read(*this);
- announce_element(Staff_elem_info(clef_p_,
- clef_req_l_));
- }
-}
-
-void
-Clef_register::pre_move_processing()
-{
- if (!clef_p_)
- return;
- if (clef_p_->change) {
- Clef_item* post_p = new Clef_item(*clef_p_);
- post_p->change = false;
- typeset_breakable_item(new Clef_item(*clef_p_),
- clef_p_, post_p);
- } else {
- typeset_breakable_item(0, 0, clef_p_);
- }
- clef_p_ = 0;
-}
-
-void
-Clef_register::post_move_processing()
-{
- clef_req_l_ = 0;
- /* not in ctor, since the reg might not be linked in.*/
- if (clef_type_str_ == "") {
- set_type("violin");
- }
-}
+++ /dev/null
-#include "colhpos.hh"
-#include "real.hh"
-#include "debug.hh"
-#include "const.hh"
-#include "vector.hh"
-
-Col_hpositions::Col_hpositions()
-{
- energy = INFTY;
-}
-
-void
-Col_hpositions::add( PCol*c)
-{
- cols.push(c);
-}
-
-void
-Col_hpositions::print() const
-{
-#ifndef NPRINT
- mtor << "energy : " << energy << '\n';
- mtor << "line of " << config.size() << " cols\n";
- Vector v(config);
- mtor << v;
-#endif
-}
-
-void
-Col_hpositions::OK()const
-{
-#ifndef NDEBUG
- assert(config.size() == cols.size());
-#endif
-}
+++ /dev/null
-/*
- commandrequest.cc -- implement Nonmusical reqs
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "commandrequest.hh"
-#include "debug.hh"
-#include "musicalrequest.hh"
-
-
-void
-Cadenza_req::do_print()const
-{
- mtor << on_b_;
-}
-
-Cadenza_req::Cadenza_req(bool b)
-{
- on_b_ =b;
-}
-/* *************** */
-
-
-int
-Bar_req::compare(const Bar_req &c1)const
-{
- return type_str_ == c1.type_str_;
-}
-
-void
-Bar_req::do_print() const
-{
- mtor << type_str_;
-}
-
-Bar_req::Bar_req(String s)
-{
- type_str_ = s;
-}
-
-Partial_measure_req::Partial_measure_req(Moment m)
-{
- duration_ =m;
-}
-/* *************** */
-Meter_change_req::Meter_change_req()
-{
- beats_i_ = 0;
- one_beat_i_ =0;
-}
-void
-Meter_change_req::set(int b,int o)
-{
- beats_i_=b;
- one_beat_i_=o;
-}
-
-void
-Timing_req::do_print()const{}
-
-void
-Command_req::do_print()const{}
-/* *************** */
-void
-Barcheck_req::do_print() const{}
-
-/* *************** */
-void
-Clef_change_req::do_print() const
-{
- mtor << clef_str_ ;
-}
-
-Clef_change_req::Clef_change_req(String s)
-{
- clef_str_ = s;
-}
-/* *************** */
-void
-Group_feature_req::do_print() const
-{
- mtor << "stemdir " << stemdir_i_;
-}
-
-Group_feature_req::Group_feature_req()
-{
- stemdir_i_ = 0;
-}
-
-void
-Group_change_req::do_print()const
-{
- mtor << "id : " << newgroup_str_;
-}
-/* *************** */
-void
-Terminate_voice_req::do_print()const
-{
-}
-
-/* *************** */
-void
-Partial_measure_req::do_print() const
-{
- mtor << duration_;
-}
-
-void
-Meter_change_req::do_print() const
-{
- mtor << beats_i_ << "*" << one_beat_i_;
-}
-
-/* *************** */
-
-void
-Measure_grouping_req::do_print() const
-{
- for (int i=0; i < elt_length_arr_.size(); i++) {
- mtor << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
- }
-}
-/* *************** */
-void
-Key_change_req::do_print() const
-{
- for (int i=0; i < melodic_p_arr_.size(); i++) {
- melodic_p_arr_[i]->print();
- }
-}
-
-Key_change_req::Key_change_req()
-{
-}
-Key_change_req::Key_change_req(Key_change_req const&c)
-{
- for (int i=0; i < c.melodic_p_arr_.size(); i++) {
- melodic_p_arr_.push( c.melodic_p_arr_[i]->clone()->melodic() );
- }
-}
-
-Key_change_req::~Key_change_req()
-{
- for (int i=0; i < melodic_p_arr_.size(); i++)
- delete melodic_p_arr_[i];
-}
+++ /dev/null
-#include "complex-staff.hh"
-#include "complex-walker.hh"
-#include "score.hh"
-#include "pscore.hh"
-#include "staffsym.hh"
-#include "score-column.hh"
-
-const NO_LINES = 5;
-
-/** Aside from putting fields right, this generates the staff symbol.
- */
-void
-Complex_staff::set_output(PScore* pscore_l )
-{
- pstaff_l_ = new PStaff(pscore_l);
- pscore_l_ = pscore_l;
- pscore_l_->add(pstaff_l_);
-
- Staff_symbol *span_p = new Staff_symbol(NO_LINES);
-
- Score_column* col_last
- =score_l_->find_col(score_l_->last(), false);
- Score_column* col_first=
- score_l_->find_col(0, false);
-
- span_p->set_extent(col_first->pcol_l_->postbreak_p_,
- col_last->pcol_l_->prebreak_p_);
-
- pscore_l_->typeset_spanner(span_p, pstaff_l_);
-}
-
-
-Staff_walker *
-Complex_staff::get_walker_p()
-{
- return new Complex_walker(this);
-}
+++ /dev/null
-/*
- complex-walker.cc -- implement Complex_walker
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "musicalrequest.hh"
-#include "staff-column.hh"
-#include "voice.hh"
-#include "pscore.hh"
-#include "complex-staff.hh"
-#include "debug.hh"
-#include "voice-group-regs.hh"
-#include "voice-regs.hh"
-#include "complex-walker.hh"
-//#include "misc.hh"
-#include "commandrequest.hh"
-#include "walkregs.hh"
-
-void
-Complex_walker::do_post_move()
-{
- walk_regs_p_->post_move_processing();
-}
-
-void
-Complex_walker::do_pre_move()
-{
- walk_regs_p_->pre_move_processing();
-}
-
-void
-Complex_walker::do_announces()
-{
- walk_regs_p_->do_announces();
-}
-
-bool
-Complex_walker::try_command_request(Command_req *req_l)
-{
- return walk_regs_p_->try_request(req_l);
-}
-
-void
-Complex_walker::try_request(Request*req)
-{
- walk_regs_p_->try_request(req);
-}
-
-void
-Complex_walker::process_requests()
-{
- Staff_column*c =ptr();
-
- for (int i=0; i < c->creationreq_l_arr_.size(); i++) {
- try_request(c->creationreq_l_arr_[i]);
- }
- for (int i=0; i < c->commandreq_l_arr_.size(); i++) {
- try_request(c->commandreq_l_arr_[i]);
- }
-
- for (int i=0; i < c->musicalreq_l_arr_.size(); i++) {
- try_request(c->musicalreq_l_arr_[i]);
- }
-
- regs_process_requests();
- do_announces();
-}
-
-void
-Complex_walker::regs_process_requests()
-{
- walk_regs_p_->process_requests();
-}
-
-void
-Complex_walker::typeset_element(Staff_elem *elem_p)
-{
- if (!elem_p)
- return;
- if (elem_p->spanner())
- pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_);
- else
- ptr()->typeset_musical_item(elem_p->item());
-}
-
-Complex_walker::Complex_walker(Complex_staff*s)
- : Staff_walker(s, s->pstaff_l_->pscore_l_)
-{
- walk_regs_p_ = new Walker_registers(this);
- do_post_move();
-}
-
-
-Complex_walker::~Complex_walker()
-{
-}
-
-Complex_staff*
-Complex_walker::staff()
-{
- return (Complex_staff*) staff_l_;
-}
-
-
-
+++ /dev/null
-#include <fstream.h>
-#include <signal.h>
-#include <std/new.h>
-#include <stdlib.h>
-#include "debug.hh"
-#include "dstream.hh"
-#include "vector.hh"
-
-Dstream *monitor=0;
-ostream * nulldev =0;
-
-struct _Dinit {
- _Dinit() {
- nulldev = new ofstream("/dev/null");
- monitor = new Dstream(&cout,".dstreamrc");
- }
- ~_Dinit() {
- delete nulldev;
- delete monitor;
- }
-} dinit;
-
-
-
-/*
- want to do a stacktrace .
- */
-void
-mynewhandler()
-{
- assert(false);
-}
-
-void
-float_handler(int)
-{
- cerr << "Floating point exception .. \n"<< flush;
- assert(false);
-}
-
-void
-debug_init()
-{
-#ifndef NDEBUG
- set_new_handler(&mynewhandler);
-#endif
- set_matrix_debug(*monitor);
- signal(SIGFPE, float_handler);
-}
-
-bool check_debug=false;
-
-void
-set_debug(bool b)
-{
- check_debug =b;
-}
-
-
+++ /dev/null
-#include <ctype.h>
-#include "dimen.hh"
-#include "debug.hh"
-#include "string.hh"
-
-Real
-parse_dimen(String dim)
-{
- int i=dim.length_i()-1;
- const char *s = dim;
- while (i > 0 && (isspace(s[i]) || isalpha(s[i])) ){
- i--;
- }
- String unit(s + i+1);
- return convert_dimen(dim.value_f(), unit);
-}
-
-
-Real
-convert_dimen(Real quant, String unit)
-{
- if (unit == "cm")
- return quant * CM_TO_PT;
- if (unit == "pt")
- return quant;
- if (unit == "mm")
- return quant*CM_TO_PT/10;
- if (unit == "in")
- return quant * INCH_TO_PT;
- error ("unknown length unit: `" + unit+"'");
-}
-
-String
-print_dimen(Real r)
-{
- String s(r);
- s += "pt ";
- return s;
-}
+++ /dev/null
-#include "directional-spanner.hh"
-
-Directional_spanner::Directional_spanner()
-{
- dir_i_ = 0;
-}
+++ /dev/null
-//
-// duration.cc -- implement Duration, Plet, Duration_convert, Duration_iterator
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-// split into 4?
-
-#include "proto.hh" // ugh, these all for midi-main.hh
-#include "plist.hh"
-#include "string.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "midi-main.hh" // *tors
-
-#include "string.hh"
-#include "moment.hh"
-#include "duration.hh"
-
-Duration::Duration( int type_i, int dots_i = 0, Plet* plet_l )
-{
- type_i_ = type_i;
- dots_i_ = dots_i;
- plet_p_ = 0;
- set_plet( plet_l );
-}
-
-Duration::Duration( Duration const& dur_c_r )
-{
- type_i_ = 0;
- dots_i_ = 0;
- plet_p_ = 0;
- *this = dur_c_r;
-}
-
-Duration::~Duration()
-{
- delete plet_p_;
-}
-
-Duration const&
-Duration::operator =( Duration const& dur_c_r )
-{
- if ( &dur_c_r == this )
- return *this;
-
- type_i_ = dur_c_r.type_i_;
- dots_i_ = dur_c_r.dots_i_;
- set_plet( dur_c_r.plet_p_ );
-
- return *this;
-}
-
-void
-Duration::set_plet( Plet* plet_l )
-{
- delete plet_p_;
- plet_p_ = 0;
- if ( plet_l )
- plet_p_ = new Plet( *plet_l );
-}
-
-Plet::Plet( int iso_i, int type_i )
-{
- iso_i_ = iso_i;
- type_i_ = type_i;
-}
-
-Plet::Plet( Plet const& plet_c_r )
-{
- iso_i_ = plet_c_r.iso_i_;
- type_i_ = plet_c_r.type_i_;
-}
-
-String
-Duration_convert::dur2_str( Duration dur )
-{
- String str( dur.type_i_ );
- str += String( '.', dur.dots_i_ );
- if ( dur.plet_p_ )
- str += String( "*" ) + String( dur.plet_p_->iso_i_ )
- + String( "/" ) + String( dur.plet_p_->type_i_ );
- return str;
-}
-
-int
-Duration_convert::dur2_i( Duration dur, int division_1_i )
-{
- return dur2_mom( dur ) * Moment( division_1_i );
-}
-
-Moment
-Duration_convert::dur2_mom( Duration dur )
-{
- if ( !dur.type_i_ )
- return 0;
-
- Moment mom = Moment( 1 , dur.type_i_ );
-
- Moment delta = mom;
- while ( dur.dots_i_-- ) {
- delta /= 2.0;
- mom += delta;
- }
-
- return mom * plet_factor_mom( dur );
-}
-
-Duration
-Duration_convert::mom2_dur( Moment mom )
-{
- /* this is cute,
- but filling an array using Duration_iterator
- might speed things up, a little
- */
- Duration_iterator iter_dur;
- assert( iter_dur );
- while ( iter_dur ) {
- Duration lower_dur = iter_dur++;
- Duration upper_dur( 0 );
- if ( iter_dur )
- upper_dur = iter_dur();
- Moment lower_mom = dur2_mom( lower_dur );
- Moment upper_mom = dur2_mom( upper_dur );
- if ( mom == lower_mom )
- return lower_dur;
- if ( mom == upper_mom ) // don-t miss last (sic)
- return upper_dur;
- if ( ( mom >= lower_mom ) && ( mom <= upper_mom ) ) {
- warning( String( "duration not exact: " ) + String( (Real)mom ) , 0 );
- if ( abs( mom - lower_mom ) < abs( mom - upper_mom ) )
- return lower_dur;
- else
- return upper_dur;
- }
- lower_dur = upper_dur;
- }
- return Duration( 0 );
-}
-
-Moment
-Duration_convert::plet_factor_mom( Duration dur )
-{
- if ( !dur.plet_p_ )
- return 1;
- return Moment( dur.plet_p_->iso_i_, dur.plet_p_->type_i_ );
-}
-
-Real
-Duration_convert::sync_f( Duration dur, Moment mom )
-{
- return mom / dur2_mom( dur );
-}
-
-Moment
-Duration_convert::i2_mom( int time_i, int division_1_i )
-{
- if ( !time_i )
- return Moment( 0 );
-
- if ( division_1_i > 0 )
- return Moment( time_i, division_1_i );
- else
- return Moment( -division_1_i, time_i );
-}
-
-Duration_iterator::Duration_iterator()
-{
- cursor_dur_.type_i_ = 128;
- cursor_dur_.set_plet( 0 );
-}
-
-Duration
-Duration_iterator::operator ++(int)
-{
- return forward_dur();
-}
-
-Duration
-Duration_iterator::operator ()()
-{
- return dur();
-}
-
-Duration_iterator::operator bool()
-{
- return ok();
-}
-
-Duration
-Duration_iterator::dur()
-{
- return cursor_dur_;
-}
-
-Duration
-Duration_iterator::forward_dur()
-{
- // should do smart table? guessing:
- // duration wholes
- // 16 0.0625
- // 32.. 0.0703
- // 8:2/3 0.0833
- // 16. 0.0938
- // 8 0.1250
- // 16.. 0.1406
- // 4:2/3 0.1667
- // 8. 0.1875
-
- assert( ok() );
-
- Duration dur = cursor_dur_;
-
- if ( !cursor_dur_.dots_i_ && !cursor_dur_.plet_p_ ) {
- cursor_dur_.type_i_ *= 2;
- cursor_dur_.dots_i_ = 2;
- }
- else if ( cursor_dur_.dots_i_ == 2 ) {
- assert( !cursor_dur_.plet_p_ );
- cursor_dur_.dots_i_ = 0;
- cursor_dur_.type_i_ /= 4;
- cursor_dur_.set_plet( &Plet( 2, 3 ) );
- }
- else if ( cursor_dur_.plet_p_
- && ( cursor_dur_.plet_p_->iso_i_ == 2 )
- && ( cursor_dur_.plet_p_->type_i_ == 3 ) ) {
- assert( !cursor_dur_.dots_i_ );
- cursor_dur_.set_plet( 0 );
- cursor_dur_.type_i_ *= 2;
- cursor_dur_.dots_i_ = 1;
- }
- else if ( cursor_dur_.dots_i_ == 1 ) {
- assert( !cursor_dur_.plet_p_ );
- cursor_dur_.dots_i_ = 0;
- cursor_dur_.type_i_ /= 2;
- }
-
- // ugh
- if ( no_triplets_bo_g && cursor_dur_.plet_p_ && ok() )
- forward_dur();
-
- return dur;
-}
-
-bool
-Duration_iterator::ok()
-{
- return ( cursor_dur_.type_i_
- && !( ( cursor_dur_.type_i_ == 1 ) && ( cursor_dur_.dots_i_ > 2 ) ) );
-}
+++ /dev/null
-/*
- grouping.cc -- implement Rhythmic_grouping
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "grouping.hh"
-#include "interval.hh"
-
-void
-Rhythmic_grouping::init()
-{
- interval_ = 0;
- children.set_size(0);
-}
-
-void
-Rhythmic_grouping::OK()const
-{
-#ifndef NDEBUG
- assert(bool(children.size()) != bool(interval_));
-
- for (int i= 0; i < children.size(); i++) {
- children[i]->OK();
- if (i>0)
- assert(children[i-1]->interval().right ==
- children[i]->interval().left);
- }
-#endif
-}
-
-Moment
-Rhythmic_grouping::length() const
-{
- return interval().length();
-}
-
-MInterval
-Rhythmic_grouping::interval()const
-{
- if (interval_)
- return *interval_;
- else
- return
- MInterval(children[0]->interval().left,
- children.top()->interval().right);
-}
-
-void
-Rhythmic_grouping::split(Rhythmic_grouping r)
-{
- if (interval_)
- return ;
-
- r.intersect(interval());
- split(r.intervals());
-
- for (int i= 0; i < children.size(); i++) {
- if (!children[i]->interval_) {
- Rhythmic_grouping here(r);
- children[i]->split(here);
- }
- }
-}
-
-
-Array<MInterval>
-Rhythmic_grouping::intervals()
-{
- Array<MInterval> r;
- if (interval_ || children.size() == 1) {
- MInterval i(interval());
- MInterval r1(i), r2(i);
- r1.right = r2.left = i.center();
- r.push(r1); r.push(r2);
- } else {
- for (int i=0; i < children.size(); i++)
- r.push(children[i]->interval());
- }
- return r;
-}
-
-void
-Rhythmic_grouping::intersect(MInterval t)
-{
- if (interval_) {
- interval_->intersect(t);
- return;
- }
-
- for (int i=0; i < children.size(); i++) {
- MInterval inter = intersection(t, children[i]->interval());
- if (inter.empty() || inter.length() <= Rational( 0 )) {
- delete children[i];
- children[i] =0;
- } else {
- children[i]->intersect(t);
- }
- }
- for (int i=0; i < children.size(); ) {
- if (!children[i])
- children.del(i);
- else
- i++;
- }
-
-}
-
-/**
- Put our children in branches of #this#.
- The min and max time intervals coincide with elements of #splitpoints#
-
- I really should be documenting what is happening here, but I find
- that difficult, since I don't really understand what's going on here.
-
- */
-void
-Rhythmic_grouping::split(Array<MInterval> splitpoints)
-{
- //check on splitpoints..
- int j = 0, i = 0, starti = 0, startj = 0;
-
- Array<Rhythmic_grouping*> ch;
- while (1) {
- if ( i >= children.size() || j >= splitpoints.size())
- break;
-
- assert(
- children[starti]->interval().left== splitpoints[startj].left);
- if (children[i]->interval().right < splitpoints[j].right) {
- i ++;
- } else if (children[i]->interval().right > splitpoints[j].right ) {
- j ++;
- } else {
-
- if (i == starti) {
- ch.push(children[i]);
- } else {
- Rhythmic_grouping *newchild=new Rhythmic_grouping(
- children.subvec(starti, i+1));
-
- ch.push(newchild);
- }
- i ++;
- j++;
- starti = i;
- startj = j;
-
-
- }
- }
- if (ch.size() != 1)
- children = ch;
- }
-
-
-Rhythmic_grouping::Rhythmic_grouping(MInterval t, int n)
-{
- init();
- if (n == 1 || !n) {
- interval_ = new MInterval(t);
- return;
- }
- Moment dt = t.length()/Rational(n);
- MInterval basic = MInterval(t.left, t.left+dt);
- for (int i= 0; i < n; i++)
- children.push(new Rhythmic_grouping( dt*Rational(i) + basic ));
-}
-
-
-Rhythmic_grouping::Rhythmic_grouping(Array<Rhythmic_grouping*> r)
- :children(r)
-{
- interval_ =0;
-}
-
-Rhythmic_grouping::~Rhythmic_grouping()
-{
- junk();
-}
-
-void
-Rhythmic_grouping::copy(Rhythmic_grouping const&s)
-{
- interval_ = (s.interval_)? new MInterval(*s.interval_) : 0;
- for (int i=0; i < s.children.size(); i++)
- children.push(new Rhythmic_grouping(*s.children[i]));
-}
-
-void
-Rhythmic_grouping::operator=(Rhythmic_grouping const &s)
-{
- junk();
- copy(s);
-}
-
-Rhythmic_grouping::Rhythmic_grouping(Rhythmic_grouping const&s)
-{
- init();
- copy(s);
-}
-
-void
-Rhythmic_grouping::junk()
-{
- delete interval_;
- for (int i=0; i < children.size(); i++)
- delete children[i];
- init();
-}
-
-void
-Rhythmic_grouping::print()const
-{
-#ifndef NPRINT
- mtor << "{ \n";
- if (interval_)
- mtor<<" Interval "<< interval_->str();
- for (int i=0; i < children.size(); i++) {
- children[i]->print();
- }
- mtor << "}\n";
-#endif
-}
-
-bool
-Rhythmic_grouping::child_fit_query(Moment start)
-{
- if (children.size())
- return ( children.top()->interval().right== start);
-
- return true;
-}
-
-void
-Rhythmic_grouping::add_child(Moment start, Moment len)
-{
- Moment stop = start+len;
-
- assert(child_fit_query(start));
- children.push(new Rhythmic_grouping(MInterval(start, stop)));
-}
-
-Rhythmic_grouping::Rhythmic_grouping()
-{
- interval_ =0;
-}
-
-int
-min_elt(Array<int> v)
-{
- int i = 1000; // ugh
- for (int j = 0 ; j < v.size(); j++)
- i = i <? v[j];
- return i;
-}
-
-Array<int>
-Rhythmic_grouping::generate_beams(Array<int> flags, int &flagidx)
-{
- assert (!interval_) ;
-
- Array< Array<int> > children_beams;
- for (int i=0; i < children.size(); i++) {
- Array<int> child_beams;
- if (children[i]->interval_) {
- int f = flags[flagidx++];
- child_beams.push(f);
- } else {
- child_beams = children[i]->
- generate_beams(flags, flagidx);
- }
- children_beams.push(child_beams);
- }
- Array<int> beams;
- int lastm, m, nextm;
- for (int i=0; i < children_beams.size(); i++) {
- bool add_left = (i >0);
- bool add_right = (i < children_beams.size() -1);
-
- if (!i)
- m = min_elt(children_beams[i]);
- if (add_right)
- nextm = min_elt(children_beams[i+1]);
-
- if (children_beams[i].size() == 1) {
- if (add_right)
- beams.push(m);
- if (add_left)
- beams.push(m);
- } else {
- if (add_left)
- beams.push(lastm <? m);
- beams.concat(children_beams[i]);
- if (add_right)
- beams.push(m <? nextm);
- }
- lastm = m;
- m = nextm;
- }
- assert(!(beams.size()%2));
- return beams;
-}
-
-void
-Rhythmic_grouping::translate(Moment m)
-{
- if (interval_)
- *interval_ += m;
- else
- for (int i=0; i < children.size(); i++)
- children[i]->translate(m);
-}
-
-void
-Rhythmic_grouping::extend(MInterval m)const
-{
- assert(m.left >= interval().left);
- while (m.right >interval().right ) {
- Array<Rhythmic_grouping*> a(children);
- for (int i=0; i < a.size(); i++) {
- a[i] =new Rhythmic_grouping(*children[i]);
- a[i]->translate(children.top()->interval().right);
- }
- ((Rhythmic_grouping*)this)->children.concat(a);
- }
- assert(m.right <= interval().right);
- OK();
-}
-
-Rhythmic_grouping
-parse_grouping(Array<int> beat_i_arr, Array<Moment> elt_length_arr)
-{
- Moment here =0;
- assert(beat_i_arr.size() == elt_length_arr.size());
-
- Array<Rhythmic_grouping*> children;
- for (int i=0; i < beat_i_arr.size(); i++) {
- Moment last = here;
- here += elt_length_arr[i] * Moment(beat_i_arr[i]);
- children.push(
- new Rhythmic_grouping(MInterval(last, here),
- beat_i_arr[i] ));
- }
- return Rhythmic_grouping(children);
-}
-
+++ /dev/null
-/*
- headreg.cc -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "rest.hh"
-#include "notehead.hh"
-#include "headreg.hh"
-#include "paper-def.hh"
-#include "complex-walker.hh"
-#include "musicalrequest.hh"
-
-Notehead_register::Notehead_register()
-{
- note_p_ = 0;
- set_feature(Features::dir(0));
- post_move_processing();
-}
-
-bool
-Notehead_register::try_request(Request *req_l)
-{
- if (req_l->note() || req_l->rest())
- note_req_l_=req_l->rhythmic();
- else
- return false;
-
- return true;
-}
-void
-Notehead_register::set_feature(Features d)
-{
- if(d.direction_i_ || d.initialiser_b_)
- dir_i_ = d.direction_i_;
-}
-
-void
-Notehead_register::process_requests()
-{
- if (!note_req_l_)
- return;
-
-
- if (note_req_l_->note()) {
- Notehead*n_p = new Notehead(8); // ugh
- note_p_ = n_p;
- n_p->set_rhythmic(note_req_l_->rhythmic());
- n_p->position = note_req_l_->note()->height() +
- *get_staff_info().c0_position_i_;
- } else {
- note_p_ = new Rest ( note_req_l_->rhythmic()->balltype,
- note_req_l_->rhythmic()->dots);
- if (note_req_l_->rhythmic()->balltype <= 2)
- note_p_->translate(
- Offset(0,
- 6 * paper()->internote()));
- }
- Staff_elem_info itinf(note_p_,note_req_l_);
- announce_element(itinf);
-}
-
-void
-Notehead_register::pre_move_processing()
-{
- if (note_p_) {
- if (dir_i_ && note_p_->name() == Rest::static_name())
- note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote()));
- typeset_element(note_p_);
- note_p_ = 0;
- }
-}
-void
-Notehead_register::post_move_processing()
-{
- note_req_l_ = 0;
-}
+++ /dev/null
-#include "idealspacing.hh"
-#include "pcol.hh"
-#include "pscore.hh"
-#include "pstaff.hh"
-#include "debug.hh"
-
-void
-Idealspacing::print() const
-{
-#ifndef NPRINT
- mtor << "idealspacing {" ;
- mtor << "distance "<<space<< " strength " << hooke ;
- mtor << "left " << left->rank() << " right " << right->rank() << "}\n";
-#endif
-}
-
-Idealspacing::Idealspacing(const PCol * l,const PCol * r)
-{
- space = 0.0;
- hooke = 0.0;
- left = l;
- right = r;
-}
-
-void
-Idealspacing::OK() const
-{
-#ifndef NDEBUG
- assert(hooke >= 0 && left && right);
-#endif
-}
+++ /dev/null
-/*
- identifier.cc -- implement identifier and derived classes
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include <assert.h>
-
-#include "identifier.hh"
-#include "lexer.hh"
-#include "debug.hh"
-
-void
-Identifier::error(String expect)
-{
- String e("Wrong identifier type: ");
- e += String(classname()) + "(expected " + expect + ")";
- ::error(e);
-}
-
-void
-Identifier::print()const
-{
- mtor << "identifier \'" << name << "\'=";
- do_print();
-}
-
-/* ugh. */
-#define DEFAULT_PRINT(Class, Content_type, accessor) \
-void \
-Class::do_print() const { \
- ((Class*)this)->accessor(false)->print(); \
-} \
-class Class
-
-DEFAULT_PRINT(Script_id, Script_def, script);
-DEFAULT_PRINT(Lookup_id, Lookup, lookup);
-DEFAULT_PRINT(Symtables_id, Symtables, symtables);
-DEFAULT_PRINT(Staff_id, Input_staff, staff);
-DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
-DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
-
-void
-Real_id::do_print() const
-{
- Identifier::print();
- mtor << *((Real_id*)this)->real(false)<< "\n";
-}
-
-void
-Notetab_id::do_print() const
-{
- mtor << "unknown" << "\n";
-}
+++ /dev/null
-/*
- input-file.cc -- implement Input_file
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl> Jan Nieuwenhuizen <jan@digicash.com>
-*/
-
-#include <iostream.h>
-#include <strstream.h>
-#include "proto.hh"
-#include "plist.hh"
-#include "input-file.hh"
-#include "debug.hh"
-#include "source-file.hh"
-#include "binary-source-file.hh"
-#include "source.hh"
-
-Input_file::Input_file(String s)
-{
- name = s;
- line = 1;
- String pf(s);
- if ( pf == "" ) {
- is = &cin;
- defined_ch_c_l_ = 0;
- sourcefile_l_ = 0;
- }
- else {
- Source_file* sourcefile_p = 0;
- // ugh, very dirty, need to go away
- if ( ( pf.right_str( 3 ).lower_str() == "mid" ) || ( pf.right_str( 4 ).lower_str() == "midi" ) )
- sourcefile_p = new Binary_source_file( pf );
- else
- sourcefile_p = new Source_file( pf );
- source_l_g->add( sourcefile_p );
- sourcefile_l_ = sourcefile_p;
- is = sourcefile_l_->istream_l();
- defined_ch_c_l_ = sourcefile_l_->ch_c_l();
- }
- cout << "[" << pf << flush;
-}
-
-Input_file::~Input_file()
-{
- cout << "]" << flush;
-}
+++ /dev/null
-#include "debug.hh"
-#include "input-music.hh"
-#include "voice.hh"
-#include "musicalrequest.hh"
-#include "voice-element.hh"
-
-void
-Input_music::check_plet(Voice_element* velt_l)
-{
- for (iter_top(velt_l->reqs,i); i.ok(); i++)
- if ( i->plet() ) {
- Moment start_moment = 0;
- if ( !find_plet_start_bo( i->plet()->type_c_, start_moment ) ) {
- error( "begin of plet not found", i->defined_ch_c_l_ );
- break;
- }
- Moment moment = 0;
- set_plet_backwards( moment, start_moment, i->plet()->dur_i_, i->plet()->type_i_ );
- i.del();
- break;
- }
-}
-
-void
-Simple_music::add(Voice_element*v)
-{
- voice_.add(v);
-}
-
-Moment
-Simple_music::length()const
-{
- return voice_.last();
-}
-void
-Simple_music::translate_time(Moment t)
-{
- voice_.start += t;
-}
-
-Voice_list
-Simple_music::convert()const
-{
- Voice_list l;
- l.bottom().add(new Voice(voice_));
- return l;
-}
-
-
-void
-Simple_music::print() const
-{
- mtor << "Simple_music {";
- voice_.print();
- mtor << "}\n";
-}
-bool
-Simple_music::find_plet_start_bo(char c, Moment& moment_r)
-{
- return voice_.find_plet_start_bo(c, moment_r);
-}
-void
-Simple_music::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i)
-{
- voice_.set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
-}
-
-/* *************** */
-
-void
-Complex_music::add(Input_music*v)
-{
- elts.bottom().add(v);
-}
-
-void
-Complex_music::print() const
-{
- for (iter_top(elts,i); i.ok(); i++)
- i->print();
-}
-
-void
-Complex_music::concatenate(Complex_music*h)
-{
- for (iter_top(h->elts,i); i.ok(); i++)
- add(i->clone());
-}
-
-Complex_music::Complex_music()
-{
-}
-
-Complex_music::Complex_music(Complex_music const&s)
-{
- for (iter_top(s.elts,i); i.ok(); i++)
- add(i->clone());
-}
-void
-Complex_music::set_default_group(String g)
-{
- for (iter_top(elts,i); i.ok(); i++)
- i->set_default_group(g);
-}
-bool
-Complex_music::find_plet_start_bo(char c, Moment& moment_r)
-{
- for (iter_bot(elts,i); i.ok(); i--) {
- if ( i->find_plet_start_bo(c, moment_r) )
- return true;
- }
- return false;
-}
-void
-Complex_music::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i)
-{
- for (iter_bot(elts,i); i.ok(); i--) {
- i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
- }
-}
-/* *************************************************************** */
-
-void
-Music_voice::print() const
-{
- mtor << "Music_voice {";
- Complex_music::print();
- mtor << "}\n";
-}
-
-void
-Music_voice::add_elt(Voice_element*v)
-{
- PCursor<Input_music*> c(elts.bottom());
- if (!c.ok() || !c->simple()) {
- Simple_music*vs = new Simple_music;
-
- c.add(vs);
- }
-
- c = elts.bottom();
- Simple_music *s = c->simple();
- s->add(v);
-
- check_plet(v);
-}
-
-Moment
-Music_voice::length()const
-{
- Moment l = 0;
-
- for (iter_top(elts,i); i.ok(); i++)
- l += i->length();
- return l;
-}
-
-
-Voice_list
-Music_voice::convert()const
-{
- Voice_list l;
- Moment here = 0;
-
- for (iter_top(elts,i); i.ok(); i++) {
- Moment len = i->length();
- Voice_list k(i->convert());
- k.translate_time(here);
- l.concatenate(k);
- here +=len;
- }
- return l;
-}
-
-void
-Music_voice::translate_time(Moment t)
-{
- elts.bottom()->translate_time(t);
-}
-
-
-
-/* *************** */
-
-void
-Music_general_chord::add_elt(Voice_element*v)
-{
- Simple_music*vs = new Simple_music;
- vs->add(v);
- elts.bottom().add(vs);
-
- check_plet(v);
-}
-
-void
-Music_general_chord::print() const
-{
- mtor << "Music_general_chord {";
- Complex_music::print();
- mtor << "}\n";
-}
-
-void
-Music_general_chord::translate_time(Moment t)
-{
- for (iter_top(elts,i); i.ok(); i++)
- i->translate_time(t);
-}
-
-Moment
-Music_general_chord::length()const
-{
- Moment l =0;
-
- for (iter_top(elts,i); i.ok(); i++)
- l = l >? i->length();
- return l;
-}
-
-Voice_list
-Music_general_chord::convert()const
-{
- Voice_list l;
- for (iter_top(elts,i); i.ok(); i++) {
- Voice_list k(i->convert());
- l.concatenate(k);
- }
- return l;
-}
-
-/* *************** */
-
-void
-Multi_voice_chord::set_default_group(String g)
-{
- int j=0;
- for (iter_top(elts, i); i.ok(); i++) {
- i->set_default_group(g + String(j));
- j++;
- }
-}
-
-
-/* *************** */
-
-void
-Voice_list::translate_time(Moment x)
-{
- for (iter_top(*this,i); i.ok(); i++)
- i->start += x;
-}
-
+++ /dev/null
-/*
- input-score.cc -- implement Input_score
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "input-score.hh"
-#include "input-staff.hh"
-#include "input-music.hh"
-#include "score.hh"
-#include "paper-def.hh"
-#include "midi-def.hh"
-#include "staff.hh"
-
-
-void
-Input_score::add(Input_staff*s)
-{
- staffs_.bottom().add(s);
-}
-
-void
-Input_score::set(Paper_def*p)
-{
- delete paper_p_;
- paper_p_ = p;
-}
-
-void
-Input_score::set(Midi_def* midi_p)
-{
- delete midi_p_;
- midi_p_ = midi_p;
-}
-
-Input_score::Input_score(Input_score const&s)
-{
- paper_p_ = (s.paper_p_)? new Paper_def(*s.paper_p_) :0;
- midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0;
- defined_ch_c_l_ = s.defined_ch_c_l_;
- errorlevel_i_ = s.errorlevel_i_;
- score_wide_music_p_ = (s.score_wide_music_p_) ?
- s.score_wide_music_p_->clone():0;
-}
-
-Score*
-Input_score::parse()
-{
- Score *s_p = new Score;
- s_p->defined_ch_c_l_= defined_ch_c_l_;
- s_p->errorlevel_i_ = errorlevel_i_;
- if (midi_p_)
- s_p->set(new Midi_def(*midi_p_));
- if (paper_p_)
- s_p->set( new Paper_def(*paper_p_));
-
- for (iter_top(staffs_,i); i.ok(); i++) {
- Staff* staf_p=i->parse(s_p, score_wide_music_p_);
- s_p->add(staf_p);
- }
-
- return s_p;
-}
-
-void
-Input_score::set(Input_music *m_p)
-{
- delete score_wide_music_p_;
- score_wide_music_p_ =m_p;
-}
-
-
-Input_score::~Input_score()
-{
- delete paper_p_;
- delete score_wide_music_p_;
- delete midi_p_;
-}
-
-Input_score::Input_score()
-{
- score_wide_music_p_ =0;
- defined_ch_c_l_=0;
- paper_p_= 0;
- midi_p_ = 0;
- errorlevel_i_ = 0;
-}
-
-void
-Input_score::print()const
-{
-#ifndef NPRINT
- mtor << "Input_score {\n";
- for (iter_top(staffs_,i); i.ok(); i++) {
- i->print();
- }
- mtor << "}\n";
-#endif
-}
+++ /dev/null
-/*
- input-staff.cc -- implement Input_staff
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "score.hh"
-#include "input-music.hh"
-#include "input-staff.hh"
-#include "staff.hh"
-#include "complex-staff.hh"
-#include "lyricstaff.hh"
-
-#include "lexer.hh"
-
-
-Input_staff::Input_staff(String s)
-{
- score_wide_music_p_ =0;
- type= s;
- defined_ch_c_l_ = 0;
-}
-
-void
-Input_staff::add(Input_music*m)
-{
- music_.bottom().add(m);
-}
-
-Staff*
-Input_staff::parse(Score*score_l, Input_music *default_score_wide)
-{
- Staff *p=0;
- if (type == "melodic")
- p = new Complex_staff;
- else if (type == "lyric")
- p = new Lyric_staff;
- else {
- error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_ );
- exit( 1 );
- }
-
- p->score_l_ = score_l;
-
- for (iter_top(music_,i); i.ok(); i++) {
- Voice_list vl = i->convert();
- p->add(vl);
- }
- Voice_list vl = (score_wide_music_p_) ? score_wide_music_p_->convert()
- : default_score_wide->convert();
- p->add(vl);
- return p;
-}
-
-Input_staff::Input_staff(Input_staff const&s)
-{
- for (iter_top(s.music_,i); i.ok(); i++)
- add(i->clone());
- defined_ch_c_l_ = s.defined_ch_c_l_;
- type = s.type;
- score_wide_music_p_ = (s.score_wide_music_p_) ?
- s.score_wide_music_p_->clone() : 0;
-}
-
-void
-Input_staff::print() const
-{
-#ifndef NPRINT
- mtor << "Input_staff {\n";
- for (iter_top(music_,i); i.ok(); i++)
- i->print();
- mtor << "}\n";
-#endif
-}
-void
-Input_staff::set_score_wide(Input_music *m_p)
-{
- delete score_wide_music_p_;
- score_wide_music_p_ = m_p;
-}
-
-Input_staff::~Input_staff()
-{
- delete score_wide_music_p_;
-}
+++ /dev/null
-#include "debug.hh"
-#include "item.hh"
-
-
-
-Item::Item()
-{
- pcol_l_ = 0;
-}
-
-void
-Item::do_print() const
-{
-#ifndef NPRINT
- mtor << "(unknown)";
-#endif
-}
-
+++ /dev/null
-#include "key-item.hh"
-#include "key.hh"
-#include "debug.hh"
-#include "molecule.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-//#include "clef-reg.hh"
-#include "key-reg.hh"
-
-const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */
-const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */
-
-
-
-Key_item::Key_item(int c)
-{
- set_c_position(c);
-}
-
-void
-Key_item::read(const Key_register& key_reg_r)
-{
- const Array<int> &idx_arr =key_reg_r.accidental_idx_arr_;
- for (int i = 0 ; i< idx_arr.size(); i++) {
- int note = idx_arr[i];
- int acc = key_reg_r.key_.acc(note);
-
- add(note, acc);
- }
-}
-
-void
-Key_item::set_c_position(int c0)
-{
- int octaves =(abs(c0) / 7) +1 ;
- c_position=(c0 + 7*octaves)%7;
-}
-
-
-void
-Key_item::add(int p, int a)
-{
- if ((a<0 && p>FLAT_TOP_PITCH) ||
- (a>0 && p>SHARP_TOP_PITCH)) {
- p -= 7; /* Typeset below c_position */
- }
- pitch.push(p);
- acc.push(a);
-}
-
-
-Molecule*
-Key_item::brew_molecule_p()const
-{
- Molecule*output = new Molecule;
- Real inter = paper()->internote();
-
- for (int i =0; i < pitch.size(); i++) {
- Symbol s= paper()->lookup_p_->accidental(acc[i]);
- Atom a(s);
- a.translate(Offset(0,(c_position + pitch[i]) * inter));
- Molecule m(a);
- output->add_right(m);
- }
- Molecule m(paper()->lookup_p_->fill(Box(
- Interval(0, paper()->note_width()),
- Interval(0,0))));
- output->add_right(m);
- return output;
-}
+++ /dev/null
-/*
- key-reg.cc -- implement Key_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-
- todo: key undo
-
- */
-#include "time-description.hh"
-#include "key-reg.hh"
-#include "key-item.hh"
-#include "commandrequest.hh"
-#include "staff-column.hh"
-#include "local-key-reg.hh"
-#include "musicalrequest.hh"
-
-Key_register::Key_register()
-{
- post_move_processing();
-}
-
-bool
-Key_register::try_request(Request * req_l)
-{
- Command_req* creq_l= req_l->command();
- if (!creq_l|| !creq_l->keychange())
- return false;
-
- assert(!keyreq_l_); // todo
- keyreq_l_ = creq_l->keychange();
- read_req(keyreq_l_);
- return true;
-}
-
-void
-Key_register::acknowledge_element(Staff_elem_info info)
-{
- Command_req * r_l = info.req_l_->command() ;
- if (r_l && r_l->clefchange() && !kit_p_) {
- int c0_i= *get_staff_info().c0_position_i_;
- kit_p_ = new Key_item(c0_i);
- kit_p_->read(*this);
- announce_element(Staff_elem_info(kit_p_, keyreq_l_));
- }
-}
-
-void
-Key_register::process_requests()
-{
- const Time_description *time_l = get_staff_info().time_c_l_;
-
- if (!keyreq_l_ &&
- (!time_l->whole_in_measure_|| !time_l->when_)) {
- default_key_b_ = true;
- }
-
- if ( default_key_b_ || keyreq_l_) {
- int c0_i= *get_staff_info().c0_position_i_;
- kit_p_ = new Key_item(c0_i);
- kit_p_->read(*this);
- announce_element(Staff_elem_info(kit_p_, keyreq_l_));
- }
-}
-
-void
-Key_register::pre_move_processing()
-{
- if (kit_p_) {
- if (default_key_b_)
- typeset_breakable_item(0,0,kit_p_);
- else
- typeset_breakable_item(
- new Key_item(*kit_p_), kit_p_, new Key_item(*kit_p_));
- kit_p_ = 0;
- }
-}
-
-
-
-void
-Key_register::read_req(Key_change_req * r)
-{
- accidental_idx_arr_.set_size(0);
- for (int i = 0; i < r->melodic_p_arr_.size(); i ++) {
- int n_i=r->melodic_p_arr_[i]->notename_i_;
- key_.set(n_i, r->melodic_p_arr_[i]->accidental_i_);
- accidental_idx_arr_.push(n_i);
- }
-}
-
-void
-Key_register::post_move_processing()
-{
- keyreq_l_ = 0;
- default_key_b_ = false;
- kit_p_ = 0;
-}
+++ /dev/null
-#include "key.hh"
-
-const int OCTAVES=14; // ugh..
-const int ZEROOCTAVE=7;
-
-Key::Key()
-{
- accidental_i_arr_.set_size(7);
- for (int i= 0; i < 7 ; i++)
- accidental_i_arr_[i] = 0;
-}
-
-Local_key::Local_key()
-{
- octaves.set_size(OCTAVES);
-}
-
-Key&
-Local_key::oct(int i)
-{
- return octaves[i+ZEROOCTAVE];
-}
-
-void
-Key::set(int i, int a)
-{
- assert(a > -3 && a < 3);
- accidental_i_arr_[i]=a;
-}
-
-
-void
-Local_key::reset(Key k)
-{
- for (int i= 0; i < OCTAVES ; i++)
- octaves[i] = k;
-}
-
+++ /dev/null
-/*
- keyword.cc -- keywords and identifiers
- */
-
-#include <stdlib.h>
-
-#include "glob.hh"
-#include "lexer.hh"
-//#include "mudobs.hh"
-//#include "gram.hh"
-
-/* for the keyword table */
-struct Keyword_ent
-{
- const char *name;
- int tokcode;
-};
-
-struct Keyword_table
-{
- Keyword_ent *table;
- int maxkey;
- Keyword_table(Keyword_ent *);
- int lookup(const char *s) const;
-};
-
-
-/* for qsort */
-int
- tabcmp(const void * p1, const void * p2)
-{
- return strcmp(((const Keyword_ent *) p1)->name,
- ((const Keyword_ent *) p2)->name);
-}
-
-Keyword_table::Keyword_table(Keyword_ent *tab)
-{
- table = tab;
-
- /* count keywords */
- for (maxkey = 0; table[maxkey].name; maxkey++);
-
- /* sort them */
- qsort(table, maxkey, sizeof(Keyword_ent), tabcmp);
-}
-
-/*
- lookup with binsearch, return tokencode.
-*/
-int
-Keyword_table::lookup(const char *s)const
-{
- int lo,
- hi,
- cmp,
- result;
- lo = 0;
- hi = maxkey;
-
- /* binary search */
- do
- {
- cmp = (lo + hi) / 2;
-
- result = strcmp(s, table[cmp].name);
-
- if (result < 0)
- hi = cmp;
- else
- lo = cmp;
- }
- while (hi - lo > 1);
- if (!strcmp(s, table[lo].name))
- {
- return table[lo].tokcode;
- } else
- return -1; /* not found */
-}
-
+++ /dev/null
-#include "leastsquares.hh"
-void
-Least_squares::OK() const
-{
- assert( input.size() > 1 );
- Real dx = 0.0;
- for (int i=1; i < input.size(); i++)
- dx += abs (input[i-1].x - input[i].x);
-
- assert(dx);
-}
-void
-Least_squares::minimise(Real &coef, Real &offset)
-{
- OK();
- Real sx = 0.0;
- Real sy = 0.0;
- Real sqx =0.0;
- Real sxy = 0.0;
-
- for (int i=0; i < input.size();i++) {
- Real x=input[i].x;
- Real y = input[i].y;
- sx += x;
- sy += y;
- sqx += sqr(x);
- sxy += x*y;
- }
- int N = input.size();
-
-
- coef = (N * sxy - sx*sy )/(N*sqx - sqr(sx));
- offset = (sy - coef * sx)/N;
-
-}
+++ /dev/null
-%{ // -*-Fundamental-*-
-
-#include <stdio.h>
-
-#include "string.hh"
-#include "notename.hh"
-#include "lexer.hh"
-#include "varray.hh"
-#include "parser.hh"
-#include "debug.hh"
-#include "input-score.hh"
-#include "parseconstruct.hh"
-#include "main.hh"
-#include "string-convert.hh"
-
-%}
-
-%option c++
-%option noyywrap
-%option nodefault
-%option yylineno
-%option debug
-%option yyclass="My_flex_lexer"
-%option stack
-
-%x notes
-%x incl
-%x quote
-%x lyrics
-
-
-
-A [a-zA-Z]
-AA {A}|_
-N [0-9]
-AN {AA}|{N}
-PUNCT [?!,.:;]
-ACCENT [\\'"^]
-NATIONAL [\241-\377]
-TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL}
-
-WORD {A}{AN}*
-ALPHAWORD {A}+
-INT -?{N}+
-REAL {INT}?(\.{N}*)?
-
-OPTSIGN !?
-PITCHMOD ['`]*{OPTSIGN}
-RESTNAME r|s|p
-NOTECOMMAND \\{WORD}
-NOTENAME [a-z]+
-UNOTENAME [A-Z][a-z]*
-DOTS \.+
-LYRICS {TEX}+
-COMMENT [%#].*\n
-
-%%
-
-\$ {
- yy_push_state(notes);
-}
-
-\@ {
- yy_push_state(lyrics);
-}
-
-<notes>{RESTNAME} {
- const char *s = YYText();
- yylval.string = new String (s);
- mtor << "rest:"<< yylval.string;
- return RESTNAME;
-}
-<notes>{UNOTENAME} {
- int *p=yylval.ii;
- return ret_notename(p, YYText(), -1);
-}
-
-<notes>{NOTENAME} {
- int *p=yylval.ii;
- return ret_notename(p, YYText(), 0);
-}
-
-<notes>{NOTECOMMAND} {
- String c = YYText() +1;
- mtor << "\\word: " << YYText()+1<<eol;
- int l = lookup_keyword(c);
- if (l != -1)
- return l;
- Identifier * id = lookup_identifier(c);
- if (id) {
- yylval.id = id;
- return IDENTIFIER;
- }
- String *sp = new String( c);
- yylval.string=sp;
- return STRING;
-}
-
-<notes>{PITCHMOD} {
- const char *s = YYText();
- mtor << "pitchmod:"<< YYText()<<eol;
- yylval.string = new String (s);
- return PITCHMOD;
-}
-<notes>{DOTS} {
- yylval.i = strlen(YYText());
- return DOTS;
-}
-<notes>{INT} {
- yylval.i = String_convert::dec2_i( String( YYText() ) );
- return INT;
-}
-<notes>{COMMENT} {
-}
-<notes>[ \t\n]+ {
-
-}
-<notes>\$ {
- yy_pop_state();
-}
-<notes>\"[^"]*\" {
- String s (YYText()+1);
- s = s.left_str(s.length_i()-1);
- yylval.string = new String(s);
- return STRING;
-}
-<notes>. {
- return yylval.c = YYText()[0];
-}
-
-\" {
- yy_push_state(quote);
-}
-<quote>[^"]* {
- yylval.string = new String (YYText());
-}
-<quote>\" {
- mtor << "quoted string\n";
- yy_pop_state();
- return STRING;
-}
-
-<lyrics>{DOTS} {
- yylval.i = strlen(YYText());
- return DOTS;
-}
-<lyrics>{INT} {
- yylval.i = String_convert::dec2_i( String( YYText() ) );
- return INT;
-}
-<lyrics>{NOTECOMMAND} {
- String c = YYText() +1;
- mtor << "\\word: " << YYText()+1<<eol;
- int l = lookup_keyword(c);
- if (l != -1)
- return l;
-
-/* let's try passing tex's typesetting macros like \ss \alpha \c */
- String* str_p = new String(YYText());//huh?
- return STRING;
-
-/* and skip identifiers...
- Identifier * id = lookup_identifier(c);
- if (id) {
- yylval.id = id;
- return IDENTIFIER;
- }
- String *sp = new String( c);
-
- yylval.string=sp;
- return STRING;
-*/
-}
-<lyrics>\"[^"]*\" {
- String s (YYText()+1);
- s = s.left_str(s.length_i()-1);
- yylval.string = new String(s);
- return STRING;
-}
-<lyrics>{LYRICS} {
- String s (YYText());
- int i = 0;
- while ((i=s.index_i("_")) != -1) // change word binding "_" to " "
- *(s.ch_l() + i) = ' ';
- if ((i=s.index_i("\\,")) != -1) // change "\," to TeX's "\c "
- {
- *(s.ch_l() + i + 1) = 'c';
- s = s.left_str(i+2) + " " + s.right_str(s.length_i()-i-2);
- }
- yylval.string = new String(s);
- return STRING;
-}
-<lyrics>\| {
- return YYText()[0];
-}
-<lyrics>{COMMENT} {
-
-}
-<lyrics>[{}] {
- return YYText()[0];
-}
-<lyrics>[()\[\]|/.^>_-] {
- return yylval.c = YYText()[0];
-}
-<lyrics>[ \t\n]+ {
-}
-<lyrics>@ {
- yy_pop_state();
-}
-
-<<EOF>> {
- mtor << "<<EOF>>";
-
- if (! close_input())
- yyterminate(); // can't move this, since it actually rets a YY_NULL
-}
-
-
-include {
- yy_push_state(incl);
-}
-<incl>[ \t]* { /* eat the whitespace */ }
-<incl>\"[^"]*\"+ { /* got the include file name */
- String s (YYText()+1);
- s = s.left_str(s.length_i()-1);
- defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1;
- new_input(s);
- yy_pop_state();
-}
-
-
-{WORD} {
- mtor << "word: " << YYText()<<eol;
- String c = YYText();
- int l = lookup_keyword(c);
- if (l != -1)
- return l;
- Identifier * id = lookup_identifier(c);
- if (id) {
- yylval.id = id;
- return IDENTIFIER;
- }
- String *sp = new String( c);
- mtor << "new id: " << *sp << eol;
- yylval.string=sp;
- return STRING;
-}
-
-{REAL} {
- Real r;
- int cnv=sscanf (YYText(), "%lf", &r);
- assert(cnv == 1);
- mtor << "REAL" << r<<'\n';
- yylval.real = r;
- return REAL;
-}
-
-[{}] {
-
- mtor << "parens\n";
- return YYText()[0];
-}
-[*:=] {
- char c = YYText()[0];
- mtor << "misc char" <<c<<"\n";
- return c;
-}
-[ \t\n]+ {
-
-}
-
-{COMMENT} {
- //ignore
-}
-. {
- error( String( "illegal character: " ) + String( YYText()[0] ), here_ch_c_l() );
- return YYText()[0];
-}
-
-%%
-
+++ /dev/null
-/*
- lexerinit.cc -- implement some stuff
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include <iostream.h>
-#include <strstream.h>
-#include "proto.hh"
-#include "plist.hh"
-#include "lexer.hh"
-#include "debug.hh"
-#include "main.hh"
-#include "source-file.hh"
-#include "source.hh"
-
-My_flex_lexer *lexer=0;
-
-int
-yylex() {
- return lexer->yylex();
-}
-
-bool
-busy_parsing()
-{
- return lexer;
-}
+++ /dev/null
-//
-// lily-stream.cc
-//
-// source file of the LilyPond music typesetter
-//
-// (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-// should i be named Mudela_stream?
-
-#include <fstream.h>
-#include <time.h>
-
-#include "proto.hh"
-#include "plist.hh"
-#include "string.hh"
-
-#include "moment.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "midi-main.hh" // *tors
-
-#include "duration.hh"
-#include "midi-event.hh"
-#include "lily-stream.hh"
-
-Lily_stream::Lily_stream( String filename_str )
-{
- filename_str_ = filename_str;
- os_p_ = 0;
- open();
- header();
-}
-
-Lily_stream::~Lily_stream()
-{
- delete os_p_;
-}
-
-Lily_stream&
-Lily_stream::operator <<( String str )
-{
- *os_p_ << str;
- return *this;
-}
-
-Lily_stream&
-Lily_stream::operator <<( Midi_event& midi_event_r )
-{
- midi_event_r.output_mudela( *this );
- return *this;
-}
-
-void
-Lily_stream::header()
-{
- *os_p_ << "% Creator: " << version_str() << "\n";
- *os_p_ << "% Automatically generated, at ";
- time_t t( time( 0 ) );
- *os_p_ << ctime( &t );
- *os_p_ << "% from input file: ";
-// *os_p_ << midi_parser_l_g->
- *os_p_ << "\n\n";
-}
-
-void
-Lily_stream::open()
-{
- os_p_ = new ofstream( filename_str_ );
- if ( !*os_p_ )
- error ( "can't open `" + filename_str_ + "\'", 0 );
-}
-
+++ /dev/null
-#include <math.h>
-#include "linespace.hh"
-#include "pcol.hh"
-#include "debug.hh"
-#include "qlp.hh"
-#include "unionfind.hh"
-#include "idealspacing.hh"
-
-const Real COLFUDGE=1e-3;
-
-
-bool
-Spacing_problem::contains(const PCol *w)
-{
- for (int i=0; i< cols.size(); i++)
- if (cols[i].pcol_ == w)
- return true;
- return false;
-}
-
-int
-Spacing_problem::col_id(const PCol *w)const
-{
- for (int i=0; i< cols.size(); i++)
- if (cols[i].pcol_ == w)
- return i;
- assert(false);
- return -1;
-}
-
-void
-Spacing_problem::OK() const
-{
-#ifndef NDEBUG
- Union_find connected(cols.size());
- Array<int> fixed;
- for (int i=0; i < ideals.size(); i++) {
- assert(ideals[i]->hooke > 0);
- int l = col_id(ideals[i]->left);
- int r = col_id(ideals[i]->right);
- connected.connect(l,r);
- }
- for (int i = 0; i < cols.size(); i++)
- if (cols[i].fixed())
- fixed.push(i);
- for (int i = 0; i < cols.size(); i++) {
- bool c=false;
- for (int j =0; j<fixed.size(); j++)
- c |= connected.equiv(fixed[j],i);
- if (!c)
- WARN << "You have unconnected columns. \n"
- "Check if bars and music fit each other\n"
- "(crashing :-)\n";
- assert(c);
- }
-#endif
-}
-
-bool
-Spacing_problem::check_constraints(Vector v) const
-{
- int dim=v.dim();
- for (int i=0; i < dim; i++) {
-
- if (cols[i].fixed()&&
- abs(cols[i].fixed_position() - v(i)) > COLFUDGE)
- return false;
-
- if (!i)
- continue;
-
- Real mindist=cols[i-1].minright()
- +cols[i].minleft();
-
- // ugh... compares
- Real dif =v(i) - v(i-1)- mindist;
- bool b = (dif > - COLFUDGE);
-
-
- if (!b)
- return false;
-
- }
- return true;
-}
-
-bool
-Spacing_problem::check_feasible() const
-{
- Vector sol(try_initial_solution());
- return check_constraints(sol);
-}
-
-// generate a solution which obeys the min distances and fixed positions
-Vector
-Spacing_problem::try_initial_solution() const
-{
- int dim=cols.size();
- Vector initsol(dim);
- for (int i=0; i < dim; i++) {
- if (cols[i].fixed()) {
- initsol(i)=cols[i].fixed_position();
- } else {
- Real mindist=cols[i-1].minright()
- +cols[i].minleft();
- assert(mindist >= 0.0);
- initsol(i)=initsol(i-1)+mindist;
-
- //nog niet
- //if (i>0)
- // assert(initsol(i) > initsol(i-1));
- }
- }
-
- return initsol;
-}
-Vector
-Spacing_problem::find_initial_solution() const
-{
- Vector v(try_initial_solution());
- assert(check_constraints(v));
- return v;
-}
-
-// generate the matrices
-void
-Spacing_problem::make_matrices(Matrix &quad, Vector &lin, Real &c) const
-{
- quad.fill(0);
- lin.fill(0);
- c = 0;
- for (int j=0; j < ideals.size(); j++){
- Idealspacing const*i=ideals[j];
- int l = col_id(i->left);
- int r = col_id(i->right);
-
- quad(r,r) += i->hooke;
- quad(r,l) -= i->hooke;
- quad(l,r) -= i->hooke;
- quad(l,l) += i->hooke;
-
- lin(r) -= i->space*i->hooke;
- lin(l) += i->space*i->hooke;
-
- c += sqr(i->space);
- }
-}
-
-// put the constraints into the LP problem
-void
-Spacing_problem::make_constraints(Mixed_qp& lp) const
-{
- int dim=cols.size();
- for (int j=0; j < dim; j++) {
- Colinfo *c=&(cols[j]);
- if (c->fixed()) {
- lp.add_fixed_var(j,c->fixed_position());
- }
- if (j > 0){
- Vector c1(dim);
-
- c1(j)=1.0 ;
- c1(j-1)=-1.0 ;
- lp.add_inequality_cons(c1, cols[j-1].minright() +
- cols[j].minleft());
- }
- }
-}
-
-Array<Real>
-Spacing_problem::solve() const
-{
- print();
- OK();
- assert(check_feasible());
-
- /* optimalisatiefunctie */
- Mixed_qp lp(cols.size());
- make_matrices(lp.quad,lp.lin, lp.const_term);
- make_constraints(lp);
- Vector start=find_initial_solution();
- Vector sol(lp.solve(start));
- if (!check_constraints(sol)) {
- WARN << "solution doesn't satisfy constraints.\n" ;
- }
-
-
- Array<Real> posns(sol);
- posns.push(lp.eval(sol));
- return posns;
-}
-
-/*
- add one column to the problem.
-*/
-void
-Spacing_problem::add_column(const PCol *col, bool fixed, Real fixpos)
-{
- Colinfo c(col,(fixed)? &fixpos : 0);
- cols.push(c);
-}
-
-void
-Spacing_problem::add_ideal(const Idealspacing *i)
-{
- const PCol *l =i->left;
- const PCol *r= i->right;
-
- if (!contains(l) || !contains(r)) {
- return;
- }
- ideals.push(i);
-}
-
-void
-Spacing_problem::print_ideal(const Idealspacing*id)const
-{
-#ifndef NPRINT
- int l = col_id(id->left);
- int r = col_id(id->right);
-
- mtor << "between " << l <<","<<r<<":" ;
- id->print();
-#endif
-}
-
-void
-Spacing_problem::print() const
-{
-#ifndef NPRINT
- for (int i=0; i < cols.size(); i++) {
- mtor << "col " << i<<' ';
- cols[i].print();
- }
- for (int i=0; i < ideals.size(); i++) {
- print_ideal(ideals[i]);
- }
-#endif
-
-}
-
-/* **************** */
-
-void
-Colinfo::print() const
-{
-#ifndef NPRINT
- mtor << "column { ";
- if (fixed())
- mtor << "fixed at " << fixed_position()<<", ";
- assert(pcol_);
- mtor << "[" << minleft() << ", " << minright() << "]";
- mtor <<"}\n";
-#endif
-}
-
-Colinfo::Colinfo(Colinfo const&c)
-{
- fixpos = (c.fixpos)?new Real(*c.fixpos):0;
- pcol_ = c.pcol_;
- width = c.width;
-}
-
-Colinfo::Colinfo(const PCol*col_p, const Real*fixed_r_p )
-{
- fixpos = (fixed_r_p)? new Real(*fixed_r_p) : 0;
- pcol_ = col_p;
- width = pcol_->width();
-}
-
-Colinfo::~Colinfo()
-{
- delete fixpos;
-}
-
-Colinfo::Colinfo()
-{
- pcol_=0;
- fixpos = 0;
-}
-void
-Colinfo::operator=(Colinfo const&c )
-{
- delete fixpos;
- fixpos = (c.fixpos)?new Real(*c.fixpos):0;
- pcol_ = c.pcol_;
- width = c.width;
-}
+++ /dev/null
-#include "local-key-item.hh"
-#include "molecule.hh"
-#include "scalar.hh"
-#include "lookup.hh"
-#include "paper-def.hh"
-#include "musicalrequest.hh"
-#include "notehead.hh"
-#include "misc.hh"
-
-
-
-Local_key_item::Local_key_item(int i)
-{
- c0_position = i;
-}
-
-void
-Local_key_item::add(Item*head_l)
-{
- support_items_.push(head_l);
- add_dependency(head_l);
-}
-
-void
-Local_key_item::add(Melodic_req*m_l)
-{
- add(m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_);
-}
-void
-Local_key_item::add (int o, int p , int a)
-{
- Local_acc l;
- l.octave = o;
- l.name = p;
- l.acc = a;
- accs.push(l);
-}
-
-void
-Local_key_item::do_pre_processing()
-{
- accs.sort(Local_acc::compare);
-}
-
-Molecule*
-Local_key_item::brew_molecule_p()const
-{
- Molecule* output = new Molecule;
- Molecule*octmol = 0;
- int lastoct = -100;
- for (int i = 0; i < accs.size(); i++) {
- // do one octave
- if (accs[i].octave != lastoct) {
- if (octmol){
- Real dy =lastoct*7*paper()->internote();
- octmol->translate(Offset(0, dy));
- output->add(*octmol);
- delete octmol;
- }
- octmol= new Molecule;
- }
- lastoct = accs[i].octave;
- Symbol s =paper()->lookup_p_->accidental(accs[i].acc);
- Atom a(s);
- Real dy = (accs[i].name + c0_position) * paper()->internote();
- a.translate(Offset(0,dy));
-
- octmol->add_right(a);
- }
-
- if (octmol){
- Real dy =lastoct*7*paper()->internote();
- octmol->translate(Offset(0, dy));
- output->add(*octmol);
- delete octmol;
- }
-
- Interval head_width=itemlist_width(support_items_);
- output->translate(Offset(-output->extent().x.right + head_width.left ,0));
-
- return output;
-}
-
-int
-Local_acc::compare(Local_acc&a, Local_acc&b)
-{
- if (a.octave - b.octave)
- return a.octave - b.octave;
- if (a.name - b.name)
- return a.name - b.name;
-
- assert(false);
-};
+++ /dev/null
-/*
- local-key-reg.cc -- implement Local_key_register
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "musicalrequest.hh"
-#include "commandrequest.hh"
-#include "local-key-reg.hh"
-#include "local-key-item.hh"
-#include "complex-walker.hh"
-#include "key-reg.hh"
-#include "debug.hh"
-#include "key-item.hh"
-
-Local_key_register::Local_key_register()
-{
- key_item_p_ = 0;
- key_c_l_ = 0;
-}
-
-void
-Local_key_register::pre_move_processing()
-{
- if (key_item_p_) {
- typeset_element(key_item_p_);
- key_item_p_ = 0;
- }
-}
-void
-Local_key_register::acknowledge_element(Staff_elem_info info)
-{
- if (info.req_l_->melodic()) {
- Melodic_req * melodic_l_ = info.req_l_->melodic();
-
- if( melodic_l_->forceacc_b_ ||
- local_key_.oct(melodic_l_->octave_i_).acc(melodic_l_->notename_i_)
- != melodic_l_->accidental_i_) {
- Item * support_l_ = info.elem_p_->item();
-
-
- if (!key_item_p_) {
- key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_);
- }
-
- key_item_p_->add(melodic_l_);
- key_item_p_->add(support_l_);
- local_key_.oct(melodic_l_->octave_i_)
- .set(melodic_l_->notename_i_, melodic_l_->accidental_i_);
- }
- } else if (info.elem_p_->name()==Key_item::static_name()) {
- Key_register * key_reg_l =
- (Key_register*)info.origin_reg_l_arr_[0];
- key_c_l_ = &key_reg_l->key_;
- local_key_.reset(*key_c_l_);
- }
-}
-
-void
-Local_key_register::process_requests()
-{
- const Time_description * time_c_l_ = get_staff_info().time_c_l_;
- if (! time_c_l_->whole_in_measure_){
- if (key_c_l_)
- local_key_.reset(*key_c_l_);
- else if( time_c_l_->when_ >0)
- warning ("Help me! can't figure current key", 0);
- }
-}
+++ /dev/null
-/*
- lookup.cc -- implement simple Lookup methods.
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "lookup.hh"
-#include "debug.hh"
-#include "symtable.hh"
-#include "dimen.hh"
-#include "tex.hh"
-#include "scalar.hh"
-
-Lookup::Lookup()
-{
- texsetting = "\\unknowntexsetting";
- symtables_ = new Symtables;
-}
-
-Lookup::Lookup(Lookup const &s)
-{
- texsetting = s.texsetting;
- symtables_ = new Symtables(*s.symtables_);
-}
-Lookup::~Lookup()
-{
- delete symtables_;
-}
-
-void
-Lookup::add(String s, Symtable*p)
-{
- symtables_->add(s, p);
-}
-
-void
-Lookup::print()const
-{
- mtor << "Lookup: " << texsetting << " {\n";
- symtables_->print();
- mtor << "}\n";
-}
-
-Symbol
-Lookup::text(String style, String text, int dir)
-{
- Array<String> a;
-
- a.push(text);
- Symbol tsym = (*symtables_)("style")->lookup(style);
- a[0] = substitute_args(tsym.tex,a);
-
- Symbol s = (*symtables_)("align")->lookup(dir);
- s.tex = substitute_args(s.tex,a);
- s.dim.y = tsym.dim.y;
- return s;
-}
-
-
-Real
-Lookup::internote()
-{
- return ball(4).dim.y.length()/2;
-}
-
-Symbol
-Lookup::ball(int j)
-{
- if (j > 4)
- j = 4;
-
- Symtable * st = (*symtables_)("balls");
- return st->lookup(String(j));
-}
-
-Symbol
-Lookup::rest(int j)
-{
- return (*symtables_)("rests")->lookup(String(j));
-}
-
-Symbol
-Lookup::fill(Box b)
-{
- Symbol s( (*symtables_)("param")->lookup("fill"));
- s.dim = b;
- return s;
-}
-
-Symbol
-Lookup::accidental(int j)
-{
- return (*symtables_)("accidentals")->lookup(String(j));
-}
-
-
-Symbol
-Lookup::bar(String s)
-{
- return (*symtables_)("bars")->lookup(s);
-}
-
-Symbol
-Lookup::script(String s)
-{
- return (*symtables_)("scripts")->lookup(s);
-}
-
-Symbol
-Lookup::clef(String s)
-{
- return (*symtables_)("clefs")->lookup(s);
-}
-
-Symbol
-Lookup::dots(int j)
-{
- if (j>3)
- error("max 3 dots"); // todo
- return (*symtables_)("dots")->lookup(j);
-}
-
-Symbol
-Lookup::flag(int j)
-{
- return (*symtables_)("flags")->lookup(j);
-}
-
-Symbol
-Lookup::streepjes(int i)
-{
- assert(i);
-
- int arg;
- String idx;
-
- if (i < 0) {
- idx = "botlines";
- arg = -i;
- } else {
- arg = i;
- idx = "toplines";
- }
- Symbol ret = (*symtables_)("streepjes")->lookup(idx);
-
- Array<String> a;
- a.push(arg);
- ret.tex = substitute_args(ret.tex, a);
-
- return ret;
-}
-
-Symbol
-Lookup::hairpin(Real &wid, bool decresc)
-{
- int idx = int(rint(wid / 6 PT));
- if(!idx) idx ++;
- wid = idx*6 PT;
- String idxstr = (decresc)? "decrescendosym" : "crescendosym";
- Symbol ret=(*symtables_)("param")->lookup(idxstr);
-
- Array<String> a;
- a.push(idx);
- ret.tex = substitute_args(ret.tex, a);
- ret.dim.x = Interval(0,wid);
- return ret;
-}
-
-Symbol
-Lookup::linestaff(int lines, Real wid)
-{
- Symbol s;
- s.dim.x = Interval(0,wid);
- Real dy = (lines >0) ? (lines-1)*internote()*2 : 0;
- s.dim.y = Interval(0,dy);
-
- Array<String> a;
- a.push(lines);
- a.push(print_dimen(wid));
-
- s.tex = (*symtables_)("param")->lookup("linestaf").tex;
- s.tex = substitute_args(s.tex, a);
-
- return s;
-}
-
-
-Symbol
-Lookup::meter(Array<Scalar> a)
-{
- Symbol s;
- s.dim.x = Interval( 0 PT, 10 PT);
- s.dim.y = Interval(0, 20 PT); // todo
- String src = (*symtables_)("param")->lookup("meter").tex;
- s.tex = substitute_args(src,a);
- return s;
-}
-
-
-Symbol
-Lookup::stem(Real y1,Real y2)
-{
- if (y1 > y2) {
- Real t = y1;
- y1 = y2;
- y2 = t;
- }
- Symbol s;
-
- s.dim.x = Interval(0,0);
- s.dim.y = Interval(y1,y2);
-
- Array<String> a;
- a.push(print_dimen(y1));
- a.push(print_dimen(y2));
-
- String src = (*symtables_)("param")->lookup("stem").tex;
- s.tex = substitute_args(src,a);
- return s;
-}
+++ /dev/null
-#include "musicalrequest.hh"
-#include "paper-def.hh"
-#include "lyric-item.hh"
-#include "stem.hh"
-#include "molecule.hh"
-#include "lookup.hh"
-#include "text-def.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "debug.hh"
-#include "main.hh"
-
-Lyric_item::Lyric_item(Lyric_req* lreq_l, int voice_count_i)
- : Text_item(lreq_l,0)
-{
- pos_i_ = -voice_count_i * 4 ; // 4 fontsize dependant. TODO
- dir_i_ = -1;
-}
-
-void
-Lyric_item::do_pre_processing()
-{
-
- // test context-error
- if ( tdef_l_->text_str_.index_i( "Gates" ) >=0)// :-)
- warning( "foul word", tdef_l_->defined_ch_c_l_ );
-}
+++ /dev/null
-#include "musicalrequest.hh"
-#include "voice.hh"
-#include "staff-walker.hh"
-#include "debug.hh"
-#include "staff.hh"
-#include "lyricstaff.hh"
-#include "lyricwalker.hh"
-#include "pscore.hh"
-
-void
-Lyric_staff::set_output(PScore*pscore_l)
-{
- pstaff_l_ = new PStaff(pscore_l);
- pscore_l_ = pscore_l;
- pscore_l_->add(pstaff_l_);
-}
-
-Staff_walker*
-Lyric_staff::get_walker_p()
-{
- return new Lyric_walker(this);
-}
+++ /dev/null
-/*
- lyricwalker.cc -- implement Lyric_walker
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-*/
-
-#include "musicalrequest.hh"
-#include "voice.hh"
-#include "pscore.hh"
-#include "lyricstaff.hh"
-#include "lyricwalker.hh"
-#include "debug.hh"
-#include "lyric-item.hh"
-#include "staff-column.hh"
-
-void
-Lyric_walker::process_requests()
-{
- allow_break();
-
- int req_count=0;
- for (int i = 0; i < ptr()->musicalreq_l_arr_.size(); i++) {
- Lyric_req * lreq_l = ptr()->musicalreq_l_arr_[i]->lreq_l();
- if (!lreq_l)
- continue;
- Item *lp = new Lyric_item(lreq_l,req_count++);
- ptr()->typeset_musical_item( lp);
- }
-}
-
-Lyric_walker::Lyric_walker(Lyric_staff* lstaff_l)
- : Staff_walker(lstaff_l, lstaff_l->pstaff_l_->pscore_l_)
-{
-
-}
-
-
+++ /dev/null
-#include <iostream.h>
-#include <assert.h>
-#include "proto.hh"
-#include "plist.hh"
-#include "lgetopt.hh"
-#include "misc.hh"
-#include "string.hh"
-#include "main.hh"
-#include "path.hh"
-#include "config.hh"
-#include "source-file.hh"
-#include "source.hh"
-
-Source source;
-Source* source_l_g = &source;
-bool only_midi = false;
-extern void parse_file(String,String);
-
-
-void
-destill_inname( String &name_str_r);
-Long_option_init theopts[] = {
- 1, "output", 'o',
- 0, "warranty", 'w',
- 0, "help", 'h',
- 0, "debug", 'd',
- 1, "init", 'i',
- 1, "include", 'I',
- 0, "midi", 'M',
- 0,0,0
-};
-
-void
-help()
-{
- cout <<
- "--help, -h This help\n"
- "--warranty, -w show warranty & copyright\n"
- "--output, -o set default output\n"
- "--debug, -d enable debug output\n"
- "--init, -i set init file\n"
- "--include, -I add to file search path.\n"
- "--midi, -M midi output only\n"
- ;
-
-}
-
-void
-notice()
-{
- cout <<
- "\n"
- "LilyPond, a music typesetter.\n"
- "Copyright (C) 1996,97 by\n"
- " Han-Wen Nienhuys <hanwen@stack.nl>\n"
- "Contributors\n"
- " Jan Nieuwenhuizen <jan@digicash.com>\n"
- " Mats Bengtsson <matsb@s3.kth.se>\n"
- "\n"
- " This program is free software; you can redistribute it and/or\n"
- "modify it under the terms of the GNU General Public License version 2\n"
- "as published by the Free Software Foundation.\n"
- "\n"
- " This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
- "General Public License for more details.\n"
- "\n"
- " You should have received a copy (refer to the file COPYING) of the\n"
- "GNU General Public License along with this program; if not, write to\n"
- "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
- "USA.\n";
-}
-
-static File_path * path =0;
-struct Main_init {
- Main_init() {
- path = new File_path(LIBDIR);
- path->push(String(LIBDIR)+"init/");
- debug_init();
- }
- ~Main_init() {
- delete path;
- }
-} main_init;
-
-int
-main (int argc, char **argv)
-{
- Getopt_long oparser(argc, argv,theopts);
- cout << get_version();
- String init_str("symbol.ini");
-
- while (Long_option_init * opt = oparser()) {
- switch ( opt->shortname){
- case 'o':
- set_default_output(oparser.optarg);
- break;
- case 'w':
- notice();
- exit(0);
- break;
- case 'I':
- path->push(oparser.optarg);
- break;
- case 'i':
- init_str = oparser.optarg;
- break;
- case 'h':
- help();
- exit(0);
- break;
- case 'd':
- set_debug(true);
- break;
- case 'M':
- only_midi = true;
- break;
- default:
- assert(false);
- break;
- }
- }
-
- int p=0;
- char *arg ;
- while ( (arg= oparser.get_next_arg()) ) {
- String f(arg);
- destill_inname(f);
- parse_file(init_str,f);
- do_scores();
- p++;
- }
- if (!p) {
- parse_file(init_str, "");
- do_scores();
- }
-
- return 0;
-}
-
-String
-find_file(String f)
-{
- return path->find(f);
-}
-
-/// make input file name: add default extension. "" is stdin.
-void
-destill_inname( String &name_str_r)
-{
- if ( name_str_r.length_i() )
- {
- if( name_str_r[ 0 ] != '-' )
- {
- String a,b,c,d;
- split_path(name_str_r,a,b,c,d);
-
- // add extension if not present.
- if (d == "")
- d = ".ly";
- name_str_r = a+b+c+d;
- }
- } else name_str_r = "";
-}
-
+++ /dev/null
-/*
- meter-reg.cc -- implement Meter_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "meter-reg.hh"
-#include "meter.hh"
-#include "commandrequest.hh"
-
-Meter_register::Meter_register()
-
-{
- post_move_processing();
-}
-
-bool
-Meter_register::try_request(Request*r_l)
-{
- Command_req* creq_l= r_l->command();
- if (!creq_l || !creq_l->meterchange())
- return false;
-
- assert(!meter_req_l_);
- meter_req_l_ = r_l->command()->meterchange();
-
- return true;
-}
-
-void
-Meter_register::process_requests()
-{
- if (meter_req_l_ ) {
- Array<Scalar> args;
- args.push(meter_req_l_->beats_i_);
- args.push(meter_req_l_->one_beat_i_);
-
- meter_p_ = new Meter(args);
- }
-
- if (meter_p_)
- announce_element(Staff_elem_info(meter_p_, meter_req_l_) );
-}
-
-void
-Meter_register::pre_move_processing()
-{
- if (meter_p_) {
- Meter * post_p =new Meter(*meter_p_);
- Meter * pre_p =new Meter(*meter_p_);
-
- typeset_breakable_item(pre_p, meter_p_, post_p);
- meter_p_ =0;
- }
-}
-
-void
-Meter_register::post_move_processing()
-{
- meter_req_l_ = 0;
- meter_p_ =0;
-}
+++ /dev/null
-#include "scalar.hh"
-#include "molecule.hh"
-#include "meter.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-
-Meter::Meter(Array<Scalar>a)
- :args(a)
-{
-}
-
-Molecule*
-Meter::brew_molecule_p()const
-{
- Symbol s = paper()->lookup_p_->meter(args);
- return new Molecule(Atom(s));
-}
-
+++ /dev/null
-//
-// midi-def.cc -- implement midi output
-//
-// source file of the LilyPond music typesetter
-//
-// (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include <math.h>
-#include "misc.hh"
-#include "midi-def.hh"
-#include "debug.hh"
-
-// classes, alphasorted
-// statics
-// constructors
-// destructor
-// routines, alphasorted
-
-Midi_def::Midi_def()
-{
- set_tempo( Moment( 1, 4 ), 60 );
- outfile_str_ = "lelie.midi";
-}
-
-Midi_def::Midi_def( Midi_def const& midi_c_r )
-{
- whole_seconds_f_ = midi_c_r.whole_seconds_f_;
- outfile_str_ = midi_c_r.outfile_str_;
-}
-
-Midi_def::~Midi_def()
-{
-}
-
-Real
-Midi_def::duration_to_seconds_f( Moment moment )
-{
- if (!moment)
- return 0;
-
- return whole_seconds_f_ * moment;
-}
-
-int
-Midi_def::get_tempo_i( Moment moment )
-{
- return Moment( whole_seconds_f_ ) * Moment( 60 ) * moment;
-}
-
-void
-Midi_def::print() const
-{
-#ifndef NPRINT
- mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
- mtor << "out: " << outfile_str_;
- mtor << "}\n";
-#endif
-}
-
-void
-Midi_def::set_tempo( Moment moment, int count_per_minute_i )
-{
- whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment;
-}
+++ /dev/null
-//
-// midi-event.cc -- implement Midi_event
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include <assert.h>
-
-#include "proto.hh"
-#include "plist.hh" // all for midi-main.hh
-#include "string.hh"
-#include "source.hh"
-#include "source-file.hh"
-#include "midi-main.hh" // *tors
-#include "moment.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "lily-stream.hh"
-
-Midi_event::Midi_event()
-{
-}
-
-Midi_event::~Midi_event()
-{
-}
-
-Moment
-Midi_event::mom()
-{
- return Moment( 0 );
-}
-
-String
-Midi_event::mudela_str()
-{
- return mudela_str_;
-}
-
-void
-Midi_event::output_mudela( Lily_stream& lily_stream_r )
-{
- lily_stream_r << mudela_str_ << String( " " );
-}
-
-Midi_key::Midi_key( int accidentals_i, int minor_i )
-{
- accidentals_i_ = accidentals_i;
- minor_i_ = minor_i;
- if ( !minor_i_ )
- key_i_ = ( ( accidentals_i % 7 )[ "cgdaebf" ] - 'a' + 2 ) % 7;
- else
- key_i_ = ( ( -accidentals_i % 7 )[ "fbeadg" ] - 'a' + 2 ) % 7;
- mudela_str_ = String( "% \\key\\" );
- if ( !minor_i_ )
- mudela_str_ += String( (char)( key_i_ - 2 + 'A' ) );
- else
- mudela_str_ += String( (char)( key_i_ - 2 + 'a' ) );
-}
-
-String
-Midi_key::notename_str( int pitch_i )
-{
- // this may seem very smart,
- // but it-s only an excuse not to read a notename table
-
- // major scale: do-do
- // minor scale: la-la ( = + 5 )
- static int notename_i_a[ 12 ] = { 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6 };
- int notename_i = notename_i_a[ ( minor_i_ * 5 + pitch_i ) % 12 ];
-
- static int accidentals_i_a[ 12 ] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
- int accidental_i = accidentals_i_a[ minor_i_ * 5 + pitch_i % 12 ];
- if ( accidentals_i_ < 0 ) {
- accidental_i = - accidental_i;
- notename_i = ( notename_i + 1 ) % 7;
- }
-
- String notename_str = (char)( ( ( notename_i + key_i_ - 2 ) % 7 ) + 'a' );
- while ( accidental_i-- > 0 )
- notename_str += "is";
- accidental_i++;
- while ( accidental_i++ < 0 )
- if ( ( notename_str == "a" ) || ( notename_str == "e" ) )
- notename_str += "s";
- else
- notename_str += "es";
- accidental_i--;
- String octave_str;
-
- octave_str += String( '\'', ( pitch_i - Midi_note::c0_pitch_i_c_ ) / 12 );
- octave_str += String( '`', ( Midi_note::c0_pitch_i_c_ - pitch_i ) / 12 );
- return octave_str + notename_str;
-}
-
-Midi_key::~Midi_key()
-{
-}
-
-Midi_note::Midi_note( Midi_key* midi_key_l, Midi_time* midi_time_l, int division_1_i, int pitch_i, int time_i )
-{
- dur_ = midi_time_l->i2_dur( time_i, division_1_i );
-
- if ( dur_.plet_p_ )
- mudela_str_ += String( "\\plet{ " )
- + String_convert::i2dec_str( dur_.plet_p_->iso_i_, 0, 0 )
- + "/"
- + String_convert::i2dec_str( dur_.plet_p_->type_i_, 0, 0 )
- + " } ";
-
- mudela_str_ += midi_key_l->notename_str( pitch_i );
-
- Duration dur = dur_;
- dur.set_plet( 0 );
- mudela_str_ += Duration_convert::dur2_str( dur );
-
- if ( dur_.plet_p_ )
- mudela_str_ += String( " \\plet{ 1/1 }" );
-}
-
-Midi_note::~Midi_note()
-{
-}
-
-Moment
-Midi_note::mom()
-{
- return Duration_convert::dur2_mom( dur_ );
-}
-
-Midi_tempo::Midi_tempo( int useconds_per_4_i )
-{
- useconds_per_4_i_ = useconds_per_4_i;
- seconds_per_1_f_ = (Real)useconds_per_4_i_ * 4 / 1e6;
- mudela_str_ = "% \\Tempo: ";
- mudela_str_ += String( useconds_per_4_i_ );
- mudela_str_ += String( ": " )
- + String( get_tempo_i( Moment( 1, 4 ) ) )
- + String( " 4 per minute" );
-}
-
-Midi_tempo::~Midi_tempo()
-{
-}
-
-int
-Midi_tempo::get_tempo_i( Moment moment )
-{
- return Moment( 60 ) / moment / Moment( seconds_per_1_f_ );
-}
-
-Midi_time::Midi_time( int num_i, int den_i, int clocks_4_i, int count_32_i )
- : sync_dur_( 8 )
-{
- sync_f_ = 1.0;
- if ( count_32_i != 8 )
- warning( String( "#32 in quarter: " ) + String( count_32_i ), 0 );
- num_i_ = num_i;
- den_i_ = 2 << den_i;
- clocks_1_i_ = clocks_4_i * 4;
- mudela_str_ = "% \\Time: ";
- mudela_str_ += String( num_i_ ) + "/" + String( den_i_ )
- + ", " + String( clocks_1_i_ )
- + ": " + String( count_32_i );
-}
-
-Midi_time::~Midi_time()
-{
-}
-
-Duration
-Midi_time::i2_dur( int time_i, int division_1_i )
-{
- Moment mom = Duration_convert::i2_mom( time_i, division_1_i );
- mom /= sync_f_;
-
- dtor << "\n% (" << time_i << ", " << mom << "): "
- << sync_f_ << endl;
-
- Duration dur = Duration_convert::mom2_dur( mom );
- if ( !dur.type_i_ ) {
- vtor << "\n% resyncing(" << time_i << ", " << mom << "): "
- << sync_f_ << " -> ";
- mom *= sync_f_;
- sync_f_ = Duration_convert::sync_f( sync_dur_, mom );
- vtor << sync_f_ << endl;
- mom /= sync_f_;
- dur = Duration_convert::mom2_dur( mom );
- }
-
- return dur;
-}
-
-int
-Midi_time::clocks_1_i()
-{
- return clocks_1_i_;
-}
-
+++ /dev/null
-//
-// midi-item.cc
-//
-// source file of the LilyPond music typesetter
-//
-// (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include <limits.h>
-#include "plist.hh"
-#include "pcol.hh"
-#include "debug.hh"
-#include "misc.hh"
-#include "request.hh"
-#include "musicalrequest.hh"
-#include "voice.hh"
-#include "midi-item.hh"
-#include "midi-stream.hh"
-#include "string-convert.hh"
-
-Midi_chunk::Midi_chunk()
-{
-}
-
-void
-Midi_chunk::add( String str )
-{
- data_str_ += str;
-}
-
-void
-Midi_chunk::set( String header_str, String data_str, String footer_str )
-{
- data_str_ = data_str;
- footer_str_ = footer_str;
- header_str_ = header_str;
-}
-
-String
-Midi_chunk::str()
-{
- String str = header_str_;
- String length_str = String_convert::i2hex_str( data_str_.length_i() + footer_str_.length_i(), 8, '0' );
- length_str = String_convert::hex2bin_str( length_str );
- str += length_str;
- str += data_str_;
- str += footer_str_;
- return str;
-}
-
-Midi_duration::Midi_duration( Real seconds_f )
-{
- seconds_f_ = seconds_f;
-}
-
-String
-Midi_duration::str()
-{
- return String( "<duration: " ) + String( seconds_f_ ) + ">";
-}
-
-Midi_header::Midi_header( int format_i, int tracks_i, int clocks_per_4_i )
-{
- String str;
-
- String format_str = String_convert::i2hex_str( format_i, 4, '0' );
- str += String_convert::hex2bin_str( format_str );
-
- String tracks_str = String_convert::i2hex_str( tracks_i, 4, '0' );
- str += String_convert::hex2bin_str( tracks_str );
-
- String tempo_str = String_convert::i2hex_str( clocks_per_4_i, 4, '0' );
- str += String_convert::hex2bin_str( tempo_str );
-
- set( "MThd", str, "" );
-}
-
-String
-Midi_item::i2varint_str( int i )
-{
- int buffer_i = i & 0x7f;
- while ( (i >>= 7) > 0 ) {
- buffer_i <<= 8;
- buffer_i |= 0x80;
- buffer_i += (i & 0x7f);
- }
-
- String str;
- while ( 1 ) {
- str += (char)buffer_i;
- if ( buffer_i & 0x80 )
- buffer_i >>= 8;
- else
- break;
- }
- return str;
-}
-
-void
-Midi_item::output_midi( Midi_stream& midi_stream_r )
-{
- midi_stream_r << str();
-}
-
-
-Midi_note::Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo )
-{
- assert(melreq_l);
- pitch_i_ = melreq_l->pitch() + c0_pitch_i_c_;
- channel_i_ = channel_i;
-
- // poor man-s staff dynamics:
- dynamic_byte_ = (melreq_l)? 0x64 - 0x10 * channel_i_:0;
- on_b_ = on_bo;
-}
-
-String
-Midi_note::str()
-{
- if ( pitch_i_ != INT_MAX ) {
- Byte status_byte = ( on_b_ ? 0x90 : 0x80 ) + channel_i_;
- String str = String( (char)status_byte );
- str += (char)pitch_i_;
- // poor man-s staff dynamics:
- str += (char)dynamic_byte_;
- return str;
- }
- return String( "" );
-}
-
-Midi_tempo::Midi_tempo( int tempo_i )
-{
- tempo_i_ = tempo_i;
-}
-
-String
-Midi_tempo::str()
-{
- int useconds_per_4_i = 60 * (int)1e6 / tempo_i_;
- String str = "ff5103";
- str += String_convert::i2hex_str( useconds_per_4_i, 6, '0' );
- return String_convert::hex2bin_str( str );
-}
-
-Midi_track::Midi_track( int number_i )
-{
-// 4D 54 72 6B MTrk
-// 00 00 00 3B chunk length (59)
-// 00 FF 58 04 04 02 18 08 time signature
-// 00 FF 51 03 07 A1 20 tempo
-
-// FF 59 02 sf mi Key Signature
-// sf = -7: 7 flats
-// sf = -1: 1 flat
-// sf = 0: key of C
-// sf = 1: 1 sharp
-// sf = 7: 7 sharps
-// mi = 0: major key
-// mi = 1: minor key
-
- number_i_ = number_i;
-
- char const* data_ch_c_l = "00" "ff58" "0404" "0218" "08"
-// "00" "ff51" "0307" "a120"
-// why a key at all, in midi?
-// key: C
- "00" "ff59" "02" "00" "00"
-// key: F (scsii-menuetto)
-// "00" "ff59" "02" "ff" "00"
- ;
-
- String data_str;
- // only for format 0 (currently using format 1)?
- data_str += String_convert::hex2bin_str( data_ch_c_l );
-
- char const* footer_ch_c_l = "00" "ff2f" "00";
- String footer_str = String_convert::hex2bin_str( footer_ch_c_l );
-
- set( "MTrk", data_str, footer_str );
-}
-
-void
-Midi_track::add( int delta_time_i, String event_str )
-{
- assert(delta_time_i >= 0);
- Midi_chunk::add( i2varint_str( delta_time_i ) + event_str );
-}
-
-void
-Midi_track::add( Moment delta_time_moment, Midi_item* mitem_l )
-{
- // use convention of 384 clocks per 4
- // use Duration_convert
- int delta_time_i = delta_time_moment * Moment( 384 ) / Moment( 1, 4 );
- add( delta_time_i, mitem_l->str() );
-}
-
+++ /dev/null
-%{
-// midi-lexer.l
-
-//#include <stdio.h>
-
-#include "string.hh"
-#include "proto.hh"
-#include "midi-main.hh"
-#include "my-midi-lexer.hh"
-#include "midi-parser.hh"
-
-%}
-
-%option c++
-%option noyywrap
-%option nodefault
-%option yylineno
-%option debug
-%option yyclass="My_midi_lexer"
-%option stack
-
-%x data
-%x event
-%x int8
-%x int16
-%x int32
-%x meta_event
-%x track
-
-INT8 [\x00-\xff]
-INT16 {INT8}{INT8}
-INT32 {INT16}{INT16}
-INT7_8UNSET [\x00-\x7f]
-INT7_8SET [\x80-\xff]
-VARINT {INT7_8SET}{0,3}{INT7_8UNSET}
-
-HEADER MThd
-TRACK MTrk
-
-XRUNNING_STATUS [\x30-\x4f]
-RUNNING_STATUS [\x00-\x5f]
-DATA_ENTRY [\x60-\x79]
-ALL_NOTES_OFF [\x7a-\x7f]
-NOTE_OFF [\x80-\x8f]
-NOTE_ON [\x90-\x9f]
-POLYPHONIC_AFTERTOUCH [\xa0-\xaf]
-CONTROLMODE_CHANGE [\xb0-\xbf]
-PROGRAM_CHANGE [\xc0-\xcf]
-CHANNEL_AFTERTOUCH [\xd0-\xdf]
-PITCHWHEEL_RANGE [\xe0-\xef]
-
-SYSEX_EVENT1 [\xf0]
-SYSEX_EVENT2 [\xf7]
-
-META_EVENT [\xff]
-
-SEQUENCE [\x00][\x02]
-TEXT [\x01]
-COPYRIGHT [\x02]
-TRACK_NAME [\x03]
-INSTRUMENT_NAME [\x04]
-LYRIC [\x05]
-MARKER [\x06]
-CUE_POINT [\x07]
-
-END_OF_TRACK [\x2f][\x00]
-TEMPO [\x51][\x03]
-SMPTE_OFFSET [\x54][\x05]
-TIME [\x58][\x04]
-KEY [\x59][\x02]
-SSME [\0x7f][\x03]
-
-%%
-
-{HEADER}/{INT32} { // using /{INT32}; longer match than {INT32}
- dtor << "lex: header" << endl;
- yy_push_state( int16 );
- yy_push_state( int16 );
- yy_push_state( int16 );
- yy_push_state( int32 );
- return HEADER;
-}
-
-{TRACK}/{INT32} { // using /{INT32}; longer match than {INT32}
- dtor << "lex: track" << endl;
- yy_push_state( track );
- yy_push_state( int32 );
- return TRACK;
-}
-{INT8} {
- error( String( "top level: illegal byte: " )
- + String_convert::bin2hex_str( String( *YYText() ) ) );
- exit( 1 );
-}
-<int32>{INT32} {
- dtor << "lex: int32" << endl;
- assert( YYLeng() == 4 );
- String str( (Byte const*)YYText(), YYLeng() );
- yylval.i = String_convert::bin2_i( str );
- yy_pop_state();
- return INT32;
-}
-<int16>{INT16} {
- dtor << "lex: int16" << endl;
- assert( YYLeng() == 2 );
- String str( (Byte const*)YYText(), YYLeng() );
- yylval.i = String_convert::bin2_i( str );
- yy_pop_state();
- return INT16;
-}
-<int8>{INT8} {
- dtor << "lex: int8" << endl;
- assert( YYLeng() == 1 );
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- return INT8;
-}
-
-<track>{VARINT} {
- String str( (Byte const*)YYText(), YYLeng() );
- yylval.i = My_midi_lexer::varint2_i( str );
- dtor << String( "lex: track: varint(" )
- + String( yylval.i ) + "): "
- + String_convert::bin2hex_str( str ) << endl;
- yy_push_state( event );
- return VARINT;
-}
-<track>{INT8} {
- error( String( "track: illegal byte: " )
- + String_convert::bin2hex_str( String( *YYText() ) ) );
- exit( 1 );
-}
-<event>{RUNNING_STATUS} {
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- dtor << String ( "lex: running status: " ) + String( yylval.i ) << endl;
- yy_pop_state();
-// yy_push_state( int8 );
- yy_push_state( int8 );
- return RUNNING_STATUS;
-}
-<event>{DATA_ENTRY} {
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- dtor << String ( "lex: undefined data entry: " ) + String( yylval.i ) << endl;
- yy_pop_state();
- yy_push_state( int8 );
- return DATA_ENTRY;
-}
-<event>{ALL_NOTES_OFF} {
- dtor << "lex: all note off" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- dtor << String ( "lex: all notes off: " ) + String( yylval.i ) << endl;
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return ALL_NOTES_OFF;
-}
-<event>{NOTE_OFF} {
- dtor << "lex: note off" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return NOTE_OFF;
-}
-<event>{NOTE_ON} {
- dtor << "lex: note on" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return NOTE_ON;
-}
-<event>{POLYPHONIC_AFTERTOUCH} {
- dtor << "lex: polyphonic aftertouch" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return POLYPHONIC_AFTERTOUCH;
-}
-<event>{CONTROLMODE_CHANGE} {
- dtor << "lex: controlmode change" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return CONTROLMODE_CHANGE;
-}
-<event>{PROGRAM_CHANGE} {
- dtor << "lex: program change" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- return PROGRAM_CHANGE;
-}
-<event>{CHANNEL_AFTERTOUCH} {
- dtor << "lex: channel aftertouch" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return CHANNEL_AFTERTOUCH;
-}
-<event>{PITCHWHEEL_RANGE} {
- dtor << "lex: pitchwheel range" << endl;
-// yylval.byte = *(Byte*)YYText();
- yylval.i = *(Byte*)YYText();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return PITCHWHEEL_RANGE;
-}
-<event>{SYSEX_EVENT1} { // len data
- dtor << "lex: sysex1" << endl;
- yy_pop_state();
- yy_push_state( data );
- return SYSEX_EVENT1;
-}
-<event>{SYSEX_EVENT2} { // len data
- dtor << "lex: sysex2" << endl;
- yy_pop_state();
-// yy_push_state( int8 ); //?
- yy_push_state( data );
- return SYSEX_EVENT2;
-}
-<event>{META_EVENT} {
- dtor << "lex: meta" << endl;
- yy_push_state( meta_event );
- return META_EVENT;
-}
-<event>{INT8} {
- error( String( "event: illegal byte: " )
- + String_convert::bin2hex_str( String( *YYText() ) ) );
- exit( 1 );
-}
-<meta_event>{SEQUENCE} { // ssss sequence number
- dtor << "lex: sequence" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( int16 );
- return SEQUENCE;
-}
-<meta_event>{TEXT} { // len data
- dtor << "lex: text" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return TEXT;
-}
-<meta_event>{COPYRIGHT} {
- dtor << "lex: copyright" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return COPYRIGHT;
-}
-<meta_event>{TRACK_NAME} {
- dtor << "lex: track name" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return TRACK_NAME;
-}
-<meta_event>{INSTRUMENT_NAME} {
- dtor << "lex: instrument name" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return INSTRUMENT_NAME;
-}
-<meta_event>{LYRIC} {
- dtor << "lex: lyric" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return LYRIC;
-}
-<meta_event>{MARKER} {
- dtor << "lex: marker" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return MARKER;
-}
-<meta_event>{CUE_POINT} {
- dtor << "lex: cue point" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return CUE_POINT;
-}
-<meta_event>{TEMPO} { // tttttt usec
- dtor << "lex: tempo" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- yy_push_state( int8 );
- return TEMPO;
-}
-<meta_event>{SMPTE_OFFSET} { // hr mn se fr ff
- dtor << "lex: smpte offset" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- yy_push_state( int8 );
- yy_push_state( int8 );
- yy_push_state( int8 );
- return SMPTE_OFFSET;
-}
-<meta_event>{TIME} { // nn dd cc bb
- dtor << "lex: time" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- yy_push_state( int8 );
- yy_push_state( int8 );
- return TIME;
-}
-<meta_event>{KEY} { // sf mi
- dtor << "lex: key" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return KEY;
-}
-<meta_event>{SSME} { // len data
- dtor << "lex: smme" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_push_state( data );
- return SSME;
-}
-<meta_event>{END_OF_TRACK} {
- dtor << "lex: end of track" << endl;
- yy_pop_state();
- yy_pop_state();
- yy_pop_state();
- return END_OF_TRACK;
-}
-<meta_event>{INT8} {
- warning( String( "meta_event: unimplemented event: " )
- + String_convert::bin2hex_str( String( *YYText() ) ),
- *this->here_ch_c_l() );
- yy_pop_state();
- yy_pop_state();
- yy_push_state( int8 );
- yy_push_state( int8 );
- return INT8;
-}
-
-<data>{VARINT} {
- dtor << "lex: data" << endl;
- String str( (Byte const*)YYText(), YYLeng() );
- int i = My_midi_lexer::varint2_i( str );
- String* str_p = new String;
- while ( i-- )
- *str_p += (char)yyinput();
- yylval.str_p = str_p;
- yy_pop_state();
- return DATA;
-}
-<data>{INT8} {
- error( String( "data: illegal byte: " )
- + String_convert::bin2hex_str( String( *YYText() ) ) );
- exit( 1 );
-}
-
-<<EOF>> {
-// mtor << "<<EOF>>";
-
- if ( !close_i() )
- yyterminate(); // can't move this, since it actually rets a YY_NULL
-}
-
-%%
-
+++ /dev/null
-//
-// midi-main.cc -- implement silly main() entry point
-// should have Root class.
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include <iostream.h>
-#include <limits.h>
-#include "proto.hh"
-#include "plist.hh"
-#include "version.hh"
-#include "fversion.hh"
-#include "string.hh"
-#include "lgetopt.hh"
-#include "source.hh"
-#include "source-file.hh"
-#include "midi-main.hh"
-#include "moment.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "midi-track.hh"
-#include "my-midi-lexer.hh"
-#include "my-midi-parser.hh"
-
-Source source;
-Source* source_l_g = &source;
-
-Verbose level_ver = NORMAL_ver;
-
-// ugh
-bool no_triplets_bo_g = false;
-
-//ugh
-char const* defined_ch_c_l = 0;
-
-// ugh, another global
-String
-find_file( String str )
-{
- return str;
-}
-
-// ugh, copied from warn.cc, cannot use
-void
-message( String message_str, char const* context_ch_c_l )
-{
- String str = "m2m: ";
- Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l );
- if ( sourcefile_l ) {
- str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
- }
- str += message_str;
- if ( sourcefile_l ) {
- str += ":\n";
- str += sourcefile_l->error_str( context_ch_c_l );
- }
-// if ( busy_parsing() )
-// cerr << endl;
- cerr << str << endl;
-}
-
-void
-warning( String message_str, char const* context_ch_c_l )
-{
- message( "warning: " + message_str, context_ch_c_l );
-}
-
-void
-error( String message_str, char const* context_ch_c_l )
-{
- message( message_str, context_ch_c_l );
- // since when exits error again?
- // i-d say: error: errorlevel |= 1; -> no output upon error
- // warning: recovery -> output (possibly wrong)
- if ( midi_lexer_l_g )
- midi_lexer_l_g->errorlevel_i_ |= 1;
-}
-
-void
-help()
-{
- btor <<
- "--debug, -d be really verbose\n"
- "--help, -h this help\n"
- "--include=DIR, -I DIR add DIR to search path\n"
- "--no-triplets, -n assume no triplets\n"
- "--output=FILE, -o FILE set FILE as default output\n"
- "--quiet, -q be quiet\n"
- "--verbose, -v be verbose\n"
- "--warranty, -w show warranty & copyright\n"
- ;
-}
-
-void
-identify()
-{
- mtor << version_str() << endl;
-}
-
-void
-notice()
-{
- mtor <<
- "\n"
- "M2m, translate midi to mudela.\n"
- "Copyright (C) 1997 by\n"
- " Han-Wen Nienhuys <hanwen@stack.nl>\n"
-// "Contributors\n"
- " Jan Nieuwenhuizen <jan@digicash.com>\n"
-// " Mats Bengtsson <matsb@s3.kth.se>\n"
- "\n"
- " This program is free software; you can redistribute it and/or\n"
- "modify it under the terms of the GNU General Public License version 2\n"
- "as published by the Free Software Foundation.\n"
- "\n"
- " This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
- "General Public License for more details.\n"
- "\n"
- " You should have received a copy (refer to the file COPYING) of the\n"
- "GNU General Public License along with this program; if not, write to\n"
- "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
- "USA.\n";
-}
-
-// should simply have Root class...
-String
-version_str()
-{
- return String ( "This is m2m " ) + VERSIONSTR
- + "/FlowerLib " + FVERSIONSTR
- + " of " + __DATE__ + " " + __TIME__;
-}
-
-int
-main( int argc_i, char* argv_sz_a[] )
-{
- long_option_init long_option_init_a[] = {
- 0, "debug", 'd',
- 0, "help", 'h',
-// 1, "include", 'I',
- 0, "no-triplets", 'n',
- 1, "output", 'o',
- 0, "quiet", 'q',
- 0, "verbose", 'v',
- 0, "warranty", 'w',
- 0,0,0
- };
- Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a );
- identify();
-
- String output_str;
- while ( long_option_init* long_option_init_p = getopt_long() )
- switch ( long_option_init_p->shortname ) {
- case 'd':
- level_ver = DEBUG_ver;
- break;
- case 'h':
- help();
- exit( 0 );
- break;
-// case 'I':
-// path->push( getopt_long.optarg );
-// break;
- case 'n':
- no_triplets_bo_g = true;
- break;
- case 'o':
- output_str = getopt_long.optarg;
- break;
- case 'q':
- level_ver = QUIET_ver;
- break;
- case 'v':
- level_ver = VERBOSE_ver;
- break;
- case 'w':
- notice();
- exit( 0 );
- break;
- default:
- assert( 0 );
- break;
- }
-
- char* arg_sz = 0;
- while ( ( arg_sz = getopt_long.get_next_arg() ) ) {
- My_midi_parser midi_parser( arg_sz );
- int error_i = midi_parser.parse();
- if ( error_i )
- return error_i;
- if ( !output_str.length_i() ) {
- output_str = String( arg_sz ) + ".ly";
- // i-m sure there-s already some routine for this
- int name_i; // too bad we can-t declare local to if
- if ( ( name_i = output_str.index_last_i( '/' ) ) != -1 )
- output_str = output_str.mid_str( name_i + 1, INT_MAX );
- }
- error_i = midi_parser.output_mudela( output_str );
- if ( error_i )
- return error_i;
- }
- return 0;
-}
+++ /dev/null
-/*
- midi-output.cc -- implement Midi_output
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>, Jan Nieuwehuizen <jan@digicash.com>
-*/
-
-#include "plist.hh"
-#include "debug.hh"
-#include "score.hh"
-#include "staff.hh"
-#include "midi-stream.hh"
-#include "midi-def.hh"
-#include "midi-output.hh"
-#include "midi-walker.hh"
-#include "midi-item.hh"
-#include "staff-column.hh"
-#include "musicalrequest.hh"
-
-
-Midi_output:: Midi_output(Score* score_l, Midi_def* midi_l )
-{
- midi_l_ = midi_l;
-
- Midi_stream midi_stream(midi_l->outfile_str_,
- score_l->staffs_.size(),
- 384 );
-// oeps, not tempo, but clocks per 4 (384 convention)
-// must set tempo in tempo request
-// midi_l->get_tempo_i(Moment(1, 4)));
-
- midi_stream_l_ = &midi_stream;
- int track_i=0;
-
- for (iter_top(score_l->staffs_,i); i.ok(); i++) {
- do_staff(i, track_i++);
- }
-
-}
-
-void
-Midi_output::do_staff(Staff*st_l,int track_i)
-{
- Midi_track midi_track( track_i );
- Midi_tempo midi_tempo( midi_l_->get_tempo_i( Moment( 1, 4 ) ) );
- midi_track.add( Moment( 0.0 ), &midi_tempo );
- for (Midi_walker w (st_l, &midi_track); w.ok(); w++)
- w.process_requests();
-
- *midi_stream_l_ << midi_track;
-}
+++ /dev/null
-%{
-
-#include <iostream.h>
-
-#include "proto.hh" // ugh, these all for midi-main.hh
-#include "plist.hh"
-#include "string.hh"
-#include "sourcefile.hh"
-#include "source.hh"
-#include "midi-main.hh" // *tors
-
-#include "my-midi-lexer.hh"
-#include "my-midi-parser.hh"
-#include "moment.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "midi-track.hh"
-#include "midi-score.hh"
-
-#ifndef NDEBUG
-#define YYDEBUG 1
-#endif
-
-//ugh
-static track_i = 0;
-
-%}
-
-%union {
- Byte byte;
- char c;
- int i;
- String* str_p;
- Request* request_p;
- Midi_event* midi_event_p; // Voice_element* ?
- Midi_score* midi_score_p; // Input_score* ?
- Midi_track* midi_track_p; // Input_music* ?
-}
-
-%token HEADER TRACK
-%token SYSEX_EVENT1 SYSEX_EVENT2
-%token META_EVENT
-%token SEQUENCE TEXT COPYRIGHT TRACK_NAME INSTRUMENT_NAME LYRIC MARKER CUE_POINT
-%token END_OF_TRACK TEMPO SMPTE_OFFSET TIME KEY SSME
-
-%token<i> INT8 INT16 INT32 INT7_8UNSET INT7_8SET VARINT
-%token<i> RUNNING_STATUS DATA_ENTRY ALL_NOTES_OFF
-%token<i> NOTE_OFF NOTE_ON
-%token<i> POLYPHONIC_AFTERTOUCH CONTROLMODE_CHANGE PROGRAM_CHANGE
-%token<i> CHANNEL_AFTERTOUCH PITCHWHEEL_RANGE
-%token<str_p> DATA
-
-%type <i> varint
-%type <midi_score_p> header midi_score
-%type <midi_track_p> track
-%type <midi_event_p> event
-%type <midi_event_p> the_event meta_event the_meta_event text_event midi_event sysex_event
-%type <midi_event_p> running_status data_entry all_notes_off
-%type <midi_event_p> note_off note_on
-%type <midi_event_p> polyphonic_aftertouch controlmode_change program_change
-%type <midi_event_p> channel_aftertouch pitchwheel_range
-
-%%
-
-midi: /* empty */
- | midi midi_score {
- midi_parser_l_g->add_score( $2 );
- track_i = 0;
- }
- ;
-
-midi_score:
- header {
- }
- | midi_score track {
- $$->add_track( $2 );
- midi_parser_l_g->reset();
- }
- ;
-
-header:
- HEADER INT32 INT16 INT16 INT16 {
- $$ = new Midi_score( $3, $4, $5 );
- midi_parser_l_g->set_division_4( $5 );
- }
- ;
-
-track:
- TRACK INT32 {
- $$ = new Midi_track( track_i++ );
- }
- | track event {
- $$->add_event( midi_parser_l_g->mom(), $2 );
- }
- ;
-
-event:
- varint the_event {
- $$ = $2;
- if ( $2 && $2->mudela_str().length_i() )
- dtor << $2->mudela_str() << " " << flush;
- }
- ;
-
-varint:
- VARINT {
- midi_parser_l_g->forward( $1 );
- }
- ;
-
-the_event:
- meta_event {
- }
- | midi_event {
- }
- | sysex_event {
- }
- ;
-
-meta_event:
- META_EVENT the_meta_event {
- $$ = $2;
- }
- |
- META_EVENT INT8 INT8 INT8 {
- $$ = 0;
- }
- ;
-
-the_meta_event:
- SEQUENCE INT16 {
- }
- | text_event DATA {
- $$ = 0;
- dtor << *$2 << endl;
- delete $2;
- }
- | END_OF_TRACK {
- $$ = 0;
- }
- | TEMPO INT8 INT8 INT8 {
- $$ = new Midi_tempo( ( $2 << 16 ) + ( $3 << 8 ) + $4 );
- dtor << $$->mudela_str() << endl; // ?? waai not at event:
- midi_parser_l_g->set_tempo( ( $2 << 16 ) + ( $3 << 8 ) + $4 );
- }
- | SMPTE_OFFSET INT8 INT8 INT8 INT8 INT8 {
- $$ = 0;
- }
- | TIME INT8 INT8 INT8 INT8 {
- $$ = new Midi_time( $2, $3, $4, $5 );
- dtor << $$->mudela_str() << endl; // ?? waai not at event:
- midi_parser_l_g->set_time( $2, $3, $4, $5 );
- }
- | KEY INT8 INT8 {
- $$ = new Midi_key( $2, $3 );
- midi_parser_l_g->set_key( $2, $3 );
- }
- | SSME DATA {
- $$ = 0;
- delete $2;
- }
- ;
-
-text_event:
- TEXT {
- dtor << "\n% Text: ";
- }
- | COPYRIGHT {
- dtor << "\n% Copyright: ";
- }
- | TRACK_NAME {
- dtor << "\n% Track name: ";
- }
- | INSTRUMENT_NAME {
- dtor << "\n% Instrument name: ";
- }
- | LYRIC {
- dtor << "\n% Lyric: ";
- }
- | MARKER {
- dtor << "\n% Marker: ";
- }
- | CUE_POINT {
- dtor << "\n% Cue point: ";
- }
- ;
-
-midi_event:
- running_status {
- }
- | data_entry {
- }
- | all_notes_off {
- }
- | note_off {
- }
- | note_on {
- }
- | polyphonic_aftertouch {
- }
- | controlmode_change {
- }
- | program_change {
- }
- | channel_aftertouch {
- }
- | pitchwheel_range {
- }
- ;
-
-running_status:
- RUNNING_STATUS INT8 { //INT8 {
- $$ = 0;
- }
- ;
-
-data_entry:
- DATA_ENTRY INT8 {
- $$ = 0;
- }
- ;
-
-all_notes_off:
- ALL_NOTES_OFF INT8 INT8 {
- $$ = 0;
- }
- ;
-
-note_off:
- NOTE_OFF INT8 INT8 {
- int i = $1;
- i = i & ~0x80;
- $$ = midi_parser_l_g->note_end_midi_event_p( $1 & ~0x80, $2, $3 );
- }
- ;
-
-note_on:
- NOTE_ON INT8 INT8 {
- int i = $1;
- i = i & ~0x90;
- $$ = 0;
- midi_parser_l_g->note_begin( $1 & ~0x90, $2, $3 );
- }
- ;
-
-polyphonic_aftertouch:
- POLYPHONIC_AFTERTOUCH INT8 INT8 {
- $$ = 0;
- }
- ;
-
-controlmode_change:
- CONTROLMODE_CHANGE INT8 INT8 {
- $$ = 0;
- }
- ;
-
-program_change:
- PROGRAM_CHANGE INT8 {
- $$ = 0;
- }
- ;
-
-channel_aftertouch:
- CHANNEL_AFTERTOUCH INT8 INT8 {
- $$ = 0;
- }
- ;
-
-pitchwheel_range:
- PITCHWHEEL_RANGE INT8 INT8 {
- $$ = 0;
- }
- ;
-
-sysex_event:
- SYSEX_EVENT1 DATA {
- $$ = 0;
- }
- | SYSEX_EVENT2 DATA { // INT8 ?
- $$ = 0;
- }
- ;
+++ /dev/null
-//
-// midi-score.cc -- implement Midi_score
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include "proto.hh"
-#include "plist.hh"
-#include "string.hh"
-#include "moment.hh"
-#include "duration.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "midi-main.hh" // *tors
-#include "midi-event.hh"
-#include "lily-stream.hh"
-#include "track-column.hh"
-#include "midi-track.hh"
-#include "midi-score.hh"
-
-Midi_score::Midi_score( int format_i, int tracks_i, int tempo_i )
-{
- format_i_ = format_i;
- tracks_i_ = tracks_i;
- tempo_i_ = tempo_i;
-}
-
-Midi_score::~Midi_score()
-{
-}
-
-void
-Midi_score::add_track( Midi_track* midi_track_p )
-{
- midi_track_p_list_.bottom().add( midi_track_p );
-}
-
-int
-Midi_score::output_mudela( String filename_str )
-{
- mtor << "Lily output to " << filename_str << " ..." << endl;
-
- Lily_stream lily_stream( filename_str );
- for ( PCursor<Midi_track*> midi_track_l_pcur( midi_track_p_list_.top() ); midi_track_l_pcur.ok(); midi_track_l_pcur++ ) {
- midi_track_l_pcur->output_mudela( lily_stream );
- lily_stream << "\n";
- }
-
- lily_stream << "score {\n";
-
- for ( PCursor<Midi_track*> midi_track_l_pcur( midi_track_p_list_.top() ); midi_track_l_pcur.ok(); midi_track_l_pcur++ ) {
- lily_stream << "\tstaff { melodic music { ";
- lily_stream << midi_track_l_pcur->name_str();
- lily_stream << " } }\n";
- }
-
- lily_stream << "\tcommands { meter { 4*4 } }\n";
- lily_stream << "\tmidi { tempo 4:60 }\n";
-
- lily_stream << "}\n";
-
- return 0;
-}
-
+++ /dev/null
-//
-// midi-stream.cc
-//
-// source file of the LilyPond music typesetter
-//
-// (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include <fstream.h>
-#include <time.h>
-#include "main.hh"
-#include "misc.hh"
-#include "midi-item.hh"
-#include "midi-stream.hh"
-#include "debug.hh"
-#include "string-convert.hh"
-
-Midi_stream::Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i )
-{
- filename_str_ = filename_str;
- tracks_i_ = tracks_i;
- clocks_per_4_i_ = clocks_per_4_i;
- os_p_ = 0;
- open();
- header();
-}
-
-Midi_stream::~Midi_stream()
-{
- delete os_p_;
-}
-
-Midi_stream&
-Midi_stream::operator <<( String str )
-{
- // still debugging...
- if ( check_debug )
- str = String_convert::bin2hex_str( str );
- // string now 1.0.26-2 handles binary streaming
- *os_p_ << str;
- return *this;
-}
-
-Midi_stream&
-Midi_stream::operator <<( Midi_item& mitem_r )
-{
- mitem_r.output_midi( *this );
- if ( check_debug )
- *os_p_ << "\n";
- return *this;
-}
-
-Midi_stream&
-Midi_stream::operator <<( int i )
-{
- // output binary string ourselves
- *this << Midi_item::i2varint_str( i );
- return *this;
-}
-
-void
-Midi_stream::header()
-{
-// *os_p_ << "% Creator: " << get_version();
-// *os_p_ << "% Automatically generated, at ";
-// time_t t(time(0));
-// *os_p_ << ctime(&t);
-
-// 4D 54 68 64 MThd
-// String str = "MThd";
-// 00 00 00 06 chunk length
-// 00 01 format 1
-// 00 01 one track
-// 00 60 96 per quarter-note
-
-// char const ch_c_l = "0000" "0006" "0001" "0001" "0060";
-// str += String_convert::hex2bin_str( ch_c_l );
-// *os_p_ << str;
-
-// *this << Midi_header( 1, 1, tempo_i_ );
- *this << Midi_header( 1, tracks_i_, clocks_per_4_i_ );
-}
-
-void
-Midi_stream::open()
-{
- os_p_ = new ofstream( filename_str_ );
- if ( !*os_p_ )
- error ("can't open `" + filename_str_ + "\'" );
-}
+++ /dev/null
-//
-// midi-template.cc -- implementemplate
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include "list.tcc"
-#include "cursor.tcc"
-
-L_instantiate(void *);
-
-class istream;
-class ostream;
-#include "proto.hh"
-#include "plist.tcc"
-#include "pcursor.tcc"
-#include "string.hh"
-#include "source-file.hh"
-
-#include "moment.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "lily-stream.hh"
-#include "track-column.hh"
-#include "midi-track.hh"
-
-IPL_instantiate(Midi_event);
-IPL_instantiate(Midi_track);
-IPL_instantiate(Source_file);
-IPL_instantiate(Track_column);
+++ /dev/null
-//
-// midi-track.cc -- implement Midi_track
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include "proto.hh"
-#include "plist.hh"
-#include "string.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "midi-main.hh" // *tors
-
-#include "moment.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "lily-stream.hh"
-#include "track-column.hh"
-#include "midi-track.hh"
-
-Midi_track::Midi_track( int track_i )
-{
- name_str_ = String( "track" ) + String( track_i );
- tcol_p_list_.bottom().add( new Track_column( Moment( 0 ) ) );
-}
-
-Midi_track::~Midi_track()
-{
-}
-
-void
-Midi_track::add_event( Moment mom, Midi_event* midi_event_p )
-{
- if ( ! midi_event_p )
- return;
- tcol_l( mom - midi_event_p->mom() )->add_event( midi_event_p );
-}
-
-// too much red tape ?
-String
-Midi_track::name_str()
-{
- return name_str_;
-}
-
-void
-Midi_track::output_mudela( Lily_stream& lily_stream_r )
-{
- lily_stream_r << name_str_ << " = music { $\n";
- lily_stream_r << "\t";
- int column_i = 8;
-
- for ( PCursor<Track_column*> tcol_l_pcur( tcol_p_list_.top() ); tcol_l_pcur.ok(); tcol_l_pcur++ ) {
- if ( tcol_l_pcur->midi_event_p_list_.size() > 1 )
- warning( "oeps, chord: can-t do that yet", 0 );
- if ( !tcol_l_pcur->midi_event_p_list_.size() )
- continue;
- lily_stream_r << **tcol_l_pcur->midi_event_p_list_.top();
- column_i += tcol_l_pcur->midi_event_p_list_.top()->mudela_str().length_i();
- if ( column_i > 40 ) {
- lily_stream_r << "\n\t";
- column_i = 8;
- }
- }
- lily_stream_r << "\n$} % " << name_str_ << "\n";
-}
-
-Track_column*
-Midi_track::tcol_l( Moment mom )
-{
- for ( PCursor<Track_column*> tcol_l_pcur( tcol_p_list_.top() ); tcol_l_pcur.ok(); tcol_l_pcur++ ) {
- if ( tcol_l_pcur->mom() == mom )
- return *tcol_l_pcur;
- if ( tcol_l_pcur->mom() > mom ) {
- Track_column* tcol_p = new Track_column( mom );
- tcol_l_pcur.insert( tcol_p );
- return tcol_p;
- }
- }
-
- Track_column* tcol_p = new Track_column( mom );
- tcol_p_list_.bottom().add( tcol_p );
- return tcol_p;
-}
-
+++ /dev/null
-/*
- midi-walker.cc -- implement Midi_walker
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>, Jan Nieuwenhuizen <jan@digicash.com>
-*/
-
-#include "musicalrequest.hh"
-#include "pscore.hh"
-#include "staff.hh"
-#include "midi-walker.hh"
-#include "midi-item.hh"
-#include "midi-stream.hh"
-#include "debug.hh"
-#include "staff-column.hh"
-
-Midi_walker::Midi_walker(Staff *st_l, Midi_track* track_l)
- : PCursor<Staff_column*>(st_l->cols_)
-{
- track_l_ = track_l;
- last_moment_= 0;
-}
-
-/**
- output notestop events for all notes which end before #max_moment#
- */
-void
-Midi_walker::do_stop_notes(Moment max_moment)
-{
- while (stop_notes.size() && stop_notes.front_idx() <= max_moment) {
- Moment stop_moment = stop_notes.front_idx();
- Melodic_req * req_l = stop_notes.get();
-
- Midi_note note(req_l, track_l_->number_i_, false);
- output_event(note, stop_moment);
- }
-}
-/** advance the track to #now#, output the item, and adjust current
- "moment". */
-void
-Midi_walker::output_event(Midi_item &i, Moment now)
-{
- Moment delta_t = now - last_moment_ ;
- last_moment_ += delta_t;
- track_l_->add(delta_t, &i );
-}
-
-void
-Midi_walker::process_requests()
-{
- do_stop_notes(ptr()->when());
- for ( int i = 0; i < ptr()->musicalreq_l_arr_.size(); i++ ) {
-
- Rhythmic_req *n = ptr()->musicalreq_l_arr_[i]->rhythmic();
- if ( !n)
- continue;
- Note_req * note_l = n->note();
- if (!note_l)
- continue;
-
- Midi_note note(note_l, track_l_->number_i_, true);
- stop_notes.enter(note_l, n->duration() + ptr()->when() );
- output_event(note, ptr()->when());
- }
-}
-
-Midi_walker::~Midi_walker()
-{
- do_stop_notes( last_moment_ + Moment(10,1)); // ugh
-}
+++ /dev/null
-#include <math.h>
-
-#include "item.hh"
-#include "misc.hh"
-#include "glob.hh"
-#include "moment.hh"
-
-
-// depreciated, see struct Duration*
-Moment
-wholes(int dur, int dots)
-{
- if (!dur)
- return 0;
-
- Moment f = Rational(1)/Moment(dur);
- Moment delta = f;
-
- while (dots--) {
- delta /= 2.0;
- f += delta;
- }
- return f;
-}
-int
-intlog2(int d) {
- int i=0;
- while (!(d&1)) {
- d/= 2;
- i++;
- }
- assert(!(d/2));
- return i;
-}
-
-double
-log_2(double x) {
- return log(x) /log(2.0);
-}
-
-Interval
-itemlist_width(const Array<Item*> &its)
-{
- Interval iv ;
- iv.set_empty();
-
- for (int j =0; j < its.size(); j++){
- iv.unite (its[j]->width());
-
- }
- return iv;
-}
-
+++ /dev/null
-#include "varray.hh"
-#include "interval.hh"
-#include "dimen.hh"
-#include "string.hh"
-#include "molecule.hh"
-#include "symbol.hh"
-#include "debug.hh"
-#include "tex.hh"
-
-void
-Atom::print() const
-{
- mtor << "texstring: " <<sym.tex<<"\n";
-}
-
-Box
-Atom::extent() const
-{
- Box b( sym.dim);
- b.translate(off);
- return b;
-}
-
-Atom::Atom(Symbol s)
-{
- sym=s;
-}
-
-
-String
-Atom::TeXstring() const
-{
- // whugh.. Hard coded...
- String s("\\placebox{%}{%}{%}");
- Array<String> a;
- a.push(print_dimen(off.y));
- a.push(print_dimen(off.x));
- a.push(sym.tex);
- return substitute_args(s, a);
-}
-
-/* *************** */
-
-String
-Molecule::TeXstring() const
-{
- String s;
- for(iter_top(ats,c); c.ok(); c++)
- s+=c->TeXstring();
- return s;
-}
-
-Box
-Molecule::extent() const
-{
- Box b;
- for(iter_top(ats,c); c.ok(); c++)
- b.unite(c->extent());
- return b;
-}
-
-void
-Molecule::translate(Offset o)
-{
- for (iter_top(ats,c); c.ok(); c++)
- c->translate(o);
-}
-
-void
-Molecule::add(const Molecule &m)
-{
- for (iter_top(m.ats,c); c.ok(); c++) {
- add(**c);
- }
-}
-
-void
-Molecule::add_right(const Molecule &m)
-{
- if (!ats.size()) {
- add(m);
- return;
- }
- Real xof=extent().x.right - m.extent().x.left;
- Molecule toadd(m);
- toadd.translate(Offset(xof, 0.0));
- add(toadd);
-}
-
-void
-Molecule::add_left(const Molecule &m)
-{
- if (!ats.size()) {
- add(m);
- return;
- }
- Real xof=extent().x.left - m.extent().x.right;
- Molecule toadd(m);
- toadd.translate(Offset(xof, 0.0));
- add(toadd);
-}
-
-
-void
-Molecule::add_top(const Molecule &m)
-{
- if (!ats.size()) {
- add(m);
- return;
- }
- Real yof=extent().y.right - m.extent().y.left;
- Molecule toadd(m);
- toadd.translate(Offset(0,yof));
- add(toadd);
-}
-
-void
-Molecule::add_bottom(const Molecule &m)
-{
- if (!ats.size()) {
- add(m);
- return;
- }
- Real yof=extent().y.left- m.extent().y.right;
- Molecule toadd(m);
- toadd.translate(Offset(0,yof));
- add(toadd);
-}
-
-void
-Molecule::operator = (const Molecule&)
-{
- assert(false);
-}
-
-Molecule::Molecule(const Molecule&s)
-{
- add(s);
-}
-
-void
-Molecule::print() const
-{
- for (iter_top(ats,c); c.ok(); c++)
- c->print();
-}
+++ /dev/null
-//
-// my-midi-lexer.cc -- implement My_midi_lexer
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include "debug.hh"
-#include "input-file.hh"
-#include "source-file.hh"
-#include "my-midi-lexer.hh"
-
-int
-yylex()
-{
- return midi_lexer_l_g->yylex();
-}
-
-My_midi_lexer* midi_lexer_l_g;
-
-My_midi_lexer::My_midi_lexer( String filename_str )
-{
- input_file_p_ = new Input_file( filename_str );
- switch_streams( input_file_p_->is );
- midi_lexer_l_g = this;
- errorlevel_i_ = 0;
-}
-
-My_midi_lexer::~My_midi_lexer()
-{
- delete input_file_p_;
- midi_lexer_l_g = 0;
-}
-
-void
-My_midi_lexer::error( char const* sz_l )
-{
- if ( !input_file_p_ ) {
-// *mlog << "error at EOF" << sz_l << '\n';
- cerr << "error at EOF" << sz_l << '\n';
- } else {
- char const* ch_c_l = here_ch_c_l();
- if ( ch_c_l ) {
- ch_c_l--;
- while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
- ch_c_l--;
- ch_c_l++;
- }
- errorlevel_i_ |= 1;
-// ::error( sz_l, ch_c_l );
- ::error( sz_l, ch_c_l );
- }
-}
-
-char const*
-My_midi_lexer::here_ch_c_l()
-{
- return input_file_p_->sourcefile_l_->ch_c_l() + yyin->tellg();
-}
-
-int
-My_midi_lexer::varint2_i( String str )
-{
- int var_i = 0;
-
- for ( int i = 0; i < str.length_i(); i++ ) {
- Byte byte = str[ i ];
- var_i <<= 7;
- var_i += byte & 0x7f;
- if ( ! ( byte & 0x80 ) )
- return var_i;
- }
- cout << "\nvarint2_i:" << String_convert::bin2hex_str( str ) << endl;
- assert( 0 ); // illegal varint
- return 0;
-}
-
-int
-My_midi_lexer::close_i()
-{
- return 0;
-}
-
+++ /dev/null
-//
-// my-midi-parser.cc -- implement My_midi_parser
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include "proto.hh"
-
-#include "plist.hh" // ugh
-#include "string.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "midi-main.hh" // *tors
-
-#include "my-midi-lexer.hh"
-#include "my-midi-parser.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "lily-stream.hh"
-#include "track-column.hh"
-#include "midi-track.hh"
-#include "midi-score.hh"
-#include "my-midi-lexer.hh"
-#include "my-midi-parser.hh"
-
-void
-yyerror(char const* sz_l )
-{
- midi_parser_l_g->error( sz_l );
-}
-
-
-My_midi_parser* midi_parser_l_g;
-
-My_midi_parser::My_midi_parser( String filename_str )
-{
- midi_lexer_p_ = new My_midi_lexer( filename_str );
- midi_parser_l_g = this;
- defined_ch_c_l_ = 0;
- fatal_error_i_ = 0;
- midi_key_p_ = 0;
- midi_score_p_ = 0;
- midi_tempo_p_ = 0;
- midi_time_p_ = 0;
- reset();
-}
-
-void
-My_midi_parser::reset()
-{
- delete midi_key_p_;
- midi_key_p_ = new Midi_key( 0, 0 );
- // useconds per 4: 250000 === 60 4 per minute
- delete midi_tempo_p_;
- midi_tempo_p_ = new Midi_tempo( 250000 );
- delete midi_time_p_;
- midi_time_p_ = new Midi_time( 4, 4, 384, 8 );
-
- now_i64_ = 0;
-
- for ( int i = 0; i < CHANNELS_i; i++ )
- for ( int j = 0; j < PITCHES_i; j++ )
-// running_i64_i64_a_[ i ][ j ] = -1;
- running_i64_i64_a_[ i ][ j ] = 0;
-}
-
-My_midi_parser::~My_midi_parser()
-{
- delete midi_lexer_p_;
- midi_parser_l_g = 0;
- delete midi_key_p_;
- delete midi_tempo_p_;
- delete midi_time_p_;
- delete midi_score_p_;
-}
-
-void
-My_midi_parser::add_score( Midi_score* midi_score_p )
-{
- assert( !midi_score_p_ );
- midi_score_p_ = midi_score_p;
-}
-
-void
-My_midi_parser::error( char const* sz_l )
-{
- midi_lexer_l_g->error( sz_l );
-
- if ( fatal_error_i_ )
- exit( fatal_error_i_ );
-}
-
-void
-My_midi_parser::forward( int i )
-{
- now_i64_ += i;
-}
-
-Moment
-My_midi_parser::mom()
-{
- return Duration_convert::i2_mom( now_i64_, division_1_i_ );
-}
-
-void
-My_midi_parser::note_begin( int channel_i, int pitch_i, int dyn_i )
-{
- // one pitch a channel at time!
- // heu, what about { < c2 > < c4 d4 > }
-// assert( running_i64_i64_a_[ channel_i ][ pitch_i ] == -1 );
- running_i64_i64_a_[ channel_i ][ pitch_i ] = now_i64_;
-}
-
-Midi_event*
-My_midi_parser::note_end_midi_event_p( int channel_i, int pitch_i, int dyn_i )
-{
- Int64 start_i64 = running_i64_i64_a_[ channel_i ][ pitch_i ];
-// running_i64_i64_a_[ channel_i ][ pitch_i ] = -1;
- // did we start?
-// assert( start_i64 != -1 );
- return new Midi_note( midi_key_p_, midi_time_p_, division_1_i_, pitch_i, now_i64_ - start_i64 );
-}
-
-int
-My_midi_parser::output_mudela( String filename_str )
-{
- assert( midi_score_p_ );
- return midi_score_p_->output_mudela( filename_str );
-}
-
-int
-My_midi_parser::parse()
-{
- return ::yyparse();
-}
-
-void
-My_midi_parser::set_division_4( int division_4_i )
-{
- division_1_i_ = division_4_i * 4;
- if ( division_4_i < 0 )
- warning( "seconds iso metrical time" , 0 );
-}
-
-void
-My_midi_parser::set_key( int accidentals_i, int minor_i )
-{
- delete midi_key_p_;
- midi_key_p_ = new Midi_key( accidentals_i, minor_i );
-}
-
-void
-My_midi_parser::set_tempo( int useconds_i )
-{
- delete midi_tempo_p_;
- midi_tempo_p_ = new Midi_tempo( useconds_i );
-}
-
-void
-My_midi_parser::set_time( int num_i, int den_i, int clocks_i, int count_32_i )
-{
- delete midi_time_p_;
- midi_time_p_ = new Midi_time( num_i, den_i, clocks_i, count_32_i );
-}
-
+++ /dev/null
-#include <strstream.h>
-
-#include "interval.hh"
-#include "identparent.hh"
-#include "assoc-iter.hh"
-#include "lexer.hh"
-#include "input-file.hh"
-#include "parser.hh"
-#include "keyword.hh"
-#include "assoc.hh"
-#include "lexer.hh"
-#include "debug.hh"
-#include "notename.hh"
-#include "source-file.hh"
-#include "parseconstruct.hh"
-
-static Keyword_ent the_key_tab[]={
- "bar", BAR,
- "cadenza", CADENZA,
- "clef", CLEF,
- "cm", CM_T,
- "command", COMMAND,
- "commands", COMMANDS,
- "duration", DURATIONCOMMAND,
- "geometric", GEOMETRIC,
- "goto", GOTO,
- "in", IN_T,
- "key", KEY,
- "meter", METER,
- "midi", MIDI,
- "mm", MM_T,
- "multivoice", MULTIVOICE,
- "octave", OCTAVECOMMAND,
- "output", OUTPUT,
- "partial", PARTIAL,
- "paper", PAPER,
- "plet", PLET,
- "pt", PT_T,
- "score", SCORE,
- "script", SCRIPT,
- "skip", SKIP,
- "staff", STAFF,
- "start", START_T,
- "stem", STEM,
- "table", TABLE,
- "symboltables", SYMBOLTABLES,
- "notenames", NOTENAMES,
- "tempo", TEMPO,
- "texid", TEXID,
- "textstyle", TEXTSTYLE,
- "unitspace", UNITSPACE,
- "voice", VOICE,
- "voices", VOICES,
- "width", WIDTH,
- "music", MUSIC,
- "grouping", GROUPING,
- 0,0
-};
-
-int
-My_flex_lexer::ret_notename(int *p, String text, int octave_mod)
-{
- text = text.lower_str();
- char const* ch_c_l = here_ch_c_l();
- if ( ch_c_l ) {
- ch_c_l--;
- while ( ( *ch_c_l == ' ' )
- || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
- ch_c_l--;
- ch_c_l++;
- }
-
- lookup_notename(p[0], p[1], text);
- p[2] = octave_mod;
- mtor << "notename: "<< text <<eol;
- if (p[0] < 0) {
-
- errorlevel_i_ |= 1;
- error( String( "notename does not exist: " ) + YYText(), ch_c_l );
- p[0] = p[1] = 0;
- }
- return NOTENAME;
-}
-
-My_flex_lexer::My_flex_lexer()
-{
- keytable = new Keyword_table(the_key_tab);
- the_id_tab = new Assoc<String, Identifier*>;
- defaulttab = 0;
- errorlevel_i_ = 0;
-}
-
-int
-My_flex_lexer::lookup_keyword(String s)
-{
- return keytable->lookup(s);
-}
-
-Identifier*
-My_flex_lexer::lookup_identifier(String s)
-{
- if (!the_id_tab->elt_query(s))
- return 0;
-
- return (*the_id_tab)[s];
-}
-
-char const*
-My_flex_lexer::here_ch_c_l()
-{
- return include_stack.top()->sourcefile_l_->ch_c_l() + yyin->tellg();
-}
-
-void
-My_flex_lexer::add_identifier(Identifier*i)
-{
- delete lookup_identifier(i->name);
- (*the_id_tab)[i->name] = i;
-}
-
-My_flex_lexer::~My_flex_lexer()
-{
- delete keytable;
- delete defaulttab;
- for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
- mtor << "deleting: " << ai.key()<<'\n';
- delete ai.val();
- }
- delete the_id_tab;
-}
-void
-My_flex_lexer::print_declarations()const
-{
- for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
- ai.val()->print();
- }
-}
-
-String
-My_flex_lexer::spot()const
-{
- return include_stack.top()->name + ": " + String( lineno() );
-}
-
-void
-My_flex_lexer::LexerError(const char *s)
-{
- if (lexer->include_stack.empty()) {
- *mlog << "error at EOF" << s << '\n';
- } else {
- char const* ch_c_l = here_ch_c_l();
- if ( ch_c_l ) {
- ch_c_l--;
- while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
- ch_c_l--;
- ch_c_l++;
- }
- errorlevel_i_ |= 1;
- error( s, ch_c_l );
- }
-}
-
-// set the new input to s, remember old file.
-void
-My_flex_lexer::new_input(String s)
-{
- if (!include_stack.empty()) {
- include_stack.top()->line = lineno();
- // should this be saved at all?
- include_stack.top()->defined_ch_c_l_ = defined_ch_c_l;
- }
-
- Input_file *newin = new Input_file(s);
- include_stack.push(newin);
- switch_streams(newin->is);
-
- yylineno = 1;
-}
-
-// pop the inputstack.
-bool
-My_flex_lexer::close_input()
-{
- Input_file *old = include_stack.pop();
- bool ok = true;
- if (include_stack.empty()) {
- ok = false;
- } else {
- Input_file *i = include_stack.top();
- switch_streams(i->is);
- yylineno = i->line;
- defined_ch_c_l = i->defined_ch_c_l_;
- }
- delete old;
- return ok;
-}
+++ /dev/null
-/*
- could use cleanup
- */
-#include <ctype.h>
-#include "lexer.hh"
-#include "string.hh"
-#include "real.hh"
-#include "debug.hh"
-#include "musicalrequest.hh"
-#include "commandrequest.hh"
-#include "voice.hh"
-#include "notename.hh"
-#include "identparent.hh"
-#include "varray.hh"
-#include "text-def.hh"
-#include "parseconstruct.hh"
-#include "input-music.hh"
-#include "voice-element.hh"
-
-int default_duration = 4, default_dots=0, default_octave=0;
-int default_plet_type = 1, default_plet_dur = 1;
-String textstyle="roman"; // in lexer?
-
-bool last_duration_mode = false;
-
-void
-set_duration_mode(String s)
-{
- s = s.upper_str();
- last_duration_mode = (s== "LAST");
-}
-
-void
-last_duration(int n)
-{
- if (last_duration_mode)
- default_duration = n;
-}
-
-/* triplet is '2/3' */
-void
-set_plet(int num,int den)
-{
- assert(num >0&& den>0);
- default_plet_dur = num;
- default_plet_type = den;
-}
-
-Text_def*
-get_text(String s) return t;
-{
- t= new Text_def;
- t->text_str_= s;
- t->style_str_ = textstyle;
- t->defined_ch_c_l_ = defined_ch_c_l;
- return t;
-}
-
-void
-set_text_style(String s)
-{
- textstyle = s;
-}
-
-void
-parse_octave (const char *a, int &j, int &oct)
-{
- while (1)
- {
- if (a[j] == '\'')
- oct ++;
- else if (a[j] == '`')
- oct --;
- else
- break;
- j++;
- }
-}
-
-void
-parse_pitch( const char *a, Melodic_req* mel_l)
-{
- int j=0;
-
- // octave
- mel_l->octave_i_ = default_octave;
- parse_octave(a,j,mel_l->octave_i_);
-
- // accidental
- mel_l->forceacc_b_ = false;
-
- if (a[j] == '!'){
- mel_l->forceacc_b_ = true;
- j++;
- }
-}
-
-Voice_element *
-get_note_element(String pitch, int * notename, int * duration )
-{
- Voice_element*v = new Voice_element;
- v->defined_ch_c_l_ = defined_ch_c_l;
-
-
- int dur = duration[0];
- int dots = duration[1];
-
- if (dur >= 2) {
- Stem_req * stem_req_p = new Stem_req(dur,dots);
- stem_req_p->plet_factor = Moment(default_plet_dur, default_plet_type);
- stem_req_p->defined_ch_c_l_ = defined_ch_c_l;
- v->add(stem_req_p);
- }
-
- if ( !defined_ch_c_l )
- defined_ch_c_l = lexer->here_ch_c_l();
-
- Note_req * rq = new Note_req;
- rq->notename_i_ =notename[0];
- rq->accidental_i_ = notename[1];
- parse_pitch(pitch, rq);
- rq->octave_i_ += notename[2];
-
- rq->balltype = dur;
- rq->dots = dots;
- rq->plet_factor = Moment(default_plet_dur, default_plet_type);
- rq->defined_ch_c_l_ = defined_ch_c_l;
-
- v->add(rq);
-
- return v;
-}
-
-Voice_element*
-get_word_element(Text_def* tdef_p, int* duration)
-{
- Voice_element* velt_p = new Voice_element;
- velt_p->defined_ch_c_l_ = defined_ch_c_l;
-
- int dur = duration[0];
- int dots=duration[1];
-
- tdef_p->defined_ch_c_l_ = defined_ch_c_l;
-
- Lyric_req* lreq_p = new Lyric_req(tdef_p);
-
- lreq_p->balltype = dur;
- lreq_p->dots = dots;
- lreq_p->plet_factor = Moment(default_plet_dur, default_plet_type);
- lreq_p->print();
- lreq_p->defined_ch_c_l_ = defined_ch_c_l;
-
- velt_p->add(lreq_p);
-
- return velt_p;
-}
-
-Voice_element *
-get_rest_element(String, int * duration )
-{
- Voice_element* velt_p = new Voice_element;
- velt_p->defined_ch_c_l_ = defined_ch_c_l;
-
- Rest_req * rest_req_p = new Rest_req;
- rest_req_p->plet_factor = Moment(default_plet_dur, default_plet_type);
- rest_req_p->balltype = duration[0];
- rest_req_p->dots = duration[1];
- rest_req_p->print();
- rest_req_p->defined_ch_c_l_ = defined_ch_c_l;
-
- velt_p->add(rest_req_p);
-
- return velt_p;
-}
-
-void
-get_default_duration(int *p)
-{
- *p++ = default_duration;
- *p = default_dots;
-}
-
-void
-set_default_duration(int *p)
-{
- default_duration = *p++;
- default_dots = *p++;
-}
-
-
-void
-set_default_octave(String d)
-{
- int i=0;
- default_octave=0;
- parse_octave(d, i, default_octave);
-}
-
-Request*
-get_plet_request( char c, int dur_i, int type_i )
-{
- Plet_req* plet_req_p = new Plet_req;
- plet_req_p->dur_i_ = dur_i;
- plet_req_p->type_i_ = type_i;
- plet_req_p->type_c_ = c;
- return plet_req_p;
-}
-
-Request*
-get_request(char c)
-{
- Request* req_p=0;
- switch (c) {
- case '|':
- req_p = new Barcheck_req;
- break;
-
- case '[':
- case ']':
- {
- Beam_req*b = new Beam_req;
- if (default_plet_type != 1)
- b->nplet = default_plet_type;
- req_p = b;
- }
- break;
-
-
- case ')':
- case '(':
- req_p = new Slur_req;
- break;
- default:
- assert(false);
- break;
- }
-
- switch (c) {
- case '(':
- case '[':
- req_p->span()->spantype = Span_req::START;
- break;
- case ')':
- case ']':
- req_p->span()->spantype = Span_req::STOP;
- break;
-
- default:
- break;
- }
-
- req_p->defined_ch_c_l_ = req_defined_ch_c_l;
- return req_p;
-}
-
-void
-add_requests(Voice_element *v, Array<Request*> &req)
-{
- for (int i = 0; i < req.size(); i++) {
- v->add(req[i]);
- }
- req.set_size(0);
-}
-
-Script_def*
-get_scriptdef(char c)
-{
- String s;
- switch (c) {
- case '^' : s = "marcato";
- break;
- case '+' : s = "stopped";
- break;
- case '-' : s = "tenuto";
- break;
- case '|': s = "staccatissimo";
- break;
- case 'o' : s = "";
- break;
- case '>' : s = "accent";
- break;
- case 'v' : s = "";
- break;
- case '.' : s = "staccato";
- break;
- }
- return lexer->lookup_identifier(s)->script(1);
-}
-
-Request*
-get_script_req(int d , Script_def*def)
-{
- Script_req* script_req_p = new Script_req(d, def);
- return script_req_p;
-}
-
-Request*
-get_text_req(int d , Text_def*def)
-{
- Text_req* text_req_p = new Text_req(d, def);
- return text_req_p;
-}
-
-Request*
-get_stemdir_req(int d)
-{
- Group_feature_req * gfreq_p = new Group_feature_req;
- gfreq_p->stemdir_i_ =d;
- return gfreq_p;
-}
-
-Request*
-get_grouping_req(Array<int> i_arr)
-{
- Measure_grouping_req * mr_p = new Measure_grouping_req;
- for (int i=0; i <i_arr.size(); ) {
- mr_p->beat_i_arr_.push(i_arr[i++]);
- mr_p->elt_length_arr_.push(Moment(1, i_arr[i++]));
- }
- return mr_p;
-}
+++ /dev/null
-#include "misc.hh"
-#include "notehead.hh"
-#include "dimen.hh"
-#include "debug.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "molecule.hh"
-#include "musicalrequest.hh"
-
-
-
-Notehead::Notehead(int ss)
-{
- x_dir = 0;
- staff_size=ss;
- position = 0;
- balltype = 0;
- dots = 0;
- extremal = 0;
-}
-
-void
-Notehead::set_rhythmic(Rhythmic_req*r_req_l)
-{
- balltype = r_req_l->balltype;
- dots = r_req_l->dots;
-}
-
-void
-Notehead::do_print()const
-{
-#ifndef NPRINT
- mtor << "balltype "<< balltype << ", position = "<< position
- << "dots " << dots;
-#endif
-}
-
-
-int
-Notehead::compare(Notehead *const &a, Notehead * const &b)
-{
- return a->position - b->position;
-}
-
-Molecule*
-Notehead::brew_molecule_p() const return out;
-{
- Paper_def *p = paper();
-
- Real dy = p->internote();
- Symbol s = p->lookup_p_->ball(balltype);
-
- out = new Molecule(Atom(s));
- if (dots) {
- Symbol d = p->lookup_p_->dots(dots);
- Molecule dm;
- dm.add(Atom(d));
- if (!(position %2))
- dm.translate(Offset(0,dy));
- out->add_right(dm);
- }
- out->translate(Offset(x_dir * p->note_width(),0));
- bool streepjes = (position<-1)||(position > staff_size+1);
- if (streepjes) {
- int dir = sign(position);
- int s =(position<-1) ? -((-position)/2): (position-staff_size)/2;
- Symbol str = p->lookup_p_->streepjes(s);
- Molecule sm;
- sm.add(Atom(str));
- if (position % 2)
- sm.translate(Offset(0,-dy* dir));
- out->add(sm);
- }
-
- out->translate(Offset(0,dy*position));
-}
-
+++ /dev/null
-#include "glob.hh"
-#include "string.hh"
-#include "notename.hh"
-#include "lexer.hh"
-#include "identifier.hh"
-
-
-
-void
-Notename_tab::lookup(int &large, int &small, String s)
-{
- large = -1;
- small = 0;
-
- for (int i =0; i < 7*5; i++)
- if (s == notetab[i])
- {
- large = i /5;
- small = i %5 - 2;
- return;
- }
-}
-
-
-void
-Notename_tab::set(int l, int s, String n)
-{
- assert(l < 8 && s <= 2 && s >= -2 && l >=0);
- notetab[l * 5 + s +2] = n;
-}
-/* *************** */
-void
-My_flex_lexer::set(Notename_tab *n)
-{
- delete defaulttab;
- defaulttab = n;
-}
-
-void
-My_flex_lexer::lookup_notename(int &large, int &small, String s)
-{
- if (!defaulttab)
- set(lookup_identifier("default_table")->
- notename_tab(true));
-
- defaulttab->lookup(large, small, s);
-}
+++ /dev/null
-#include <math.h>
-#include "misc.hh"
-#include "paper-def.hh"
-#include "debug.hh"
-#include "lookup.hh"
-#include "dimen.hh"
-
-
-
-// golden ratio
-const Real PHI = (1+sqrt(5))/2;
-
-// see Roelofs, p. 57
-Real
-Paper_def::duration_to_dist(Moment d)
-{
- if (!d)
- return 0;
-
- return whole_width * pow(geometric_, log_2(d));
-}
-
-Real
-Paper_def::rule_thickness()const
-{
- return 0.4 PT;
-}
-
-Paper_def::Paper_def(Lookup *l)
-{
- lookup_p_ = l;
- linewidth = 15 *CM_TO_PT; // in cm for now
- whole_width = 8 * note_width();
- geometric_ = sqrt(2);
- outfile = "lelie.out";
-}
-
-Paper_def::~Paper_def()
-{
- delete lookup_p_;
-}
-Paper_def::Paper_def(Paper_def const&s)
-{
- lookup_p_ = new Lookup(*s.lookup_p_);
- geometric_ = s.geometric_;
- whole_width = s.whole_width;
- outfile = s.outfile;
- linewidth = s.linewidth;
-}
-
-void
-Paper_def::set(Lookup*l)
-{
- assert(l != lookup_p_);
- delete lookup_p_;
- lookup_p_ = l;
-}
-
-Real
-Paper_def::interline() const
-{
- return lookup_p_->ball(4).dim.y.length();
-}
-
-Real
-Paper_def::internote() const
-{
- return lookup_p_->internote();
-}
-Real
-Paper_def::note_width()const
-{
- return lookup_p_->ball(4).dim.x.length( );
-}
-Real
-Paper_def::standard_height() const
-{
- return 20 PT;
-}
-
-void
-Paper_def::print() const
-{
-#ifndef NPRINT
- mtor << "Paper {width: " << print_dimen(linewidth);
- mtor << "whole: " << print_dimen(whole_width);
- mtor << "out: " <<outfile;
- lookup_p_->print();
- mtor << "}\n";
-#endif
-}
+++ /dev/null
-%{ // -*-Fundamental-*-
-#include <iostream.h>
-
-#include "lookup.hh"
-#include "misc.hh"
-#include "lexer.hh"
-#include "paper-def.hh"
-#include "midi-def.hh"
-#include "input-score.hh"
-#include "main.hh"
-#include "keyword.hh"
-#include "debug.hh"
-#include "parseconstruct.hh"
-#include "dimen.hh"
-#include "identifier.hh"
-#include "commandrequest.hh"
-#include "musicalrequest.hh"
-#include "voice-element.hh"
-
-#ifndef NDEBUG
-#define YYDEBUG 1
-#endif
-
-Array<Request*> pre_reqs, post_reqs;
-Array<const char *> define_spots;
-Paper_def*default_paper();
-char const* defined_ch_c_l;
-char const* req_defined_ch_c_l;
-int fatal_error_i = 0;
-
-%}
-
-
-%union {
- Request * request;
- Real real;
- Identifier *id;
- Voice *voice;
- Voice_element *el;
- String *string;
- const char *consstr;
- Paper_def *paper;
- Midi_def* midi;
- Input_music *music;
- Music_general_chord *chord;
- Music_voice *mvoice;
- int i;
- char c;
- int ii[10];
- Moment *moment;
-
- Array<String> * strvec;
- Array<int> *intvec;
- Array<Melodic_req*> *melreqvec;
- Input_staff *staff;
- Input_score *score;
- Symtables * symtables;
- Symtable * symtable;
- Symbol * symbol;
- Lookup*lookup;
- Interval *interval;
- Box *box;
- Notename_tab *notename_tab;
- Script_def * script;
- Text_def * textdef;
-}
-
-%token VOICE STAFF SCORE TITLE BAR OUTPUT MULTIVOICE
-%token CM_T IN_T PT_T MM_T PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND
-%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
-%token KEY CLEF TABLE VOICES STEM
-%token PARTIAL MUSIC GROUPING CADENZA
-%token END SYMBOLTABLES TEXID TABLE NOTENAMES SCRIPT TEXTSTYLE PLET
-%token GOTO
-%token MIDI TEMPO
-
-%token <id> IDENTIFIER
-%token <string> PITCHMOD DURATION RESTNAME
-%token <ii> NOTENAME
-%token <real> REAL
-%token <string> STRING
-
-%token <i> DOTS INT
-%type <real> unit
-%type <melreqvec> pitch_list
-%type <c> open_request_parens close_request_parens close_plet_parens
-%type <id> declaration
-%type <string> declarable_identifier
-%type <paper> paper_block paper_body
-%type <midi> midi_block midi_body
-%type <real> dim real
-%type <ii> default_duration explicit_duration notemode_duration mudela_duration
-%type <ii> notename
-%type <moment> duration_length
-%type <el> voice_elt full_element lyrics_elt command_elt
-
-%type <score> score_block score_body
-%type <staff> staff_block staff_init staff_body
-%type <i> int
-%type <intvec> intastint_list
-%type <request> post_request pre_request command_req
-%type <string> pitchmod
-%type <music> music
-%type <chord> music_chord music_chord_body
-
-%type <mvoice> music_voice_body music_voice
-
-%type <interval> dinterval
-%type <box> box
-%type <symtable> symtable symtable_body
-%type <lookup> symtables symtables_body
-%type <symbol> symboldef
-%type <notename_tab> notename_tab notename_tab_body
-%type <i> script_dir
-%type <script> script_definition script_body mudela_script
-%type <request> script_req textscript_req
-%type <textdef> mudela_text
-
-
-%%
-
-mudela: /* empty */
- | mudela score_block {
- add_score($2);
- }
- | mudela add_declaration { }
- | mudela mudela_command {}
- ;
-
-mudela_command:
- notename_tab { lexer->set($1); }
- ;
-
-/*
- DECLARATIONS
-*/
-add_declaration: declaration {
- lexer->add_identifier($1);
- }
- ;
-
-declarable_identifier:
- STRING { $$ = $1; }
- | IDENTIFIER { $$ = new String($1->name); }
- ;
-
-declaration:
- declarable_identifier '=' staff_block {
- $$ = new Staff_id(*$1, $3);
- delete $1;
- }
- | declarable_identifier '=' music_voice {
- $$ = new M_voice_id(*$1, $3);
- delete $1;
- }
- | declarable_identifier '=' script_definition {
- $$ = new Script_id(*$1, $3);
- delete $1;
- }
- | declarable_identifier '=' music_chord {
- $$ = new M_chord_id(*$1, $3);
- delete $1;
- }
- | declarable_identifier '=' symtables {
- $$ = new Lookup_id(*$1, $3);
- delete $1;
- }
- | declarable_identifier '=' notename_tab {
- $$ = new Notetab_id(*$1, $3);
- delete $1;
- }
- | declarable_identifier '=' real {
- $$ = new Real_id(*$1, new Real($3));
- delete $1;
- }
- | declarable_identifier error '}' {
-
- }
- ;
-
-notename_tab:
- NOTENAMES '{' notename_tab_body '}' { $$ = $3; }
- ;
-
-notename_tab_body: {
- $$ = new Notename_tab;
- }
- | IDENTIFIER {
- $$ = $1->notename_tab(true);
- }
- | notename_tab_body STRING int int {
- $$->set($3, $4, *$2);
- delete $2;
- }
- ;
-
-/*
- SCORE
-*/
-score_block:
- SCORE { define_spots.push(lexer->here_ch_c_l()); }
- /*cont*/ '{' score_body '}' {
- $$ = $4;
- $$->defined_ch_c_l_ = define_spots.pop();
- if (!$$->paper_p_ && ! $$->midi_p_)
- $$->paper_p_ = default_paper();
-
- /* handle error levels. */
- $$->errorlevel_i_ = lexer->errorlevel_i_;
- lexer->errorlevel_i_ = 0;
- }
- ;
-
-score_body: {
- $$ = new Input_score;
- }
- | score_body staff_block { $$->add($2); }
- | score_body COMMANDS '{' music_voice_body '}' {
- $$->set($4);
- }
- | score_body paper_block { $$->set($2); }
- | score_body midi_block { $$->set($2); }
- | score_body error {
-
- }
- ;
-
-intastint_list:
- /* */ { $$ =new Array<int>; }
- | intastint_list int '*' int {
- $$->push($2); $$->push($4);
- }
- ;
-
-
-/*
- PAPER
-*/
-paper_block:
- PAPER
-
- '{' paper_body '}' { $$ = $3; }
- ;
-
-paper_body:
- /* empty */ {
- $$ = default_paper();
- }
- | paper_body WIDTH dim { $$->linewidth = $3;}
- | paper_body OUTPUT STRING { $$->outfile = *$3;
- delete $3;
- }
- | paper_body symtables { $$->set($2); }
- | paper_body UNITSPACE dim { $$->whole_width = $3; }
- | paper_body GEOMETRIC REAL { $$->geometric_ = $3; }
- | paper_body error {
-
- }
- ;
-
-/*
- MIDI
-*/
-midi_block:
- MIDI
-
- '{' midi_body '}' { $$ = $3; }
- ;
-
-midi_body: {
- $$ = new Midi_def;
- }
- | midi_body OUTPUT STRING {
- $$->outfile_str_ = *$3;
- delete $3;
- }
- | midi_body TEMPO mudela_duration ':' int {
- $$->set_tempo( wholes( $3[0], $3[1] ), $5 );
- }
- | midi_body error {
-
- }
- ;
-
-/*
- STAFFs
-*/
-staff_block:
- STAFF { define_spots.push(lexer->here_ch_c_l()); }
-/*cont*/ '{' staff_body '}' {
- $$ = $4;
- $$-> defined_ch_c_l_ = define_spots.pop();
- }
- ;
-
-
-
-staff_init:
- IDENTIFIER { $$ = $1->staff(true); }
- | STRING {
- $$ = new Input_staff(*$1);
- delete $1;
- }
- ;
-
-staff_body:
- staff_init
- | staff_body COMMANDS '{' music_voice_body '}' {
- $$->set_score_wide($4);
- }
- | staff_body music {
- $2->set_default_group( "staff_music" + String($$->music_.size()));
- $$->add($2);
- }
- | staff_body error {
- }
- ;
-
-/*
- MUSIC
-*/
-music:
- music_voice { $$ = $1; }
- | music_chord { $$ = $1; }
- ;
-
-music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
- ;
-
-music_voice_body:
- /* */ {
- $$ = new Music_voice;
- }
- | music_voice_body IDENTIFIER {
- $$->concatenate($2->mvoice(true));
- }
- | music_voice_body full_element {
- $$->add_elt($2);
- }
- | music_voice_body voice_command {
- }
- | music_voice_body music {
- $$->add($2);
- }
- | music_voice_body error {
- }
- ;
-
-music_chord: '{' music_chord_body '}' { $$ = $2; }
- ;
-
-music_chord_body:
- /* */ {
- $$ = new Voice_group_chord;
- }
- | MULTIVOICE {
- $$ = new Multi_voice_chord;
- }
- | music_chord_body IDENTIFIER {
- $$->concatenate($2->mchord(true));
- }
- | music_chord_body music {
- $$->add($2);
- }
- | music_chord_body full_element {
- $$ ->add_elt($2);
- }
- | music_chord_body error {
- }
- ;
-
-
-/*
- VOICE ELEMENTS
-*/
-full_element: pre_requests voice_elt post_requests {
- add_requests($2, pre_reqs);
- add_requests($2, post_reqs);
- $$ = $2;
- }
- | pre_requests lyrics_elt post_requests {
- add_requests($2, pre_reqs);
- add_requests($2, post_reqs);
- $$ = $2;
- }
- | command_elt
- ;
-
-command_elt:
-/* empty */ {
- $$ = new Voice_element;
- $$-> defined_ch_c_l_ = lexer->here_ch_c_l();
- }
-/* cont: */
- command_req {
- $2-> defined_ch_c_l_ = $$->defined_ch_c_l_;
- $$->add($2);
-
- }
- ;
-
-command_req:
- '|' {
- $$ = new Barcheck_req;
- }
- | BAR STRING {
- $$ = new Bar_req(*$2);
- delete $2;
- }
- | METER '{' int '*' int '}' {
- Meter_change_req *m = new Meter_change_req;
- m->set($3,$5);
- $$ = m;
- }
- | SKIP '{' duration_length '}' {
- Skip_req * skip_p = new Skip_req;
- skip_p->duration_ = *$3;
- delete $3;
- $$ = skip_p;
- }
- | CADENZA '{' int '}' {
- $$ = new Cadenza_req($3);
- }
- | PARTIAL '{' duration_length '}' {
- $$ = new Partial_measure_req(*$3);
- delete $3;
- }
- | STEM '{' int '}' {
- $$ = get_stemdir_req($3);
- }
- | CLEF STRING {
- $$ = new Clef_change_req(*$2);
- delete $2;
- }
- | KEY '{' pitch_list '}' {
- Key_change_req *key_p= new Key_change_req;
- key_p->melodic_p_arr_ = *$3;
- $$ = key_p;
- delete $3;
- }
- | GROUPING '{' intastint_list '}' {
- $$ = get_grouping_req(*$3); delete $3;
- }
- ;
-
-post_requests:
- {
- assert(post_reqs.empty());
- }
- | post_requests post_request {
- $2->defined_ch_c_l_ = lexer->here_ch_c_l();
- post_reqs.push($2);
- }
- | post_requests close_plet_parens INT '/' INT {
- post_reqs.push( get_request($2) );
- req_defined_ch_c_l = lexer->here_ch_c_l();
- post_reqs.push( get_plet_request( $2, $3, $5 ) );
- }
- ;
-
-post_request:
- close_request_parens {
- $$ = get_request($1);
- }
- | script_req
- | textscript_req
- ;
-
-close_plet_parens:
- ']' {
- req_defined_ch_c_l = lexer->here_ch_c_l();
- $$ = ']';
- }
- ;
-
-close_request_parens:
- '(' {
- $$='(';
- }
- | ']' {
- $$ = ']';
- }
- ;
-
-open_request_parens:
- ')' {
- $$=')';
- }
- | '[' {
- $$='[';
- }
- ;
-
-script_definition:
- SCRIPT '{' script_body '}' { $$ = $3; }
- ;
-
-script_body:
- STRING int int int {
- $$ = new Script_def(*$1,$2, $3,$4);
- delete $1;
- }
- ;
-
-textscript_req:
- script_dir mudela_text { $$ = get_text_req($1,$2); }
- ;
-
-mudela_text:
- STRING {
- defined_ch_c_l = lexer->here_ch_c_l();
- $$ = get_text(*$1);
- delete $1;
- }
- ;
-
-script_req:
- script_dir mudela_script {
- $$ = get_script_req($1, $2);
- }
- ;
-
-mudela_script:
- IDENTIFIER { $$ = $1->script(true); }
- | script_definition { $$ = $1; }
- | '^' { $$ = get_scriptdef('^'); }
- | '+' { $$ = get_scriptdef('+'); }
- | '-' { $$ = get_scriptdef('-'); }
- | '|' { $$ = get_scriptdef('|'); }
- | 'o' { $$ = get_scriptdef('o'); }
- | '>' { $$ = get_scriptdef('>'); }
- | '.' { $$ = get_scriptdef('.'); }
- | DOTS {
- if ( $1 > 1 )
- warning( "too many staccato dots", lexer->here_ch_c_l() );
- $$ = get_scriptdef('.');
- }
- | error {
- $$ = get_scriptdef('.');
- yyerrok;
- }
- ;
-
-script_dir:
- '_' { $$ = -1; }
- |'^' { $$ = 1; }
- |'-' { $$ = 0; }
- ;
-
-pre_requests:
- | pre_requests pre_request {
- pre_reqs.push($2);
- $2->defined_ch_c_l_ = lexer->here_ch_c_l();
- }
- ;
-
-pre_request:
- open_request_parens {
- defined_ch_c_l = lexer->here_ch_c_l();
- $$ = get_request($1);
- }
- ;
-
-voice_command:
- PLET '{' INT '/' INT '}' {
- set_plet($3,$5);
- }
- | DURATIONCOMMAND '{' STRING '}' {
- set_duration_mode(*$3);
- delete $3;
- }
- | DURATIONCOMMAND '{' notemode_duration '}' {
- set_default_duration($3);
- }
- | OCTAVECOMMAND '{' pitchmod '}' {
- set_default_octave(*$3);
- delete $3;
- }
- | TEXTSTYLE STRING {
- set_text_style(*$2);
- delete $2;
- }
- ;
-
-duration_length:
- mudela_duration {
- $$ = new Moment(wholes($1[0], $1[1]));
- }
- |int '*' mudela_duration {
- $$ = new Moment(Rational($1) * wholes($3[0], $3[1]));
- }
- ;
-
-notemode_duration:
- explicit_duration
- | default_duration
- ;
-
-mudela_duration:
- int {
- $$[0] = $1;
- $$[1] = 0;
- }
- | int DOTS {
- $$[0] = $1;
- $$[1] = $2;
- }
- ;
-
-
-explicit_duration:
- INT {
- last_duration($1);
- $$[0] = $1;
- $$[1] = 0;
- }
- | INT DOTS {
- last_duration($1);
- $$[0] = $1;
- $$[1] = $2;
- }
- | DOTS {
- get_default_duration($$);
- $$[1] = $1;
- }
- | INT '*' INT '/' INT {
- // ugh, must use Duration
- set_plet( $3, $5 );
- $$[ 0 ] = $1;
- $$[ 1 ] = 0;
- set_plet( 1, 1 );
- }
- ;
-
-default_duration:
- {
- get_default_duration($$);
- }
- ;
-
-pitchmod: {
- defined_ch_c_l = lexer->here_ch_c_l();
- $$ = new String;
- }
- | PITCHMOD {
- defined_ch_c_l = lexer->here_ch_c_l();
- $$ = $1;
- }
- ;
-
-notename:
- NOTENAME
- ;
-
-voice_elt:
- pitchmod notename notemode_duration {
- $$ = get_note_element(*$1, $2, $3);
- delete $1;
- }
- | RESTNAME notemode_duration {
- $$ = get_rest_element(*$1, $2);
- delete $1;
-
- }
- ;
-
-lyrics_elt:
- mudela_text notemode_duration {
- $$ = get_word_element($1, $2);
- };
-
-/*
- UTILITIES
- */
-pitch_list: {
- $$ = new Array<Melodic_req*>;
- }
- | pitch_list NOTENAME {
- Melodic_req *m_p = new Melodic_req;
- m_p->notename_i_ = $2[0];
- m_p->accidental_i_ = $2[1];
- $$->push(m_p);
- }
- ;
-
-int:
- real {
- $$ = int($1);
- if ( distance($1,Real(int($$)) ) > 1e-8)
- error( "integer expected", lexer->here_ch_c_l() );
- }
- ;
-
-real:
- INT {
- $$ = Real($1);
- }
- | REAL {
- $$ = $1;
- }
- | IDENTIFIER {
- $$ = * $1->real(0);
- }
- ;
-
-
-
-dim:
- real unit { $$ = $1*$2; }
- ;
-
-
-unit: CM_T { $$ = 1 CM; }
- |IN_T { $$ = 1 INCH; }
- |MM_T { $$ = 1 MM; }
- |PT_T { $$ = 1 PT; }
- ;
-
-/*
- symbol tables
-*/
-symtables:
- SYMBOLTABLES '{' symtables_body '}' { $$ = $3; }
- ;
-
-symtables_body:
- {
- $$ = new Lookup;
- }
- | IDENTIFIER {
- $$ = new Lookup(*$1->lookup(true));
- }
- | symtables_body TEXID STRING {
- $$->texsetting = *$3;
- delete $3;
- }
- | symtables_body STRING '=' symtable {
- $$->add(*$2, $4);
- delete $2;
- }
- ;
-
-symtable:
- TABLE '{' symtable_body '}' { $$ = $3; }
- ;
-
-symtable_body:
- { $$ = new Symtable; }
- | symtable_body STRING symboldef {
- $$->add(*$2, *$3);
- delete $2;
- delete $3;
- }
- ;
-
-symboldef:
- STRING box {
- $$ = new Symbol(*$1, *$2);
- delete $1;
- delete $2;
- }
- | STRING {
- Box b;
- $$ = new Symbol(*$1, b);
- delete $1;
- }
- ;
-
-box:
- dinterval dinterval {
- $$ = new Box(*$1, *$2);
- delete $1;
- delete $2;
- }
- ;
-
-dinterval: dim dim {
- $$ = new Interval($1, $2);
- }
- ;
-
-%%
-
-void
-yyerror(const char *s)
-{
- lexer->LexerError(s);
-
- if ( fatal_error_i )
- exit( fatal_error_i );
-}
-
-void
-parse_file(String init, String s)
-{
- *mlog << "Parsing ... ";
- lexer = new My_flex_lexer;
-
-#ifndef NDEBUG
- yydebug = !monitor->silence("InitParser") && check_debug;
- lexer->set_debug( !monitor->silence("InitLexer") && check_debug);
-#endif
-
- lexer->new_input(init);
-
- yyparse();
-
-#ifndef NDEBUG
- if (check_debug && !monitor->silence("InitDeclarations"))
- lexer->print_declarations();
-
- yydebug = !monitor->silence("Parser") && check_debug;
- lexer->set_debug( !monitor->silence("Lexer") && check_debug);
-#endif
-
- lexer->new_input(s);
- yyparse();
- delete lexer;
- lexer = 0;
-
- if(!define_spots.empty())
- warning("Braces don't match.",0);
-}
-
-Paper_def*
-default_paper()
-{
- return new Paper_def(
- lexer->lookup_identifier("default_table")->lookup(true));
-}
-
-
+++ /dev/null
-#include "pcol.hh"
-#include "pscore.hh"
-#include "pstaff.hh"
-#include "debug.hh"
-
-Interval
-PCol::width() const
-{
- Interval w;
-
- for (iter_top(its,i); i.ok(); i++)
- w.unite(i->width());
- if (w.empty())
- w.unite(Interval(0,0));
- return w;
-}
-
-int
-PCol::rank() const
-{
- if(!pscore_l_)
- return -1;
- PCursor<PCol*> me=pscore_l_->find_col( (PCol*)this);
- if (!me.ok())
- return -1;
- PCursor<PCol*> bot(pscore_l_->cols.top());
- return me - bot;
-}
-
-void
-PCol::print() const
-{
-#ifndef NPRINT
- mtor << "PCol {";
-
- if (rank() >= 0)
- mtor << "rank: " << rank() << '\n';
-
- mtor << "# symbols: " << its.size() ;
- if (breakable_b()){
- mtor << "\npre,post: ";
- prebreak_p_->print();
- postbreak_p_->print();
- } else if (daddy_l_) {
- mtor<<'\n' << ((this == daddy_l_->prebreak_p_) ?
- "prebreak" : "postbreak");
- mtor << '\n';
- }
- mtor << "extent: " << width().str() << "\n";
- mtor << "}\n";
-#endif
-}
-
-int
-PCol::compare(const PCol &c1, const PCol &c2)
-{
- PScore*ps_l = c1.pscore_l_;
- PCursor<PCol*> ac(ps_l->find_col(&c1));
- PCursor<PCol*> bc(ps_l->find_col(&c2));
- assert(ac.ok() && bc.ok());
- return ac - bc;
-}
-
-void
-PCol::OK() const
-{
-#ifndef NDEBUG
- if (prebreak_p_ || postbreak_p_ ) {
- assert(prebreak_p_&&postbreak_p_);
- assert(prebreak_p_->daddy_l_ == this);
- assert(postbreak_p_->daddy_l_ == this);
- }
-#endif
-}
-
-void
-PCol::set_breakable()
-{
- if (breakable_b())
- return;
-
- prebreak_p_ = new PCol(this);
- postbreak_p_ = new PCol(this);
- prebreak_p_->pscore_l_ = pscore_l_;
- postbreak_p_->pscore_l_ = pscore_l_;
-}
-
-bool
-PCol::breakable_b() const
-{
- return prebreak_p_||postbreak_p_;
-}
-
-PCol::PCol(PCol *parent)
-{
- daddy_l_ = parent;
- prebreak_p_=0;
- postbreak_p_=0;
- line_l_=0;
- hpos = -1.0;
- pscore_l_ = 0;
-}
-
-PCol::~PCol()
-{
- delete prebreak_p_;
- delete postbreak_p_;
-}
-
-void
-PCol::add( Item *i)
-{
- its.bottom().add(i);
- i->pcol_l_ = this;
-}
-
-bool
-PCol::used_b()const
-{
- return breakable_b() || its.size();
-}
+++ /dev/null
-#include "idealspacing.hh"
-#include "debug.hh"
-#include "lookup.hh"
-#include "spanner.hh"
-#include "paper-def.hh"
-#include "molecule.hh"
-#include "dimen.hh"
-#include "scoreline.hh"
-#include "pscore.hh"
-#include "tex-stream.hh"
-#include "item.hh"
-#include "break.hh"
-
-Idealspacing*
-PScore::get_spacing(PCol*l, PCol*r)
-{
- assert(l!=r);
-
- Idealspacing*i_p =new Idealspacing(l,r);
- suz.bottom().add(i_p);
-
- return i_p;
-}
-
-
-void
-PScore::clean_cols()
-{
- for (iter_top(cols,c); c.ok(); )
- if (!c->used_b()) {
- delete c.get_p();
- } else
- c++;
-}
-
-
-void
-PScore::add(PStaff *s)
-{
- assert(s->pscore_l_ == this);
- staffs.bottom().add(s);
-}
-
-
-void
-PScore::do_connect(PCol *c1, PCol *c2, Real d, Real h)
-{
- if (!c1 || !c2 )
- return;
- Idealspacing*s_l=get_spacing(c1,c2);
-
-
- s_l->hooke = h;
- s_l->space =d;
-}
-
-void
-PScore::connect(PCol* c1, PCol *c2, Real d, Real h)
-{
- do_connect(c1,c2,d,h);
- do_connect(c1->postbreak_p_, c2,d,h);
- do_connect(c1, c2->prebreak_p_,d,h);
- do_connect(c1->postbreak_p_, c2->prebreak_p_,d,h);
-}
-
-void
-PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
-{
- assert(c && i && s);
-
- if (breakstat == 0) {
- typeset_item(i, c->prebreak_p_, s);
- return;
- }
-
- if (breakstat == 2) {
- typeset_item(i, c->postbreak_p_, s);
- return;
- }
-
-
- its.bottom().add(i);
- s->add(i);
- c->add(i);
-
- /* first do this, because i->width() may follow the 0-pointer */
- i->add_processing();
-}
-
-void
-PScore::typeset_spanner(Spanner*span_p, PStaff*ps)
-{
- span_p->pstaff_l_ = ps;
- spanners.bottom().add(span_p);
- ps->spans.bottom().add(span_p);
-
- // do not init start/stop fields. These are for broken spans only.
- span_p->add_processing();
-}
-
-
-void
-PScore::add(PCol *p)
-{
- p->pscore_l_ = this;
- if (p->breakable_b()){
- p->prebreak_p_->pscore_l_ = this;
- p->postbreak_p_->pscore_l_ = this;
- }
- cols.bottom().add(p);
-}
-
-PScore::PScore( Paper_def*p)
-{
- paper_l_ = p;
-}
-
-void
-PScore::output(Tex_stream &ts)
-{
- int l=1;
-
- ts << "\n "<< paper_l_->lookup_p_->texsetting << "%(Tex id)\n";
- for (iter_top(lines,lic); lic.ok(); lic++) {
- ts << "% line of score no. " << l++ <<"\n";
- ts << lic->TeXstring();
- if ((lic+1).ok())
- ts << "\\interscoreline\n";
- }
-}
-
-
-Array<Item*>
-PScore::select_items(PStaff*ps, PCol*pc)
-{
- Array<Item*> ret;
- assert(ps && pc);
- for (iter_top(pc->its,i); i.ok(); i++){
- if (i->pstaff_l_ == ps)
- ret.push((Item*)(const Item*)i);
- }
- return ret;
-}
-
-void
-PScore::OK()const
-{
-#ifdef NDEBUG
- for (iter_top(cols,cc); cc.ok(); cc++)
- cc->OK();
- for (iter_top(suz,i); i.ok(); i++)
- i->OK();
-#endif
-}
-
-void
-PScore::print() const
-{
-#ifndef NPRINT
- mtor << "PScore { ";
- paper_l_->print();
- mtor << "\ncolumns: ";
- for (iter_top(cols,cc); cc.ok(); cc++)
- cc->print();
-
- mtor << "\nideals: ";
- for (iter_top(suz,i); i.ok(); i++)
- i->print();
- mtor << "}\n";
-#endif
-}
-
-void
-PScore::preprocess()
-{
- for (iter_top(spanners,i); i.ok(); i++) {
- i->pre_processing();
- }
- for (iter_top(its,i); i.ok(); i++){
- i->pre_processing();
- }
-}
-
-void
-PScore::postprocess()
-{
- for (iter_top(broken_spans,i); i.ok(); i++) { // could chase spans as well.
- i->post_processing();
- }
- for (iter_top(its,i); i.ok(); i++){
- i->post_processing();
- }
-
- for (iter_top(broken_spans,i); i.ok(); i++) {
- i->molecule_processing();
- }
- for (iter_top(its,i); i.ok(); i++){
- i->molecule_processing();
- }
-
- for (iter_top(lines,i); i.ok(); i++)
- i->process();
-
-}
-
-PCursor<PCol *>
-PScore::find_col(const PCol *c)const
-{
- const PCol*what = c;
- if (what->daddy_l_ )
- what = what->daddy_l_;
-
- return cols.find((PCol*)what);
-}
-
-void
-PScore::add_broken(Spanner*s)
-{
- assert(s->left->line_l_ == s->right->line_l_);
- broken_spans.bottom().add(s);
- s->left->starters.bottom().add (s);
- s->right->stoppers.bottom().add (s);
-}
-
-void
-PScore::set_breaking(Array<Col_hpositions> breaking)
-{
- for (int j=0; j < breaking.size(); j++) {
- Array<PCol*> &curline(breaking[j].cols);
- Array<Real> &config(breaking[j].config);
-
- Line_of_score *s_p = new Line_of_score(curline,this);
- lines.bottom().add(s_p);
- for (int i=0; i < curline.size(); i++){
- curline[i]->hpos = config[i];
- }
- }
-}
-
-void
-PScore::calc_breaking()
-{
- Word_wrap w(*this);
- set_breaking(w.solve());
-}
-
-void
-PScore::process()
-{
- clean_cols();
- *mlog << "Preprocessing ... " <<flush;
- preprocess();
- *mlog << "\nCalculating column positions ... " <<flush;
- calc_breaking();
- *mlog << "\nPostprocessing ..." << endl;
- postprocess();
-}
+++ /dev/null
-#include "pstaff.hh"
-#include "molecule.hh"
-
-PStaff::PStaff(PScore*ps)
-{
- pscore_l_=ps;
-}
-
-void
-PStaff::add(Item *i)
-{
- its.bottom().add(i);
- i->pstaff_l_ = this;
-}
+++ /dev/null
-#include "debug.hh"
-#include "const.hh"
-#include "qlp.hh"
-#include "choleski.hh"
-
-void
-Mixed_qp::add_equality_cons(Vector , double )
-{
- assert(false);
-}
-
-void
-Mixed_qp::add_fixed_var(int i, Real r)
-{
- eq_cons.push(i);
- eq_consrhs.push(r);
-}
-
-void
-Ineq_constrained_qp::add_inequality_cons(Vector c, double r)
-{
- cons.push(c);
- consrhs.push(r);
-}
-
-Ineq_constrained_qp::Ineq_constrained_qp(int novars):
- quad(novars),
- lin(novars),
- const_term (0.0)
-{
-}
-
-void
-Ineq_constrained_qp::OK() const
-{
-#ifndef NDEBUG
- assert(cons.size() == consrhs.size());
- Matrix Qdif= quad - quad.transposed();
- assert(Qdif.norm()/quad.norm() < EPS);
-#endif
-}
-
-
-Real
-Ineq_constrained_qp::eval (Vector v)
-{
- return v * quad * v + lin * v + const_term;
-}
-
-/**
- eliminate appropriate variables, until we have a Ineq_constrained_qp
- then solve that.
-
- PRE
- cons should be ascending
- */
-Vector
-Mixed_qp::solve(Vector start) const
-{
- print();
- Ineq_constrained_qp pure(*this);
-
- for (int i= eq_cons.size()-1; i>=0; i--) {
- pure.eliminate_var(eq_cons[i], eq_consrhs[i]);
- start.del(eq_cons[i]);
- }
- Vector sol = pure.solve(start);
- for (int i= 0; i < eq_cons.size(); i++) {
- sol.insert( eq_consrhs[i],eq_cons[i]);
- }
- return sol;
-}
-
-/*
- assume x(idx) == value, and adjust constraints, lin and quad accordingly
-
- TODO: add const_term
- */
-void
-Ineq_constrained_qp::eliminate_var(int idx, Real value)
-{
- Vector row(quad.row(idx));
- row*= value;
-
- quad.delete_row(idx);
-
- quad.delete_column(idx);
-
- lin.del(idx);
- row.del(idx);
- lin +=row ;
-
- for (int i=0; i < cons.size(); i++) {
- consrhs[i] -= cons[i](idx) *value;
- cons[i].del(idx);
- }
-}
-
-
-
-void
-Ineq_constrained_qp::assert_solution(Vector sol) const
-{
- Array<int> binding;
- for (int i=0; i < cons.size(); i++) {
- Real R=cons[i] * sol- consrhs[i];
- assert(R> -EPS);
- if (R < EPS)
- binding.push(i);
- }
- // KKT check...
- // todo
-}
-
-void
-Ineq_constrained_qp::print() const
-{
-#ifndef NPRINT
- mtor << "Quad " << quad;
- mtor << "lin " << lin <<"\n"
- << "const " << const_term<<"\n";
- for (int i=0; i < cons.size(); i++) {
- mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
- mtor << "\n";
- }
-#endif
-}
-
-/* *************** */
-
-Mixed_qp::Mixed_qp(int n)
- : Ineq_constrained_qp(n)
-{
-}
-
-void
-Mixed_qp::OK() const
-{
-#ifndef NDEBUG
- Ineq_constrained_qp::OK();
- assert(eq_consrhs.size() == eq_cons.size());
-#endif
-}
-
-void
-Mixed_qp::print() const
-{
-#ifndef NPRINT
- Ineq_constrained_qp::print();
- for (int i=0; i < eq_cons.size(); i++) {
- mtor << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";
- }
-#endif
-}
-
+++ /dev/null
-#include "qlpsolve.hh"
-#include "const.hh"
-#include "debug.hh"
-#include "choleski.hh"
-
-const Real TOL=1e-2; // roughly 1/10 mm
-
-String
-Active_constraints::status() const
-{
- String s("Active|Inactive [");
- for (int i=0; i< active.size(); i++) {
- s += String(active[i]) + " ";
- }
-
- s+="| ";
- for (int i=0; i< inactive.size(); i++) {
- s += String(inactive[i]) + " ";
- }
- s+="]";
-
- return s;
-}
-
-void
-Active_constraints::OK()
-{
- #ifndef NDEBUG
- H.OK();
- A.OK();
- assert(active.size() +inactive.size() == opt->cons.size());
- assert(H.dim() == opt->dim());
- assert(active.size() == A.rows());
- Array<int> allcons;
-
- for (int i=0; i < opt->cons.size(); i++)
- allcons.push(0);
- for (int i=0; i < active.size(); i++) {
- int j = active[i];
- allcons[j]++;
- }
- for (int i=0; i < inactive.size(); i++) {
- int j = inactive[i];
- allcons[j]++;
- }
- for (int i=0; i < allcons.size(); i++)
- assert(allcons[i] == 1);
-#endif
-}
-
-Vector
-Active_constraints::get_lagrange(Vector gradient)
-{
- Vector l(A*gradient);
-
- return l;
-}
-
-void
-Active_constraints::add(int k)
-{
- // add indices
- int cidx=inactive[k];
- active.push(cidx);
-
- inactive.swap(k,inactive.size()-1);
- inactive.pop();
-
- Vector a( opt->cons[cidx] );
- // update of matrices
- Vector Ha = H*a;
- Real aHa = a*Ha;
- Vector addrow(Ha.dim());
- if (abs(aHa) > EPS) {
- /*
- a != 0, so if Ha = O(EPS), then
- Ha * aH / aHa = O(EPS^2/EPS)
-
- if H*a == 0, the constraints are dependent.
- */
- H -= Matrix(Ha/aHa , Ha);
-
-
- /*
- sorry, don't know how to justify this. ..
- */
- addrow=Ha;
- addrow/= aHa;
- A -= Matrix(A*a, addrow);
- A.insert_row(addrow,A.rows());
- }else
- WARN << "degenerate constraints";
-}
-
-void
-Active_constraints::drop(int k)
-{
- int q=active.size()-1;
-
- // drop indices
- inactive.push(active[k]);
- active.swap(k,q);
- A.swap_rows(k,q);
- active.pop();
-
- Vector a(A.row(q));
- if (a.norm() > EPS) {
- /*
-
- */
- Real q = a*opt->quad*a;
- H += Matrix(a,a/q);
- A -= A*opt->quad*Matrix(a,a/q);
- }else
- WARN << "degenerate constraints";
- #ifndef NDEBUG
- Vector rem_row(A.row(q));
- assert(rem_row.norm() < EPS);
- #endif
-
- A.delete_row(q);
-}
-
-
-Active_constraints::Active_constraints(Ineq_constrained_qp const *op)
- : A(0,op->dim()),
- H(op->dim()),
- opt(op)
-{
- for (int i=0; i < op->cons.size(); i++)
- inactive.push(i);
- Choleski_decomposition chol(op->quad);
- H=chol.inverse();
-}
-
-/** Find the optimum which is in the planes generated by the active
- constraints.
- */
-Vector
-Active_constraints::find_active_optimum(Vector g)
-{
- return H*g;
-}
-
-/* *************************************************************** */
-
-int
-min_elt_index(Vector v)
-{
- Real m=INFTY; int idx=-1;
- for (int i = 0; i < v.dim(); i++){
- if (v(i) < m) {
- idx = i;
- m = v(i);
- }
- assert(v(i) <= INFTY);
- }
- return idx;
-}
-
-
-/**the numerical solving. Mordecai Avriel, Nonlinear Programming: analysis and methods (1976)
- Prentice Hall.
-
- Section 13.3
-
- This is a "projected gradient" algorithm. Starting from a point x
- the next point is found in a direction determined by projecting
- the gradient onto the active constraints. (well, not really the
- gradient. The optimal solution obeying the active constraints is
- tried. This is why H = Q^-1 in initialisation) )
-
-
- */
-Vector
-Ineq_constrained_qp::solve(Vector start) const
-{
- Active_constraints act(this);
-
-
- act.OK();
-
-
- Vector x(start);
- Vector gradient=quad*x+lin;
-// Real fvalue = x*quad*x/2 + lin*x + const_term;
-// it's no use.
-
- Vector last_gradient(gradient);
- int iterations=0;
-
- while (iterations++ < MAXITER) {
- Vector direction= - act.find_active_optimum(gradient);
-
- mtor << "gradient "<< gradient<< "\ndirection " << direction<<"\n";
-
- if (direction.norm() > EPS) {
- mtor << act.status() << '\n';
-
- Real minalf = INFTY;
-
- Inactive_iter minidx(act);
-
-
- /*
- we know the optimum on this "hyperplane". Check if we
- bump into the edges of the simplex
- */
-
- for (Inactive_iter ia(act); ia.ok(); ia++) {
-
- if (ia.vec() * direction >= 0)
- continue;
- Real alfa= - (ia.vec()*x - ia.rhs())/
- (ia.vec()*direction);
-
- if (minalf > alfa) {
- minidx = ia;
- minalf = alfa;
- }
- }
- Real unbounded_alfa = 1.0;
- Real optimal_step = min(minalf, unbounded_alfa);
-
- Vector deltax=direction * optimal_step;
- x += deltax;
- gradient += optimal_step * (quad * deltax);
-
- mtor << "step = " << optimal_step<< " (|dx| = " <<
- deltax.norm() << ")\n";
-
- if (minalf < unbounded_alfa) {
- /* bumped into an edge. try again, in smaller space. */
- act.add(minidx.idx());
- mtor << "adding cons "<< minidx.idx()<<'\n';
- continue;
- }
- /*ASSERT: we are at optimal solution for this "plane"*/
-
-
- }
-
- Vector lagrange_mult=act.get_lagrange(gradient);
- int m= min_elt_index(lagrange_mult);
-
- if (m>=0 && lagrange_mult(m) > 0) {
- break; // optimal sol.
- } else if (m<0) {
- assert(gradient.norm() < EPS) ;
-
- break;
- }
-
- mtor << "dropping cons " << m<<'\n';
- act.drop(m);
- }
- if (iterations >= MAXITER)
- WARN<<"didn't converge!\n";
-
- mtor << ": found " << x<<" in " << iterations <<" iterations\n";
- assert_solution(x);
- return x;
-}
-
-
+++ /dev/null
-/*
- register.cc -- implement Request_register
-
- Sourcefile of LilyPond musictypesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "voice.hh"
-#include "musicalrequest.hh"
-#include "register.hh"
-#include "notehead.hh"
-#include "complex-walker.hh"
-#include "local-key-item.hh"
-#include "complex-staff.hh"
-#include "registergroup.hh"
-#include "debug.hh"
-
-
-bool
-Request_register::try_request(Request*)
-{
- return false;
-}
-
-Request_register::Request_register()
-{
- daddy_reg_l_ = 0;
-}
-
-void
-Request_register::announce_element(Staff_elem_info i)
-{
- i.origin_reg_l_arr_.push(this);
- daddy_reg_l_->announce_element(i);
-}
-
-void
-Request_register::typeset_element(Staff_elem*p)
-{
- daddy_reg_l_->typeset_element(p);
-}
-
-Paper_def*
-Request_register::paper()const
-{
- return daddy_reg_l_->paper();
-}
-
-void
-Request_register::typeset_breakable_item(Item * pre_p , Item * nobreak_p,
- Item * post_p)
-{
- daddy_reg_l_->typeset_breakable_item(pre_p, nobreak_p, post_p);
-}
-
-bool
-Request_register::acceptable_request_b(Request*)const
-{
- return false;
-}
-
-bool
-Request_register::contains_b(Request_register *reg_l)
-{
- return this == reg_l;
-}
-
-Staff_info
-Request_register::get_staff_info() return inf;
-{
- inf = daddy_reg_l_->get_staff_info();
-}
-
-void
-Request_register::print() const
-{
-#ifndef NPRINT
- mtor << name() << " {";
- do_print();
- mtor << "}\n";
-#endif
-}
-
-void
-Request_register::do_print()const
-{
-}
+++ /dev/null
-/*
- registergroup.cc -- implement Register_group_register
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "registergroup.hh"
-#include "register.hh"
-
-bool
-Register_group_register::acceptable_request_b(Request* r)
-{
- for (iter_top(reg_list_, i); i.ok(); i++) {
- if (i->acceptable_request_b(r))
- return true;
- }
- return false;
-}
-
-void
-Register_group_register::set_feature(Features d)
-{
- for (iter_top(reg_list_, i); i.ok(); i++) {
- i->set_feature(d);
- }
-}
-
-void
-Register_group_register::pre_move_processing()
-{
- for (iter_top(reg_list_, i); i.ok(); i++)
- i->pre_move_processing();
-}
-
-void
-Register_group_register::process_requests()
-{
- for (iter_top(reg_list_, i); i.ok(); i++)
- i->process_requests();
-}
-
-void
-Register_group_register::post_move_processing()
-{
- for (iter_top(reg_list_, i); i.ok(); i++)
- i->post_move_processing();
-}
-
-void
-Register_group_register::acknowledge_element(Staff_elem_info info)
-{
- if (!contains_b(info.origin_reg_l_arr_[0]))
- return;
-
- for (iter_top(reg_list_, i); i.ok(); i++)
- i->acknowledge_element(info);
-}
-
-bool
-Register_group_register::contains_b(Request_register* reg_l)
-{
- bool parent_b = Request_register::contains_b(reg_l);
-
- if (parent_b)
- return true;
- for (iter_top(reg_list_, j); j.ok(); j++)
- if (j->contains_b(reg_l))
- return true;
- return false;
-}
-
-
-
-bool
-Register_group_register::try_request(Request*req_l)
-{
- for (iter_top(reg_list_, i); i.ok(); i++)
- if (i->try_request(req_l))
- return true;
- return false;
-}
-
-void
-Register_group_register::add(Request_register *reg_p)
-{
- reg_list_.bottom().add(reg_p);
- reg_p->daddy_reg_l_ = this;
-}
-
-
-Register_group_register::~Register_group_register()
-{
-
-}
-
-Request_register *
-Register_group_register::get_register_p(Request_register*reg_l)
-{
- iterator(reg_list_) reg_cur= reg_list_.find(reg_l);
- assert(reg_cur.ok());
- return reg_cur.get_p();
-}
-
-void
-Register_group_register::terminate_register(Request_register*r_l)
-{
- delete get_register_p(r_l);
-}
-
-void
-Register_group_register::do_print()const
-{
-#ifndef NPRINT
- for (iter_top(reg_list_, i); i.ok(); i++)
- i->print();
-#endif
-}
+++ /dev/null
-/*
- request.cc -- implement all musical requests.
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "musicalrequest.hh"
-#include "misc.hh"
-#include "debug.hh"
-#include "script-def.hh"
-#include "text-def.hh"
-#include "voice.hh"
-#include "voice-element.hh"
-
-void
-Stem_req::do_print() const
-{
- Rhythmic_req::do_print();
- mtor << "dir : " << dir_i_;
-}
-
-Stem_req::Stem_req(int s, int d)
- : Rhythmic_req(s,d)
-{
- dir_i_ = 0;
-}
-
-/* ************** */
-void Musical_req::do_print()const{}
-void Request::do_print() const{}
-
-/* *************** */
-
-void
-Request::print() const
-{
- mtor << name() << " {";
- do_print();
- mtor << "}\n";
-}
-
-
-
-void
-Span_req::do_print() const
-{
-#ifndef NPRINT
- mtor << spantype ;
-#endif
-}
-
-Request::Request()
-{
- elt_l_ = 0;
- defined_ch_c_l_ = 0;
-}
-Request::Request(Request const&src)
-{
- elt_l_ = 0;
- defined_ch_c_l_ = src.defined_ch_c_l_;
-}
-/* *************** */
-Spacing_req::Spacing_req()
-{
- next = 0;
- distance = 0;
- strength = 0;
-}
-void
-Spacing_req::do_print()const
-{
- mtor << "next " << next << "dist " << distance << "strength\n";
-}
-
-void
-Blank_req::do_print()const
-{
- Spacing_req::do_print();
-}
-/* *************** */
-Melodic_req::Melodic_req()
-{
- notename_i_ = 0;
- octave_i_ = 0;
- accidental_i_ = 0;
- forceacc_b_ = false;
-}
-
-void
-Melodic_req::do_print() const
-{
- mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
-}
-
-int
-Melodic_req::height() const
-{
- return notename_i_ + octave_i_*7;
-}
-
-/*
- should be settable from input to allow "viola"-mode
- */
-static Byte pitch_byte_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
-
-int
-Melodic_req::pitch() const
-{
- return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
-}
-
-Plet_req::Plet_req()
-{
- type_c_ = ']';
- dur_i_ = 1;
- type_i_ = 1;
-}
-
-void
-Plet_req::do_print() const
-{
- mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
-}
-
-/* *************** */
-int
-Rhythmic_req::compare(const Rhythmic_req &r1, const Rhythmic_req &r2)
-{
- return sign(r1.duration() - r2.duration());
-}
-Rhythmic_req::Rhythmic_req(int b, int d)
-{
- plet_factor = 1;
- balltype = b;
- dots = d;
-}
-
-Rhythmic_req::Rhythmic_req()
-{
- plet_factor = 1;
- balltype = 1;
- dots = 0;
-}
-
-void
-Rhythmic_req::do_print() const
-{
- mtor << "ball: " << balltype ;
- int d =dots;
- while (d--)
- mtor << '.';
-
- mtor<<", plet factor"<<plet_factor<<"\n";
-}
-
-
-Moment
-Rhythmic_req::duration() const {
- return wholes(balltype,dots)*plet_factor;
-}
-/* *************** */
-
-Lyric_req::Lyric_req(Text_def* def_p)
- :Text_req(0, def_p)
-{
- def_p->align_i_ = 0; // centre
- dir_i_ = -1; // lyrics below (invisible) staff
-}
-
-void
-Lyric_req::do_print() const
-{
- Rhythmic_req::do_print();
- Text_req::do_print();
-}
-/* *************** */
-void
-Note_req::do_print() const
-{
- Melodic_req::do_print();
- Rhythmic_req::do_print();
-}
-/* *************** */
-void
-Rest_req::do_print() const
-{
- Rhythmic_req::do_print();
-}
-
-/* *************** */
-Beam_req::Beam_req()
-{
- nplet = 0;
-}
-
-void Beam_req::do_print()const{}
-/* *************** */
-void Slur_req::do_print()const{}
-/* *************** */
-int
-Span_req:: compare(const Span_req &r1, const Span_req &r2)
-{
- return r1.spantype - r2.spantype;
-}
-
-Span_req::Span_req()
-{
- spantype = NOSPAN;
-}
-
-/* *************** */
-Script_req::Script_req(int d , Script_def*def)
-{
- dir_i_ = d;
- scriptdef_p_ = def;
-}
-
-int
-Script_req::compare(const Script_req &d1, const Script_req &d2)
-{
- return d1.dir_i_ == d2.dir_i_ &&
- d1.scriptdef_p_->compare(*d2.scriptdef_p_);
-}
-
-Script_req::Script_req(Script_req const &s)
- : Request( s )
-{
- dir_i_ = s.dir_i_;
- scriptdef_p_ = new Script_def(*s.scriptdef_p_);
-}
-
-void
-Script_req::do_print() const
-{
- mtor << " dir " << dir_i_ ;
- scriptdef_p_->print();
-}
-
-
-Script_req::~Script_req()
-{
- delete scriptdef_p_;
-}
-/* *************** */
-int
-Text_req:: compare(const Text_req &r1, const Text_req &r2)
-{
- bool b1 = (r1.dir_i_ == r2.dir_i_);
- bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
- return b1 && b2;
-}
-Text_req::~Text_req()
-{
- delete tdef_p_;
- tdef_p_ = 0;
-}
-
-Text_req::Text_req(Text_req const& src)
-{
- tdef_p_ = new Text_def(*src.tdef_p_);
- dir_i_ = src.dir_i_;
-}
-
-Text_req::Text_req(int dir_i, Text_def* tdef_p)
-{
- dir_i_ = dir_i;
- tdef_p_ = tdef_p;
-}
-
-void
-Text_req::do_print() const
-{
- mtor << " dir " << dir_i_ ;
- tdef_p_->print();
-}
-
-/* *************** */
-
-Moment
-Skip_req::duration() const
-{
- return duration_;
-}
-
-void
-Skip_req::do_print() const
-{
- mtor << "duration: " << duration();
-}
-
-Voice *
-Request::voice_l()
-{
- if (!elt_l_)
- return 0;
- else
- return (Voice*)elt_l_->voice_l_;
-}
+++ /dev/null
-#include "rest.hh"
-#include "dimen.hh"
-#include "debug.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "molecule.hh"
-
-
-Rest::Rest(int t, int d)
-{
- balltype = t;
- dots = d;
-}
-
-
-void
-Rest::do_print()const
-{
-#ifndef NPRINT
- mtor << "Rest "<<balltype<< "dots " << dots;
- Item::print();
-#endif
-}
-
-Molecule*
-Rest::brew_molecule_p()const
-{
- Paper_def *p =paper();
-
- Symbol s;
- s = p->lookup_p_->rest(balltype);
-
- Molecule *m = new Molecule(Atom(s));
- if (dots) {
- Symbol d =p->lookup_p_->dots(dots);
- Molecule dm;
- dm.add(Atom(d));
- m->add_right(dm);
- }
- return m;
-}
-
+++ /dev/null
-/*
- score-column.cc -- implement Score_column
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "pcol.hh"
-#include "score-column.hh"
-
-int
-Score_column::compare(Score_column & c1, Score_column &c2)
-{
- return sign(c1.when_ - c2.when_);
-}
-
-void
-Score_column::set_breakable()
-{
- pcol_l_->set_breakable();
-}
-
-Score_column::Score_column(Moment w)
-{
- when_ = w;
- pcol_l_ = new PCol(0);
- musical_b_ = false;
-}
-
-bool
-Score_column::used_b() {
- return pcol_l_->used_b();
-}
-
-void
-Score_column::print() const
-{
-#ifndef NPRINT
- mtor << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n';
- mtor << "durations: [";
- for (int i=0; i < durations.size(); i++)
- mtor << durations[i] << " ";
- mtor << "]\n";
- pcol_l_->print();
- mtor << "}\n";
-#endif
-}
-
-int
-Moment_compare(Moment &a , Moment& b)
-{
- return sign(a-b);
-}
-
-void
-Score_column::preprocess()
-{
- durations.sort(Moment_compare);
-}
-void
-Score_column::add_duration(Moment d)
-{
- assert(d);
- for (int i = 0; i< durations.size(); i++) {
- if (d == durations[i])
- return ;
- }
- durations.push(d);
-}
-
-bool
-Score_column::breakable_b()
-{
- return pcol_l_->breakable_b();
-}
+++ /dev/null
-/*
- score-walker.cc -- implement Score_walker
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "debug.hh"
-#include "plist.hh"
-#include "score-walker.hh"
-#include "score.hh"
-#include "staff-walker.hh"
-#include "staff.hh"
-#include "score-column.hh"
-
-Score_walker::Score_walker(Score *s)
- :PCursor<Score_column *> (s->cols_)
-{
- score_l_ = s;
- for (iter_top(s->staffs_,i); i.ok(); i++) {
- Staff_walker* w_p=i->get_walker_p();
- w_p->score_walk_l_ =this;
- walker_p_arr_.push(w_p);
- }
-
- if(ok()) {
- s->find_col(0, false)->set_breakable();
- s->find_col(s->last(), false)->set_breakable();
- }
- reinit();
-}
-
-
-void
-Score_walker::reinit()
-{
- disallow_break_walk_l_arr = walker_p_arr_;
- disallow_break_count_ = disallow_break_walk_l_arr.size();
-}
-
-
-/** Advance the cursor, and all Staff_walkers contained in this. Reset
- runtime fields */
-void
-Score_walker::operator ++(int )
-{
- Moment last = ptr()->when();
-
- PCursor<Score_column *>::operator++(0);
- if (ok() && ptr()->when() == last)
- PCursor<Score_column *>::operator++(0);
- reinit();
- if (!ok())
- return;
- for (int i=0; i< walker_p_arr_.size(); i++) {
- if (walker_p_arr_[i]->ok() &&
- walker_p_arr_[i]->when() < when()) {
-
- walker_p_arr_[i]->operator++(0);
- }
- }
-}
-
-/** Allow the command_column to be breakable for one staff. If all
- staffs allow, then allow a break here. */
-void
-Score_walker::allow_break(Staff_walker*w)
-{
- for (int i=0; i < disallow_break_walk_l_arr.size(); i++) {
- if (w == disallow_break_walk_l_arr[i]) {
- disallow_break_count_ --;
- disallow_break_walk_l_arr[i] =0;
-
- if (!disallow_break_count_) {
- PCursor<Score_column*> col_cursor = *this;
- if (ptr()->musical_b())
- col_cursor --;
- col_cursor->set_breakable();
- }
- }
- }
-}
-
-Moment
-Score_walker::when()
-{
- return ptr()->when();
-}
-
-void
-Score_walker::process()
-{
- for (int i=0; i < walker_p_arr_.size(); i++) {
- Staff_walker *w = walker_p_arr_[i];
- if ( w->ok() && w->when() == when() ) {
- walker_p_arr_[i]->process();
- }
- }
- if (when().denominator() == 1) {
- *mlog << "." <<flush;
- }
-}
-
-Score_walker::~Score_walker()
-{
- for (int i=0; i < walker_p_arr_.size(); i++)
- delete walker_p_arr_[i];
- assert( !score_l_->find_col(score_l_->last(), true)->used_b());
-}
-
-
+++ /dev/null
-/*
- score.cc -- implement Score
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "tex-stream.hh"
-#include "score.hh"
-#include "score-column.hh"
-#include "pscore.hh"
-#include "staff.hh"
-#include "debug.hh"
-#include "paper-def.hh"
-#include "main.hh"
-#include "source.hh"
-#include "source-file.hh"
-#include "score-walker.hh"
-#include "midi-output.hh"
-#include "midi-def.hh"
-
-extern String default_out_fn;
-
-void
-Score::setup_music()
-{
- *mlog << "\nSetting up music ..." << flush;
- if (last() == Moment(0)) {
- errorlevel_i_ |= 1;
- error("Need to have music in a score.", defined_ch_c_l_);
- }
-
- for (iter_top(staffs_,i); i.ok(); i++) {
- i->setup_staffcols();
- i->OK();
- }
-}
-
-void
-Score::process_music()
-{
- *mlog << "Processing music ..." << flush;
- for (Score_walker w(this); w.ok(); w++) {
- w.process();
- }
-}
-
-void
-Score::process()
-{
- setup_music();
-
- paper();
- midi();
-}
-
-void
-Score::paper()
-{
- if (!paper_p_)
- return;
-
- pscore_p_ = new PScore(paper_p_);
-
- find_col(0, false)->set_breakable(); // ugh
- find_col(last(), false)->set_breakable();
- do_cols();
-
- for (iter_top(staffs_,i); i.ok(); i++)
- i->set_output(pscore_p_);
-
-
- process_music();
- clean_cols(); // can't move clean_cols() farther up.
- print();
- calc_idealspacing();
-
- // debugging
- OK();
- *mlog << endl;
- pscore_p_->process();
-
- // output
- paper_output();
-
-}
-
-/**
- Remove empty cols, preprocess other columns.
- */
-void
-Score::clean_cols()
-{
- for (iter_top(staffs_,i); i.ok(); i++)
- i->clean_cols();
-
- for (iter_top(cols_,c); c.ok(); ) {
- if (!c->pcol_l_->used_b()) {
- delete c.get_p();
- } else {
- c->preprocess();
- c++;
- }
- }
-}
-
-/**
- Create columns at time #w#.
- this sux. We should have Score_column create the appropriate PCol.
- Unfortunately, PCols don't know about their position.
-
- @return cursor pointing to the nonmusical (first) column
- */
-PCursor<Score_column*>
-Score::create_cols(Moment w)
-{
- Score_column* c1 = new Score_column(w);
- Score_column* c2 = new Score_column(w);
-
- c1->musical_b_ = false;
- c2->musical_b_ = true;
-
- iter_top(cols_,i);
-
- for (; i.ok(); i++) {
- assert(i->when() != w);
- if (i->when() > w)
- break;
- }
-
- if (!i.ok()) {
- cols_.bottom().add(c1);
- cols_.bottom().add(c2);
- i = cols_.bottom();
- i --;
- } else {
- i.insert(c1);
- i.insert(c2);
- i -= 2;
- }
- return i;
-}
-
-PCursor<Score_column*>
-Score::find_col(Moment w, bool mus)
-{
- iter_top( cols_,i);
-
- for (; i.ok(); i++) {
- if (i->when() == w && i->musical_b_ == mus)
- return i;
- if (i->when() > w)
- break;
- }
- i = create_cols(w);
- if (mus)
- i++;
- return i;
-}
-
-void
-Score::do_cols()
-{
- iter_top(cols_,i);
- for (; i.ok(); i++) {
- pscore_p_->add(i->pcol_l_);
- }
-}
-
-Moment
-Score::last() const
-{
- Moment l = 0;
- for (iter_top(staffs_,i); i.ok(); i++) {
- l = l>? i->last();
- }
- return l;
-}
-
-void
-Score::set(Paper_def *pap_p)
-{
- delete paper_p_;
- paper_p_ = pap_p;
-}
-
-void
-Score::set(Midi_def* midi_p)
-{
- delete midi_p_;
- midi_p_ = midi_p;
-}
-
-void
-Score::OK() const
-{
-#ifndef NDEBUG
- for (iter_top(staffs_,i); i.ok(); i++) {
- i->OK();
- assert(i->score_l_ == this);
- }
- staffs_.OK();
- cols_.OK();
- for (iter_top(cols_,cc); cc.ok() && (cc+1).ok(); cc++) {
- assert(cc->when() <= (cc+1)->when());
- }
-#endif
-}
-
-
-void
-Score::print() const
-{
-#ifndef NPRINT
- mtor << "score {\n";
- for (iter_top(staffs_,i); i.ok(); i++) {
- i->print();
- }
- for (iter_top(cols_,i); i.ok(); i++) {
- i->print();
- }
- if (pscore_p_)
- pscore_p_->print();
- if (midi_p_)
- midi_p_->print();
-
- mtor << "}\n";
-#endif
-}
-
-Score::Score()
-{
- pscore_p_=0;
- paper_p_ = 0;
- midi_p_ = 0;
- errorlevel_i_ = 0;
- defined_ch_c_l_ = 0;
-}
-
-Score::~Score()
-{
- delete pscore_p_;
- delete paper_p_;
- delete midi_p_;
-}
-
-void
-Score::paper_output()
-{
- OK();
- if (paper_p_->outfile=="")
- paper_p_->outfile = default_out_fn + ".out";
-
- if ( errorlevel_i_ ) {
- *mlog << "lilypond: warning: no output to: " << paper_p_->outfile
- << " (errorlevel=" << errorlevel_i_ << ")" << endl;
- return;
- }
-
- *mlog << "TeX output to " << paper_p_->outfile << " ...\n";
-
- Tex_stream the_output(paper_p_->outfile);
-
- the_output << "% outputting Score, defined at: " <<
- source_l_g->
- sourcefile_l (defined_ch_c_l_)->file_line_no_str(defined_ch_c_l_) << "\n";
- pscore_p_->output(the_output);
-}
-
-void
-Score::midi()
-{
- if (!midi_p_)
- return;
-
- if (midi_p_->outfile_str_ == "")
- midi_p_->outfile_str_ = default_out_fn + ".midi";
-
- *mlog << "midi output to " << midi_p_->outfile_str_ << " ...\n";
- Midi_output(this, midi_p_);
-}
-
-void
-Score::add(Staff*s)
-{
- s->score_l_ = this;
- staffs_.bottom().add(s);
-}
+++ /dev/null
-#include "scoreline.hh"
-#include "staffline.hh"
-#include "dimen.hh"
-#include "spanner.hh"
-#include "symbol.hh"
-#include "paper-def.hh"
-#include "pcol.hh"
-#include "pscore.hh"
-
-
-String
-Line_of_score::TeXstring() const
-{
- String s("\\vbox{%<- line of score\n");
- for (iter_top(staffs,sc); sc.ok(); sc++){
- s += sc->TeXstring();
- if ((sc+1).ok())
- s+= "\\interstaffline\n";
- }
- s += "}";
- return s;
-}
-
-
-Line_of_score::Line_of_score(Array<PCol *> sv,
- PScore *ps)
-{
- pscore_l_ = ps;
- for (int i=0; i< sv.size(); i++) {
- PCol *p=(PCol *) sv[i];
- cols.bottom().add(p);
- p->line_l_=this;
- }
-
- for (iter_top(pscore_l_->staffs,sc); sc.ok(); sc++)
- staffs.bottom().add(new Line_of_staff(this, sc));
-}
-/* construct a line with the named columns. Make the line field
- in each column point to this
-
- #sv# isn't really const!!
- */
-
-
-void
-Line_of_score::process()
-{
- for (iter_top(staffs,i); i.ok(); i++)
- i->process();
-}
-
+++ /dev/null
-#include "main.hh"
-#include "input-score.hh"
-#include "score.hh"
-#include "string.hh"
-#include "paper-def.hh"
-#include "debug.hh"
-
-static Array<Input_score*> score_array_global;
-String default_out_fn = "lelie";
-
-void
-do_scores()
-{
- for (int i=0; i < score_array_global.size(); i++) {
- Input_score* &is_p = score_array_global[i];
- if (is_p->errorlevel_i_) {
- warning("Score contains errors. Will not process it. ",
- is_p->defined_ch_c_l_);
- delete is_p;
- continue;
- }
-
- if (only_midi) {
- delete is_p->paper_p_;
- is_p->paper_p_ = 0;
- }
-
- Score * s_p = is_p->parse();
- delete is_p;
- s_p->print ();
- s_p->process();
- delete s_p;
- }
- score_array_global.set_size(0);
-}
-
-void
-add_score(Input_score * s)
-{
- score_array_global.push(s);
-}
-
-void
-set_default_output(String s)
-{
- default_out_fn = s;
-}
-
+++ /dev/null
-#include "debug.hh"
-#include "script-def.hh"
-
-Script_def::Script_def(String idx, int stem, int staff ,bool invert)
-{
- symidx = idx ;
- stemdir =stem;
- staffdir = staff;
- invertsym = invert;
-}
-void
-Script_def::print() const
-{
- mtor << "Script_def{ idx: " << symidx
- << " direction, stem: " << stemdir << " staff : " << staffdir << "}\n";
-}
-int
-Script_def::compare(Script_def const & c)
-{
- return !(symidx == c.symidx &&
- stemdir == c.stemdir&&
- staffdir == c.staffdir&&
- invertsym == c.invertsym);
-}
+++ /dev/null
-/*
- script-reg.cc -- implement Script_register
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "script-reg.hh"
-#include "script.hh"
-#include "musicalrequest.hh"
-#include "complex-walker.hh"
-#include "stem.hh"
-
-Script_register::Script_register()
-{
- script_p_ = 0;
- post_move_processing();
-}
-
-bool
-Script_register::try_request(Request *r_l)
-{
- if (!r_l->script())
- return false ;
-
- if (script_req_l_
- && Script_req::compare(*script_req_l_, *r_l->script()))
-
- return false;
-
- script_req_l_ = r_l->script();
-
- return true;
-}
-
-void
-Script_register::process_requests()
-{
- if (script_req_l_) {
- script_p_ = new Script(script_req_l_, 10);
- announce_element(
- Staff_elem_info(script_p_, script_req_l_));
- }
-}
-
-void
-Script_register::acknowledge_element(Staff_elem_info info)
-{
- if (!script_p_)
- return;
- if (info.elem_p_->name() == Stem::static_name())
- script_p_->set_stem((Stem*)info.elem_p_);
- else if (info.req_l_->rhythmic())
- script_p_->set_support(info.elem_p_->item());
-}
-
-void
-Script_register::pre_move_processing()
-{
- if (script_p_){
- script_p_->dir = dir_i_;
- typeset_element(script_p_);
- script_p_ = 0;
- }
-}
-void
-Script_register::post_move_processing()
-{
- script_req_l_ = 0;
-}
-
-void
-Script_register::set_feature(Features i)
-{
- if (i.direction_i_|| i.initialiser_b_)
- dir_i_ = i.direction_i_;
-}
+++ /dev/null
-#include "musicalrequest.hh"
-#include "paper-def.hh"
-#include "script.hh"
-#include "stem.hh"
-#include "molecule.hh"
-#include "lookup.hh"
-
-
-
-void
-Script::set_stem(Stem*st_l)
-{
- stem_l_ = st_l;
- add_dependency(st_l);
-}
-
-void
-Script::set_support(Item*i)
-{
- support.push(i);
- add_dependency(i);
-}
-
-Script::Script(Script_req* rq, int staflen)
-{
- staffsize =staflen;
- specs_l_ = rq->scriptdef_p_;
- stem_l_ = 0;
- pos = 0;
- symdir=1;
- dir =rq->dir_i_;
-}
-
-void
-Script::set_symdir()
-{
- if (specs_l_->invertsym)
- symdir = (dir < 0) ? -1:1;
-}
-
-void
-Script::set_default_dir()
-{
- if (specs_l_->stemdir) {
- if (!stem_l_)
- dir = 1;
- else
- dir = stem_l_->dir * specs_l_->stemdir;
- }
-}
-
-Interval
-Script::support_height() const return r;
-{
- for (int i=0; i < support.size(); i++)
- r.unite(support[i]->height());
-}
-
-void
-Script::set_default_index()
-{
- Real inter_f= paper()->internote();
- Interval dy = symbol().dim.y;
-
- int d = specs_l_->staffdir;
- Real y ;
- if (!d) {
- Interval v= support_height();
- y = v[dir] -dy[-dir] + 2*dir*inter_f;
- } else {
- y = (d > 0) ? staffsize + 2: -2; // ug
- y *=inter_f;
- Interval v= support_height();
-
- if (d > 0) {
- y = y >? v.max();
- } else if (d < 0) {
- y = y <? v.min();
- }
- }
-
- if (stem_l_) {
- Interval v= stem_l_->height();
-
- if (d > 0 || (!d && dir > 0)) {
- y = y >? v.max();
- }else if (d < 0 || (!d && dir < 0)) {
- y = y <? v.min();
- }
- }
-
- pos = int(rint(Real(y)/inter_f));
-}
-
-Interval
-Script::width() const
-{
- return symbol().dim.x;
-}
-
-Symbol
-Script::symbol()const
-{
- String preidx_str = (symdir < 0) ?"-" :"";
- return paper()->lookup_p_->script(preidx_str + specs_l_->symidx);
-}
-
-void
-Script::do_pre_processing()
-{
- set_default_dir();
- set_symdir();
-}
-
-void
-Script::do_post_processing()
-{
- set_default_index();
-}
-
-Molecule*
-Script::brew_molecule_p() const
-{
- Real dy = paper()->internote();
-
- Molecule*out = new Molecule(Atom(symbol()));
- out->translate(Offset(0,dy * pos));
- return out;
-}
+++ /dev/null
-/*
- slur-reg.cc -- implement Slur_register
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "plist.hh"
-#include "musicalrequest.hh"
-#include "complex-walker.hh"
-#include "slur-reg.hh"
-#include "slur.hh"
-#include "debug.hh"
-#include "notehead.hh"
-
-void
-Slur_register::set_feature(Features i)
-{
- dir_i_ = i.direction_i_;
-}
-
-Slur_register::Slur_register()
-{
- set_feature(Features::dir(0));
-}
-
-bool
-Slur_register::try_request(Request *req_l)
-{
- if(!req_l->slur())
- return false;
-
- new_slur_req_l_arr_.push(req_l->slur());
- return true;
-}
-
-void
-Slur_register::acknowledge_element(Staff_elem_info info)
-{
- if (info.elem_p_->name() == Notehead::static_name()) {
- Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh
- for (int i = 0; i < slur_l_stack_.size(); i++)
- slur_l_stack_[i]->add(head_p );
- for (int i = 0; i < end_slur_l_arr_.size(); i++)
- end_slur_l_arr_[i]->add(head_p);
- }
-}
-/*
- abracadabra
- */
-void
-Slur_register::process_requests()
-{
- Array<Slur*> start_slur_l_arr_;
- for (int i=0; i< new_slur_req_l_arr_.size(); i++) {
- Slur_req* slur_req_l = new_slur_req_l_arr_[i];
- // end slur: move the slur to other array
- if (slur_req_l->spantype == Span_req::STOP) {
- if (slur_l_stack_.empty())
- warning("can't find slur to end",
- slur_req_l->defined_ch_c_l_);
- else {
- end_slur_l_arr_.push(slur_l_stack_.pop());
- requests_arr_.pop();
- }
- } else if (slur_req_l->spantype == Span_req::START) {
- // push a new slur onto stack.
- //(use temp. array to wait for all slur STOPs)
- Slur * s_p =new Slur;
- requests_arr_.push(slur_req_l);
- start_slur_l_arr_.push(s_p);
- announce_element(Staff_elem_info(s_p, slur_req_l));
- }
- }
- for (int i=0; i < start_slur_l_arr_.size(); i++)
- slur_l_stack_.push(start_slur_l_arr_[i]);
-}
-
-void
-Slur_register::pre_move_processing()
-{
- for (int i = 0; i < end_slur_l_arr_.size(); i++) {
- if (dir_i_)
- end_slur_l_arr_[i]->dir_i_ = dir_i_;
- typeset_element(end_slur_l_arr_[i]);
- }
- end_slur_l_arr_.set_size(0);
-}
-
-void
-Slur_register::post_move_processing()
-{
- new_slur_req_l_arr_.set_size(0);
-}
-Slur_register::~Slur_register()
-{
- for (int i=0; i < requests_arr_.size(); i++) {
- warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_);
- }
-}
+++ /dev/null
-/*
-
- TODO:
- think about crossing stems.
- */
-#include "slur.hh"
-#include "scalar.hh"
-#include "lookup.hh"
-#include "paper-def.hh"
-#include "notehead.hh"
-#include "pcol.hh"
-#include "molecule.hh"
-#include "debug.hh"
-#include "boxes.hh"
-
-
-
-Slur::Slur()
-{
- open_right=open_left=false;
-}
-
-Offset
-Slur::center() const
-{
- int pos1 = encompass.top()->position;
- int pos2 = encompass[0]->position;
-
- int dy = pos1-pos2;
-
- Real w = width().length();
-
- return Offset(w/2,dy * paper()->internote());
-}
-
-void
-Slur::add(Notehead*n)
-{
- encompass.push(n);
- add_dependency(n);
-}
-
-void
-Slur::set_default_dir()
-{
- int sumpos=0;
- for (int i=0; i < encompass.size(); i ++) {
- sumpos += encompass[i]->position;
- }
-
- /* should consult stems */
- Real meanpos = sumpos/Real(encompass.size());
- if (meanpos < 5) // todo
- dir_i_ = -1;
- else
- dir_i_ = 1;
-}
-
-void
-Slur::do_pre_processing()
-{
- right = encompass.top()->pcol_l_;
- left = encompass[0]->pcol_l_;
-}
-
-Spanner*
-Slur::do_break_at(PCol*l, PCol*r) const
-{
- assert(l->line_l_ == r->line_l_);
- Slur*ret = new Slur(*this);
-
- ret->encompass.set_size(0);
- for (int i =0; i < encompass.size(); i++) {
- if (encompass[i]->pcol_l_->line_l_==l->line_l_)
- ret->encompass.push(encompass[i]);
- }
- if (right != r)
- ret->open_right = true;
- if (left != l)
- ret->open_left = true;
-
-
- return ret;
-}
-
-void
-Slur::do_post_processing()
-{
- if (!dir_i_)
- set_default_dir();
-}
-
-Molecule*
-Slur::brew_molecule_p() const
-{
- Molecule*output = new Molecule;
-
- int minp=1000, maxp=-1000; // todo
- for (int i=0; i<encompass.size(); i++) {
- minp = encompass[i]->position <? minp;
- maxp = encompass[i]->position >? maxp;
- }
- assert(encompass.size()>0); // todo
-
- Notehead *lnote_p =encompass[0];
- Notehead *rnote_p =encompass.top();
- int lpos_i = lnote_p->position;
- int rpos_i = rnote_p->position;
- Offset left_off(lnote_p->x_dir, lpos_i + 2*dir_i_);
- Offset right_off(lnote_p->x_dir, rpos_i + 2*dir_i_);
- if (!lnote_p->extremal)
- left_off += Offset(0.5, -dir_i_);
- if (!rnote_p->extremal)
- right_off+= Offset(-0.5, -dir_i_);
-
- int dy = int(right_off.y - left_off.y);
-
- Real nw_f = paper()->note_width();
- Real nh_f = paper()->internote();
- Real w = width().length();
-
- w+= (right_off.x - left_off.x) * nw_f ;
- Real round_w = w; // slur lookup rounds the slurwidth .
-
- Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir_i_);
-
- Real error = w-round_w;
-
- Atom a(sl);
- a.translate(Offset((left_off.x + 0.5 )*nw_f + error/2,
- left_off.y * nh_f));
- output->add(a);
- return output;
-}
-
+++ /dev/null
-//
-// source-file.cc
-//
-
-#include <sys/types.h> // open, mmap
-#include <sys/stat.h> // open
-#include <sys/mman.h> // mmap
-#include <limits.h> // INT_MAX
-#include <fcntl.h> // open
-#include <unistd.h> // close, stat
-#include <stdio.h> // fdopen
-#include <string.h> // strerror
-#include <errno.h> // errno
-#include <assert.h>
-#include <strstream.h>
-
-#include "string.hh"
-#include "proto.hh"
-#include "plist.hh"
-#include "lexer.hh"
-#include "debug.hh"
-#include "parseconstruct.hh"
-#include "main.hh" // find_file
-
-#include "source-file.hh"
-
-Source_file::Source_file( String &filename_str )
-{
- data_caddr_ = 0;
- fildes_i_ = 0;
- size_off_ = 0;
- name_str_ = filename_str;
- istream_p_ = 0;
-
- open();
- map();
- // ugh!?, should call name_str() !
- filename_str = name_str_;
-}
-
-Source_file::~Source_file()
-{
- delete istream_p_;
- istream_p_ = 0;
- unmap();
- close();
-}
-
-char const*
-Source_file::ch_c_l()
-{
- assert( this );
- return (char const*)data_caddr_;
-}
-
-void
-Source_file::close()
-{
- if ( fildes_i_ ) {
- ::close( fildes_i_ );
- fildes_i_ = 0;
- }
-}
-
-String
-Source_file::error_str( char const* pos_ch_c_l )
-{
- assert( this );
- if ( !in_b( pos_ch_c_l ) )
- return "";
-
- char const* begin_ch_c_l = pos_ch_c_l;
- char const* data_ch_c_l = ch_c_l();
- while ( begin_ch_c_l > data_ch_c_l )
- if ( *--begin_ch_c_l == '\n' ) {
- begin_ch_c_l++;
- break;
- }
-
- char const* end_ch_c_l = pos_ch_c_l;
- while ( end_ch_c_l < data_ch_c_l + size_off_ )
- if ( *end_ch_c_l++ == '\n' ) {
- break;
- }
- end_ch_c_l--;
-
-#if 1
-// String( char const* p, int length ) is missing!?
- String line_str( (Byte const*)begin_ch_c_l, end_ch_c_l - begin_ch_c_l );
-#else
- int length_i = end_ch_c_l - begin_ch_c_l;
- char* ch_p = new char[ length_i + 1 ];
- strncpy( ch_p, begin_ch_c_l, length_i );
- ch_p[ length_i ] = 0;
- String line_str( ch_p );
- delete ch_p;
-#endif
-
- int error_col_i = 0;
- char const* scan_ch_c_l = begin_ch_c_l;
- while ( scan_ch_c_l < pos_ch_c_l )
- if ( *scan_ch_c_l++ == '\t' )
- error_col_i = ( error_col_i / 8 + 1 ) * 8;
- else
- error_col_i++;
-
- String str = line_str.left_str( pos_ch_c_l - begin_ch_c_l )
- + String( '\n' )
- + String( ' ', error_col_i )
- + line_str.mid_str( pos_ch_c_l - begin_ch_c_l + 1, INT_MAX ); // String::mid should take 0 arg..
- return str;
-}
-
-bool
-Source_file::in_b( char const* pos_ch_c_l )
-{
- return ( pos_ch_c_l && ( pos_ch_c_l >= ch_c_l() ) && ( pos_ch_c_l < ch_c_l() + size_off_ ) );
-}
-
-istream*
-Source_file::istream_l()
-{
- assert( fildes_i_ );
- if ( !istream_p_ ) {
- if ( size_off_ ) // can-t this be done without such a hack?
- istream_p_ = new istrstream( ch_c_l(), size_off_ );
- else {
- istream_p_ = new istrstream( "", 0 );
- istream_p_->set(ios::eofbit);
- }
- }
- return istream_p_;
-}
-
-off_t
-Source_file::length_off()
-{
- return size_off_;
-}
-
-int
-Source_file::line_i( char const* pos_ch_c_l )
-{
- if ( !in_b( pos_ch_c_l ) )
- return 0;
-
- int i = 1;
- char const* scan_ch_c_l = ch_c_l();
- while ( scan_ch_c_l < pos_ch_c_l )
- if ( *scan_ch_c_l++ == '\n' )
- i++;
- return i;
-}
-
-void
-Source_file::map()
-{
- if ( fildes_i_ == -1 )
- return;
-
- data_caddr_ = (caddr_t)mmap( (void*)0, size_off_, PROT_READ, MAP_SHARED, fildes_i_, 0 );
-
- if ( (int)data_caddr_ == -1 )
- // ugh: defined_ch_c_l...
- warning( String( "can't map: " ) + name_str_ + String( ": " ) + strerror( errno ), defined_ch_c_l ); //lexer->here_ch_c_l() );
-}
-
-String
-Source_file::name_str()
-{
- return name_str_;
-}
-
-void
-Source_file::open()
-{
- String name_str = find_file( name_str_ );
- if ( name_str != "" )
- name_str_ = name_str;
-
- fildes_i_ = ::open( name_str_, O_RDONLY );
-
- if ( fildes_i_ == -1 ) {
- warning( String( "can't open: " ) + name_str_ + String( ": " ) + strerror( errno ), defined_ch_c_l ); // lexer->here_ch_c_l() );
- return;
- }
-
- struct stat file_stat;
- fstat( fildes_i_, &file_stat );
- size_off_ = file_stat.st_size;
-}
-
-void
-Source_file::unmap()
-{
- if ( data_caddr_ ) {
- munmap( data_caddr_, size_off_ );
- data_caddr_ = 0;
- size_off_ = 0;
- }
-}
-String
-Source_file::file_line_no_str(char const *ch_c_l )
-{
- return name_str() + ": "
- + String( line_i( ch_c_l ) );
-}
+++ /dev/null
-//
-// source.cc
-//
-
-#include <assert.h>
-
-#include "string.hh"
-#include "proto.hh"
-#include "plist.hh"
-
-#include "source-file.hh"
-#include "source.hh"
-
-Source::Source()
-{
-}
-
-Source::~Source()
-{
-}
-
-void
-Source::add( Source_file* sourcefile_p )
-{
- sourcefile_p_iplist_.bottom().add( sourcefile_p );
-}
-
-Source_file*
-Source::sourcefile_l( char const* ch_c_l )
-{
- PCursor<Source_file*> sourcefile_l_pcur( sourcefile_p_iplist_.top() );
- for ( ; sourcefile_l_pcur.ok(); sourcefile_l_pcur++ )
- if ( sourcefile_l_pcur->in_b( ch_c_l ) )
- return *sourcefile_l_pcur;
- return 0;
-}
+++ /dev/null
-#include "debug.hh"
-#include "spanner.hh"
-#include "pcol.hh"
-
-
-
-void
-Spanner::do_print()const
-{
- mtor << " (unknown) ";
-}
-
-Spanner*
-Spanner::broken_at(PCol*c1, PCol *c2)const
-{
- Spanner *span_p = do_break_at(c1,c2);
-
- for (int i=0; i < dependants.size(); i++) {
- dependants[i]->substitute_dependency((Staff_elem*)this, span_p);
- }
-
- span_p->left = c1;
- span_p->right = c2;
-
- return span_p;
-}
-
-Spanner::Spanner()
-{
- left = right = 0;
-}
-
-
-Interval
-Spanner::width()const
-{
- Real r = right->hpos;
- Real l = left->hpos;
- assert(*left < *right);
- assert(r>=l);
-
- return Interval(0, r-l);
-}
+++ /dev/null
-/*
- staff-column.cc -- implement Staff_column
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "staff.hh"
-#include "voice.hh"
-#include "time-description.hh"
-#include "score-column.hh"
-#include "staff-column.hh"
-#include "commandrequest.hh"
-#include "musicalrequest.hh"
-#include "interval.hh"
-#include "pscore.hh"
-#include "item.hh"
-#include "pcol.hh"
-#include "voice-element.hh"
-
-void
-Staff_column::OK() const
-{
-#ifndef NDEBUG
- assert (command_column_l_->when() == musical_column_l_->when());
-#endif
-}
-
-Moment
-Staff_column::when() const
-{
- return (command_column_l_)?
- command_column_l_->when():
- musical_column_l_->when();
-}
-
-void
-Staff_column::add(Voice_element*ve)
-{
- for (iter_top(ve->reqs,j); j.ok(); j++) {
- if (j->command()) {
- Command_req * c_l = j->command();
- if (c_l->timing()) {
- timing_req_l_arr_.push(j->command()->timing());
- }
- if (c_l->groupchange())
- creationreq_l_arr_.push(c_l);
- else if (!c_l->barcheck() && !c_l->partial() &&
- !c_l->measuregrouping())
- setup_one_request(j); // no need to bother children
- } else {
- if (j->rhythmic()) {
- musical_column_l_->add_duration(j->rhythmic()->duration());
- }
- if (!j->musical()->skip())
- setup_one_request(j);
- }
- }
-}
-
-Staff_column::Staff_column()
-{
- musical_column_l_ = 0;
- command_column_l_ = 0;
- staff_l_ = 0;
-}
-
-
-
-
-Staff_column::~Staff_column()
-{
-}
-
-void
-Staff_column::set_cols(Score_column*c1, Score_column*c2)
-{
- command_column_l_ = c1;
- musical_column_l_ = c2;
-}
-
-void
-Staff_column::setup_one_request(Request * j)
-{
- if (j->command()) // ugh
- commandreq_l_arr_.push(j);
- else if (j->musical())
- musicalreq_l_arr_.push(j);
-}
-
-void
-Staff_column::typeset_musical_item(Item*i)
-{
- assert(i);
- Score_column * scorecolumn_l = musical_column_l_;
- musical_column_l_->pcol_l_->pscore_l_->typeset_item(i, scorecolumn_l->pcol_l_,
- staff_l_->pstaff_l_);
-}
-
-/**
- align items in #item_l_arr#,
-
- @return the width of the items after aligning.
- */
-Interval
-align_items(Array<Item*> item_l_arr)
-{
- Interval wid(0,0);
- for (int i =0; i < item_l_arr.size(); i++) {
- Interval item_width= item_l_arr[i]->width();
- Real dx =wid.right - item_width.left;
- item_width += dx;
- item_l_arr[i]->translate(Offset(dx ,0));
- wid.unite(item_width);
- }
- return wid;
-}
-
-void
-translate_items(Real x, Array<Item*> item_l_arr)
-{
- for (int i =0; i < item_l_arr.size(); i++)
- item_l_arr[i]->translate(Offset(x, 0));
-}
-/*
- UGR
- This still sux
- */
-void
-Staff_column::typeset_breakable_items(Array<Item *> &pre_p_arr,
- Array<Item *> &nobreak_p_arr,
- Array<Item *> &post_p_arr)
-{
- PCol * c= command_column_l_->pcol_l_;
- PScore *ps_l=command_column_l_->pcol_l_->pscore_l_;
-
- if (!c->breakable_b()) {
- for (int i =0; i < pre_p_arr.size(); i++)
- delete pre_p_arr[i];
- pre_p_arr.set_size(0);
- for (int i =0; i < post_p_arr.size(); i++)
- delete post_p_arr[i];
- post_p_arr.set_size(0);
- }
-
-
- for (int i =0; i < pre_p_arr.size(); i++) {
- ps_l->typeset_item(pre_p_arr[i], c, staff_l_->pstaff_l_,0);
- }
- for (int i =0; i < nobreak_p_arr.size(); i++) {
- ps_l->typeset_item(nobreak_p_arr[i], c, staff_l_->pstaff_l_,1);
- }
- for (int i =0; i < post_p_arr.size(); i++) {
- ps_l->typeset_item(post_p_arr[i], c, staff_l_->pstaff_l_,2);
- }
-
- Interval pre_wid= align_items(pre_p_arr);
- translate_items( -pre_wid.right, pre_p_arr);
- align_items(nobreak_p_arr);
- Interval post_wid =align_items(post_p_arr);
- translate_items (-post_wid.left , post_p_arr);
-
- pre_p_arr.set_size(0);
- post_p_arr.set_size(0);
- nobreak_p_arr.set_size(0);
-}
+++ /dev/null
-/*
- staff-elem-info.cc -- implement Staff_elem_info
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "staff-elem-info.hh"
-#include "request.hh"
-
-Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l)
-{
- elem_p_ = s_l;
- voice_l_ = (r_l)?r_l->voice_l():0;
- req_l_ = r_l;
-}
-
-Staff_elem_info::Staff_elem_info()
-{
- elem_p_ = 0;
- voice_l_ = 0;
-
- req_l_ = 0;
-}
-
-Features::Features()
-{
- direction_i_ = 0;
- initialiser_b_ = false;
-}
-
-Features
-Features::dir(int d) return f;
-{
- f.initialiser_b_ = true;
- f.direction_i_ = d;
-}
+++ /dev/null
-#include "pscore.hh"
-#include "symbol.hh"
-#include "pstaff.hh"
-#include "molecule.hh"
-#include "staff-elem.hh"
-#include "debug.hh"
-
-String
-Staff_elem::TeXstring() const
-{
- Molecule m(*output);
- m.translate(offset_); // ugh?
- return m.TeXstring();
-}
-
-Staff_elem::Staff_elem(Staff_elem const&s)
- : dependants(s.dependants),
- dependencies(s.dependencies)
-{
- status = s.status;
- assert(!s.output);
- output = 0;
- pstaff_l_ = s.pstaff_l_;
- offset_ = Offset(0,0);
-}
-/**
- TODO:
- If deleted, then remove dependants depency!
- */
-Staff_elem::~Staff_elem()
-{
- delete output;
-}
-
-void
-Staff_elem::translate(Offset O)
-{
- offset_ += O;
-}
-Interval
-Staff_elem::width() const
-{
- Interval r;
-
- if (!output){
- Molecule*m = brew_molecule_p();
- r = m->extent().x;
- delete m;
- } else
- r = output->extent().x;
-
- if (!r.empty()) // float exception on DEC Alpha
- r+=offset_.x;
-
- return r;
-}
-Interval
-Staff_elem::height() const
-{
- Interval r;
-
- if (!output){
- Molecule*m = brew_molecule_p();
- r = m->extent().y;
- delete m;
- } else
- r = output->extent().y;
-
- if (!r.empty())
- r+=offset_.y;
-
-
- return r;
-}
-
-void
-Staff_elem::print()const
-{
-#ifndef NPRINT
- mtor << name() << "{\n";
- do_print();
- if (output)
- output->print();
-
- mtor << "}\n";
-#endif
-}
-
-
-
-Staff_elem::Staff_elem()
-{
- pstaff_l_=0;
- offset_ = Offset(0,0);
- output = 0;
- status = ORPHAN;
-}
-
-
-Paper_def*
-Staff_elem::paper() const
-{
- assert(pstaff_l_);
- return pstaff_l_->pscore_l_->paper_l_;
-}
-
-void
-Staff_elem::add_processing()
-{
- if (status >= VIRGIN)
- return;
- status = VIRGIN;
- do_add_processing();
-}
-
-void
-Staff_elem::pre_processing()
-{
- if (status >= PRECALCED )
- return;
- assert(status != PRECALCING); // cyclic dependency
- status = PRECALCING;
-
- for (int i=0; i < dependencies.size(); i++)
- if (dependencies[i])
- dependencies[i]->pre_processing();
-
-
- do_pre_processing();
- status = PRECALCED;
-}
-void
-Staff_elem::post_processing()
-{
- if (status >= POSTCALCED)
- return;
- assert(status != POSTCALCING);// cyclic dependency
- status=POSTCALCING;
-
- for (int i=0; i < dependencies.size(); i++)
- if (dependencies[i])
- dependencies[i]->post_processing();
- do_post_processing();
- status=POSTCALCED;
-}
-
-void
-Staff_elem::molecule_processing()
-{
- if (status >= OUTPUT)
- return;
- status = OUTPUT; // do it only once.
- for (int i=0; i < dependencies.size(); i++)
- if (dependencies[i])
- dependencies[i]->molecule_processing();
-
- output= brew_molecule_p();
-}
-
-void
-Staff_elem::do_post_processing()
-{
-}
-
-void
-Staff_elem::do_pre_processing()
-{
-}
-
-void
-Staff_elem::do_add_processing()
-{
-}
-
-void
-Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep)
-{
- bool hebbes_b=false;
- for (int i=0; i < dependencies.size(); i++) {
- if (dependencies[i] == old){
- dependencies[i] = newdep;
- hebbes_b = true;
- } else if (dependencies[i] == newdep) {
- hebbes_b = true;
- }
- }
- if (!hebbes_b)
- dependencies.push(newdep);
-}
-
-void
-Staff_elem::add_dependency(Staff_elem * p)
-{
- for (int i=0; i < dependencies.size(); i ++)
- if (dependencies[i] == p)
- return;
-
- dependencies.push(p);
- p->dependants.push(p);
-}
+++ /dev/null
-/*
- staff-walker.cc -- implement Staff_walker
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "grouping.hh"
-#include "staff.hh"
-#include "musicalrequest.hh"
-#include "staff-walker.hh"
-#include "staff-column.hh"
-#include "score-column.hh"
-#include "debug.hh"
-#include "time-description.hh"
-#include "commandrequest.hh"
-#include "grouping.hh"
-#include "score-walker.hh"
-
-Staff_walker::~Staff_walker()
-{
- do_pre_move();
-}
-
-Staff_walker::Staff_walker(Staff_walker const &s)
- :PCursor<Staff_column*> (s)
-{
- assert(false);
-}
-
-Staff_walker::Staff_walker(Staff * s, PScore*ps )
- : PCursor<Staff_column*> (s->cols_)
-{
- staff_l_ = s;
- pscore_l_ = ps;
-
- // should be in tdes. TODO
- default_grouping = new Rhythmic_grouping(MInterval(0, 1), 4);
- score_walk_l_ = 0;
-}
-
-Moment
-Staff_walker::when() const
-{
- return ptr()->when();
-}
-
-
-void
-Staff_walker::process_timing_reqs()
-{
- for (int i=0; i < ptr()->timing_req_l_arr_.size(); i++) {
- Timing_req * tr_l = ptr()->timing_req_l_arr_[i];
- if (tr_l->meterchange()) {
- int b_i=tr_l->meterchange()->beats_i_;
- int o_i = tr_l->meterchange()->one_beat_i_;
- time_.set_meter(b_i, o_i);
-
- *default_grouping = Rhythmic_grouping(
- MInterval(0,Moment(b_i, o_i)), b_i);
- }
- }
-
- for (int i=0; i < ptr()->timing_req_l_arr_.size(); i++) {
- Timing_req * tr_l = ptr()->timing_req_l_arr_[i];
- if (tr_l->partial()) {
- time_.setpartial(tr_l->partial()->duration_);
- } else if (tr_l->barcheck() && time_.whole_in_measure_) {
- warning( "Barcheck failed", tr_l->defined_ch_c_l_ );
- } else if (tr_l->cadenza()) {
- time_.set_cadenza(tr_l->cadenza()->on_b_);
- } else if (tr_l->measuregrouping()) {
- *default_grouping = parse_grouping(
- tr_l->measuregrouping()->beat_i_arr_,
- tr_l->measuregrouping()->elt_length_arr_);
- }
- }
- time_.OK();
-}
-
-void
-Staff_walker::operator++(int i)
-{
- Moment last = when();
-
- do_pre_move();
- PCursor<Staff_column*>::operator++(i);
- if (ok() ) {
- Moment delta_t = when() - last;
- assert(delta_t >0);
- time_.add( delta_t );
- }
- do_post_move();
-}
-
-void
-Staff_walker::process()
-{
- process_timing_reqs();
- process_requests();
-}
-
-void
-Staff_walker::allow_break()
-{
- score_walk_l_->allow_break(this);
-}
-
+++ /dev/null
-#include "staff.hh"
-#include "score.hh"
-#include "voice.hh"
-#include "staff-walker.hh"
-#include "staff-column.hh"
-#include "score-column.hh"
-#include "voice-element.hh"
-#include "debug.hh"
-#include "musicalrequest.hh"
-#include "commandrequest.hh" // todo
-#include "midi-stream.hh"
-
-void
-Staff::add(PointerList<Voice*> const &l)
-{
- for (iter_top(l,i); i.ok(); i++)
- voice_list_.bottom().add(i);
-}
-
-Paper_def *
-Staff::paper() const
-{
- return score_l_->paper_p_;
-}
-
-void
-Staff::clean_cols()
-{
- iter_top(cols_,i);
- for(; i.ok(); ){
- if (!i->musical_column_l_->used_b())
- i->musical_column_l_ = 0;
- if (!i->command_column_l_->used_b())
- i->command_column_l_ =0;
-
- if (!i->command_column_l_&& !i->musical_column_l_)
- delete i.get_p();
- else
- i++;
- }
-}
-
-Staff_column *
-Staff::get_col(Moment w, PCursor<Staff_column*> *last)
-{
- iter_top(cols_,i);
- if (last && last->ok() && (*last)->when() <= w)
- i = *last;
-
- for (; i.ok(); i++) {
- if (i->when() == w) {
- if (last)
- *last = i;
- return i;
- } else if (i->when() > w)
- break;
- }
-
-
- PCursor<Score_column*> scorecolumns(score_l_->find_col(w, false));
- Staff_column* staffcolumn_p = new Staff_column;
- staffcolumn_p->staff_l_ = this;
- Score_column* comcol_l = scorecolumns++;
- staffcolumn_p->set_cols(comcol_l, scorecolumns);
-
- if (!i.ok()) {
- cols_.bottom().add( staffcolumn_p);
- i = cols_.bottom();
- } else {
- i.insert(staffcolumn_p);
- i--;
- }
- if (last)
- *last = i;
- return i;
-}
-
-/**
- put all stuff grouped vertically in the Staff_cols.
- Do the preprarations for walking the cols. not virtual
- */
-void
-Staff::setup_staffcols()
-{
- for (iter_top(voice_list_,i); i.ok(); i++) {
- PCursor<Staff_column*> last(cols_);
- Moment now = i->start;
- for (iter_top(i->elts,j); j.ok(); j++) {
-
- Staff_column *s_l= get_col(now, &last);
- assert(now == s_l->when());
- s_l->add(j);
- now += j->duration;
- }
-
- }
- OK();
-}
-
-void
-Staff::OK() const
-{
-#ifndef NDEBUG
- cols_.OK();
- voice_list_.OK();
- iter_top(cols_, i);
- iter_top(cols_, j);
- i++;
- for (; i.ok(); j++,i++) {
- assert(j->when () < i->when() );
- }
- assert(score_l_);
-#endif
-}
-
-
-Moment
-Staff::last() const
-{
- Moment l = 0;
- for (iter_top(voice_list_,i); i.ok(); i++) {
- l = l >? i->last();
- }
- return l;
-}
-
-void
-Staff::print() const
-{
-#ifndef NPRINT
- mtor << "Staff {\n";
- for (iter_top(voice_list_,i); i.ok(); i++) {
- i->print();
- }
- mtor <<"}\n";
-#endif
-}
-
-Staff::Staff()
-{
- score_l_ =0;
- pscore_l_ =0;
- pstaff_l_ =0;
-}
+++ /dev/null
-#include "staffline.hh"
-#include "scoreline.hh"
-#include "dimen.hh"
-#include "spanner.hh"
-#include "symbol.hh"
-#include "paper-def.hh"
-#include "molecule.hh"
-#include "pcol.hh"
-#include "pscore.hh"
-
-static String
-make_vbox(Interval i)
-{
- Real r = (i.empty()) ? 0.0 : i.length();
- String s("\\vbox to ");
- s += print_dimen(r);
- s += "{\\vskip "+print_dimen(i.right)+" ";
- return s;
-}
-
-
-String
-Line_of_staff::TeXstring() const
-{
- String s("%line_of_staff\n");
-
- s+=make_vbox(height());
- // the staff itself: eg lines, accolades
- s += "\\hbox{";
- {
- iter_top(line_of_score_l_->cols,cc);
- Real lastpos=cc->hpos;
-
- // all items in the current line & staff.
- for (; cc.ok(); cc++) {
- Real delta=cc->hpos - lastpos;
- lastpos = cc->hpos;
-
- // moveover
- if (delta)
- s +=String( "\\kern ") + print_dimen(delta);
-
- // now output the items.
- for (iter_top(cc->its,i); i.ok(); i++) {
- if (i->pstaff_l_ == pstaff_l_)
- s += i->TeXstring();
- }
- // spanners.
- for (iter_top(cc->starters,i); i.ok(); i++)
- if (i->pstaff_l_ == pstaff_l_)
- s += i->TeXstring();
- }
- }
- s+="\\hss}\\vss}";
- return s;
-}
-
-Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
-{
- line_of_score_l_=sc;
- pstaff_l_=st;
-
- PCol *linestart = sc->cols.top();
- PCol *linestop = sc->cols.bottom();
-
- for (iter_top(pstaff_l_->spans,i); i.ok(); i++) {
- PCol *brokenstart = &max(*linestart, *i->left);
- PCol *brokenstop = &min(*linestop, *i->right);
- if ( *brokenstart < *brokenstop) {
- Spanner*span_p =i->broken_at(brokenstart,brokenstop);
- line_of_score_l_->pscore_l_-> // higghl
- add_broken(span_p);
- }
- }
-}
-
-
-Interval
-Line_of_staff::height() const
-{
- Interval y(0,0);
-
- iter_top(line_of_score_l_->cols,cc);
-
- // all items in the current line & staff.
- for (; cc.ok(); cc++) {
- for (iter_top(cc->its,i); i.ok(); i++) {
- if (i->pstaff_l_ == pstaff_l_)
- y.unite(i->height());
-
- }
- // spanners.
- for (iter_top(cc->starters,i); i.ok(); i++)
- if (i->pstaff_l_ == pstaff_l_) {
- y.unite(i->height());
- }
- }
-
- return y;
-}
-
-void
-Line_of_staff::process()
-{
-#if 0
- if (!pstaff_l_->stafsym_p_)
- pstaff_l_->brew_molecule_p(line_of_score_l_->pscore_l_->
- paper_l_->linewidth);
-#endif
-}
+++ /dev/null
-/*
- staffsym.cc -- implement Staff_symbol
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "staffsym.hh"
-#include "lookup.hh"
-#include "paper-def.hh"
-#include "debug.hh"
-
-
-
-Staff_symbol::Staff_symbol(int l)
-{
- no_lines_i_ = l;
-}
-
-void
-Staff_symbol::do_print()const
-{
- mtor << "lines: " << no_lines_i_;
-}
-
-Molecule*
-Staff_symbol::brew_molecule_p() const
-{
- Atom a = paper()->lookup_p_->linestaff(no_lines_i_, width().length());
- return new Molecule(a);
-}
-
-Spanner*
-Staff_symbol::do_break_at(PCol*p1, PCol*p2)const
-{
- Staff_symbol *span_p=new Staff_symbol(*this);
- return span_p;
-}
-
-void
-Staff_symbol::set_extent(PCol*p1, PCol*p2)
-{
- assert(p1&&p2);
- left = p1;
- right = p2;
-}
+++ /dev/null
-/*
- stem-beam-reg.cc -- part of LilyPond
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "musicalrequest.hh"
-#include "stem-beam-reg.hh"
-#include "beam.hh"
-#include "stem.hh"
-#include "grouping.hh"
-#include "textspanner.hh"
-#include "complex-walker.hh"
-#include "complex-staff.hh"
-#include "debug.hh"
-#include "grouping.hh"
-#include "notehead.hh"
-
-Stem_beam_register::Stem_beam_register()
-{
- post_move_processing();
- current_grouping = 0;
- beam_p_ = 0;
- set_feature(Features::dir(0));
- start_req_l_ = 0;
-}
-
-bool
-Stem_beam_register::try_request(Request*req_l)
-{
- if ( req_l->beam() ) {
- if (bool(beam_p_ ) == bool(req_l->beam()->spantype == Span_req::START))
- return false;
-
- if (beam_req_l_ && Beam_req::compare(*beam_req_l_ , *req_l->beam()))
- return false;
-
- beam_req_l_ = req_l->beam();
- return true;
- }
-
- if ( req_l->stem() ) {
- if (current_grouping && !current_grouping->child_fit_query(
- get_staff_info().time_c_l_->whole_in_measure_))
- return false;
-
- if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem()))
- return false;
-
- stem_req_l_ = req_l->stem();
- return true;
- }
- return false;
-}
-
-void
-Stem_beam_register::process_requests()
-{
- if (beam_req_l_) {
- if (beam_req_l_->spantype == Span_req::STOP) {
- end_beam_b_ = true;
- start_req_l_ = 0;
- } else {
- beam_p_ = new Beam;
- start_req_l_ = beam_req_l_;
-
- current_grouping = new Rhythmic_grouping;
- if (beam_req_l_->nplet) {
- Text_spanner* t = new Text_spanner();
- t->set_support(beam_p_);
- t->spec.align_i_ = 0;
- t->spec.text_str_ = beam_req_l_->nplet;
- t->spec.style_str_="italic";
- typeset_element(t);
- }
-
- }
- }
-
- if (stem_req_l_) {
- stem_p_ = new Stem(4);
- if (current_grouping)
- current_grouping->add_child(
- get_staff_info().time_c_l_->whole_in_measure_,
- stem_req_l_->duration());
-
- stem_p_->flag = stem_req_l_->balltype;
-
- if (beam_p_) {
- if (stem_req_l_->balltype<= 4)
- warning( "stem doesn't fit in Beam",
- stem_req_l_->defined_ch_c_l_);
- else
- beam_p_->add(stem_p_);
- stem_p_->print_flag = false;
- } else {
- stem_p_->print_flag = true;
- }
-
- announce_element(Staff_elem_info(stem_p_, stem_req_l_));
- }
-}
-
-void
-Stem_beam_register::acknowledge_element(Staff_elem_info info)
-{
- if (!stem_p_)
- return;
-
- if (info.elem_p_->name() == Notehead::static_name() &&
- stem_req_l_->duration() == info.req_l_->rhythmic()->duration())
-
- stem_p_->add((Notehead*)info.elem_p_);
-}
-
-void
-Stem_beam_register::pre_move_processing()
-{
- if (stem_p_) {
- if (default_dir_i_)
- stem_p_->dir = default_dir_i_;
-
- typeset_element(stem_p_);
- stem_p_ = 0;
- }
- if (beam_p_ && end_beam_b_) {
- const Rhythmic_grouping * rg_c_l = get_staff_info().rhythmic_c_l_;
- rg_c_l->extend(current_grouping->interval());
- beam_p_->set_grouping(*rg_c_l, *current_grouping);
- typeset_element(beam_p_);
- delete current_grouping;
- current_grouping = 0;
- beam_p_ = 0;
- }
- end_beam_b_ = false;
-}
-void
-Stem_beam_register::post_move_processing()
-{
- stem_p_ = 0;
- beam_req_l_ = 0;
- stem_req_l_ = 0;
- end_beam_b_ = false;
-}
-
-Stem_beam_register::~Stem_beam_register()
-{
- if (beam_p_)
- warning("unterminated beam", start_req_l_->defined_ch_c_l_);
-}
-
-void
-Stem_beam_register::set_feature(Features i)
-{
- default_dir_i_ = i.direction_i_;
-}
+++ /dev/null
-#include "stem.hh"
-#include "dimen.hh"
-#include "debug.hh"
-#include "paper-def.hh"
-#include "notehead.hh"
-#include "lookup.hh"
-#include "molecule.hh"
-#include "pcol.hh"
-#include "misc.hh"
-
-const int STEMLEN=7;
-
-
-Stem::Stem(int c) //, Moment len)
-{
- beams_left = 0;
- beams_right = 0;
- minnote = 1000; // invalid values
- maxnote = -1000;
- bot = top = 0;
- flag = 4;
- dir =0;
- staff_center=c;
- stemlen=0;
- print_flag=true;
- stem_xoffset=0;
-}
-
-void
-Stem::do_print() const
-{
-#ifndef NPRINT
- mtor << "flag "<< flag << " print_flag " << print_flag
- << "min,max [" << minnote << ", " << maxnote << "]";
-#endif
-}
-void
-Stem::set_stemend(Real se)
-{
-
- // todo: margins
- if (! ((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)) )
- warning("Weird stem size; check for narrow beams",0);
-
- top = (dir < 0) ? maxnote : se;
- bot = (dir < 0) ? se : minnote;
- flag = dir*abs(flag);
-}
-
-void
-Stem::add(Notehead *n)
-{
- assert(status < PRECALCED);
-
- if (n->balltype == 1)
- return;
- int p = n->position;
- if (p < minnote)
- minnote = p;
- if (p > maxnote)
- maxnote = p;
- heads.push(n);
- n->add_dependency(this);
-}
-
-
-int
-Stem::get_default_dir()
-{
- if (dir)
- return dir;
- Real mean = (minnote+maxnote)/2;
- return (mean > staff_center) ? -1: 1;
-}
-
-void
-Stem::set_default_dir()
-{
- dir = get_default_dir();
-}
-
-void
-Stem::set_default_stemlen()
-{
- if (!dir)
- set_default_dir();
-
- int stafftop = 2*staff_center;
- stemlen = STEMLEN + (maxnote - minnote);
-
- // uhh... how about non 5-line staffs?
- if (maxnote < -2 && dir == 1){
- int t = staff_center - staff_center/2;
- stemlen = t - minnote +2;
- } else if (minnote > stafftop + 2 && dir == -1) {
- int t = staff_center + staff_center/2;
- stemlen = maxnote -t +2;
- }
-
- assert(stemlen);
-}
-
-
-void
-Stem::set_default_extents()
-{
- if (minnote > maxnote) {
- warning("Empty stem. Ugh!", 0);
- minnote = -10;
- maxnote = 20;
- }
-
- if (!stemlen)
- set_default_stemlen();
-
- set_stemend((dir< 0) ? maxnote-stemlen: minnote +stemlen);
- if (dir > 0){
- stem_xoffset = paper()->note_width()-paper()->rule_thickness();
- } else
- stem_xoffset = 0;
-}
-
-void
-Stem::set_noteheads()
-{
- if(!heads.size())
- return;
- heads.sort(Notehead::compare);
- heads[0]->extremal = -1;
- heads.top()->extremal = 1;
- int parity=1;
- int lastpos = heads[0]->position;
- for (int i=1; i < heads.size(); i ++) {
- int dy =abs(lastpos- heads[i]->position);
-
- if (dy <= 1) {
- if (parity)
- heads[i]->x_dir = (stem_xoffset>0) ? 1:-1;
- parity = !parity;
- } else
- parity = 0;
- lastpos = heads[i]->position;
- }
-}
-
-void
-Stem::do_pre_processing()
-{
- if (bot == top)
- set_default_extents();
- set_noteheads();
-}
-
-
-Interval
-Stem::width()const
-{
- if (!print_flag || abs(flag) <= 4)
- return Interval(0,0); // TODO!
- Paper_def*p= paper();
- Interval r(p->lookup_p_->flag(flag).dim.x);
- r+= stem_xoffset;
- return r;
-}
-
-Molecule*
-Stem::brew_molecule_p()const return out;
-{
- assert(bot!=top);
-
-
- Paper_def *p =paper();
-
- Real dy = p->internote();
- Symbol ss =p->lookup_p_->stem(bot*dy,top*dy);
-
-
- out = new Molecule(Atom(ss));
-
- if (print_flag&&abs(flag) > 4){
- Symbol fl = p->lookup_p_->flag(flag);
- Molecule m(fl);
- if (flag < -4){
- out->add_bottom(m);
- } else if (flag > 4) {
- out->add_top(m);
- } else
- assert(false);
- }
-
- out->translate(Offset(stem_xoffset,0));
-}
-
-Real
-Stem::hindex()const
-{
- return pcol_l_->hpos + stem_xoffset; // hmm. + offset_.x;
-}
-
-
+++ /dev/null
-#include "symbol.hh"
-#include "varray.hh"
-
-
-Symbol::Symbol()
- : dim(Interval(0,0),Interval(0,0))
-{
- tex = "\\unknown";
-}
-Symbol::Symbol(String s, Box b)
- : dim(b)
-{
- tex = s;
-}
-
-
-String
-Symbol::str()const return s;
-{
- s = "symbol(\'"+tex+"\', (" + dim.x.str() + ", " + dim.y.str() + "))";
-}
+++ /dev/null
-#include "misc.hh"
-#include "dimen.hh"
-#include "debug.hh"
-#include "real.hh"
-#include "symbol.hh"
-#include "assoc.hh"
-#include "assoc-iter.hh"
-#include "symtable.hh"
-
-Symtables::Symtables()
-{
-}
-
-Symtables::Symtables(Symtables const &s)
-{
- for (Assoc_iter<String, Symtable*> i(s); i.ok(); i++) {
- add(i.key(), new Symtable(*i.val()));
- }
-}
-
-Symtables::~Symtables()
-{
- for (Assoc_iter<String, Symtable*> i(*this); i.ok(); i++) {
- delete i.val();
- }
-}
-
-Symbol
-Symtable::lookup(String s) const
-{
- if (elt_query(s))
- return (*this)[s];
- else {
- error( "Unknown symbol `" +s+"'\n");
- }
- Symbol sy; // unreachable
- return sy;
-}
-
-Symtable*
-Symtables::operator()(String s)
-{
- return Assoc<String, Symtable*>::operator[](s);
-}
-void
-Symtables::print() const
-{
- for (Assoc_iter<String, Symtable*> i(*this); i.ok(); i++) {
- mtor << "table \'" << i.key() << "\' {\n";
- i.val()->print();
- mtor << "}\n";
- }
-}
-void
-Symtable::print() const
-{
- for (Assoc_iter<String, Symbol> i(*this); i.ok(); i++) {
- mtor << "\'" << i.key() << "\'->" << i.val().str() << "\n";
- }
-}
-
+++ /dev/null
-#include "idealspacing.hh"
-#include "plist.hh"
-#include "pcol.hh"
-#include "item.hh"
-#include "musicalrequest.hh"
-#include "spanner.hh"
-#include "scoreline.hh"
-#include "staffline.hh"
-
-#include "pcursor.tcc"
-#include "plist.tcc"
-
-
-#define IPLC_instantiate(a) IPL_instantiate(a); PL_instantiate(const a)
-
-
-IPLC_instantiate(Line_of_score);
-IPLC_instantiate(Line_of_staff);
-IPLC_instantiate(Item);
-IPLC_instantiate(Spanner);
-IPLC_instantiate(PStaff);
-IPLC_instantiate(Idealspacing);
-IPLC_instantiate(PCol);
-
+++ /dev/null
-/*
- template2.cc -- instantiate some list templates.
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "symbol.hh"
-#include "voice.hh"
-#include "voice-element.hh"
-#include "musicalrequest.hh"
-#include "staff.hh"
-#include "score-column.hh"
-#include "staff-column.hh"
-#include "spanner.hh"
-#include "plist.tcc"
-#include "pcursor.tcc"
-
-IPL_instantiate(Request);
-IPL_instantiate(Score_column);
-IPL_instantiate(Staff_column);
-IPL_instantiate(Staff);
-IPL_instantiate(Voice_element);
-IPL_instantiate(Voice);
-
-
+++ /dev/null
-#include "request.hh"
-#include "input-score.hh"
-#include "input-staff.hh"
-#include "input-music.hh"
-#include "molecule.hh"
-#include "source-file.hh"
-#include "voice-element.hh"
-#include "plist.tcc"
-#include "pcursor.tcc"
-
-IPL_instantiate(Atom);
-IPL_instantiate(Atom);
-IPL_instantiate(Input_staff);
-IPL_instantiate(Input_music);
-IPL_instantiate(Source_file);
+++ /dev/null
-/*
- template4.cc -- instantiate PointerList baseclass.
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "proto.hh"
-#include "list.tcc"
-#include "cursor.tcc"
-
-L_instantiate(void *);
+++ /dev/null
-#include "proto.hh"
-#include "string.hh"
-#include "moment.hh"
-#include "real.hh"
-
-#include "interval.tcc"
-
-Interval__instantiate(Real);
-Interval__instantiate(Rational);
+++ /dev/null
-#include "proto.hh"
-#include "plist.tcc"
-#include "register.hh"
-#include "voice-group-regs.hh"
-#include "voice-regs.hh"
-
-
-IPL_instantiate(Voice_registers);
-IPL_instantiate(Voice_group_registers);
-IPL_instantiate(Request_register);
+++ /dev/null
-/*
- tex-stream.cc -- implement Tex_stream
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include <fstream.h>
-#include <time.h>
-
-#include "tex.hh"
-#include "main.hh"
-#include "tex-stream.hh"
-#include "debug.hh"
-
-Tex_stream::Tex_stream(String filename)
-{
- os = new ofstream(filename);
- if (!*os)
- error("can't open `" + filename+"\'");
- nest_level = 0;
- outputting_comment=false;
- header();
-}
-void
-Tex_stream::header()
-{
- *os << "% Creator: " << get_version();
- *os << "% Automatically generated, at ";
- time_t t(time(0));
- *os << ctime(&t);
-}
-Tex_stream::~Tex_stream()
-{
- delete os;
- assert(nest_level == 0);
-}
-
-// print string. don't forget indent.
-Tex_stream &
-Tex_stream::operator<<(String s)
-{
-
- for (const char *cp = s; *cp; cp++) {
- if (outputting_comment) {
- *os << *cp;
- if (*cp == '\n') {
- outputting_comment=false;
-
- }
- continue;
- }
- switch(*cp)
- {
- case '%':
- outputting_comment = true;
- *os << *cp;
- break;
- case '{':
- nest_level++;
- *os << *cp;
- break;
- case '}':
- nest_level--;
- *os << *cp;
-
- if (nest_level < 0) {
- delete os; // we want to see the remains.
- assert(nest_level>=0);
- }
- /* FALLTHROUGH */
-
- case '\n':
- *os << "%\n";
- *os << String(' ', nest_level);
- break;
- default:
- *os << *cp;
- break;
- }
- }
- return *this;
-}
-
-
-/* *************************************************************** */
+++ /dev/null
-#include "dimen.hh"
-#include "tex.hh"
-#include "symbol.hh"
-#include "const.hh"
-#include "varray.hh"
-
-String
-vstrut(Real h)
-{
- return String("\\vrule height ") + print_dimen(h) + "depth 0pt width 0pt";
-}
-
-
-static void
-substitute_arg(String& r, String arg)
-{
- int p = r.index_i('%');
- if (p < 0)
- return ;
-
- r = r.left_str(p) + arg + r.right_str(r.length_i() - p -1);
-}
-
-
-String
-substitute_args(String source, Array<String> args)
-{
- String retval (source);
- for (int i = 0 ; i < args.size(); i++)
- substitute_arg(retval, args[i]);
- while (retval.index_i('%') >= 0)
- substitute_arg(retval, "");
- return retval;
-}
-
-String
-substitute_args(String source, Array<Scalar> args)
-{
- Array<String> sv;
- for (int i = 0 ; i < args.size(); i++)
- sv.push(args[i]);
-
- return substitute_args(source, sv);
-}
+++ /dev/null
-/*
-
- Code to generate beams for TeX
-
- */
-
-#include <math.h>
-#include "symbol.hh"
-#include "molecule.hh"
-#include "tex.hh"
-#include "symtable.hh"
-#include "dimen.hh"
-#include "debug.hh"
-#include "lookup.hh"
-
-Symbol
-Lookup::beam_element(int sidx, int widx, Real slope)
-{
- Symbol bs=(*symtables_)("beamslopes")->lookup("slope");
-
- Array<String> args;
- args.push(sidx);
- args.push(widx);
- bs.tex = substitute_args(bs.tex,args);
- int w = 2 << widx;
- Real width = w PT;
- bs.dim.x = Interval(0,width);
- bs.dim.y = Interval(0,width*slope);
- return bs;
-}
-
-// ugh.. hard wired tex-code.
-static int
-slope_index(Real &s)
-{
- if (abs(s) > 0.5) {
- WARN << "beam steeper than 0.5 (" << s << ")\n";
- s = sign(s) * 0.5;
- }
-
- int i = int(rint(s * 20.0));
-
- s = i/20.0;
- if (s>0)
- return 6*i +122;
- else
- return -6 * i+ 186;
-}
-
-Symbol
-Lookup::rule_symbol(Real height, Real width)
-{
- Symbol bs=(*symtables_)("beamslopes")->lookup("horizontal");
- Array<String> args;
- args.push(print_dimen(height));
- args.push(print_dimen(width));
- bs.tex = substitute_args(bs.tex,args);
- bs.dim.x = Interval(0,width);
- bs.dim.y = Interval(0,height);
- return bs;
-}
-
-Symbol
-Lookup::beam(Real &slope, Real width)
-{
- int sidx = slope_index(slope);
- if (!slope)
- return rule_symbol(2 PT, width);
- if (width < 2 PT) {
- WARN<<"Beam too narrow. (" << print_dimen(width) <<")\n";
- width = 2 PT;
- }
- Real elemwidth = 64 PT;
- int widx = 5;
-
- Molecule m;
-
- while (elemwidth > width) {
- widx --;
- elemwidth /= 2.0;
- }
- Real overlap = elemwidth/4;
- Real last_x = width - elemwidth;
- Real x = overlap;
- Atom elem(beam_element(sidx, widx, slope));
- Atom a(elem);
- m.add(a);
- while (x < last_x) {
- a=elem;
- a.translate(Offset(x-overlap, (x-overlap)*slope));
- m.add(a);
- x += elemwidth - overlap;
- }
- a=elem;
- a.translate(Offset(last_x, (last_x) * slope));
- m.add(a);
-
- Symbol ret;
- ret.tex = m.TeXstring();
- ret.dim.y = Interval(0,width*slope);
- ret.dim.x = Interval(0,width);
-
- return ret;
-}
-
-
+++ /dev/null
-#include <math.h>
-#include "misc.hh"
-#include "lookup.hh"
-#include "molecule.hh"
-#include "dimen.hh"
-#include "debug.hh"
-
-static
-char direction_char(int y_sign)
-{
- char c='#';
- switch(y_sign){
- case -1:
- c = 'd';
- break;
- case 0:
- c = 'h';
- break;
- case 1:
- c = 'u';
- break;
- default:
- assert(false);
- }
- return c;
-}
-
-Symbol
-Lookup::half_slur_middlepart(Real &dx, int dir)
-{
- if (dx >= 400 PT) {// todo
- WARN<<"halfslur too large" <<print_dimen(dx)<< "shrinking (ugh)\n";
- dx = 400 PT;
- }
- int widx = int(floor(dx / 4.0));
- dx = widx * 4.0;
- if (widx) widx --;
- else {
- WARN << "slur too narrow\n";
- }
-
- Symbol s;
-
- s.dim.y = Interval(min(0,0), max(0,0)); // todo
- s.dim.x = Interval(0,dx);
-
- String f = String("\\hslurchar");
- f += direction_char(0);
-
- int idx = widx;
- if (dir < 0)
- idx += 128;
-
-
- f+=String( "{" ) + String( idx ) + "}";
- s.tex = f;
- Atom a(s);
- a.translate(Offset(dx/2,0));
- s.tex = a.TeXstring();
-
- return s;
-}
-Symbol
-Lookup::half_slur(int dy, Real &dx, int dir, int xpart)
-{
- Real orig_dx = dx;
- if (!xpart)
- return half_slur_middlepart(dx, dir);
-
- int widx;
-
- if (dx >= 96 PT) {
- WARN << "Slur half too wide." << print_dimen(orig_dx) << " shrinking (ugh)\n";
- dx = 96 PT;
- }
-
- widx = int(rint(dx/12.0));
- dx = widx*12.0;
- if (widx)
- widx --;
- else {
- WARN << "slur too narrow " << print_dimen(orig_dx)<<"\n";
- }
-
- Symbol s;
- s.dim.x = Interval(0,dx);
- s.dim.y = Interval(min(0,dy), max(0,dy));
-
-
- String f = String("\\hslurchar");
-
- f+= direction_char(dir);
-
- int hidx = dy;
- if (hidx <0)
- hidx = -hidx;
- hidx --;
- int idx =-1;
-
-
- idx = widx * 16 + hidx;
- if (xpart < 0)
- idx += 128;
-
- f+=String( "{" ) + String( idx ) + "}";
-
-
- s.tex = f;
-
- return s;
-}
-
-Symbol
-Lookup::slur (int dy , Real &dx, int dir)
-{
- assert(dx >=0 && abs(dir) <= 1);
- int y_sign = sign(dy);
-
- bool large = dy > 16;
-
- if (y_sign) {
- large |= dx>= 4*16 PT;
- } else
- large |= dx>= 4*54 PT;
-
- if (large) {
- return big_slur(dy, dx, dir);
- }
- Real orig_dx = dx;
- int widx = int(floor(dx/4.0)); // slurs better too small..
- dx = 4.0 * widx;
- if (widx)
- widx --;
- else {
- WARN << "slur too narrow: " << print_dimen(orig_dx) << "\n";
- }
-
- int hidx = dy;
- if (hidx <0)
- hidx = -hidx;
- hidx --;
- if (hidx > 16) {
- WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
- }
-
- Symbol s;
- s.dim.x = Interval(0,dx);
- s.dim.y = Interval(min(0,dy), max(0,dy));
-
- String f = String("\\slurchar") + String( direction_char(y_sign) );
-
- int idx=-1;
- if (y_sign) {
- idx = hidx * 16 + widx;
- if (dir < 0)
- idx += 128;
- } else {
- if (dx >= 4*54 PT) {
- WARN << "slur too wide: " << print_dimen(dx) <<
- " shrinking (ugh)\n";
- dx = 4*54 PT;
- }
- idx = widx;
- if (dir < 0)
- idx += 54;
- }
-
- f+=String( "{" ) + String( idx ) + "}";
- s.tex = f;
-
- Atom a(s);
- a.translate(Offset(dx/2,0));
- s.dim = a.extent();
- s.tex = a.TeXstring();
- return s;
-}
-
-Symbol
-Lookup::big_slur(int dy , Real &dx, int dir)
-{
- assert(dx >= 24 PT);
- Real slur_extra =abs(dy) /2.0 + 2;
- int l_dy = int(Real (dy)/2 + slur_extra*dir);
- int r_dy = dy - l_dy;
-
- Real left_wid = dx/4.0;
- Real right_wid = left_wid;
-
- Atom l = half_slur(l_dy, left_wid, dir, -1);
- Atom r = half_slur(r_dy, right_wid, dir, 1);
- Real mid_wid = dx - left_wid - right_wid;
-
- Atom m = half_slur(0, mid_wid, dir, 0);
-
- Molecule mol;
- mol.add(l);
- Atom a(m);
- a.translate(Offset(0,slur_extra * internote()));
- mol.add_right(m);
- mol.add_right(r);
- mol.translate(Offset(0, l_dy * internote()));
- Symbol s;
- s.tex = mol.TeXstring();
- s.dim = mol.extent();
- return s;
-}
-
-
+++ /dev/null
-#include "debug.hh"
-#include "lookup.hh"
-#include "paper-def.hh"
-#include "molecule.hh"
-#include "text-def.hh"
-
-Text_def::Text_def()
-{
- align_i_ = 1; // right
- style_str_ = "roman";
- defined_ch_c_l_ = 0;
-}
-bool
-Text_def::compare(const Text_def&def)
-{
- return align_i_ == def.align_i_ && text_str_ == def.text_str_
- && style_str_ == def.style_str_;
-}
-
-Atom
-Text_def::create_atom(Paper_def*p) const
-{
- return p->lookup_p_->text(style_str_, text_str_, -align_i_);
-}
-
-void
-Text_def::print() const
-{
- mtor << "Text `" << text_str_ << "\', style " <<
- style_str_ << "align " << align_i_ << '\n';
-}
+++ /dev/null
-/*
- text-reg.cc -- implement Text_register
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "musicalrequest.hh"
-#include "text-reg.hh"
-#include "textitem.hh"
-
-Text_register::Text_register()
-{
- text_p_ = 0;
- set_feature(Features::dir(0));
- post_move_processing();
-}
-
-bool
-Text_register::try_request(Request*req_l)
-{
- if (!req_l->text())
- return false;
- if (text_req_l_ &&
- Text_req::compare(*req_l->text(), *text_req_l_))
-
- return false;
-
- text_req_l_ = req_l->text();
- return true;
-}
-
-void
-Text_register::process_requests()
-{
-
- if (text_req_l_) {
- text_p_ = new Text_item(text_req_l_, 10); // UGH
- announce_element(Staff_elem_info(text_p_, text_req_l_));
- }
-}
-void
-Text_register::pre_move_processing()
-{
- if (text_p_) {
- text_p_->dir_i_ = dir_i_;
- typeset_element(text_p_);
- text_p_ = 0;
- }
-}
-void
-Text_register::set_feature(Features i)
-{
- dir_i_ = i.direction_i_;
-}
-void
-Text_register::post_move_processing()
-{
- text_req_l_ = 0;
-}
+++ /dev/null
-/*
- textitem.cc -- implement Text_item
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-
- #include "musicalrequest.hh"
-#include "paper-def.hh"
-#include "textitem.hh"
-#include "stem.hh"
-#include "molecule.hh"
-#include "lookup.hh"
-
-
-
-Text_item::Text_item(Text_req* treq_l, int staffsize_i)
-{
- staffsize_i_ = staffsize_i;
- dir_i_ = treq_l->dir_i_;
- if (!dir_i_)
- dir_i_ = -1;
- tdef_l_ = treq_l->tdef_p_;
-}
-
-void
-Text_item::set_default_index()
-{
- pos_i_ = (dir_i_ > 0) ? staffsize_i_ + 2: -4;
-}
-
-void
-Text_item::do_pre_processing()
-{
- set_default_index();
-}
-
-
-Molecule*
-Text_item::brew_molecule_p() const
-{
- Molecule* mol_p = new Molecule(tdef_l_->create_atom(paper()));
- mol_p->translate(Offset(0, pos_i_ * paper()->internote()));
-
- if(dir_i_<0)
- mol_p->translate(Offset(0, -mol_p->extent().y.length() ));
-
- return mol_p;
-}
+++ /dev/null
-#include "molecule.hh"
-#include "boxes.hh"
-#include "textspanner.hh"
-#include "text-def.hh"
-#include "debug.hh"
-#include "paper-def.hh"
-
-
-
-void
-Text_spanner::set_support(Directional_spanner*d)
-{
- support = d;
- add_dependency(d);
-}
-
-Text_spanner::Text_spanner()
-{
- support = 0;
-}
-
-void
-Text_spanner::do_print() const
-{
- spec.print();
-}
-
-void
-Text_spanner::do_post_processing()
-{
- switch(spec.align_i_) {
- case 0:
- text_off_ = support->center() +
- Offset(0,support->dir_i_ * paper()->internote() * 4); // todo
- break;
- default:
- assert(false);
- break;
- }
-}
-
-Molecule*
-Text_spanner::brew_molecule_p() const
-{
- Atom tsym (spec.create_atom(paper()));
- tsym.translate(text_off_);
-
- Molecule*output = new Molecule;
- output->add( tsym );
- return output;
-}
-
-void
-Text_spanner::do_pre_processing()
-{
- right = support->right;
- left = support->left;
- assert(left && right);
-}
-
-Interval
-Text_spanner::height()const
-{
- return brew_molecule_p()->extent().y;
-}
-
-Spanner*
-Text_spanner::do_break_at(PCol*c1, PCol*c2)const
-{
- return new Text_spanner(*this); // todo
-}
+++ /dev/null
-/*
- time-description.cc -- implement Time_description
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "time-description.hh"
-#include "debug.hh"
-
-String
-Time_description::str()const
-{
- String s( "Time_description { ");
- if (cadenza_b_)
- s+=String( " (cadenza) ");
- s+= "at ";
- s+=when_;
- s+="\nmeter " + String(whole_per_measure_/one_beat_) +":" +
- String(Rational(Rational(1)/one_beat_));
- s+= "\nposition "+String( bars_i_) + ":"+ whole_in_measure_ +"\n}\n";
- return s;
-}
-
-void
-Time_description::print() const
-{
-#ifndef NPRINT
- mtor << str();
-#endif
-}
-void
-Time_description::OK() const
-{
-#ifndef NDEBUG
- if (!cadenza_b_)
- assert(whole_in_measure_ < whole_per_measure_);
- assert(0 <= whole_in_measure_);
- assert(one_beat_);
-#endif
-}
-
-void
-Time_description::set_cadenza(bool b)
-{
- if (cadenza_b_ && !b) {
- if (whole_in_measure_) {
- bars_i_ ++;
- whole_in_measure_ = 0;
- }
- }
- cadenza_b_ = b ;
-}
-
-Time_description::Time_description()
-{
- whole_per_measure_ = 1;
- whole_in_measure_ =0;
- one_beat_ = Moment(1,4);
- when_ = 0;
- bars_i_ = 0;
- cadenza_b_ = false;
-}
-
-void
-Time_description::add(Moment dt)
-{
- assert(dt >= Rational(0));
- when_ += dt;
- whole_in_measure_ += dt;
-
- while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_ ) {
- whole_in_measure_ -= whole_per_measure_;
- bars_i_ ++;
- }
-}
-
-void
-Time_description::set_meter(int l, int o)
-{
- assert(o);
- one_beat_ = Rational(1)/Moment(o);
- whole_per_measure_ = Moment(l) * one_beat_;
- if(whole_in_measure_)
- error_t("Meterchange should be at start of measure", *this);
-}
-
-void
-Time_description::setpartial(Moment p)
-{
- if (when_)
- error_t ("Partial measure only allowed at beginning.", *this);
- if (p<Rational(0)||p > whole_per_measure_)
- error_t ("Partial measure has incorrect size", *this);
- whole_in_measure_ = whole_per_measure_ - p;
-}
-
-Moment
-Time_description::barleft()
-{
- assert(!cadenza_b_);
- return whole_per_measure_-whole_in_measure_;
-}
-
-int
-Time_description::compare(Time_description &t1, Time_description&t2)
-{
- int i = sign(t1.when_-t2.when_);
-
- if (!i) {
- assert(t1.bars_i_==t2.bars_i_);
- assert(t1.one_beat_ == t2.one_beat_);
- assert(t1.whole_in_measure_ == t2.whole_in_measure_);
- assert(t1.whole_per_measure_ == t2.whole_per_measure_);
- }
-
- return i;
-}
+++ /dev/null
-//
-// track-column.cc -- implement Track_column
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-
-#include "proto.hh"
-#include "plist.hh"
-#include "string.hh"
-#include "moment.hh"
-#include "duration.hh"
-#include "midi-event.hh"
-#include "lily-stream.hh"
-#include "track-column.hh"
-#include "midi-track.hh"
-
-Track_column::Track_column( Moment mom )
-{
- mom_ = mom;
-}
-
-Track_column::~Track_column()
-{
-}
-
-void
-Track_column::add_event( Midi_event* midi_event_p )
-{
- midi_event_p_list_.bottom().add( midi_event_p );
-}
-
-Moment
-Track_column::mom()
-{
- return mom_;
-}
+++ /dev/null
-#include "version.hh"
-#include "fversion.hh"
-
-static char *s = "LilyPond " VERSIONSTR "/FlowerLib " FVERSIONSTR
-". Compile: " __DATE__ ", " __TIME__ " (" COMPILER ")\n";
-
-const char *
-get_version()
-{
- return s;
-}
+++ /dev/null
-/*
- voicegroup.cc -- implement Voice_group_registers
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "plist.hh"
-#include "musicalrequest.hh"
-#include "voice-regs.hh"
-#include "voice-group-regs.hh"
-#include "register.hh"
-#include "text-reg.hh"
-#include "stem-beam-reg.hh"
-#include "script-reg.hh"
-#include "complex-walker.hh"
-#include "commandrequest.hh"
-#include "debug.hh"
-
-static int temp_id_count;
-
-Voice_group_registers::Voice_group_registers(String id)
-{
- add(new Text_register);
- add(new Stem_beam_register);
- add(new Script_register);
-
- if (id=="") // UGH
- id = __FUNCTION__ + String(temp_id_count++);
- group_id_str_ = id;
-}
-
-bool
-Voice_group_registers::try_request(Request*r_l)
-{
- for (int i=0; i < voice_regs_l_.size(); i++) {
- if (voice_regs_l_[i]->voice_l_ == r_l->voice_l())
- goto gotcha;
- }
- return false;
-gotcha:
- if (r_l->groupfeature()) {
- set_feature(Features::dir(r_l->groupfeature()->stemdir_i_));
- return true;
- }
- return Register_group_register::try_request(r_l);
-}
-
-
-bool
-Voice_group_registers::static_acceptable_request_b(Request*r)
-{
- return (r->stem() || r->beam() || r->text() || r->script() ||
- r->groupfeature());
-}
-
-void
-Voice_group_registers::terminate_register(Request_register*r_l)
-{
- if (r_l->name() == Voice_registers::static_name()) {
- for (int i=0; i <voice_regs_l_.size(); i++) {
- if (r_l == voice_regs_l_[i])
- voice_regs_l_.del(i);
- Register_group_register::terminate_register(r_l);
- return;
- }
- }
- assert(false);
-}
-void
-Voice_group_registers::do_print() const
-{
-#ifndef NPRINT
- mtor << "ID: " << group_id_str_<<"\n";
- Register_group_register::do_print();
-#endif
-}
-void
-Voice_group_registers::add(Request_register*r_l)
-{
- Register_group_register::add(r_l);
- if (r_l->name() == Voice_registers::static_name())
- voice_regs_l_.push( (Voice_registers*)r_l );
-}
+++ /dev/null
-/*
- voice-regs.cc -- implement Voice_registers
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-#include "commandrequest.hh"
-#include "musicalrequest.hh"
-#include "voice-regs.hh"
-#include "register.hh"
-#include "slur-reg.hh"
-#include "headreg.hh"
-#include "walkregs.hh"
-#include "debug.hh"
-
-Voice_registers::Voice_registers(Voice *v_p)
-{
- voice_l_ = v_p;
- add(new Notehead_register);
- add(new Slur_register);
-}
-
-void
-Voice_registers::acknowledge_element(Staff_elem_info i)
-{
- if (i.voice_l_ != voice_l_)
- return;
- Register_group_register::acknowledge_element(i);
-}
-
-bool
-Voice_registers::try_request(Request*r_l)
-{
- if (r_l->voice_l() !=voice_l_)
- return false;
-
- Command_req *c=r_l->command();
- if (c&&c->terminate()) {
- daddy_reg_l_->terminate_register(this);
- return true; // scary. We're deleted now..
- } else if (c&&c->groupchange()) {
-
- ((Walker_registers*)daddy_reg_l_->daddy_reg_l_)-> // scary.
- change_group(c->groupchange(), this,
- (Voice_group_registers*)daddy_reg_l_); // UGR!
- return true;
- }
-
- return Register_group_register::try_request(r_l);
-}
-
-bool
-Voice_registers::acceptable_request_b(Request*r)
-{
-// return (r->rest() || r->note() || r->slur() || r->groupchange());
- return r->groupchange()
- || Register_group_register::acceptable_request_b(r);
-}
-void
-Voice_registers::do_print() const
-{
- mtor << "Voice= " << voice_l_<<'\n';
- Register_group_register::do_print();
-}
+++ /dev/null
-/*
- voice.cc -- implement Voice
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "voice.hh"
-#include "musicalrequest.hh"
-#include "commandrequest.hh"
-#include "midi-item.hh"
-#include "midi-stream.hh"
-#include "voice-element.hh"
-
-void
-Voice::set_default_group(String s)
-{
- elts.top()->set_default_group(s);
-}
-
-bool
-Voice::find_plet_start_bo(char c, Moment& moment_r)
-{
- for (iter_bot(elts, i); i.ok(); i--)
- if ( i->find_plet_start_bo(c, moment_r) )
- return true;
- return false;
-}
-
-void
-Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment,
- int num_i, int den_i)
-{
- for (iter_bot(elts, i); i.ok(); i--)
- if ( now_moment_r <= until_moment )
- i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
- else
- return;
-}
-
-Voice::Voice(Voice const&src)
-{
- for (iter_top(src.elts, i); i.ok(); i++)
- add(new Voice_element(**i));
-
- start = src.start;
-}
-
-Voice::Voice()
-{
- start = 0;
-}
-
-void
-Voice::add(Voice_element*v)
-{
- v->voice_l_ = this;
- elts.bottom().add(v);
-}
-
-void
-Voice::print() const
-{
-#ifndef NPRINT
- mtor << "Voice { start: "<< start<<eol;
- for (iter_top(elts,i); i.ok(); i++)
- i->print();
- mtor << "}\n";
-#endif
-}
-
-Moment
-Voice::last() const
-{
- Moment l =0;
- if (elts.size())
- l = start;
-
- for (iter_top(elts,i); i.ok(); i++)
- l += i->duration;
- return l;
-}
-
+++ /dev/null
-/*
- voiceelt.cc -- implement Voice_element
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "voice.hh"
-#include "voice-element.hh"
-#include "musicalrequest.hh"
-#include "commandrequest.hh"
-
-
-void
-Voice_element::print() const
-{
-#ifndef NPRINT
- mtor << "voice_element { dur :"<< duration <<"\n";
- for (iter_top(reqs,rc); rc.ok(); rc++) {
- rc->print();
- }
- mtor << "}\n";
-#endif
-}
-
-void
-Voice_element::add(Request*r)
-{
- if (r->duration()) {
- assert (!duration || duration == r->duration());
- duration = r->duration();
- }
-
- r->elt_l_ = this;
- reqs.bottom().add(r);
-}
-
-
-Voice_element::Voice_element()
-{
- voice_l_ = 0;
- duration = 0;
- defined_ch_c_l_ = 0;
-}
-
-Voice_element::Voice_element(Voice_element const&src)
-{
- defined_ch_c_l_ = src.defined_ch_c_l_;
-
- voice_l_=0;
- for (iter_top(src.reqs, i); i.ok(); i++)
- add(i->clone());
-
-}
-bool
-Voice_element::find_plet_start_bo(char c, Moment& moment_r)
-{
- assert( c == ']' );
- moment_r += duration;
- for ( PCursor<Request*> req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) {
- if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START )
- return true;
- }
- return false;
-}
-
-void
-Voice_element::set_default_group(String s)
-{
- for (iter_top(reqs, i); i.ok(); i++)
- if (i->groupchange())
- return ;
- Group_change_req *greq = new Group_change_req;
- greq->newgroup_str_ = s;
- add(greq);
-}
-
-void
-Voice_element::set_plet_backwards(Moment& now_moment_r,
- Moment until_moment, int num_i, int den_i)
-{
- now_moment_r += duration;
- if ( now_moment_r > until_moment )
- return;
- for ( PCursor<Request*> req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) {
- if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START )
- req_l_pcur->beam()->nplet = den_i;
- if (req_l_pcur->rhythmic())
- req_l_pcur->rhythmic()->plet_factor = Moment(num_i, den_i);
- if (req_l_pcur->stem())
- req_l_pcur->stem()->plet_factor = Moment(num_i, den_i);
- }
-}
+++ /dev/null
-/*
- walkregs.cc -- implement Walker_registers
-
- source file of the LilyPond music typesetter
-
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
-
-#include "debug.hh"
-#include "clef-reg.hh"
-#include "local-key-reg.hh"
-#include "key-reg.hh"
-#include "meter-reg.hh"
-#include "bar-reg.hh"
-#include "bar.hh"
-#include "walkregs.hh"
-#include "staff-elem.hh"
-#include "staff.hh"
-#include "complex-walker.hh"
-#include "staff-column.hh"
-#include "voice-group-regs.hh"
-#include "voice-regs.hh"
-#include "commandrequest.hh"
-
-
-Walker_registers::Walker_registers(Complex_walker *w)
-{
- walk_l_ = w;
- add( new Bar_register);
- add( new Clef_register);
- add( new Key_register);
- add( new Meter_register);
- add( new Local_key_register);
-}
-
-void
-Walker_registers::announce_element(Staff_elem_info info)
-{
- if (info.elem_p_->name() == Bar::static_name()) {
- walk_l_->allow_break();
- }
- announce_info_arr_.push(info);
-}
-
-void
-Walker_registers::acknowledge_element(Staff_elem_info )
-{
- assert(false);
-}
-
-void
-Walker_registers::do_announces()
-{
- Request dummy_req;
- for (int i = 0; i < announce_info_arr_.size(); i++){
- Staff_elem_info info = announce_info_arr_[i];
-
- if (!info.req_l_)
- info.req_l_ = &dummy_req;
- Register_group_register::acknowledge_element(info);
- }
- announce_info_arr_.set_size(0);
-}
-
-void
-Walker_registers::typeset_element(Staff_elem *elem_p)
-{
- typeset_musical_item(elem_p);
-}
-
-void
-Walker_registers::typeset_musical_item(Staff_elem * elem_p)
-{
- walk_l_->typeset_element(elem_p);
-}
-
-void
-Walker_registers::typeset_breakable_item(Item * pre_p , Item * nobreak_p,
- Item * post_p)
-{
- if (pre_p)
- prebreak_item_p_arr_.push(pre_p);
- if (nobreak_p)
- nobreak_item_p_arr_.push(nobreak_p);
- if (post_p)
- postbreak_item_p_arr_.push(post_p);
-}
-
-void
-Walker_registers::pre_move_processing()
-{
- // this generates all items.
- Register_group_register::pre_move_processing();
- walk_l_->ptr()->typeset_breakable_items(prebreak_item_p_arr_,
- nobreak_item_p_arr_,
- postbreak_item_p_arr_);
-}
-void
-Walker_registers::post_move_processing()
-{
- Register_group_register::post_move_processing();
-}
-
-void
-Walker_registers::change_group(Group_change_req * greq_l,
- Voice_registers *voice_regs_l,
- Voice_group_registers * old_group)
-{
- Voice_registers *regs_p = (old_group)
- ? (Voice_registers*) old_group->get_register_p(voice_regs_l)
- : new Voice_registers(greq_l->voice_l());
- Voice_group_registers * new_group_l = get_group(greq_l->newgroup_str_);
- new_group_l->add(regs_p);
-
- mtor << "processed change request";
- print();
-}
-
-Voice_group_registers *
-Walker_registers::get_group(String id)
-{
- for (int i=0; i < group_l_arr_.size(); i++) {
- if (group_l_arr_[i]->group_id_str_ == id)
- return group_l_arr_[i];
- }
- Voice_group_registers *group_p = new Voice_group_registers(id);
- group_l_arr_.push(group_p);
- add(group_p);
- return group_p;
-}
-
-void
-Walker_registers::terminate_register(Request_register * reg)
-{
- for (int i=0; i < group_l_arr_.size(); i++) {
- if (group_l_arr_[i] == reg) {
- group_l_arr_.del(i);
- Register_group_register::terminate_register(reg);
- return;
- }
- }
- assert(false);
-}
-
-bool
-Walker_registers::try_request(Request * r)
-{
- bool b = Register_group_register::try_request(r);
- if (!b) {
- Command_req * cr_l = r->command() ;
-
- if (cr_l && cr_l->groupchange()) {
- change_group(cr_l->groupchange(), 0, 0);
- } else
- warning("junking request: " + String(r->name()),
- r->defined_ch_c_l_);
- }
- return b;
-}
-
-
-Staff_info
-Walker_registers::get_staff_info() return inf;
-{
- inf.c0_position_i_ = &walk_l_->c0_position_i_;
- inf.walk_l_ = walk_l_;
- inf.time_c_l_ = &walk_l_->time_;
- inf.rhythmic_c_l_ = walk_l_->default_grouping;
-}
-Paper_def*
-Walker_registers::paper()const
-{
- return walk_l_->staff_l_->paper();
-}
+++ /dev/null
-#include "debug.hh"
-#include "lexer.hh"
-#include "moment.hh"
-#include "time-description.hh"
-#include "proto.hh"
-#include "plist.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "main.hh"
-
-ostream &warnout (cerr);
-ostream *mlog(&cerr);
-/*
-void
-warning(String s)
-{
- WARN << s;
-}
-*/
-
-void
-error(String s)
-{
- if (busy_parsing())
- yyerror(s);
- else
- cerr << "error: " << s << "\n";
-
- exit(1);
-}
-
-void
-error_t(const String& s, const Moment& r)
-{
- String t_mom = String(trunc(r)) + String(r - Moment(trunc(r)));
- String e=s+ " (t = " + t_mom + ")";
- error(e);
-}
-
-void
-error_t(const String& s, Time_description const &t_tdes)
-{
- String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n";
- error(e);
-}
-
-void
-message( String message_str, char const* context_ch_c_l )
-{
- String str = "lilypond: ";
- Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l );
- if ( sourcefile_l ) {
- str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
- }
- str += message_str;
- if ( sourcefile_l ) {
- str += ":\n";
- str += sourcefile_l->error_str( context_ch_c_l );
- }
- if ( busy_parsing() )
- cerr << endl;
- cerr << str << endl;
-}
-
-void
-warning( String message_str, char const* context_ch_c_l )
-{
- message( "warning: " + message_str, context_ch_c_l );
-}
-
-void
-error( String message_str, char const* context_ch_c_l )
-{
- message( message_str, context_ch_c_l );
- // since when exits error again?
- // i-d say: error: errorlevel |= 1; -> no output upon error
- // warning: recovery -> output (possibly wrong)
- if ( lexer )
- lexer->errorlevel_i_ |= 1;
-// exit( 1 );
-}
+++ /dev/null
-//
-// windhoos.cc
-//
-#ifdef _WIN32
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <winbase.h>
-
-/*
-HANDLE CreateFileMapping(
- HANDLE hFile, // handle to file to map
- LPSECURITY_ATTRIBUTES lpFileMappingAttributes, // optional security attributes
- DWORD flProtect, // protection for mapping object
- DWORD dwMaximumSizeHigh, // high-order 32 bits of object size
- DWORD dwMaximumSizeLow, // low-order 32 bits of object size
- LPCTSTR lpName // name of file-mapping object
- );
-
-
-LPVOID MapViewOfFile(
- HANDLE hFileMappingObject, // file-mapping object to map into address space
- DWORD dwDesiredAccess, // access mode
- DWORD dwFileOffsetHigh, // high-order 32 bits of file offset
- DWORD dwFileOffsetLow, // low-order 32 bits of file offset
- DWORD dwNumberOfBytesToMap // number of bytes to map
- );
-
-
-io.h:
-long _get_osfhandle( int filehandle );
-*/
-
-// cygnus's gnu-win32-b17.1 does not have _get_osfhandle
-// however, after some hacking, it turns out that:
-
-static const int OSF_OFFSET_i = 72;
-static const int OSF_BASE_i = -3;
-static const int OSF_FACTOR_i = 8;
-// let-s hope bill doesn-t change his mind any time soon :-)
-
-// so that, while waiting for cygnus's mmap, we can write:
-
-// #define HAVE_GET_OSFHANDLE // no we still cannot; works only with cl.exe
-long
-_get_osfhandle( int filedes_i )
-{
- return (long)( OSF_OFFSET_i + ( filedes_i + OSF_BASE_i ) * OSF_FACTOR_i );
-}
-
-#ifdef HAVE_GET_OSFHANDLE
-
-#include <iostream.h>
-
-caddr_t
-mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
-{
- (void)flags;
- (void)prot;
- (void)addr;
- HANDLE osf = (HANDLE)_get_osfhandle( fd );
- HANDLE file_handle = CreateFileMapping( osf, (void*)0, PAGE_READONLY,
- 0, len, 0 );
- return (caddr_t)MapViewOfFile( file_handle, FILE_MAP_READ, 0, offset, len );
-}
-
-
-int
-munmap(caddr_t addr, size_t len)
-{
- (void)len;
- return UnmapViewOfFile( addr );
-}
-
-#else // ! HAVE_GET_OSFHANDLE //
-
-caddr_t
-mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
-{
- (void)flags;
- (void)prot;
- (void)addr;
- (void)offset;
- char* ch_p = new char[ len ];
- if ( ch_p )
- read( fd, (void*)ch_p, len );
- return ch_p;
-}
-
-
-int
-munmap(caddr_t addr, size_t len)
-{
- (void)len;
- delete (char*)addr;
- return 0;
-}
-
-#endif // !HAVE_GET_OSFHANDLE //
-
-
-#endif // _WIN32 //
+++ /dev/null
-#include "break.hh"
-#include "pscore.hh"
-#include "debug.hh"
-
-/** el stupido. This should be done more accurately:
-
- It would be nice to have a Dynamic Programming type of algorithm
- similar to TeX's
-
- */
-Array<Col_hpositions>
-Word_wrap::solve()
-{
- problem_OK();
- iter_top(pscore_.cols,curcol);
- Array<Col_hpositions> breaking;
- Line_of_cols breakpoints(find_breaks());
- assert(breakpoints.size()>=2);
-
- int break_idx_i=0;
- while ( break_idx_i < breakpoints.size() -1) {
- Col_hpositions minimum;
- Col_hpositions current;
-
- // do another line
- PCol *post = breakpoints[break_idx_i]->postbreak_p_;
- current.add( post);
- curcol++; // skip the breakable.
- break_idx_i++;
-
- while (break_idx_i < breakpoints.size()) {
-
- // add another measure.
- while (breakpoints[break_idx_i] != curcol.ptr()){
- current.add(curcol);
- curcol++;
- }
- current.add(breakpoints[break_idx_i]->prebreak_p_ );
-
- // try to solve
- if (!feasible(current.cols)) {
- if (!minimum.cols.size())
- error("sorry, this measure is too long, breakpoint: "
- + String(break_idx_i) );
- current.energy = INFTY; // make sure we go back
- } else {
- current = solve_line(current.cols);
- current.print();
- }
-
- // update minimum, or backup.
- if (current.energy < minimum.energy) {
- minimum = current;
- } else { // we're one col too far.
- break_idx_i--;
- while (curcol.ptr() != breakpoints[break_idx_i])
- curcol --;
- break; // do the next line.
- }
-
-
- // add nobreak version of breakable column
- current.cols.top()=breakpoints[break_idx_i];
- curcol ++;
- break_idx_i++;
- }
-
- *mlog << "[" <<break_idx_i<<"]"<<flush;
- breaking.push(minimum);
- }
-
- return breaking;
-}
-
-Word_wrap::Word_wrap(PScore&ps)
- : Break_algorithm(ps)
-{
-}