--- /dev/null
+/*
+ pcursor.hh -- part of flowerlib
+
+ (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen
+*/
+
+#ifndef PCURSOR_HH
+#define PCURSOR_HH
+
+#include "plist.hh"
+#include "cursor.hh"
+
+/** cursor to go with PointerList.
+ don't create PointerList<void*>'s.
+ This cursor is just an interface class for Cursor. It takes care of the
+ appropriate type casts
+ */
+template<class T>
+class PCursor : private Cursor<void *> {
+ friend class IPointerList<T>;
+
+ /// delete contents
+ void junk();
+public:
+ Cursor<void*>::ok;
+ Cursor<void*>::del;
+ Cursor<void*>::backspace;
+ T remove_p() {
+ T p = ptr();
+ Cursor<void*>::del();
+ return p;
+ }
+ T remove_prev_p() {
+ assert( ok() );
+ (*this)--;
+ return remove_p();
+ }
+
+ PointerList<T> &list() { return (PointerList<T>&)Cursor<void*>::list(); }
+ PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);}
+ PCursor<T> operator--(int) { return Cursor<void*>::operator--(0); }
+ PCursor<T> operator+=(int i) { return Cursor<void*>::operator+=(i);}
+ PCursor<T> operator-=(int i) { return Cursor<void*>::operator-=(i); }
+ PCursor<T> operator -(int no) const { return Cursor<void*>::operator-(no);}
+ int operator -(PCursor<T> op) const { return Cursor<void*>::operator-(op);}
+ PCursor<T> operator +( int no) const {return Cursor<void*>::operator+(no);} PCursor(const PointerList<T> & l) : Cursor<void*> (l) {}
+
+ PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
+ void* vptr() const { return *((Cursor<void*> &) *this); }
+
+ // should return T& ?
+ T ptr() const { return (T) vptr(); }
+ T operator ->() const { return ptr(); }
+ operator T() { return ptr(); }
+ T operator *() { return ptr(); }
+ void add(const T& p ) { Cursor<void*>::add((void*) p); }
+ void insert(const T& p ) { Cursor<void*>::insert((void*) p);}
+ static int compare(PCursor<T> a,PCursor<T>b) {
+ return Cursor<void*>::compare(a,b);
+ }
+};
+
+
+
+#include "compare.hh"
+template_instantiate_compare(PCursor<T>, PCursor<T>::compare, template<class T>);
+
+#endif
--- /dev/null
+/*
+ list.hh -- part of flowerlib
+
+ (c) 1996 Han-Wen Nienhuys & Jan Nieuwenhuizen
+*/
+
+#ifndef PLIST_HH
+#define PLIST_HH
+
+#include "list.hh"
+
+/**
+ A list of pointers.
+
+ Use for list of pointers, e.g. PointerList<AbstractType*>.
+ This class does no deletion of the pointers, but it knows how to
+ copy itself (shallow copy). We could have derived it from List<T>,
+ but this design saves a lot of code dup; for all PointerLists in the
+ program only one parent List<void*> is instantiated.
+ */
+template<class T>
+class PointerList : public List<void *>
+{
+ public:
+ PCursor<T> top() const{
+ return PCursor<T> (List<void*>::top());
+ }
+ PCursor<T> bottom() const {
+ return PCursor<T> (List<void*>::bottom());
+ }
+ PCursor<T> find(T) const;
+ void concatenate(PointerList<T> const &s) { List<void*>::concatenate(s); }
+ PointerList() {}
+};
+
+/** PointerList which deletes pointers given to it.
+ NOTE:
+
+ The copy constructor doesn't do what you'd want:
+ Since T might have a virtual ctor, we don't try to do a
+
+ new T(*cursor)
+
+ You have to copy this yourself, or use the macro PointerList__copy
+
+ */
+template<class T>
+class IPointerList : public PointerList<T> {
+public:
+ IPointerList(const IPointerList&) { set_empty(); }
+ IPointerList() { }
+ ~IPointerList();
+};
+
+#define IPointerList__copy(T, to, from, op) \
+ for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
+ to.bottom().add(_pc_->op)\
+ \
+
+
+template<class T>
+void PL_copy(IPointerList<T*> &dst,IPointerList<T*> const&src);
+
+
+#define PL_instantiate(a) template class PointerList<a*>; \
+ template class PCursor<a*>;
+#define IPL_instantiate(a) PL_instantiate(a); \
+ template class IPointerList<a*>
+
+#include "plist.inl"
+
+#endif
--- /dev/null
+/* -*-c++-*-
+ plist.inl -- part of flowerlib
+
+ (c) 1996 Han-Wen Nienhuys& Jan Nieuwenhuizen
+*/
+
+#ifndef PLIST_INL
+#define PLIST_INL
+
+template<class T>
+void
+PL_copy(IPointerList<T*> &to, IPointerList<T*> const&src)
+{
+ for (PCursor<T*> pc(src); pc.ok(); pc++) {
+ T *q = pc;
+ T *p=new T(*q) ;
+ to.bottom().add(p);
+ }
+}
+
+#endif
--- /dev/null
+/*
+
+ string.cc - implement String
+
+ (c) 1997 Han-Wen Nienhuys & Jan Nieuwenhuizen
+
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <assert.h>
+#include <string.h>
+
+#include "string.hh"
+#include "libc-extension.hh"
+#include "string-convert.hh"
+
+#ifdef STRING_DEBUG
+void* mymemmove( void* dest, void const* src, size_t n );
+#define memmove mymemmove
+#endif
+
+// return array, alloced with new.
+Byte*
+String::copy_byte_p() const
+{
+ Byte const* src = strh_.byte_c_l();
+ Byte* dest = new Byte[strh_.length_i() + 1];
+ memcpy( dest, src, strh_.length_i() + 1 );
+ return dest;
+}
+void
+String::print_on(ostream& os) const
+{
+ if (!strh_.is_binary_bo())
+ os << ch_c_l();
+ else
+ for ( int i = 0; i < length_i(); i++ )
+ os << (Byte)(*this)[ i ];
+}
+\f
+/*
+ copying, constructing.
+ */
+String&
+String::operator = (String const&source )
+{
+ strh_ = source.strh_;
+ return *this;
+}
+
+
+String::String(Rational r)
+{
+ *this = String_convert::rational_str(r);
+}
+
+String::String (double f, char const* fmt)
+{
+ *this= String_convert::double_str(f,fmt);
+}
+
+String::String( char c, int n )
+{
+ *this = String_convert::char_str (c,n);
+}
+
+/**
+ @see
+ String_convert::int_str
+ */
+String::String(int i, const char * format )
+{
+ *this = String_convert::int_str(i,format);
+}
+
+String::String (bool b)
+{
+ *this = (char const* ) (b ? "true" : "false");
+}
+
+String::String( char const* source )
+{
+ assert(source);
+ strh_ = source;
+}
+
+String::String( Byte const* byte_l, int length_i )
+{
+ strh_.set( byte_l, length_i );
+}
+\f
+void
+String::append(String s)
+{
+ strh_.append( s.byte_c_l(), s.length_i() );
+}
+void
+String::operator +=(String s)
+{
+ append(s);
+}
+
+void
+String::prepend(String s)
+{
+ s += *this;
+ *this = s;
+}
+
+int
+String::length_i() const
+{
+ return strh_.length_i();
+}
+
+Byte const*
+String::byte_c_l() const
+{
+ return strh_.byte_c_l();
+}
+
+char const*
+String::ch_c_l() const
+{
+ return strh_.ch_c_l();
+}
+
+Byte*
+String::byte_l()
+{
+ return strh_.byte_l();
+}
+
+char*
+String::ch_l()
+{
+ return strh_.ch_l();
+}
+
+/**
+ Do a signed comparison, analogous to memcmp;
+ */
+int
+String::compare_i(String const& s1, String const& s2 )
+{
+ Byte const* p1 = s1.byte_c_l();
+ Byte const* p2 = s2.byte_c_l();
+ if ( p1 == p2 )
+ return 0;
+
+ int i1 = s1.length_i();
+ int i2 = s2.length_i();
+
+ int result= memcmp( p1, p2, i1 <? i2 );
+ return result ? result : i1-i2;
+}
+
+\f
+int
+String::index_last_i( char const c ) const
+{
+ if ( !length_i() )
+ return -1;
+
+ char const* me = strh_.ch_c_l();
+ char const* p = memrchr(me, length_i(), c );
+ if ( p )
+ return p - me;
+ return -1;
+}
+
+int
+String::index_last_i( char const* string ) const // UGK!
+{
+ assert(false); // broken
+ int length = strlen( string ); // ugrh
+ if ( !length_i() || !length )
+ return -1;
+
+ int next_i = index_i( string );
+ if ( next_i == -1 )
+ return -1;
+
+ int index_i = 0;
+ while( next_i >= 0 ) {
+ index_i += next_i;
+ next_i = right_str( length_i() - index_i - length ).index_i( string );
+ }
+ return index_i;
+}
+
+/** find a character.
+
+ @return
+ the index of the leftmost character #c# (0 <= return < length_i()),
+ or -1 if not found.
+
+ ? should return length_i()?, as in string.left_str(index_i(delimiter))
+*/
+int
+String::index_i(char c ) const
+{
+ char const* me = strh_.ch_c_l();
+ char const* p = (char const *) memchr( me,c, length_i());
+ if ( p )
+ return p - me;
+ return -1;
+}
+
+/**
+ find the substring.
+
+ @return
+ index of leftmost occurrence of #searchfor#
+ */
+int
+String::index_i( String searchfor ) const
+{
+ char const* me = strh_.ch_c_l();
+ char const* p = (char const *) memmem(
+ me, length_i(), searchfor.ch_c_l(), searchfor.length_i());
+
+ if ( p )
+ return p - me;
+ else
+ return -1;
+}
+
+/** find chars of a set.
+
+ @return
+ the index of the leftmost occurance of an element of #set#
+ */
+int
+String::index_any_i( String set ) const
+{
+ int n = length_i();
+ if ( !n )
+ return -1;
+
+ const void * me_l = (const void*) strh_.ch_c_l();
+ for (int i=0; i < set.length_i(); i++) {
+ char * found=(char*) memchr(me_l, set[i], n );
+ if (found) {
+ return found - me_l;
+ }
+ }
+ return -1;
+}
+\f
+String
+String::left_str( int n ) const
+{
+ if (n >= length_i())
+ return *this;
+
+ String retval;
+ if (n < 1)
+ return retval;
+
+ retval = *this;
+ retval.strh_.trunc(n);
+ return retval;
+}
+
+String
+String::right_str( int n ) const
+{
+ if (n > length_i())
+ return *this;
+
+ if ( n < 1)
+ return "";
+
+ return String( strh_.byte_c_l() + length_i() - n, n );
+}
+
+
+String
+String::nomid_str( int index_i, int n ) const
+{
+ if ( index_i < 0 ) {
+ n += index_i;
+ index_i = 0;
+ }
+ if ( n <= 0)
+ return *this;
+
+ return
+ left_str( index_i ) +
+ right_str( length_i() - index_i - n ) ;
+}
+
+/*
+ proposal: change to "cut()"
+ */
+String
+String::mid_str( int index_i, int n ) const
+{
+ if (index_i <0) {
+ n += index_i;
+ index_i=0;
+ }
+
+ if ( !length_i() || ( index_i < 0 ) || ( index_i >= length_i() ) || ( n < 1 ) )
+ return String();
+
+ if ( ( n > length_i() ) || ( index_i + n > length_i() ) )
+ n = length_i() - index_i;
+
+ return String( byte_c_l() + index_i, n );
+}
+\f
+String
+String::upper_str() const
+{
+ String str = *this;
+ str.to_upper();
+ return str;
+}
+void
+String::to_upper()
+{
+ char *s = (char*)strh_.byte_l();
+ strnupr( s ,length_i());
+}
+
+void
+String::to_lower()
+{
+ char* s = strh_.ch_l();
+ strnlwr(s,length_i());
+}
+
+
+String
+String::lower_str() const
+{
+ String str = *this;
+ str.to_lower();
+ return str;
+}
+String
+String::reversed_str() const
+{
+ String str = *this;
+ strrev( str.byte_l(), str.length_i() );
+ return str;
+}
+
+int
+String::value_i() const
+{
+ return String_convert::dec2_i( *this );
+}
+
+double
+String::value_f() const
+{
+ return String_convert::dec2_f( *this );
+}
+
+
+++ /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
-/*
- 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
+/*
+ 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
+//
+// 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
+/*
+ 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
+/*
+ midioutput.cc -- implement Midi_output
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>, Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+// "" huh?
+#include "time.h"
+
+#include "proto.hh"
+#include "plist.hh"
+#include "string.hh"
+#include "string-convert.hh"
+#include "debug.hh"
+#include "score.hh"
+#include "staff.hh"
+#include "main.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;
+ score_l_ = score_l;
+
+ Midi_stream midi_stream(midi_l->outfile_str_, score_l_->staffs_.size(), 384 );
+ midi_stream_l_ = &midi_stream;
+
+ header();
+ staffs();
+}
+
+void
+Midi_output::do_staff(Staff*st_l,int track_i)
+{
+ Midi_track midi_track( track_i );
+
+ // set track name
+ Midi_text track_name( Midi_text::TRACK_NAME, "Track " + String_convert::i2dec_str( track_i, 2, 0 ) );
+ midi_track.add( Moment( 0.0 ), &track_name );
+
+ // set instrument :-)
+ Midi_text instrument_name( Midi_text::INSTRUMENT_NAME, "piano" );
+ midi_track.add( Moment( 0.0 ), &instrument_name );
+
+ // set key, help, where to get key, where to get major/minor?
+ int accidentals_i = 0;
+ int minor_i = 0;
+
+ // sorry, wanna test this...
+ // menuetto in F
+ if ( ( infile_str_g.index_i( "scsii-menuetto" ) >= 0 )
+ || ( infile_str_g.index_i( "standchen" ) >= 0 ) )
+ accidentals_i = -1;
+ // standchen in d
+ if ( ( infile_str_g.index_i( "standchen" ) >= 0 ) )
+ minor_i = 1;
+
+ Midi_key midi_key( accidentals_i, minor_i );
+ midi_track.add( Moment( 0.0 ), &midi_key );
+
+ 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;
+}
+
+void
+Midi_output::header()
+{
+ Midi_track midi_track( 0 );
+
+ time_t t = time( 0 );
+
+ // perhaps multiple text events?
+ String str = String( "Creator: " ) + get_version() + "\n";
+ str += "Generated, at ";
+ str += ctime( &t );
+ str += ", from musical definition: " + infile_str_g;
+ str += "\n";
+
+ Midi_text creator( Midi_text::TEXT, str );
+ midi_track.add( Moment( 0.0 ), &creator );
+
+ struct tm* tm_l = gmtime( &t );
+ String year_str = String_convert::i2dec_str( 1900 + tm_l->tm_year, 4, '0' );
+
+ // your copyleft here
+ str = " Copyleft (o) " + year_str;
+ str += " Han-Wen Nienhuys <hanwen@stack.nl>, "
+ " Jan Nieuwenhuizen <jan@digicash.com>\n";
+
+ Midi_text copyleft( Midi_text::COPYRIGHT, str );
+ midi_track.add( Moment( 0.0 ), ©left );
+ *midi_stream_l_ << midi_track;
+}
+
+void
+Midi_output::staffs()
+{
+ int track_i = 1;
+ for (iter_top(score_l_->staffs_,i); i.ok(); i++)
+ do_staff(i, track_i++);
+}
+
--- /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
-/*
- 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
-/*
- 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
-}