Add DIR to search path.
+=item B<-k, --key>=ACC[:MINOR],
+
+Set default key. ACC > 0 sets number of sharps; ACC < 0 sets number
+of flats. A minor key is indicated by ":1".
+
=item B<-n, --no-silly>,
Assume no plets or double dots, assume smallest (reciprocal) duration 16.
+pl 9.jcn3
+ - bf: standchen
+ - update 20pt table
+ - mi2mu: bf's, --key option
+ - removed Duration(int,int)
+ - bf: Duration_convert::dur2_str
+
pl 9.jcn2
- redo of mi2mu frontend (midi-parser)
- bf: String_convert::bin2_i; added bin2_u
TOPLEVEL_PATCH_LEVEL = 9
# use to send patches, always empty for released version:
-TOPLEVEL_MY_PATCH_LEVEL = .jcn2
+TOPLEVEL_MY_PATCH_LEVEL = .jcn3
linewidth = 15.0 \cm;
rule_thickness = 0.4\pt;
bar_size = 20.0 \pt;
- interline = 4.\pt;
- notewidth = 5.0\pt;
+ interline = 5.\pt;
+ notewidth = 6.0\pt;
wholewidth = 4.8\pt;
unitspace = 22.\pt;
% basicspace = 4.\pt;
% geometric = 1.414;
geometric = 0.;
- basicspace = 8.\pt;
+ arithmetic_basicspace = 2.5;
+ arithmetic_multiplier = 4.8\pt;
+
%
interbeam = 2.667\pt;
- gourlay_energybound = 50000.;
- gourlay_maxmeasures = 6.;
+ gourlay_energybound = 100000.;
+ gourlay_maxmeasures = 8.;
castingalgorithm = \Gourlay;
\symboltables { \table_twenty }
}
"style" = \table {
- "roman" "\settext{%}" 0.0\pt 5.0\pt 0.0\pt 8.0\pt
+ "roman" "\settext{%}" 0.0\pt 6.0\pt 0.0\pt 8.0\pt
"italic" "\setitalic{%}" 0.0\pt 0.0\pt 0.0\pt 8.0\pt
"dynamic" "\setdynamic{%}" 0.0\pt 0.0\pt 0.0\pt 8.0\pt
}
}
"style" = \table {
- "roman" "\settext{%}" 0.0\pt 5.0\pt 0.0\pt 8.0\pt
+ "roman" "\settext{%}" 0.0\pt 7.5\pt 0.0\pt 10.0\pt
"italic" "\setitalic{%}" 0.0\pt 0.0\pt 0.0\pt 8.0\pt
"dynamic" "\setdynamic{%}" 0.0\pt 0.0\pt 0.0\pt 8.0\pt
}
}
"balls" = \table {
- "1" "\wholeball" 0.0\pt 7.5\pt -2.5\pt 2.5\pt
- "2" "\halfball" 0.0\pt 6.0\pt -2.5\pt 2.5\pt
- "4" "\quartball" 0.0\pt 6.0\pt -2.5\pt 2.5\pt
+ "-1" "\breveball" 0.0\pt 7.5\pt -2.5\pt 2.5\pt
+ "0" "\wholeball" 0.0\pt 7.5\pt -2.5\pt 2.5\pt
+ "1" "\halfball" 0.0\pt 6.0\pt -2.5\pt 2.5\pt
+ "2" "\quartball" 0.0\pt 6.0\pt -2.5\pt 2.5\pt
}
"slur" = \table {
"botlines" "\botlines{%}" -3.0\pt 9.0\pt 0.0\pt 0.0\pt
}
+% "|" "\maatstreep{%}" 0.0\pt 5.0\pt 0.0\pt 20.0\pt
"bars" = \table {
"empty" "\emptybar"
"" "" 0.0\pt 0.0\pt 0.0\pt 16.0\pt
- "|" "\maatstreep{%}" 0.0\pt 5.0\pt 0.0\pt 20.0\pt
+ "|" "\maatstreep{%}" 0.0\pt .64\pt 0.0\pt 20.0\pt
"||" "\doublebar{%}" 0.0\pt 4.0\pt 0.0\pt 20.0\pt
"|." "\finishbar{%}" 0.0\pt 2.0\pt 0.0\pt 20.0\pt
".|" "\startbar{%}" 0.0\pt 4.0\pt 0.0\pt 20.0\pt
"rests" = \table {
"-1o" "\breverest" 0.0\pt 6.0\pt 0.0\pt 4.0\pt
"-1" "\breverest" 0.0\pt 6.0\pt 0.0\pt 4.0\pt
- "1o" "\outsidewholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt
- "1" "\wholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt
- "2" "\halfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt
- "2o" "\outsidehalfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt
- "4o" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt
- "8o" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt
- "16o" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt
- "4" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt
- "8" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt
- "16" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt
- "32" "\thirtysecondrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt
- "64" "\sixtyfourthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt
- "128" "\hundredtwentyeighthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt
+ "0o" "\outsidewholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt
+ "0" "\wholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt
+ "1" "\halfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt
+ "1o" "\outsidehalfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt
+ "2o" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt
+ "3o" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt
+ "4o" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt
+ "2" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt
+ "3" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt
+ "4" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt
+ "5" "\thirtysecondrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt
+ "6" "\sixtyfourthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt
+ "7" "\hundredtwentyeighthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt
}
"meters" = \table {
% 20pt music uses whole pagewidth
linewidth= 195.\mm;
% 20pt music needs some space
- unitspace= 12.\mm;
- % we want gourlay, don't set geometric
- % geometric= 1.4;
- gourlay_maxmeasures = 9.;
+ unitspace= 13.\mm;
}
\midi{
\tempo 4 = 54;
\instrument{M\"a\ss ig} % heu
%#%\tempo{M\"a\ss ig}
\maketit
-% \input standchen.out
+\def\startbar#1{}%huh?
\input lelie.tex
\end{document}
}
-\score{
- <
- < \id "Lyric" "1";
- \tekstI
- \tekstII
- >
- < \id "Piano" "";
- \multi 2;
- \melodic < \melodie \commands >
- \melodic < \begeleiding \commands >
- >
- >
- \paper{
- linewidth= 160.\mm;
- %castingalgorithm = \Wordwrap;
- % on two pages...
- unitspace= 8.\mm;
- %geometric= 1.4;
- gourlay_maxmeasures = 9.;
- \output "standchen.out";
- }
- \midi{
- \tempo 4 = 54;
- }
-}
return String( "[" ) + String( dur.ticks_i_ ) + "]";
String str;
- if (dur.durlog_i_ >= 0)
- str="breve";
+ if (dur.durlog_i_ <= 0)
+ str="\\breve";
else
str= String( type2_i(dur.durlog_i_) );
str += String( '.', dur.dots_i_ );
Han-Wen Nienhuys <hanwen@stack.nl>
*/
+#include <assert.h>
#include "proto.hh"
#include "plist.hh"
#include "string.hh"
ticks_i_ = 0;
}
-Duration::Duration( int type_i, int dots_i = 0 )
-{
- durlog_i_ = type_i;
- dots_i_ = dots_i;
- ticks_i_ = 0;
-}
-
bool
Duration::duration_type_b(int t)
{
Ctor of Duration.
*/
Duration();
- Duration( int type_i, int dots_i = 0 );
/// is the "plet factor" of this note != 1 ?
bool plet_b();
String str()const;
#include "proto.hh"
#include "moment.hh"
+#include "mi2mu-proto.hh"
struct Midi_parser_info
{
Byte const* byte_L_;
Byte const* end_byte_L_;
Source_file* source_l_;
+ Mudela_score* score_l_;
Moment bar_mom_;
};
String notename_str (int pitch_i);
virtual String str();
-private:
+//private:
int accidentals_i_;
int minor_i_;
- int key_i_;
};
class Mudela_meter : public Mudela_item
Mudela_text (Mudela_text::Type type, String str);
virtual String str();
-private:
+//private:
Type type_;
String text_str_;
};
#include "mi2mu-global.hh"
#include "midi-score-parser.hh"
+#include "mudela-item.hh"
#include "mudela-score.hh"
#include "version.hh"
" -d, --debug print lots of debugging stuff\n"
" -h, --help this help\n"
" -I, --include=DIR add DIR to search path\n"
+ " -k, --key=ACC[:MINOR] set key: ACC +sharps/-flats; :1 minor\n"
" -n, --no-silly assume no plets or double dots, smallest is 32\n"
" -o, --output=FILE set FILE as default output\n"
" -p, --no-plets assume no plets\n"
int
main (int argc_i, char* argv_sz_a[])
{
+ Mudela_key key (0, 0);
rat_printer = print_rat;
Long_option_init long_option_init_a[] =
{0, "no-quantify", 'b'},
{0, "debug", 'd'},
{0, "help", 'h'},
+ {1, "key", 'k'},
{0, "no-silly", 'n'},
{1, "output", 'o'},
{0, "no-plets", 'p'},
// case 'I':
// path->push (getopt_long.optional_argument_ch_C_);
// break;
+ case 'k':
+ {
+ String str = getopt_long.optional_argument_ch_C_;
+ int i = str.index_i (':');
+ i = (i >=0 ? i : str.length_i ());
+ key.accidentals_i_ = String_convert::dec2_i (str.left_str (i));
+ key.minor_i_ = (int)(bool)String_convert::dec2_i (str.mid_str (i,1));
+ break;
+ }
case 'n':
Duration_convert::no_double_dots_b_s = true;
Duration_convert::no_triplets_b_s = true;
if (!score_p)
return 1;
+ if (!score_p->mudela_key_l_)
+ score_p->mudela_key_l_ = &key;
mudela_score_l_g = score_p;
score_p->process();
errorlevel_i_ = 0;
byte_L_ = 0;
end_byte_L_ = 0;
+ score_l_ = 0;
}
Midi_parser::Midi_parser ()
info_l_->division_1_i_ = get_i (2) * 4;
if (info_l_->division_1_i_ < 0)
exit ("Cannot handle non-metrical time");
+ // ugh
+ Duration::division_1_i_s = info_l_->division_1_i_;
forward_byte_L (length_i - 6);
}
Mudela_score*
Midi_score_parser::parse_score ()
{
- Mudela_meter m4 (1, 4, 0, 0);
+ int current_bar_i = 0;
+ Mudela_meter m4 (4, 2, 24, 8);
Moment bar4_mom = m4.bar_mom ();
+ Mudela_score* score_p = new Mudela_score( 1, 1, 1 );
+ info_l_->score_l_ = score_p;
+
Link_array<Midi_track_parser> tracks;
for (int i = 0; i < info_l_->tracks_i_; i++)
tracks.push (new Midi_track_parser (info_l_));
- int current_bar_i = 0;
-
- Mudela_score* score_p = new Mudela_score( 1, 1, 1 );
+ LOGOUT (NORMAL_ver) << "Parsing...\n";
while (tracks.size ())
{
int i = find_earliest_i (tracks);
#include "midi-track-parser.hh"
#include "mudela-column.hh"
#include "mudela-item.hh"
+#include "mudela-score.hh"
#include "mudela-staff.hh"
Midi_track_parser::Midi_track_parser (Midi_parser_info* info_l)
int length_i = get_var_i ();
String str = get_str (length_i);
// LOGOUT (DEBUG_ver) << str << endl;
- item_p = new Mudela_text ((Mudela_text::Type)byte, str);
+ Mudela_text::Type t = (Mudela_text::Type)byte;
+ Mudela_text* p = new Mudela_text (t, str);
+ item_p = p;
+ if (t == Mudela_text::COPYRIGHT)
+ mudela_staff_p_->copyright_str_ = p->text_str_;
+ else if (t == Mudela_text::TRACK_NAME)
+ mudela_staff_p_->name_str_ = p->text_str_;
+ else if (t == Mudela_text::INSTRUMENT_NAME)
+ mudela_staff_p_->instrument_str_ = p->text_str_;
}
// END_OF_TRACK [\x2f][\x00]
else
unsigned useconds_per_4_u = get_u (3);
// $$ = new Mudela_tempo ( ($2 << 16) + ($3 << 8) + $4);
// LOGOUT (DEBUG_ver) << $$->str() << endl;
- item_p = new Mudela_tempo ( useconds_per_4_u );
+ Mudela_tempo* p = new Mudela_tempo ( useconds_per_4_u );
+ item_p = p;
+ info_l_->score_l_->mudela_tempo_l_ = p;
}
// SMPTE_OFFSET [\x54][\x05]
else if ((byte == 0x54) && (next == 0x05))
int count_32_i = (int)next_byte ();
Mudela_meter* p = new Mudela_meter ( num_i, den_i, clocks_4_i, count_32_i );
item_p = p;
+ info_l_->score_l_->mudela_meter_l_ = p;
info_l_->bar_mom_ = p->bar_mom ();
}
// KEY [\x59][\x02]
next_byte ();
int accidentals_i = (int)next_byte ();
int minor_i = (int)next_byte ();
- item_p = new Mudela_key (accidentals_i, minor_i);
+ Mudela_key* p = new Mudela_key (accidentals_i, minor_i);
+ item_p = p;
+ info_l_->score_l_->mudela_key_l_ = p;
}
// SSME [\0x7f][\x03]
else if ((byte == 0x7f) && (next == 0x03))
item_p = new Mudela_text ((Mudela_text::Type)byte, str);
}
else
- exit ("Invalid MIDI meta-event");
+ {
+ next_byte ();
+ next_byte ();
+ warning ("Unimplemented MIDI meta-event");
+ }
}
}
else
{
accidentals_i_ = accidentals_i;
minor_i_ = minor_i;
- if (accidentals_i >= 0)
- key_i_ = ((accidentals_i % 7)[ "cgdaebf" ] - 'a' - 2) % 7;
- else
- key_i_ = ((-accidentals_i % 7)[ "cfbeadg" ] - 'a' - 2) % 7;
}
String
Mudela_key::str ()
{
+ int key_i = 0;
+ if (accidentals_i_ >= 0)
+ key_i = ((accidentals_i_ % 7)[ "cgdaebf" ] - 'a' - 2) % 7;
+ else
+ key_i = ((-accidentals_i_ % 7)[ "cfbeadg" ] - 'a' - 2) % 7;
String str = "\\key ";
if (!minor_i_)
- str += String ((char) ((key_i_ + 2) % 7 + 'A'));
+ str += String ((char) ((key_i + 2) % 7 + 'A'));
else // heu, -2: should be - 1 1/2: A -> fis
- str += String ((char) ((key_i_ + 2 - 2) % 7 + 'a'));
+ str += String ((char) ((key_i + 2 - 2) % 7 + 'a'));
str = String ("% \"") + str
+ String ('"') + "; % not supported yet\n";
return str;
Mudela_meter::Mudela_meter (int num_i, int den_i, int clocks_4_i, int count_32_i)
: Mudela_item (0)
{
- sync_dur_.durlog_i_ = 3 ;
+ sync_dur_.durlog_i_ = 3;
sync_f_ = 1.0;
if (count_32_i != 8)
warning (String ("#32 in quarter: ") + String (count_32_i));
Mudela_meter::bar_mom ()
{
Duration d;
- d.durlog_i_ = den_i_;
+ d.durlog_i_ = den_i_;
return Moment (num_i_) * Duration_convert::dur2_mom (d);
}
#include "mudela-staff.hh"
#include "mudela-stream.hh"
-static Mudela_key key_c (0, 0);
+//static Mudela_key key_c (0, 0);
static Mudela_meter meter_4 (4, 2, 24, 8);
// useconds per 4: 250000 === 60 4 per minute
static Mudela_tempo tempo_60 (1000000);
tracks_i_ = tracks_i;
tempo_i_ = tempo_i;
column_l_array_.push (new Mudela_column (this, Moment (0)));
- mudela_key_l_ = &key_c;
+// mudela_key_l_ = &key_c;
+ mudela_key_l_ = 0;
mudela_meter_l_ = &meter_4;
mudela_tempo_l_ = &tempo_60;
}
Mudela_column*
Mudela_score::find_column_l (Moment mom)
{
+#if 0
// should do binary search
for (int i = 0; i < column_l_array_.size (); i++ )
if ( column_l_array_[i]->at_mom () == mom )
return column_l_array_[i];
return 0;
+#else
+ int upper_i = max (0, column_l_array_.size () - 1);
+ int lower_i = 0;
+ int i = 0; //upper_i;
+ while (1)
+ {
+ Moment i_mom = column_l_array_ [i]->at_mom ();
+ if (i_mom == mom)
+ return column_l_array_ [i];
+ if (mom < i_mom)
+ upper_i = i;
+ else
+ lower_i = i;
+ if ((upper_i == lower_i) || (i == column_l_array_.size () - 1))
+ {
+ // we don't do inserts
+ assert (0);
+ Mudela_column* col_p = new Mudela_column (this, mom);
+ column_l_array_.push (col_p);
+ return col_p;
+ }
+ i = (upper_i + lower_i + 1 ) / 2;
+ }
+ assert (0);
+ return 0;
+#endif
}
Mudela_column*
LOGOUT(NORMAL_ver) << "\nQuantifying columns..." << endl;
+ int current_bar_i = 0;
+ Moment bar_mom = mudela_meter_l_->bar_mom();
+
int n = 5 >? Duration_convert::no_smaller_than_i_s;
+ n = Duration_convert::type2_i (n);
Moment s = Moment (1, n);
Moment sh = Moment (1, 2 * n);
for (int i = 0; i < column_l_array_.size(); i++)
{
-// Moment mom = column_l_array_[ i ]->at_mom();
-// column_l_array_[ i ]->at_mom_ = Duration_convert::dur2_mom (dur);
- column_l_array_[ i ]->at_mom_ =
-// s * (int) ( (sh + column_l_array_[ i ]->at_mom()) / s);
- s * (int) ( (column_l_array_[ i ]->at_mom()) / s);
- LOGOUT(NORMAL_ver) << '.';
+ column_l_array_ [i]->at_mom_ =
+ s * (int) ( (column_l_array_ [i]->at_mom()) / s);
+
+ int bar_i = (int) (column_l_array_ [i]->at_mom () / bar_mom) + 1;
+ if (bar_i > current_bar_i)
+ {
+ LOGOUT (NORMAL_ver) << '[' << bar_i << ']' << flush;
+ current_bar_i = bar_i;
+ }
}
LOGOUT(NORMAL_ver) << endl;
}
if (!start_i)
{
start_i = end_i = i;
- start_mom = column_l_array_[ i ]->at_mom();
+ start_mom = column_l_array_ [i]->at_mom();
continue;
}
// find all columns within noise's distance
while ( (i < n)
- && (column_l_array_[ i ]->at_mom() - start_mom < noise_mom))
+ && (column_l_array_ [i]->at_mom() - start_mom < noise_mom))
end_i = ++i;
// bluntly set all to time of first in group
for (int j = start_i; j < end_i; j++)
- column_l_array_[ j ]->at_mom_ = start_mom;
+ column_l_array_ [j]->at_mom_ = start_mom;
start_i = end_i = 0;
}