--- /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
-/*
- midiwalker.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 "staffwalker.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
-/*
- inputfile.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 "inputfile.hh"
-#include "debug.hh"
-#include "sourcefile.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-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
+/*
+ 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
-/*
- midioutput.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 "midistream.hh"
-#include "mididef.hh"
-#include "midioutput.hh"
-#include "midiwalker.hh"
-#include "midiitem.hh"
-#include "staffcolumn.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
-/*
- midiwalker.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 "midiwalker.hh"
-#include "midiitem.hh"
-#include "midistream.hh"
-#include "debug.hh"
-#include "staffcolumn.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
-}