g++ (there are quite a few). Not having to support other compilers
saves us a *lot* of trouble. LilyPond & FlowerLib uses:
-=over 5
+=over 6
=item *
builtin bool
+=item *
+64 bit integral type long long
+
=item *
typeof
# Sources.make
# sourcefiles to be shipped. Also used for dependencies
-hdr=bar.hh barreg.hh beam.hh boxes.hh break.hh clefreg.hh clefitem.hh\
+hdr=bar.hh barreg.hh beam.hh\
+ binary-source-file.hh\
+ boxes.hh break.hh clefreg.hh clefitem.hh\
colhpos.hh commandrequest.hh \
complexwalker.hh complexstaff.hh\
const.hh debug.hh dimen.hh directionalspanner.hh\
# m2m headers
#
mym2mhh=\
- binary-source-file.hh\
+ duration.hh\
+ lily-stream.hh\
midi-event.hh\
midi-main.hh\
midi-score.hh\
midi-track.hh\
my-midi-lexer.hh\
my-midi-parser.hh\
+ track-column.hh\
+
+#
+
+# m2m shared headers
+#
+mym2msharedhh=\
+ binary-source-file.hh\
#
-
+
# m2m source
#
mym2mcc=\
- binary-source-file.cc\
+ duration.cc\
+ lily-stream.cc\
midi-event.cc\
midi-main.cc\
midi-score.cc\
midi-track.cc\
my-midi-lexer.cc\
my-midi-parser.cc\
+ track-column.cc\
#
# m2m shared source
#
mym2msharedcc=\
+ binary-source-file.cc\
inputfile.cc\
sourcefile.cc\
source.cc\
-
#
+
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=36
+PATCHLEVEL=37
MAKE=${MAKE:-make}
PREFIX=${PREFIX:-.}
-NEEDFLOWERVER=1.1.2
+NEEDFLOWERVER=1.1.4
echo using PREFIX=$PREFIX
echo I need Flower version $NEEDFLOWERVER
--- /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
+
#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();
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_;
/// (midi_track)
class Midi_track {
public:
- Midi_track();
+ Midi_track( int track_i );
~Midi_track();
- void add_event( Midi_event* midi_event_p );
+ 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
struct Midi_item {
/* *************** */
- static String int2varlength_str( int i );
+ static String i2varint_str( int i );
virtual void output_midi( Midi_stream& midi_stream_r );
virtual String str() = 0;
};
int close_i();
void error( char const* sz_l );
char const* here_ch_c_l();
- static int varint2int_i( String str );
+ static int varint2_i( String str );
int yylex();
private:
#ifndef MY_MIDI_PARSER_HH
#define MY_MIDI_PARSER_HH
-#include "proto.hh"
-#include "varray.hh"
-#include "string.hh"
+// #include "proto.hh"
+// #include "string.hh"
int yyparse();
void add_score( Midi_score* midi_score_p );
void error( char const* sz_l );
int parse();
- void forward( Real f );
+ 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( String filename_str );
- void set_division( int clocks_per_4_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:
- Real now_f_;
- Real step_f_;
+ Int64 now_i64_; // 31 bits yields tipically about 1000 bars
static int const CHANNELS_i = 16;
static int const PITCHES_i = 128;
- Real running_f_f_a_[ CHANNELS_i ][ PITCHES_i ];
+ Int64 running_i64_i64_a_[ CHANNELS_i ][ PITCHES_i ];
- Array<Midi_score*> midi_score_p_array_;
- int clocks_per_whole_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_;
#include "fproto.hh"
#include "real.hh"
+/// (i64)
+typedef long long Int64;
+
struct Absdynamic_req;
struct Accidental;
struct Atom;
struct Complex_walker;
struct Cresc_req;
struct Decresc_req;
+struct Duration;
+struct Duration_iterator;
struct Durational_req;
struct Dynamic;
struct Group_change_req;
struct Key_item;
struct Keyword;
struct Keyword_table;
+struct Lily_stream;
struct Line_of_score;
struct Line_of_staff;
struct Linestaff;
struct Output;
struct PCol;
struct Plet_req;
+struct Plet;
struct PScore;
struct PStaff;
struct Paperdef;
struct Text_req;
struct Timing_req;
struct Time_description;
+struct Track_column;
struct Voice;
struct Voice_element;
struct Voice_group_registers;
private:
void set_symdir();
void set_default_dir();
- void set_default_pos();
+ void set_default_index();
Symbol symbol()const;
};
void add(Notehead*n);
const char * name() const;
- Real hpos()const;
+ Real hindex()const;
void do_print() const;
void set_stemend(Real);
int get_default_dir();
/* ***************/
const char * name() const;
- virtual void set_default_pos();
+ virtual void set_default_index();
Molecule* brew_molecule_p() const;
void do_pre_processing();
--- /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
+
martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\
coriolan-alto.ly rhythm.ly \
standchen.tex scsii-menuetto.tex scsii-menuetto.ly\
- martien.tex
+ martien.tex\
+ pre1.midi.ly fugue1.midi.ly
dist:
--- /dev/null
+% Creator: This is m2m 0.0.36-2/FlowerLib 1.1.3-1 of Feb 27 1997 02:41:23
+% Automatically generated, at Thu Feb 27 08:38:27 1997
+% from input file:
+
+track0 = music { $
+ % \Time: 4/8, 96: 8 % \Tempo: 967742: 61 4 per minute
+ % \Tempo: 1000000: 60 4 per minute
+ % \Tempo: 1052632: 56 4 per minute
+ % \Tempo: 1132075: 53 4 per minute
+ % \Tempo: 1200000: 50 4 per minute
+ % \Tempo: 1463415: 40 4 per minute
+ % \Tempo: 1578947: 38 4 per minute
+
+$} % track0
+
+track1 = music { $
+ g8 a8 b8 c8. d32 c32 b8 e8 a8 d8. e16 d16 c16
+ b16 g16 a16 b16 c16 b16 c16 d16 e16 d16 e16
+ fis16 g8 b8 c8 a8 d16 c16 b16 a16 g8. g16 f16
+ e16 f16 g16 a16 g16 a16 b16 c2 b4 c8 d8 e8 f8.
+ g32 f32 e8 a8 d8 g8. a16 g16 f16 e8 a8. b16 a16
+ g16 f2 e8. fis16 g2 fis4 g16 f16 e16 d16 c16
+ d16 c16 b16 a16 c16 b16 a16 c16 a16 gis8 e8
+ d8 c16 b16 a16 gis16 a16 b16 c16 fis16 gis16
+ a16 b8 a16 b16 c8 f8 e8 d4 c16 b16 c64 b64 c64
+ b64 c64 b64 c64 b64 c64 b32. a32. a4 g8 a8 b8
+ c8. d32 c32 b8 c8 d8 e8 f8. g32 f32 e8 a8 d8 g8.
+ a16 g16 f16 e8 a8 d8 ais8 a8 g16 f16 g16 f16
+ g16 e16 f16 g16 g64 a64 g32 f32 g32 a16 cis16
+ d16 g16 f64 e64 f64 e64 f64 e16. d32. d8. g8
+ a8 b8 c8. d32 c32 b8 e8 a8 d8. e16 d16 c16 b16
+ c16 d16 e16 f16 g16 a16 g16 f16 e16 d16 c16
+ c64 b64 c64 b8. c8 d8 g8 c4 b8 c4 b8 ais8 a8 d4
+ c8 d8 e8 f8.. a32. g32. f32. e32. f32. e32.
+ d32. c2 g32 a32 b16 c16 d16 e16 f8. c32 d32
+ e32 f16 g16 a8. b16 c2
+$} % track1
+
+track2 = music { $
+ c8 d8 e8 f8. g32 f32 e8 a8 d8 g8. a16 g16 f16
+ e16 f16 e16 d16 c16 d16 c16 b16 a8 fis8 g4.
+ f16 e16 f8 d8 g8 f8 e8 d8 g4 f16 e16 f8.. f16
+ e8 d4 c8 f8 g16 f16 e16 f8 d8 g4.. g8 a8 b8 c8.
+ d32 c32 b8 e8 a8 d8. e16 d16 c16 b16.. d8 e8
+ fis8 g8. a32 g32 f8 b8 e8 a8. b16 a16 gis16
+ fis8 f8 e8 d8. e16 fis16 gis16 a16 gis16 a16
+ b16 gis16 fis16 gis16 a16 b8 c8 d8 e8 f8. g32
+ f32 e8 a8 d8 g8. a16 g16 f16 e16. e16. fis16.
+ g4 fis8 gis8 a4 g8 a8 b8 c8. d32 c32 b16. e8
+ a8 d8. e16 d16 c16 b8 g8 cis8 d8 e8 cis8 d8 e8
+ a8 e8 fis8 g8 a8. b32 a32 g8 c8 fis8 b8. c16
+ b16 a16 g16 fis16 e16 d16 e4 d4. a16 g16 f16
+ e16 g16 f16 g4. a16 a16 ais8 c4 d8 g8 g4. f4
+ e8 d4 e16. a4 g4 f8 g8 a8 ais8. c32 ais32 a8
+ d8 g8 c8. d16 c16 ais16 a16 ais16 a16 g16 f16
+ g16 f16 e16 g16 a4 f16 d8 e2
+$} % track2
+
+track3 = music { $
+ g8 a8 b8 c8. d32 c32 b8 e8 a8 d8. e16 d16 c16
+ b8 c4 ais8 a8 d8 g8 c8 a16 b16 c16 d4 g4 g8 a8
+ b8 c8. d32 c32 b8 e8 a8 d8. e16 d16 c16 b8 e4.
+ d4 b16 c16 a16 e16 d16 c16 b16 c16 a16 b16 c16
+ d16 c16 b16 a16 g4 e8 fis8 gis8 a8. b32 a32
+ g8 c8 fis8 b8. c16 b16 a16 gis16.. a4 gis8
+ a4 g8 a8 b8 c8. d32 c32 b8 e8 a8 d4 g8 d4 c8 a8
+ e4 d8 a8 b8 cis8 d8. e32 d32 c8 f8 b8 e8. f16
+ e16 d16 cis8 a8 b8 cis8 d8. e32 d32 c8 fis8
+ b8 e8. fis16 e16 d16 c4.. d16 c16 b16 a16 g16
+ a16 fis16 g16.. b16.. c16.. d8 e8. f32 e32
+ d8 g8 c8 f8. g16 f16 e16 d4 e8 d4 g8 g4. c8 d8
+ e8 f8. g32 f32 e8 a8 d8 g8. a16 g16 f16 e16 d16
+ e16 f16 g16 a16 ais16 g16 a16 e16 f16 g16 a16
+ b16 c16 a16 c1
+$} % track3
+
+track4 = music { $
+ c8 d8 e8 f8. g32 f32 e8 a8 d8 g8. a16 g16 f16
+ e16 f16 e16 d16 c16 d16 c16 b16 a8 d8 a8 fis8
+ g16 a16 ais16 g16 cis8 d8 a4 e4 a16 b16 c16
+ d16 c16 b16 a16 g16 c8 g8 a8 b8 c8. d32 c32 b8
+ e8 a8 d8. e16 d16 c16 b8 e4 d8 c8 f4 e4 d4 e8 f8
+ e16 d16 e4 a4 g8 a8 b8 c8. d32 c32 b8 e8 a8 d8.
+ e16 d16 c16 b8 ais8 a8 g8 a8 fis8 g8 e8 d4 e8
+ f8 g8. a32 g32 f8 ais8 e8 a8. b16. a16 g16 f16
+ e16 f16 d16 g8 a8 d4.. e16 d16 c16 b16 a16 g16
+ fis16 e8 e8 fis8 g4 a16 g16 fis8 d8 g1 a4 b8
+ c8 f16 a16 g16 f16 e16 d16 c16 b16 c16 d16 e16
+ f16 g8 g8 b2 c8
+$} % track4
+
+score {
+ staff { melodic music { track0 } }
+ staff { melodic music { track1 } }
+ staff { melodic music { track2 } }
+ staff { melodic music { track3 } }
+ staff { melodic music { track4 } }
+ commands { meter { 4*4 } }
+ midi { tempo 4:60 }
+}
--- /dev/null
+% Creator: This is m2m 0.0.36-2/FlowerLib 1.1.3-1 of Feb 27 1997 02:41:23
+% Automatically generated, at Thu Feb 27 02:54:33 1997
+% from input file:
+
+track0 = music { $
+ % \Time: 4/8, 96: 8 % \Tempo: 857143: 69 4 per minute
+ % \Tempo: 882353: 67 4 per minute
+ % \Tempo: 909091: 65 4 per minute
+ % \Tempo: 937500: 64 4 per minute
+ % \Tempo: 967742: 61 4 per minute
+ % \Tempo: 1000000: 60 4 per minute
+ % \Tempo: 1200000: 50 4 per minute
+ % \Tempo: 1224490: 48 4 per minute
+ % \Tempo: 833333: 72 4 per minute
+
+$} % track0
+
+track1 = music { $
+ g16 c16 e16 g16 c16 e16 g16 c16 e16 g16 c16
+ e16 a16 d16 f16 a16 d16 f16 a16 d16 f16 a16
+ d16 f16 g16 d16 f16 g16 d16 f16 g16 d16 f16
+ g16 d16 f16 g16 c16 e16 g16 c16 e16 g16 c16
+ e16 g16 c16 e16 a16 e16 a16 a16 e16 a16 a16
+ e16 a16 a16 e16 a16 fis16 a16 d16 fis16 a16
+ d16 fis16 a16 d16 fis16 a16 d16 g16 d16 g16
+ g16 d16 g16 g16 d16 g16 g16 d16 g16 e16 g16
+ c16 e16 g16 c16 e16 g16 c16 e16 g16 c16 e16
+ g16 c16 e16 g16 c16 e16 g16 c16 e16 g16 c16
+ d16 fis16 c16 d16 fis16 c16 d16 fis16 c16
+ d16 fis16 c16 d16 g16 b16 d16 g16 b16 d16 g16
+ b16 d16 g16 b16 e16 g16 cis16 e16 g16 cis16
+ e16 g16 cis16 e16 g16 cis16 d16 a16 d16 d16
+ a16 d16 d16 a16 d16 d16 a16 d16 d16 f16 b16
+ d16 f16 b16 d16 f16 b16 d16 f16 b16 c16 g16
+ c16 c16 g16 c16 c16 g16 c16 c16 g16 c16 a16
+ c16 f16 a16 c16 f16 a16 c16 f16 a16 c16 f16
+ a16 c16 f16 a16 c16 f16 a16 c16 f16 a16 c16
+ f16 g16 b16 f16 g16 b16 f16 g16 b16 f16 g16
+ b16 f16 g16 c16 e16 g16 c16 e16 g16 c16 e16
+ g16 c16 e16 ais16 c16 e16 ais16 c16 e16 ais16
+ c16 e16 ais16 c16 e16 a16 c16 e16 a16 c16 e16
+ a16 c16 e16 a16 c16 e16 a16 c16 dis16 a16 c16
+ dis16 a16 c16 dis16 a16 c16 dis16 b16 c16
+ d16 b16 c16 d16 b16 c16 d16 b16 c16 d16 g16
+ b16 d16 g16 b16 d16 g16 b16 d16 g16 b16 d16
+ g16 c16 e16 g16 c16 e16 g16 c16 e16 g16 c16
+ e16 g16 c16 f16 g16 c16 f16 g16 c16 f16 g16
+ c16 f16 g16 b16 f16 g16 b16 f16 g16 b16 f16
+ g16 b16 f16 a16 c16 fis16 a16 c16 fis16 a16
+ c16 fis16 a16 c16 fis16 g16 c16 g16 g16 c16
+ g16 g16 c16 g16 g16 c16 g16 g16 c16 f16 g16
+ c16 f16 g16 c16 f16 g16 c16 f16 g16 b16 f16
+ g16 b16 f16 g16 b16 f16 g16 b16 f16 g16 ais16
+ e16 g16 ais16 e16 g16 ais16 e16 g16 ais16
+ e16 f16 a16 c16 f16 c16 a16 c16 a16 f16 a16
+ f16 d16 f16 d16 g16 b16 d16 f16 d16 b16 d16
+ b16 g16 b16 d16 f16 e64 f64 e32 d16 c1
+$} % track1
+
+track2 = music { $
+ c2 e4. c2 e4. c2 d4. c2 d4. b2 d4. b2 d4. c2 e4.
+ c2 e4. c2 e4. c2 e4. c2 d4. c2 d4. b2 d4. b2 d4.
+ b2 c4. b2 c4. a2 c4. a2 c4. d2 a4. d2 a4. g2 b4.
+ g2 b4. g2 ais4. g2 ais4. f2 a4. f2 a4. f2 gis4.
+ f2 gis4. e2 g4. e2 g4. e2 f4. e2 f4. d2 f4. d2
+ f4. g2 d4. g2 d4. c2 e4. c2 e4. c2 g4. c2 g4.
+ f2 f4. f2 f4. fis2 c2 fis2 c4. gis2 f4. gis2
+ f4. g2 f4. g2 f4. g2 e2 g2 e4. g2 d4. g2 d2 g2
+ d4. g2 d4. g2 dis4. g2 dis4. g2 e4. g2 e4. g2
+ d4. g2 d4. g2 d4. g2 d4. c2 c4. c2 c4. c1 c1 b1
+ c1 c1
+$} % track2
+
+score {
+ staff { melodic music { track0 } }
+ staff { melodic music { track1 } }
+ staff { melodic music { track2 } }
+ commands { meter { 4*4 } }
+ midi { tempo 4:60 }
+}
Stem_info::Stem_info(const Stem*s)
{
- x = s->hpos();
+ x = s->hindex();
int dir = s->dir;
idealy = max(dir*s->top, dir*s->bot);
miny = max(dir*s->minnote, dir*s-> maxnote);
Beam::set_stemlens()
{
iter_top(stems,s);
- Real x0 = s->hpos();
+ Real x0 = s->hindex();
for (; s.ok() ; s++) {
- Real x = s->hpos()-x0;
+ Real x = s->hindex()-x0;
s->set_stemend(left_pos + slope * x);
}
}
Beam::width() const
{
Beam * me = (Beam*) this; // ugh
- return Interval( (*me->stems.top()) ->hpos(),
- (*me->stems.bottom()) ->hpos() );
+ return Interval( (*me->stems.top()) ->hindex(),
+ (*me->stems.bottom()) ->hindex() );
}
/*
Molecule
Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const
{
- assert( !next || next->hpos() > here->hpos() );
- assert( !prev || prev->hpos() < here->hpos() );
+ 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();
if (prev) {
int lhalfs= lhalfs = here->beams_left - prev->beams_right ;
int lwholebeams= here->beams_left <? prev->beams_right ;
- Real w = (here->hpos() - prev->hpos())/4;
+ Real w = (here->hindex() - prev->hindex())/4;
Symbol dummy;
Atom a(dummy);
if (lhalfs) // generates warnings if not
int rhalfs = here->beams_right - next->beams_left;
int rwholebeams = here->beams_right <? next->beams_left;
- Real w = next->hpos() - here->hpos();
+ Real w = next->hindex() - here->hindex();
Atom a = paper()->lookup_p_->beam(sl, w + stemdx);
int j = 0;
{
Real inter=paper()->internote();
out = new Molecule;
- Real x0 = stems.top()->hpos();
+ Real x0 = stems.top()->hindex();
for (iter_top(stems,i); i.ok(); i++) {
PCursor<Stem*> p(i-1);
Stem * next = n.ok() ? n.ptr() : 0;
Molecule sb = stem_beams(i, next, prev);
- Real x = i->hpos()-x0;
+ Real x = i->hindex()-x0;
sb.translate(Offset(x, (x * slope + left_pos)* inter));
out->add(sb);
}
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 = StringConversion::bin2hex_str( pre_str );
+ pre_str = String_convert::bin2hex_str( pre_str );
for ( int i = 2; i < pre_str.length_i(); i += 3 )
- pre_str = pre_str.left( i ) + " " + pre_str.mid( i + 1, INT_MAX );
+ 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 = StringConversion::bin2hex_str( post_str );
+ post_str = String_convert::bin2hex_str( post_str );
for ( int i = 2; i < post_str.length_i(); i += 3 )
- post_str = post_str.left( i ) + " " + post_str.mid( i + 1, INT_MAX );
+ post_str = post_str.left_str( i ) + " " + post_str.mid_str( i + 1, INT_MAX );
String str = pre_str
+ String( '\n' )
Real
parse_dimen(String dim)
{
- int i=dim.len()-1;
+ 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.fvalue(), unit);
+ return convert_dimen(dim.value_f(), unit);
}
--- /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 "sourcefile.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 ) ) );
+}
else {
Source_file* sourcefile_p = 0;
// ugh, very dirty, need to go away
- if ( ( pf.right( 3 ).lower() == "mid" ) || ( pf.right( 4 ).lower() == "midi" ) )
+ 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 );
return DOTS;
}
<notes>{INT} {
- yylval.i = String(YYText()).value();
+ yylval.i = String_convert::dec2_i( String( YYText() ) );
return INT;
}
<notes>{COMMENT} {
}
<notes>\"[^"]*\" {
String s (YYText()+1);
- s = s.left(s.len()-1);
+ s = s.left_str(s.length_i()-1);
yylval.string = new String(s);
return STRING;
}
return DOTS;
}
<lyrics>{INT} {
- yylval.i = String(YYText()).value();
+ yylval.i = String_convert::dec2_i( String( YYText() ) );
return INT;
}
<lyrics>{NOTECOMMAND} {
}
<lyrics>\"[^"]*\" {
String s (YYText()+1);
- s = s.left(s.len()-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.pos("_")) != 0) // change word binding "_" to " "
- *(s.ch_l() + i - 1) = ' ';
- if ((i=s.pos("\\,")) !=0) // change "\," to TeX's "\c "
+ 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) = 'c';
- s = s.left(i+1) + " " + s.right(s.len()-i-1);
+ *(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;
<incl>[ \t]* { /* eat the whitespace */ }
<incl>\"[^"]*\"+ { /* got the include file name */
String s (YYText()+1);
- s = s.left(s.len()-1);
- defined_ch_c_l = here_ch_c_l() - String( YYText() ).len() - 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();
}
--- /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 "sourcefile.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 );
+}
+
// override Text_item
// test context-error
- if ( tdef_l_->text_str_.pos( "Gates" ) )// :-)
+ if ( tdef_l_->text_str_.index_i( "Gates" ) )// :-)
warning( "foul word", tdef_l_->defined_ch_c_l_ );
}
void
-destill_inname( String &inName);
+destill_inname( String &name_str_r);
long_option_init theopts[] = {
1, "output", 'o',
0, "warranty", 'w',
/// make input file name: add default extension. "" is stdin.
void
-destill_inname( String &inName)
+destill_inname( String &name_str_r)
{
- if ( inName.len() )
+ if ( name_str_r.length_i() )
{
- if( inName[ 0 ] != '-' )
+ if( name_str_r[ 0 ] != '-' )
{
String a,b,c,d;
- split_path(inName,a,b,c,d);
+ split_path(name_str_r,a,b,c,d);
// add extension if not present.
if (d == "")
d = ".ly";
- inName = a+b+c+d;
+ name_str_r = a+b+c+d;
}
- } else inName = "";
+ } else name_str_r = "";
}
}
{INT8} {
error( String( "top level: illegal byte: " )
- + StringConversion::bin2hex_str( String( *YYText() ) ) );
+ + 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 = StringConversion::bin2int_i( str );
+ yylval.i = String_convert::bin2_i( str );
yy_pop_state();
return INT32;
}
dtor << "lex: int16" << endl;
assert( YYLeng() == 2 );
String str( (Byte const*)YYText(), YYLeng() );
- yylval.i = StringConversion::bin2int_i( str );
+ yylval.i = String_convert::bin2_i( str );
yy_pop_state();
return INT16;
}
<track>{VARINT} {
String str( (Byte const*)YYText(), YYLeng() );
- yylval.i = My_midi_lexer::varint2int_i( str );
+ yylval.i = My_midi_lexer::varint2_i( str );
dtor << String( "lex: track: varint(" )
+ String( yylval.i ) + "): "
- + StringConversion::bin2hex_str( str ) << endl;
+ + String_convert::bin2hex_str( str ) << endl;
yy_push_state( event );
return VARINT;
}
<track>{INT8} {
error( String( "track: illegal byte: " )
- + StringConversion::bin2hex_str( String( *YYText() ) ) );
+ + String_convert::bin2hex_str( String( *YYText() ) ) );
exit( 1 );
}
<event>{RUNNING_STATUS} {
}
<event>{INT8} {
error( String( "event: illegal byte: " )
- + StringConversion::bin2hex_str( String( *YYText() ) ) );
+ + String_convert::bin2hex_str( String( *YYText() ) ) );
exit( 1 );
}
<meta_event>{SEQUENCE} { // ssss sequence number
}
<meta_event>{INT8} {
warning( String( "meta_event: unimplemented event: " )
- + StringConversion::bin2hex_str( String( *YYText() ) ),
+ + String_convert::bin2hex_str( String( *YYText() ) ),
*this->here_ch_c_l() );
yy_pop_state();
yy_pop_state();
<data>{VARINT} {
dtor << "lex: data" << endl;
String str( (Byte const*)YYText(), YYLeng() );
- int i = My_midi_lexer::varint2int_i( str );
+ int i = My_midi_lexer::varint2_i( str );
String* str_p = new String;
while ( i-- )
*str_p += (char)yyinput();
}
<data>{INT8} {
error( String( "data: illegal byte: " )
- + StringConversion::bin2hex_str( String( *YYText() ) ) );
+ + String_convert::bin2hex_str( String( *YYText() ) ) );
exit( 1 );
}
// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
#include <iostream.h>
+#include <limits.h>
#include "proto.hh"
#include "plist.hh"
#include "version.hh"
#include "sourcefile.hh"
#include "midi-main.hh"
#include "moment.hh"
+#include "duration.hh"
#include "midi-event.hh"
#include "midi-track.hh"
#include "my-midi-lexer.hh"
Verbose level_ver = NORMAL_ver;
+// ugh
+bool no_triplets_bo_g = false;
+
//ugh
char const* defined_ch_c_l = 0;
{
btor <<
"--debug, -d be really verbose\n"
- "--help, -h This help\n"
- "--include, -I add to file search path.\n"
- "--output, -o set default output\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 << "This is m2m " << VERSIONSTR << "/FlowerLib " << FVERSIONSTR
- << " of " << __DATE__ << " " << __TIME__ << endl;
+ mtor << version_str() << endl;
}
void
"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[] )
{
0, "debug", 'd',
0, "help", 'h',
// 1, "include", 'I',
+ 0, "no-triplets", 'n',
1, "output", 'o',
0, "quiet", 'q',
0, "verbose", 'v',
// case 'I':
// path->push( getopt_long.optarg );
// break;
+ case 'n':
+ no_triplets_bo_g = true;
+ break;
case 'o':
output_str = getopt_long.optarg;
break;
int error_i = midi_parser.parse();
if ( error_i )
return error_i;
- error_i = midi_parser.output( output_str );
+ 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;
}
#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"
#define YYDEBUG 1
#endif
+//ugh
+static track_i = 0;
+
%}
%union {
midi: /* empty */
| midi midi_score {
midi_parser_l_g->add_score( $2 );
+ track_i = 0;
}
;
}
| 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( $5 );
+ midi_parser_l_g->set_division_4( $5 );
}
;
track:
TRACK INT32 {
- $$ = new Midi_track;
+ $$ = new Midi_track( track_i++ );
}
| track event {
- $$->add_event( $2 );
+ $$->add_event( midi_parser_l_g->mom(), $2 );
}
;
event:
varint the_event {
- if ( $2 && $2->mudela_str().length_i() ) {
- if ( ( $2->mudela_str()[ 0 ] >= 'a' )
- && $2->mudela_str()[ 0 ] <= 'g' )
- qtor << $2->mudela_str() << " ";
- else
- vtor << $2->mudela_str() << " ";
- }
+ $$ = $2;
+ if ( $2 && $2->mudela_str().length_i() )
+ dtor << $2->mudela_str() << " " << flush;
}
;
}
| text_event DATA {
$$ = 0;
- vtor << *$2 << endl;
+ dtor << *$2 << endl;
delete $2;
}
| END_OF_TRACK {
}
| TEMPO INT8 INT8 INT8 {
$$ = new Midi_tempo( ( $2 << 16 ) + ( $3 << 8 ) + $4 );
- vtor << $$->mudela_str() << endl; // ?? waai not at event:
+ 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 {
}
| TIME INT8 INT8 INT8 INT8 {
$$ = new Midi_time( $2, $3, $4, $5 );
- vtor << $$->mudela_str() << endl; // ?? waai not at event:
+ dtor << $$->mudela_str() << endl; // ?? waai not at event:
midi_parser_l_g->set_time( $2, $3, $4, $5 );
}
| KEY INT8 INT8 {
text_event:
TEXT {
- vtor << endl << "Text: ";
+ dtor << "\n% Text: ";
}
| COPYRIGHT {
- vtor << endl << "Copyright: ";
+ dtor << "\n% Copyright: ";
}
| TRACK_NAME {
- vtor << endl << "Track name: ";
+ dtor << "\n% Track name: ";
}
| INSTRUMENT_NAME {
- vtor << endl << "Instrument name: ";
+ dtor << "\n% Instrument name: ";
}
| LYRIC {
- vtor << endl << "Lyric: ";
+ dtor << "\n% Lyric: ";
}
| MARKER {
- vtor << endl << "Marker: ";
+ dtor << "\n% Marker: ";
}
| CUE_POINT {
- vtor << endl << "Cue point: ";
+ dtor << "\n% Cue point: ";
}
;
// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
#include "proto.hh"
+#include "plist.hh"
+#include "string.hh"
+#include "moment.hh"
+#include "duration.hh"
+#include "sourcefile.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"
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;
+}
+
#include "string.hh"
#include "sourcefile.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);
// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
#include "proto.hh"
+#include "plist.hh"
#include "string.hh"
+#include "sourcefile.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()
+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( Midi_event* midi_event_p )
+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;
+}
+
Midi_chunk::str()
{
String str = header_str_;
- String length_str = StringConversion::int2hex_str( data_str_.length_i() + footer_str_.length_i(), 8, '0' );
- length_str = StringConversion::hex2bin_str( length_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_;
{
String str;
- String format_str = StringConversion::int2hex_str( format_i, 4, '0' );
- str += StringConversion::hex2bin_str( format_str );
+ String format_str = String_convert::i2hex_str( format_i, 4, '0' );
+ str += String_convert::hex2bin_str( format_str );
- String tracks_str = StringConversion::int2hex_str( tracks_i, 4, '0' );
- str += StringConversion::hex2bin_str( tracks_str );
+ String tracks_str = String_convert::i2hex_str( tracks_i, 4, '0' );
+ str += String_convert::hex2bin_str( tracks_str );
- String tempo_str = StringConversion::int2hex_str( clocks_per_4_i, 4, '0' );
- str += StringConversion::hex2bin_str( tempo_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::int2varlength_str( int i )
+Midi_item::i2varint_str( int i )
{
int buffer_i = i & 0x7f;
while ( (i >>= 7) > 0 ) {
{
int useconds_per_4_i = 60 * (int)1e6 / tempo_i_;
String str = "ff5103";
- str += StringConversion::int2hex_str( useconds_per_4_i, 6, '0' );
- return StringConversion::hex2bin_str( str );
+ str += String_convert::i2hex_str( useconds_per_4_i, 6, '0' );
+ return String_convert::hex2bin_str( str );
}
Midi_track::Midi_track( int number_i )
String data_str;
// only for format 0 (currently using format 1)?
- data_str += StringConversion::hex2bin_str( data_ch_c_l );
+ data_str += String_convert::hex2bin_str( data_ch_c_l );
char const* footer_ch_c_l = "00" "ff2f" "00";
- String footer_str = StringConversion::hex2bin_str( footer_ch_c_l );
+ String footer_str = String_convert::hex2bin_str( footer_ch_c_l );
set( "MTrk", data_str, footer_str );
}
Midi_track::add( int delta_time_i, String event_str )
{
assert(delta_time_i >= 0);
- Midi_chunk::add( int2varlength_str( delta_time_i ) + event_str );
+ 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() );
}
filename_str_ = filename_str;
tracks_i_ = tracks_i;
clocks_per_4_i_ = clocks_per_4_i;
+ os_p_ = 0;
open();
header();
}
{
// still debugging...
if ( check_debug )
- str = StringConversion::bin2hex_str( str );
+ str = String_convert::bin2hex_str( str );
// string now 1.0.26-2 handles binary streaming
*os_p_ << str;
return *this;
Midi_stream::operator <<( int i )
{
// output binary string ourselves
- *this << Midi_item::int2varlength_str( i );
+ *this << Midi_item::i2varint_str( i );
return *this;
}
// 00 60 96 per quarter-note
// char const ch_c_l = "0000" "0006" "0001" "0001" "0060";
-// str += StringConversion::hex2bin_str( ch_c_l );
+// str += String_convert::hex2bin_str( ch_c_l );
// *os_p_ << str;
// *this << Midi_header( 1, 1, tempo_i_ );
}
int
-My_midi_lexer::varint2int_i( String str )
+My_midi_lexer::varint2_i( String str )
{
int var_i = 0;
if ( ! ( byte & 0x80 ) )
return var_i;
}
- cout << "\nvarint2int:" << StringConversion::bin2hex_str( str ) << endl;
+ cout << "\nvarint2_i:" << String_convert::bin2hex_str( str ) << endl;
assert( 0 ); // illegal varint
return 0;
}
#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"
{
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 );
-// midi_tempo_p_ = new Midi_tempo( 384 ); // wiellie dunno!
- // 07A120 == 500000
- midi_tempo_p_ = new Midi_tempo( 0x07a120 ); // wiellie dunno!
- midi_time_p_ = new Midi_time( 4, 4, 0x24, 8 );
+ // 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 );
- defined_ch_c_l_ = 0;
- fatal_error_i_ = 0;
- now_f_ = 0;
- step_f_ = 0;
+ now_i64_ = 0;
for ( int i = 0; i < CHANNELS_i; i++ )
for ( int j = 0; j < PITCHES_i; j++ )
- running_f_f_a_[ i ][ j ] = 0;
+// running_i64_i64_a_[ i ][ j ] = -1;
+ running_i64_i64_a_[ i ][ j ] = 0;
}
My_midi_parser::~My_midi_parser()
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 )
{
- midi_score_p_array_.push( midi_score_p );
- cout << endl;
+ assert( !midi_score_p_ );
+ midi_score_p_ = midi_score_p;
}
void
}
void
-My_midi_parser::forward( Real f )
+My_midi_parser::forward( int i )
+{
+ now_i64_ += i;
+}
+
+Moment
+My_midi_parser::mom()
{
- // ugh
- if ( f )
- step_f_ = f;
- now_f_ += step_f_;
+ 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 if start at t = 0?
-// assert( !running_f_f_a_[ channel_i ][ pitch_i ] );
- running_f_f_a_[ channel_i ][ pitch_i ] = now_f_;
+ // 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 )
{
- Real start_f = running_f_f_a_[ channel_i ] [ pitch_i ];
- // did we start? -> heu, don-t know: what if start at t = 0?
-// assert( start_f );
- return new Midi_note( midi_key_p_, midi_time_p_, clocks_per_whole_i_, pitch_i, now_f_ - start_f );
+ 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( String filename_str )
+My_midi_parser::output_mudela( String filename_str )
{
- return 0;
+ assert( midi_score_p_ );
+ return midi_score_p_->output_mudela( filename_str );
}
int
}
void
-My_midi_parser::set_division( int clocks_per_4_i )
+My_midi_parser::set_division_4( int division_4_i )
{
- clocks_per_whole_i_ = clocks_per_4_i * 4;
- if ( clocks_per_4_i < 0 )
+ division_1_i_ = division_4_i * 4;
+ if ( division_4_i < 0 )
warning( "seconds iso metrical time" , 0 );
}
int
My_flex_lexer::ret_notename(int *p, String text, int octave_mod)
{
- text.lower();
+ text = text.lower_str();
char const* ch_c_l = here_ch_c_l();
if ( ch_c_l ) {
ch_c_l--;
void
set_duration_mode(String s)
{
- s.upper();
+ s = s.upper_str();
last_duration_mode = (s== "LAST");
}
/*
should be settable from input to allow "viola"-mode
*/
-static Byte pitch_by_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
+static Byte pitch_byte_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
int
Melodic_req::pitch() const
{
- return pitch_by_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
+ return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
}
Plet_req::Plet_req()
}
void
-Script::set_default_pos()
+Script::set_default_index()
{
Real inter_f= paper()->internote();
Interval dy = symbol().dim.y;
void
Script::do_post_processing()
{
- set_default_pos();
+ set_default_index();
}
Molecule*
else
error_col_i++;
- String str = line_str.left( pos_ch_c_l - begin_ch_c_l )
+ String str = line_str.left_str( pos_ch_c_l - begin_ch_c_l )
+ String( '\n' )
+ String( ' ', error_col_i )
- + line_str.mid( pos_ch_c_l - begin_ch_c_l + 1, INT_MAX ); // String::mid should take 0 arg..
+ + line_str.mid_str( pos_ch_c_l - begin_ch_c_l + 1, INT_MAX ); // String::mid should take 0 arg..
return str;
}
}
Real
-Stem::hpos()const
+Stem::hindex()const
{
return pcol_l_->hpos + stem_xoffset; // hmm. + offset_.x;
}
static void
substitute_arg(String& r, String arg)
{
- int p = r.pos('%');
+ int p = r.index_i('%');
if (!p ) return ;
else p--;
- r = r.left(p) + arg + r.right(r.len() - p -1);
+ r = r.left_str(p) + arg + r.right_str(r.length_i() - p -1);
}
String retval (source);
for (int i = 0 ; i < args.size(); i++)
substitute_arg(retval, args[i]);
- while (retval.pos('%'))
+ while (retval.index_i('%'))
substitute_arg(retval, "");
return retval;
}
}
void
-Text_item::set_default_pos()
+Text_item::set_default_index()
{
pos_i_ = (dir_i_ > 0) ? staffsize_i_ + 2: -4;
}
void
Text_item::do_pre_processing()
{
- set_default_pos();
+ set_default_index();
}
--- /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_;
+}