Commands_at 1
Input_command 1
Time_description 1
-Melodic_req 0
-Stem_req 0
+Melodic_req 1
+Midi_walker 0
+Stem_req 1
Group_change_req 1
Script_req 1
Colinfo 1
/**
short description.
Long class documentation.
+ (Hungarian postfix)
*/
class Class {
/** short description.
void print() const
/**
- protected member. Usually invoked by non-virtual A_virtual_func()
+ protected member. Usually invoked by non-virtual XXXX()
*/
- virtual do_A_virtual_func()
+ virtual do_XXXX()
/**add some data to *this.
Presence of these methods usually imply that it is not feasible to this
=head2 Hungarian
-The Hungarian Notation was conceived by
-or at least got its name from,
-the hungarian programmer x.
-It is a naming convention with the aim
-to make code more readable (for fellow programmers)
-and more accessible for programmers
-that are new to a project.
-
-The essence of the Hungarian Notation
-is that every identifier has a part
-which identifies its type
-(for functions this is the result type).
-This is particularly useful in object oriented programming,
-where a particular object implies a specific interface
-(a set of member functions, perhaps some redefined operators),
-and for accounting heap allocated memory pointers and links.
+The Hungarian Notation was conceived by or at least got its name from,
+the hungarian programmer x. It is a naming convention with the aim to
+make code more readable (for fellow programmers) and more accessible
+for programmers that are new to a project.
+
+The essence of the Hungarian Notation is that every identifier has a
+part which identifies its type (for functions this is the result
+type). This is particularly useful in object oriented programming,
+where a particular object implies a specific interface (a set of
+member functions, perhaps some redefined operators), and for
+accounting heap allocated memory pointers and links.
=head2 Advantages
=over 5
+=item C<byte>
+unsigned cher. (The postfix _by is ambiguous)
+
=item C<b>
bool
=item C<test_ch>
Variable Test: a character
-=item C<firstName_str>
+=item C<first_name_str>
Variable first_name: a String class object
=item C<first_name_ch_a>
ASCII script input, with identifiers (for music reuse),
customizable notenames, customizable fontset
+=item *
+MIDI output lets you check if you have entered the correct notes.
+
=item *
Multiple staffs in one score. Each staff can have a different meters.
=item *
multiple voices within one staff; beams optionally shared
-between voices. (well, more than 2 voices won't look pretty)
+between voices. (well, more than 2 voices won't look pretty --yet.)
=item *
multiple scores within one input file. Each score is output to
used interactively. LilyPond writes output to a file. It will not be
extended to play music, or to recognize music.
-It will output MIDI, though (at some stage)
-
=item *
LilyPond is intended to run on Unix platforms, but it should
be portable to any platform which can run TeX and the GNU tools
=over 5
-=item B<-I,--include>=F<FILE>
+=item B<-I,--include>=F<FILE>,
add F<FILE> to the search path for input files.
-=item B<-d,--debug>,
+=item B<-d,--debug>,
Turn debugging info. LilyPond will read the file F<.dstreamrc>, which
tells for what functions and classes may produce copious debugging
output.
-=item B<-w,--warranty>,
+=item B<-w,--warranty>,
Show the warranty with which LilyPond comes. (It comes with B<NO WARRANTY>!)
-=item B<-o,--output=>F<FILE>,
+=item B<-o,--output=>F<FILE>,
Set the default output file to F<FILE>.
=item B<-i,--init=>F<FILE>
-set init file (default: F<symbol.ini>)
+set init file to F<FILE> (default: F<symbol.ini>)
-=item B<--include, -I>
-add to file search path.
+=item B<--include, -I>=F<DIRECTORY>
+add F<DIRECTORY> to the search path for input files.
=back
=head1 PREREQUISITES
-Compilation:
+For compilation you need.
=over 5
GNU make.
=item *
-flex (2.5.1 or better)
+Flex (2.5.1 or better)
=item *
Bison.
=item *
The "Flower" library, which should be available from the same
-source you got this from.
+source you got this from. The version of flower lib should match the
+one which is found in the F<configure> script.
=item *
-perl. The Makefile uses perl for trivial operations, and you
+Perl. The Makefile uses Perl for trivial operations, and you
could tinker with it to use sed or awk.
=back
=over 5
=item *
-a fast computer (well; full page of music typically takes 1
-minute on my 486/66, using the DEBUG compile)
+a fast computer (a full page of music typically takes 1 minute
+on my 486/66, using the DEBUG compile. It's lot slower than most
+MusiXTeX preprocessors)
=item *
TeX
=item *
-The MusixTeX fonts. (I use version T.59)
+The MusixTeX fonts. (I use version those found in MusixTeX
+Taupin version T.59)
=back
make
You might want to edit Variables.make to tailor the compilation flags.
-why G++ >= 2.7? LilyPond & flower lib uses:
+why G++ >= 2.7? LilyPond & FlowerLib uses:
=over 5
hw:~/musix/spacer$ xdvi test&
[1] 855
-Check out F<kortjakje.ly>, it has some comments
+Check out the input files, some of them have comments
=head1 PROBLEMS
-If LilyPond bombs out, then please recompile using B<-g>, and send a
-copy of the input which causes the error and a gdb stacktrace of the
-crash. It also helps if you can print the values of the objects. So if
-your trace is
+If LilyPond bombs out, then please recompile using with debugging info
+turned on, and send a copy of the input which causes the error and a
+gdb stacktrace of the crash. It also helps if you can print the values
+of the objects. So if your trace is
(gdb) backtrace 12
#0 Interval::operator+= (this=0x11fffec60..)
LilyPond has no connection with the music package RoseGarden, other
than the names being similar :-)
-
=head1 HISTORY
(for a detailed changelog, see F<NEWS>)
=head1 DESCRIPTION
+Some questions that have been answered before.
Q: Why are [] around the notes, and () inbetween?
Q: Why GPL?
A: Yes.
+
+Q: Why shouldn't I put all commands (\clef, \meter) inside the music?
+
+A: You should do what you like, but at some time we will enable
+quoting of music ("Stichnoten"). Besides if you are going to type an
+orchestral score, then you'd probably want to enter most of those
+commands only once.
+
+
=item 2. Processing:
-Requests are processed and granted. In this step data-structures for
-3. are created and filled with data: PScore, PCol, PStaff
+Requests are processed and granted. This is done by three cooperating
+structeres: Staff, Staff_walker and Staff_column. In this step
+data-structures for 3. are created and filled with data: PScore, PCol,
+PStaff
=item 3. Calculation:
The judge in this "allocation" problem is Staff (actually, it's child
C<Complex_staff>). It uses the C<Request_register> to do most of the
-work class. For each request C<Complex_staff> queries so-called
+work. For each request C<Complex_staff> queries so-called
C<Request_register>s if they want to accept a request eg, the
C<Notehead_register> will accept C<Note_req>s, and turn down
-C<Slur_req>s. If C<Complex_staff> cannot find a register wants the
-request, it is junked (with a warning message).
+C<Slur_req>s. If C<Complex_staff> cannot find a register that wants
+the request, it is junked (with a warning message).
After all requests have been either assigned, or junked, the Register
will process the requests (which usually means creating an C<Item> or
LilyPond first reads 'symbol.ini', which contains declarations crucial
to proper operation of LilyPond (symbol tables, note names).
-This language looks a lot like Rayce's which in turn owes a lot to the
-POVRay raytracer. Now, I know, musictypesetting and Raytracing do not
-necessarily require the same input format, but I was just to lazy to
-make up a new and/or better input format. Suggestions appreciated.
+This language looks a lot like Rayce's (Rayce is a raytracer that I've
+written as a hobby project. I used as a practice program for writing
+(among others) C++ and Yacc. It also gave me RSI :-( ) which in turn
+owes a lot to the POVRay raytracer. Now, I know, musictypesetting and
+Raytracing do not necessarily require the same input format, but I was
+just to lazy to make up a new and/or better input format. Suggestions
+appreciated.
local $base="lilypond/";
local @examples=("wohltemperirt");
-system 'make html';
+system 'pod2html';
print "resetting refs.\n";
"gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif"
}
-system "mkdir docxx; make -C.. docxx; ln ../docxx/* ./docxx/;"
-
-system "tar cf website.tar *.html *.gif *.png *.ps docxx/;" .
-"gzip -9 website.tar;"
+system "mkdir docxx; make -C.. docxx; ln ../docxx/* ./docxx/;" .
+ "tar cf website.tar *.html *.gif *.png *.ps docxx/;" .
+ "gzip -9 website.tar;"
all: kompijl doc
-win32: # value of $(OSTYPE) on windhoos; "make $OSTYPE" if u use bash :-)
+# value of $(OSTYPE) on windhoos; "make $OSTYPE" if u use bash :-)
+win32:
$(MAKE) -C . CXX=g++
doc:
+*******
+pl33
+Examples
+ - Swedish notenames (MB)
+Features
+ - Jan's patches, see below
+Bugfix
+ - some midi bugfixes.
+
+pl pre33-1 (JCN)
+
+
+ - midi output using pitches iso notename
+Examples
+ - added midi output (some midi output files broken?)
+ - all melodic fixed (except for error.ly:-)
+ - midi.ly
+Bugfix
+ - midiwalker line break
+ - empty/nonexistent include at top of ly
+ - midi #tracks
+ - midi pitch c0
+ - midi poor man-s staff dynamics
+Internal
+ - Midi_column, Midi_staff, Midi_walker
+
+pl pre33 (JCN)
+ - Jan's patches, see below
+
+Features
+ - simple plet notation (JCN)
+ - lyrics centred, but no fully suppored? (JCN)
+Internal
+ - Midi_stream
+ - Mididef
+ - Midi_item, Midi_pitch, Midi_duration
+ - Midi_chunk, Midi_header, Midi_track
+ - preparations for midi output
+ - no exit upon context error (JCN)
+ - converted some "warnings" to errors; no output (JCN)
+Bugfix:
+ - simple plet bugfix
+Examples
+ - updated standchen, menuetto (JCN)
+ - new plet notation (JCN)
+ - plet.ly (parse and spacing tests) (JCN)
+
+*******
pl 32
+Features
- multiple meters, see rhythm.ly
-
-
-pl 32-2
- skip syntax/Skip_req
- - command carnage
- score_wide_music: commands in staff now override commands in score.
Internal:
+ - command carnage
- Key_register
- Bar_register
- Meter_register
- website added to doco
- clef must *inside* music
- fixed spurious "beam too narrow" messages.
-Internal
+Internal:
- merge musical / non-musical staff_column
- musical/ non-musical requests
- Clef_register
- split up request.hh, Musical_req vs. Nonmusical_req
-
+*******
pl 31
Examples
- standchen updated
Bugfix
- calcideal assertion bugfix
-
+*******
pl 30
Features
pl 29
- multiplatform Makefile (JN)
- context errors: bugfixes (JN)
-
+*******
pl 28
Internal
- stupid typo in Staff_elem::post_processing()
- init of hpos in PCol::PCol
- Word_wrap::solve() bug
-
+*******
pl 27
- preliminary WIN32 support (JN)
Features
Internal:
- Text_reg and Script_reg
-
+*******
pl 26
- Documentation/lelie_logo.png
- 8-bit chars for input (see ltest.tex) (MB)
- added Request_register
- Voice_group_registers, Voice_registers, *_register
- Complex_staff
-
+*******
pl 25
- other clefs added, keys typeset properly (MB)
+*******
pl 24:
- Lyrics (JCN)
- Commands in music-mode (an input feature) (there you are, Mats)
+*******
pl 23:
- TODO file inc'd
- cadenza mode.
- unconnected columns
+*******
pl 22:
- doco from mpp
- repeat signs
- bug noteheadswap
- huge memleak fixed; unearthed lots of bugs
+*******
pl 21:
- scripts
- texts
- Move breaking stuff into a separate class Break_algorithm
- dependencies for Staff_elem's
+*******
pl 20:
- updated doco to .pod
- include files from .ly
- Rational for time measurement
- directionalspanner/textspanner
+*******
pl 19:
- grouping code: LilyPond can set advanced multibeams.
Internal changes:
- struct Moment
+*******
pl 18:
- robust Staff_commands
+*******
pl 17:
- robust Input_commands
- merged Vertical_/Horizontal music
- PARTIALs with duration
- modularized lexer: multiple runs
+*******
pl 16
- notenames configurable
+*******
pl 15
- grouping code
- multibeams (simple)
+*******
pl 14
- symtables from .ly
- Input_command
- Input_{score/staff}
+*******
pl 13
- Horizontal/Vertical music
- Input_commands
-IMPORTANT: if you have downloaded a
+IMPORTANT:
+
+if you have downloaded a
*.pre*
version, then this is version is *not* meant for producing nice output
-(but to keep your patchsets up to date)
+(but to keep your patchsets up to date). It might not even compile.
====================
+
Please refer to the directory Documentation/, Documentation/README.*
To generate the pretty-printed docs, do this:
LilyPond is a long way from finished and polished. I do appreciate
criticism, comments, bugreports, patches, etc. Please send e-mail to
+me,
- hanwen@stack.urc.tue.nl
+ hanwen@stack.nl
Have fun!
keyword.hh leastsquares.hh lexer.hh linespace.hh \
localkeyitem.hh localkeyreg.hh lookup.hh \
lyriccolumn.hh lyricitem.hh lyricstaff.hh lyricwalker.hh\
- main.hh meter.hh meterreg.hh misc.hh\
+ main.hh meter.hh meterreg.hh\
+ midicolumn.hh mididef.hh midiitem.hh midistaff.hh midistream.hh\
+ midiwalker.hh midiscorewalker.hh\
+ misc.hh\
molecule.hh moment.hh musicalrequest.hh\
notehead.hh notename.hh offset.hh paperdef.hh\
parseconstruct.hh pcol.hh proto.hh pscore.hh pstaff.hh qlp.hh\
localkeyitem.cc localkeyreg.cc lookup.cc\
lyriccolumn.cc lyricitem.cc lyricstaff.cc lyricwalker.cc\
main.cc meter.cc meterreg.cc\
+ mididef.cc midicolumn.cc midiitem.cc midistaff.cc midistream.cc\
+ midiwalker.cc midiscorewalker.cc\
misc.cc molecule.cc mylexer.cc note.cc notehead.cc notename.cc\
paperdef.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\
register.cc request.cc rest.cc sccol.cc score.cc\
before 0.1
- * martien.ly, standchen.ly
+ * Register_groups as a baseclass.
+
+ * Junk Staff/Staff_col children.
* pushgroup, popgroup.
* basic dynamics
- * triplet notation
-
- * midi output
+ * MIDI syntax.
* decent TeX page layout
- * < .. > vs. { .. }
+ * < .. > vs. { .. } syntax? !
This is an assorted collection of stuff that will be done, might be
done, or is an idea that I want to think about
* $cis ( | ) cis$
+ * Group_feature at start of music.
+
+ * size of Key_item
+
SEVERELY LACKING:
* grace notes
SMALLISH PROJECTS
- * bar numbers
+ * parshape
+
+ * bar numbers/repetition marks
* read from mmap directly: study yy_scan_buffer
* enter Requests directly
- * itemcolumns
+ * itemcolumns: Use dummy items.
* use an embedded language: scheme, lisp, S-lang, Perl, ?
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=32
+PATCHLEVEL=33
# VM hardware to trap malloc/free errors.
#
-EXTRALIB= #+=-lefence
+EXTRALIB+= #-lefence
####
#### END USER CONFIGURABLE part.
STRIPDEBUG=true #replace to do stripping of certain objects
LINKER=$(CXX)
+include Site.make
-
-include Site.make
\ No newline at end of file
+include Site.make
#!/bin/sh
+# script to setup library and auto generated files.
+
+function setversion() {
+ eval `sed -n 's/^\([A-Z]*\)=\([p0-9].*\)$/\1=\2/p' Variables.make`
+ NEWVER=$MAJVER.$MINVER.$PATCHLEVEL
+ echo
+ echo "Current version ("`pwd`") is $NEWVER"
+ echo
+}
+
+MAKE=${MAKE:-make}
PREFIX=${PREFIX:-.}
+NEEDFLOWERVER=1.1.1
+
echo using PREFIX=$PREFIX
+echo I need Flower version $NEEDFLOWERVER
-NEEDFLOWERVER=1.0.27
flowertar=flower-$NEEDFLOWERVER
here=`pwd`
cd ..
+
if [ -x flower ]
then
echo Found flowerdir
fi
rm flower
ln -s $flowertar flower
-
fi
+
echo Compiling Library
-(cd flower;make)
+{
+ cd flower;
+ setversion
+ if [ $NEWVER != $NEEDFLOWERVER ]; then
+ echo "You seem to be having an incorrect version of the Flower library"
+ else
+ echo "You got the correct Flower version."
+ fi
+ $MAKE
+}
cd $here
echo '#define LIBDIR "'$PREFIX'/"'> hdr/config.hh
touch Site.make
-make -f Initial.make
+$MAKE -f Initial.make
+
+1.1:
+
+
+------------------
+1.0:
+
+pl 27-1,2 (not released)
+ patches by JCN
+ - stringutils.cc included again
+ - bin2hex_str bugfix
+ - String class handles null bytes
+ - StringUtils inlined/outlined by #define
+ - StringConversion (only hex for now)
+
pl 27
- (temporarily?) removed findcursor* t*mat*
- win32 patches (JN)
pl 22
- - Array::add -> Array::push
\ No newline at end of file
+ - Array::add -> Array::push
-cc=choleski.cc dataf.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\
-path.cc scalar.cc smat.cc string.cc textdb.cc unionfind.cc vector.cc
+cc=choleski.cc datafile.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\
+path.cc scalar.cc smat.cc string.cc stringconversion.cc stringutil.cc\
+textdb.cc textstream.cc unionfind.cc vector.cc
templatecc=cursor.tcc list.tcc plist.tcc interval.tcc\
pcursor.tcc
hh=assoc.hh associter.hh choleski.hh compare.hh cursor.hh dstream.hh\
fproto.hh handle.hh interval.hh iterate.hh lgetopt.hh link.hh list.hh\
matrix.hh path.hh pcursor.hh plist.hh rational.hh real.hh scalar.hh\
-smat.hh string.hh stringutil.hh textdb.hh textstr.hh unionfind.hh\
-varray.hh vector.hh vsmat.hh
+smat.hh string.hh stringconversion.hh stringutil.hh \
+textdb.hh textstream.hh unionfind.hh\
+varray.hh vector.hh vsmat.hh datafile.hh
+
+extra=stringtest.cc
MAJVER=1
-MINVER=0
-PATCHLEVEL=27
+MINVER=1
+PATCHLEVEL=0
PACKAGENAME=flower
#PROFILEFLAG=-pg
-DEBUGFLAG= -O2 -DNDEBUG # -g
-OPTIFLAG=-DNDEBUG -DNPRINT -O2
+DEBUGFLAG= -g
+OPTIFLAG= -DNPRINT -O2 -DSTRING_UTILS_INLINED -DNDEBUG
#########################################
obs=$(cc:.cc=.o)
staticlib=libflower.a
-ALLSOURCES=$(hh) $(cc) $(inl) $(templatecc)
+ALLSOURCES=$(hh) $(cc) $(inl) $(templatecc) $(extra)
DFILES=$(ALLSOURCES) Makefile Variables.make make_version\
Sources.make TODO README NEWS
DDIR=$(DNAME)
+++ /dev/null
-#include <fstream.h>
-#include <ctype.h>
-
-#include "textstr.hh"
-Text_stream::Text_stream(String fn)
-{
- if (fn == "")
- {
- name = "<STDIN>";
- f = stdin;
- }
-
- else
- {
- name = fn;
- f = fopen(fn, "r");
- }
-
- if (!f) {
- cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n";
- exit(1);
- }
-
- line_no = 1;
- }
-
-void
-Text_stream::message(String s)
-{
- cerr << "\n"<<get_name() << ": " << line()<<": "<<s<<endl;
-}
-
-void
-Data_file::gobble_white()
-{
- char c;
-
- while ((c=data_get()) == ' ' ||c == '\t')
- if (eof())
- break;
-
- data_unget(c);
-}
-
-String
-Data_file::get_word()
-{// should handle escape seq's
- String s;
-
- while (1)
- {
- char c = data_get();
-
- if (isspace(c) || eof())
- {
- data_unget(c);
- break;
- }
-
-
- if (c == '\"')
- {
- rawmode= true;
-
- while ((c = data_get()) != '\"')
- if (eof())
- error("EOF in a string");
- else
- s += c;
-
-
- rawmode= false;
- }
- else
- s += c;
- }
-
- return s;
-}
-
-/** get a char
- Only class member who uses text_file::get
- */
-char
-Data_file::data_get() {
- char c = get();
- if (!rawmode && c == '#') // gobble comment
- {
- while ((c = get()) != '\n' && !eof())
- ;
- return '\n';
- }
-
- return c;
-}
-
-/// read line, gobble '\n'
-String Data_file::get_line()
-{
- char c;
- String s;
-
- while ((c = data_get()) != '\n' && !eof())
- s += c;
- return s;
-}
-
-/// gobble stuff before first entry on a line.
-void
-Data_file::gobble_leading_white()
-{
- // eat blank lines.
- while (!eof()) {
- char c = data_get();
- if (!isspace(c)) {
- data_unget(c);
- break;
- }
- }
-}
-
-
--- /dev/null
+#include <fstream.h>
+#include <ctype.h>
+
+#include "datafile.hh"
+
+void
+Data_file::gobble_white()
+{
+ char c;
+
+ while ((c=data_get()) == ' ' ||c == '\t')
+ if (eof())
+ break;
+
+ data_unget(c);
+}
+
+String
+Data_file::get_word()
+{// should handle escape seq's
+ String s;
+
+ while (1)
+ {
+ char c = data_get();
+
+ if (isspace(c) || eof())
+ {
+ data_unget(c);
+ break;
+ }
+
+
+ if (c == '\"')
+ {
+ rawmode= true;
+
+ while ((c = data_get()) != '\"')
+ if (eof())
+ error("EOF in a string");
+ else
+ s += c;
+
+
+ rawmode= false;
+ }
+ else
+ s += c;
+ }
+
+ return s;
+}
+
+/** get a char
+ Only class member who uses text_file::get
+ */
+char
+Data_file::data_get() {
+ char c = get();
+ if (!rawmode && c == '#') // gobble comment
+ {
+ while ((c = get()) != '\n' && !eof())
+ ;
+ return '\n';
+ }
+
+ return c;
+}
+
+/// read line, gobble '\n'
+String Data_file::get_line()
+{
+ char c;
+ String s;
+
+ while ((c = data_get()) != '\n' && !eof())
+ s += c;
+ return s;
+}
+
+/// gobble stuff before first entry on a line.
+void
+Data_file::gobble_leading_white()
+{
+ // eat blank lines.
+ while (!eof()) {
+ char c = data_get();
+ if (!isspace(c)) {
+ data_unget(c);
+ break;
+ }
+ }
+}
+
+
--- /dev/null
+/*
+ datafile.hh -- declare Data_file
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef DATAFILE_HH
+#define DATAFILE_HH
+
+#include "textstream.hh"
+
+/// read a data file
+class Data_file : private Text_stream
+{
+
+ public:
+ bool rawmode;
+
+ Text_stream::line;
+ Text_stream::eof;
+ Text_stream::get_name;
+
+ char data_get();
+ void data_unget(char c) {
+ unget(c);
+ }
+
+ /// read line, eat #\n#
+ String get_line();
+
+ /// read a word till next space, leave space. Also does quotes
+ String get_word();
+
+ /// gobble horizontal white stuff.
+ void gobble_white();
+
+ /// gobble empty stuff before first field.
+ void gobble_leading_white();
+ Data_file(String s) : Text_stream(s) {
+ //*mlog << "(" << s << flush;
+ rawmode= false;
+ }
+
+ ~Data_file() {
+ // *mlog << ")"<<flush;
+ }
+
+ warning(String s) {
+ message("warning: " + s);
+ }
+ error(String s){
+ message(s);
+ exit(1);
+ }
+};
+#endif // DATAFILE_HH
{
os = r;
silent = new Assoc<String,bool>;
+ indentlvl = 0;
if (!os)
return;
- indentlvl = 0;
const char * fn =cfg_nm ? cfg_nm : ".dstreamrc";
{
#include "dstream.hh"
#include "matrix.hh"
-static Dstream *dout = new Dstream(0,0);
-
+static Dstream *dout = 0;
+/**
+ Set the debugging output. Will not delete/swallow argument.
+ */
void set_matrix_debug(Dstream&ds)
{
dout = &ds;
Matrix::operator String() const
{
- String s("matrix {\n");
+ String s;
#ifndef NPRINT
+ s="matrix {\n";
for (int i=0; i< rows(); i++){
for (int j = 0; j < cols(); j++) {
s+= String(dat->elem(i,j), "%6f ");
Matrix::print() const
{
#ifndef NPRINT
+ if (!dout)
+ return;
*dout << *this;
#endif
}
Vector::operator String() const
{
- String s("vector [");
+ String s;
#ifndef NPRINT
+ s="vector [";
for (int i=0; i < dim(); i++) {
s += String(dat[i], "%6f") + String(' ');
}
-#endif
s+="]";
+#endif
return s;
}
Vector::print() const
{
#ifndef NDEBUG
+ if (!dout)
+ return;
*dout << *this<<'\n';
#endif
}
+#include <assert.h>
#include <stdio.h>
#include "scalar.hh"
int conv = false;
if (len()) {
long l =0;
- conv = sscanf(data, "%ld", &l);
+ conv = sscanf(strh_.ch_c_l(), "%ld", &l);
}
return len() && conv;
}
Rehacked by HWN 3/nov/95
removed String &
introduced Class String_handle
-
-*/
+ */
#include <string.h>
#include <stdlib.h>
#include "string.hh"
-static char* strlwr( char* s )
+static char*
+strlwr( char* s )
{
char* p = s;
return s;
}
-static char* strupr( char* s )
+static char*
+strupr( char* s )
{
char* p = s;
}
// return array, alloced with new.
-char *
-String::copy_array() const
+Byte*
+String::copy_by_p() const
{
- const char *src = data;
- char *dest = new char[data.len() + 1];
- strcpy(dest, src);
+ Byte const* src = strh_.by_c_l();
+ Byte* dest = new Byte[strh_.length_i() + 1];
+ memmove( dest, src, strh_.length_i() + 1 );
return dest;
}
void
String::printOn(ostream& os) const
{
- os << (const char*) data;
+ if ( length_i() == strlen( ch_c_l() ) )
+ os << ch_c_l();
+ else
+ for ( int i = 0; i < length_i(); i++ )
+ os << (Byte)(*this)[ i ];
}
String::String (bool b)
{
- *this = (const char *) (b ? "true" : "false");
+ *this = (char const* ) (b ? "true" : "false");
}
-String::String( const char* source )
+String::String( char const* source )
{
assert(source);
- data = source;
+ strh_ = source;
+}
+
+String::String( Byte const* by_l, int length_i )
+{
+ assert( !length_i || by_l );
+ strh_.set( by_l, length_i );
}
void
String::operator +=(String s)
{
- *this += (const char *) s;
+ strh_.append( s.by_c_l(), s.length_i() );
}
int
-String::len() const
+String::length_i() const
{
- return data.len();
+ return strh_.length_i();
}
String::String(char c, int n)
char s[81];
memset(s, c, l);
s[l] = 0;
- data = s;
+// strh_ = s;
+ strh_.set( (Byte*)s, n );
}
String::String(int i)
{
- char digits[ 81 ]; // who the FUCK is 80???
+ char digits[ 81 ]; // who the fuck is 80???
digits[ 0 ] = '\0';
sprintf(digits, "%d", i ); // assume radix 10
- data = digits;
+ strh_ = digits;
}
-String::String( const int i, const int n, const char c )
+String::String( const int i, const int n, char const c )
{
char fillChar = c;
if ( fillChar)
String v( i );
- data = String( fillChar, n - v.len() ) + String( v );
- // String convd to const char *
+ String str = String( fillChar, n - v.length_i() ) + String( v );
+ strh_.set( str.by_c_l(), str.length_i() );
}
-const char*
-String::cptr() const
+Byte const*
+String::by_c_l() const
{
- return data;
+ return strh_.by_c_l();
}
+char const*
+String::ch_c_l() const
+{
+ return strh_.ch_c_l();
+}
+Byte*
+String::by_l()
+{
+ return strh_.by_l();
+}
+
+char*
+String::ch_l()
+{
+ return strh_.ch_l();
+}
-// signed comparison, analogous to strcmp;
+// signed comparison, analogous to memcmp;
int
-String::compare(const String& s1,const String &s2 )
+String::compare(String const& s1, String const& s2 )
{
- const char * p1=s1.cptr();
- const char * p2 = s2.cptr();
- if (p1 == p2)
+ Byte const* p1 = s1.by_c_l();
+ Byte const* p2 = s2.by_c_l();
+ if ( p1 == p2 )
return 0;
- return strcmp(p1,p2);
+ int i1 = s1.length_i();
+ int i2 = s2.length_i();
+ int i = i1 <? i2;
+
+ if (! i )
+ return 0;
+
+ int result = memcmp( p1, p2, i );
+
+ return (result)? result : i1 - i2;
}
int
-String::lastPos( const char c ) const
+String::lastPos( char const c ) const
{
- const char *me = data;
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ char const* me = strh_.ch_c_l();
int pos = 0;
- if ( len() )
+ if ( length_i() )
{
- const char* p = strrchr(me, c );
+ char const* p = strrchr(me, c );
if ( p )
pos = p - me + 1;
}
}
int
-String::lastPos( const char* string ) const
+String::lastPos( char const* string ) const
{
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
int pos = 0;
int length = strlen( string );
- if ( len() && length )
+ if ( length_i() && length )
{
int nextpos = this->pos( string );
while( nextpos )
{
pos += nextpos;
- nextpos = right( len() - pos - length + 1 ).pos( string );
+ nextpos = right( length_i() - pos - length + 1 ).pos( string );
}
}
return pos;
// find c
// return 0 if not found.
-// ? should return len()?, as in string.left(pos(delimiter))
+// ? should return length_i()?, as in string.left(pos(delimiter))
int
String::pos(char c ) const
{
- const char *me = data;
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ char const* me = strh_.ch_c_l();
int pos = 0;
- if ( len() )
+ if ( length_i() )
{
- const char* p = strchr( me, c );
+ char const* p = strchr( me, c );
if ( p )
pos = p - me + 1;
}
// find searchfor. (what if this == "" && searchfor == "") ???
int
-String::pos( const char* searchfor ) const
+String::pos( char const* searchfor ) const
{
- const char *me = data;
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ char const* me = strh_.ch_c_l();
int pos = 0;
- if ( len() && searchfor)
+ if ( length_i() && searchfor)
{
- const char* p = strstr(me, searchfor);
+ char const* p = strstr(me, searchfor);
if ( p )
pos = p - me + 1;
}
// find chars of a set.
int
-String::posAny( const char* string ) const
+String::posAny( char const* string ) const
{
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
int pos = 0;
- const char *s = (const char *)data;
- if ( len() && string )
+ char const* s = (char const* )strh_.ch_c_l();
+ if ( length_i() && string )
{
- const char* p = strpbrk( s, string );
+ char const* p = strpbrk( s, string );
if ( p )
pos = p - s + 1;
}
String
String::left( int n ) const
{
- if (n >= len())
+ if (n >= length_i())
return *this;
String retval;
return retval;
retval = *this;
- retval.data.trunc(n);
+ retval.strh_.trunc(n);
return retval;
}
String
String::right( int n ) const
{
- if (n > len())
+ if (n > length_i())
return *this;
- String retval;
if ( n < 1)
- return retval;
+ String();
- const char *src = (const char *)data + len() - n;
- retval += src;
-
- return retval;
+ return String( strh_.by_c_l() + length_i() - n, n );
}
if ( pos < 1 )
return String("");
- if ( pos > len())
+ if ( pos > length_i())
return *this;
- return String( String( left( pos - 1 ) ) + right( len() - pos - n + 1 ));
+ return String( String( left( pos - 1 ) ) + right( length_i() - pos - n + 1 ));
}
String
String::mid( int pos, int n ) const
{
- String retval;
-
- // HWN. This SUX:
- // pos 1 == data->string[ 0 ];
+ // HWN. This SUX: JCN: yep, please change me + all my invocations
+ // pos 1 == strh_->string[ 0 ];
// pos 0 allowed for convenience
- if ( !len() || ( pos < 0 ) || ( pos > len() ) && ( n < 1 ) )
- return retval;
+ if ( !length_i() || ( pos < 0 ) || ( pos > length_i() ) && ( n < 1 ) )
+ return String();
- retval = ((const char *) data) + pos -1;
- if (n > retval.len())
- n =retval.len();
- retval.data.trunc(n);
- return retval;
+ // overflow...
+ if ( ( n > length_i() ) || ( pos + n - 1 > length_i() ) )
+ n = length_i() - pos + 1;
+
+ return String( by_c_l() + pos -1, n );
}
String
String::upper()
{
- char *s = data.array_for_modify();
- strupr(s );
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ char *s = strh_.by_l();
+ strupr( s );
return *this;
}
// to lowercase
-String String::lower()
+String
+String::lower()
{
- char *s = data.array_for_modify();
+ // not binary safe
+ assert( length_i() == strlen( ch_c_l() ) );
+ char* s = strh_.by_l();
strlwr(s);
return *this;
}
-String::String (double f, const char *fmt)
+String::String (double f, char const* fmt)
{
/* worst case would be printing HUGE (or 1/HUGE), which is approx
- 2e318, this number would have approx 318 zero's in its string.
+ 2e318, this number would have approx 318 zero's in its string.
1024 is a safe length for the buffer
*/
String::value() const
{
long l =0;
- if (len()) {
- int conv = sscanf(data, "%ld", &l);
+ if (length_i()) {
+ int conv = sscanf(strh_.ch_c_l(), "%ld", &l);
assert(conv);
}
return l;
String::fvalue() const
{
double d =0;
- if (len()) {
- int conv = sscanf(data, "%lf", &d);
+ if (length_i()) {
+ int conv = sscanf(strh_.ch_c_l(), "%lf", &d);
assert(conv);
}
return d;
}
-char *strrev(char *s)
+Byte*
+strrev( Byte* by_l, int length_i )
{
- char c;
- char *p = s;
- char *q = s + strlen(s) - 1;
-
- while (q > p) {
- c = *p;
- *p++ = *q;
- *q-- = c;
+ Byte by;
+ Byte* left_by_l = by_l;
+ Byte* right_by_l = by_l + length_i;
+
+ while ( right_by_l > left_by_l ) {
+ by = *left_by_l;
+ *left_by_l++ = *right_by_l;
+ *right_by_l-- = by;
}
- return s;
+ return by_l;
}
String
String::reversed() const
{
- String retval=*this;
- char *s = retval.data.array_for_modify();
- strrev(s);
- return retval;
+ String str = *this;
+ strrev( str.by_l(), str.length_i() );
+ return str;
}
#include "stringutil.hh"
-/** the smart string class.
-
+/**
+
Intuitive string class. provides
-
+\begin{itemize}
+\item
ref counting through #String_handle#
+\item
conversion from bool, int, double, char *, char.
+\item
conversion to int, upcase, downcase
+\item
printable.
+\item
indexing (pos, posAny, lastPos)
+\item
cutting (left, right, mid)
+\item
concat (+=, +)
+\item
signed comparison (<, >, ==, etc)
+\item
No operator[] is provided, since this would be enormously slow. If needed,
- convert to const char *.
+ convert to const char *.
+\end{itemize}
*/
class String
{
protected:
- String_handle data; // should derive String from String_handle?
+ String_handle strh_; // should derive String from String_handle?
public:
- /** init to "". needed because other constructors are provided.*/
+
+ /** init to "". needed because other constructors are provided.*/
String() { }
String(Rational);
/// String s = "abc";
String( const char* source );
+
+ String( Byte const* l_by_c, int length_i );
/// "ccccc"
String( char c, int n = 1 );
String( int i, int n, char c = ' ' );
/// return a "new"-ed copy of contents
- char *copy_array() const; // return a "new"-ed copy of contents
+ Byte* copy_by_p() const; // return a "new"-ed copy of contents
- const char *cptr() const;
- const char *ptr() { return ((const String *)this)->cptr(); }
+ char const* ch_c_l() const;
+ Byte const* by_c_l() const;
+ char* ch_l();
+ Byte* by_l();
- /// return the data. Don't use for writing the data.
- operator const char *() const { return cptr(); }
+ /// deprecated; use ch_c_l()
+ operator const char *() const { return ch_c_l(); }
- String operator =( const String & source ) { data = source.data; return *this; }
+ String operator =( const String & source ) { strh_ = source.strh_; return *this; }
/// concatenate s
- void operator += (const char *s) { data += s; }
+ void operator += (char const* s) { strh_ += s; }
void operator += (String s);
- char operator []( int n ) const { return data[n]; }
+ char operator []( int n ) const { return strh_[n]; }
/// return n leftmost chars
String left( int n ) const;
String reversed() const;
- /// return a piece starting at pos (first char = pos 1), length n
+ /// return a piece starting at pos (first char = pos 1), ength n
String mid(int pos, int n ) const;
/// cut out a middle piece, return remainder
String nomid(int pos, int n ) const;
- /// signed comparison, analogous to strcmp;
+ /// signed comparison, analogous to memcmp;
static int compare(const String& s1,const String& s2);
/// index of rightmost c
/// index of rightmost element of string
int lastPos( const char* string ) const;
- /** index of leftmost c.
- RETURN:
+ /**
+ index of leftmost c.
+
+ @return
0 if not found, else index + 1
*/
int pos(char c ) const;
double fvalue() const;
/// the length of the string
- int len() const;
+ int length_i() const;
+
+ // deprecated
+ int len() const {
+ return length_i();
+ }
};
String quoteString(String message, String quote);
+#include "stringconversion.hh"
+
#endif
--- /dev/null
+/*
+ PROJECT: FlowerSoft C++ library
+ FILE : stringconversion.cc
+
+--*/
+
+
+#include <assert.h>
+#include "string.hh"
+
+String
+StringConversion::bin2hex_str( String bin_str )
+{
+ String str;
+ Byte const* by_c_l = bin_str.by_c_l();
+ for ( int i = 0; i < bin_str.length_i(); i++ ) {
+ str += (char)nibble2hex_by( *by_c_l >> 4 );
+ str += (char)nibble2hex_by( *by_c_l++ );
+ }
+ return str;
+}
+
+int
+StringConversion::hex2bin_i( String hex_str, String& bin_str_r )
+{
+ if ( hex_str.length_i() % 2 )
+ hex_str = "0" + hex_str;
+
+ bin_str_r = "";
+ Byte const* by_c_l= hex_str.by_c_l();
+ int i = 0;
+ while ( i < hex_str.length_i() ) {
+ int high_i = hex2nibble_i( *by_c_l++ );
+ int low_i = hex2nibble_i( *by_c_l++ );
+ if ( high_i < 0 || low_i < 0 )
+ return 1; // illegal char
+ bin_str_r += String( (char)( high_i << 4 | low_i ), 1 );
+ i += 2;
+ }
+ return 0;
+}
+
+String
+StringConversion::hex2bin_str( String hex_str )
+{
+ String str;
+// silly, asserts should alway be "on"!
+// assert( !hex2bin_i( hex_str, str ) );
+ int error_i = hex2bin_i( hex_str, str );
+ assert( !error_i );
+ return str;
+}
+
+int
+StringConversion::hex2nibble_i( Byte by )
+{
+ if ( by >= '0' && by <= '9' )
+ return by - '0';
+ if ( by >= 'A' && by <= 'F' )
+ return by - 'A' + 10;
+ if ( by >= 'a' && by <= 'f')
+ return by - 'a' + 10;
+ return -1;
+}
+
+String
+StringConversion::int2hex_str( int i, int length_i, char ch )
+{
+ String str;
+ if ( !i )
+ str = "0";
+ while ( i ) {
+ str = ( i % 16 )["0123456789abcdef"] + str;
+ i /= 16;
+ }
+ if ( str.length_i() < length_i )
+ str = String( ch, length_i - str.length_i() ) + str;
+ return str;
+}
+
+Byte
+StringConversion::nibble2hex_by( Byte by )
+{
+ if ( ( by & 0x0f ) <= 9 )
+ return ( by & 0x0f ) + '0';
+ else
+ return ( by & 0x0f ) - 10 + 'a';
+}
--- /dev/null
+/*
+ PROJECT: FlowerSoft C++ library
+ FILE : stringconversion.hh
+
+*/
+
+#ifndef __STRING_CONVERSION_HH
+#define __STRING_CONVERSION_HH
+
+/**
+ all conversions from/to String go in here.( some time, anyway )
+ Quite empty
+ */
+class StringConversion {
+ static int hex2bin_i( String hex_str, String& bin_str_r );
+ static int hex2nibble_i( Byte by );
+ static Byte nibble2hex_by( Byte by );
+public:
+ static String bin2dec_str( String dec_str );
+static String bin2hex_str( String bin_str );
+ static String dec2bin_str( String str );
+ static int dec2int_i( String str );
+ static int hex2int_i( String str );
+ static String hex2bin_str( String str );
+ static String int2hex_str( int i, int length_i, char ch );
+ static String int2dec_str( int i, int length_i, char ch );
+};
+
+#endif // __STRING_CONVERSION_HH //
--- /dev/null
+// stringtest.cc
+
+#include <iostream.h>
+#include "string.hh"
+
+int
+main()
+{
+ String str( "hai" );
+ cout << str << endl;
+ cout << "left" << endl;
+ cout << " 0:" << str.left( 0 ) << endl;
+ cout << " 1:" << str.left( 1 ) << endl;
+ cout << " 2:" << str.left( 2 ) << endl;
+ cout << " 3:" << str.left( 3 ) << endl;
+ cout << " 4:" << str.left( 4 ) << endl;
+ cout << "right" << endl;
+ cout << " 0:" << str.right( 0 ) << endl;
+ cout << " 1:" << str.right( 1 ) << endl;
+ cout << " 2:" << str.right( 2 ) << endl;
+ cout << " 3:" << str.right( 3 ) << endl;
+ cout << " 4:" << str.right( 4 ) << endl;
+
+ str += " daar";
+ cout << str << endl;
+
+ str = String( "hallo" ) + " daar" + '!';
+ cout << str << endl;
+
+ if ( str == String( "" ) )
+ cout << str << " is empty" << endl;
+ String fn = "";
+ if ( fn == "" )
+ cout << fn << " is empty" << endl;
+
+ fn = "";
+ fn += "";
+ delete fn.copy_by_p();
+
+ delete str.copy_by_p();
+
+ cout << StringConversion::bin2hex_str( String( (char)0xff ) ) << endl;
+}
--- /dev/null
+// stringutil.cc
+#ifndef __STRING_UTIL_CC
+#define __STRING_UTIL_CC
+
+// include only when
+// * reading stringutil.hh, or
+// * string util stuff not inlined
+#if !defined STRING_UTILS_INLINED
+
+#include <assert.h>
+#include <memory.h>
+#include "stringutil.hh"
+
+
+// namespace StringData { namespaces are broken in this version of g++
+// gcc version 2.7.2.1
+
+
+StringData::StringData()
+{
+ references=0;
+ maxlen = INITIALMAX;
+ data_by_p_ = new Byte[maxlen + 1];
+ data_by_p_[0] = 0;
+ length_i_ = 0;
+}
+
+StringData::StringData(StringData const &src)
+{
+ references=0;
+ maxlen = length_i_ = src.length_i_;
+ data_by_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead.
+ memmove( data_by_p_, src.data_by_p_, length_i_ + 1 );
+}
+
+
+StringData::~StringData()
+{
+ assert(references == 0);
+ delete[] data_by_p_;
+}
+
+void
+StringData::setmax(int j)
+{
+ OKW();
+ if (j > maxlen) {
+ delete data_by_p_;
+ maxlen = j;
+ data_by_p_ = new Byte[maxlen + 1];
+
+ data_by_p_[0] = 0;
+ length_i_ = 0;
+ }
+}
+
+
+void
+StringData::remax(int j)
+{
+ OKW();
+ if (j > maxlen) {
+ maxlen = j;
+ Byte *p = new Byte[maxlen + 1];
+ memmove( p, data_by_p_, length_i_ + 1 );
+ delete[] data_by_p_;
+ data_by_p_ = p;
+ // length_i_ = strlength_i(data_by_p_);
+ }
+}
+
+
+void
+StringData::OKW()
+{
+ assert (references == 1);
+}
+
+void
+StringData::OK()
+{
+// can-t do this with binary data
+// assert(strlen(data_by_p_) == size_t(length_i_));
+ assert(maxlen >= length_i_);
+ assert(bool(data_by_p_));
+ assert(references >= 1);
+}
+
+// // needed?
+// well, we can't -> depreciated
+// void update() {
+// length_i_ = strlen (data_by_p_);
+// }
+
+
+void
+StringData::tighten()
+{ // should be dec'd const
+ maxlen = length_i_;
+ Byte *p = new Byte[maxlen + 1];
+ memmove( p, data_by_p_, length_i_ + 1 );
+ delete[] data_by_p_;
+ data_by_p_ = p;
+}
+
+// assignment.
+void
+StringData::set( Byte const* by_c_l, int length_i )
+{
+ OKW();
+
+ assert( by_c_l && by_c_l != data_by_p_);
+
+ length_i_ = length_i;
+ remax( length_i_ );
+ memmove( data_by_p_, by_c_l, length_i_ );
+ data_by_p_[ length_i_ ] = 0;
+}
+
+
+void
+StringData::set( char const* ch_c_l )
+{
+ set( (Byte const*)ch_c_l, strlen( ch_c_l ) );
+}
+
+
+/// concatenation.
+void
+StringData::append( Byte const* by_c_l, int length_i )
+{
+ OK();
+ OKW();
+ int old_i = length_i_;
+
+ length_i_ += length_i;
+ remax( length_i_ );
+ memmove( data_by_p_ + old_i, by_c_l, length_i );
+ data_by_p_[ length_i_ ] = 0;
+}
+
+
+void
+StringData::operator += ( char const* ch_c_l )
+{
+ append( (Byte const*)ch_c_l, strlen( ch_c_l ) );
+}
+
+char const*
+StringData::ch_c_l() const
+{
+ return (char const*)data_by_p_;
+}
+
+char*
+StringData::ch_l()
+{
+ return (char*)data_by_p_;
+}
+
+Byte const*
+StringData::by_c_l() const
+{
+ return data_by_p_;
+}
+
+// idem, non const
+Byte*
+StringData::by_l()
+{
+ OKW();
+ return data_by_p_;
+}
+
+void
+StringData::trunc(int j)
+{
+ OKW();
+ assert(j >= 0 && j <= length_i_);
+ data_by_p_[j] = 0;
+ length_i_ = j;
+}
+
+Byte&
+StringData::operator [](int j)
+{
+ assert(j >= 0 && j <= length_i_);
+ return data_by_p_[j] ;
+}
+
+Byte
+StringData::operator [](int j) const
+{
+ assert(j >= 0 && j <= length_i_);
+ return data_by_p_[j];
+}
+
+
+// } namespace broken
+
+
+
+
+// namespace String_handle {
+
+
+void
+String_handle::down()
+{
+ if (!(--data->references)) delete data; data = 0;
+}
+
+/// increase ref count
+void
+String_handle::up(StringData *d)
+{
+ data=d; data->references ++;
+}
+
+void
+String_handle::copy()
+{
+ if (data->references !=1){
+ StringData *newdata = new StringData(*data);
+ down();
+ up(newdata);
+ }
+}
+
+String_handle::String_handle()
+{
+ up(new StringData);
+}
+String_handle::~String_handle()
+{
+ down();
+}
+String_handle::String_handle(String_handle const & src)
+{
+ up(src.data);
+}
+
+Byte*
+String_handle::by_l()
+{
+ copy();
+ return data->by_l();
+}
+
+char*
+String_handle::ch_l()
+{
+ copy();
+ return (char*)data->by_l();
+}
+
+Byte
+const* String_handle::by_c_l() const
+{
+ return data->by_c_l();
+}
+
+char const*
+String_handle::ch_c_l() const
+{
+ return (char const*)data->by_c_l();
+}
+
+void
+String_handle::operator =(String_handle const &src)
+{
+ if (this == &src)
+ return;
+ down();
+ up(src.data);
+}
+
+void
+String_handle::operator += (char const *s)
+{
+ copy();
+ *data += s;
+}
+
+
+Byte
+String_handle::operator[](int j) const
+{
+ return (*data)[j];
+}
+
+// !NOT SAFE!
+// don't use this for loops. Use by_c_l()
+Byte &
+String_handle::operator[](int j)
+{
+ copy(); // hmm. Not efficient
+ return data->by_l()[j];
+}
+
+void
+String_handle::append( Byte const* by_c_l, int length_i )
+{
+ copy();
+ data->append( by_c_l, length_i );
+}
+
+void
+String_handle::set( Byte const* by_c_l, int length_i )
+{
+ copy();
+ data->set( by_c_l, length_i );
+}
+
+void
+String_handle::operator = (char const *p)
+{
+ copy();
+ data->set( p );
+}
+
+void
+String_handle::trunc(int j)
+{
+ copy(); data->trunc(j);
+}
+
+int
+String_handle::length_i() const
+{
+ return data->length_i_;
+}
+
+
+// } namespaces broken
+
+
+#endif // not STRING_UTILS_INLINED //
+
+#endif // __STRING_UTIL_CC //
-#ifndef STRINGUTIL_HH
-#define STRINGUTIL_HH
-#include <assert.h>
-
+#ifndef __STRING_UTIL_HH
+#define __STRING_UTIL_HH
+#if 0
#if !defined(NDEBUG)
#define NDEBUG BLONDE
#endif
-
+#endif
const INITIALMAX=8;
class String_handle;
-/** Internal String struct.
+
+typedef unsigned char Byte;
+
+#ifdef STRING_UTILS_INLINED
+#define INLINE inline
+#else
+#define INLINE
+#endif
+
+/**Internal String struct.
the data itself. Handles simple tasks (resizing, resetting)
*/
-
class StringData {
// GNU malloc: storage overhead is 8 bytes anyway.
-
friend class String_handle;
int maxlen; // maxlen is arraysize-1
- int length;
- char* string;
+ int length_i_;
+ Byte* data_by_p_;
int references;
/// init to ""
- StringData() {
- references=0;
- maxlen = INITIALMAX;
- string = new char[maxlen + 1];
- string[0] = 0;
- length = 0;
- }
+ INLINE StringData();
/// init from src. Conservative allocation.
- StringData(StringData const &src) {
- references=0;
- maxlen = length = src.length;
- string = new char[maxlen+1]; // should calc GNU 8byte overhead.
- strcpy(string, src.string);
- }
+ INLINE StringData(StringData const &src);
- ~StringData() {
- assert(references == 0);
- delete[] string;
- }
-
+ ~StringData();
/** POST: maxlen >= j.
- IN: j, maximum stringlength.
+ IN: j, maximum stringlength_i_.
contents thrown away.
*/
- void setmax(int j) {
- OKW();
- if (j > maxlen) {
- delete string;
- maxlen = j;
- string = new char[maxlen + 1];
-
- string[0] = 0;
- length = 0;
- }
- }
+ INLINE void setmax(int j);
/** POST: maxlen >= j.
- IN: j, maximum stringlength.
+ IN: j, maximum stringlength_i_.
contents are kept if it grows.
*/
- void remax(int j) {
- OKW();
- if (j > maxlen) {
- maxlen = j;
- char *p = new char[maxlen + 1];
- strcpy(p,string);
- delete[] string;
- string = p;
- // length = strlen(string);
- }
- }
- /// check if writeable.
- void OKW() {
-
- assert (references == 1);
+ INLINE void remax(int j);
- }
+ /// check if writeable.
+ INLINE void OKW();
/// check state.
- void OK() {
- assert(strlen(string) == size_t(length));
- assert(maxlen >= length);
- assert(bool(string));
- assert(references >= 1);
- }
-
- // needed?
- void update() {
- length = strlen (string);
- }
+ INLINE void OK();
/// reduce memory usage.
- void tighten() { // should be dec'd const
- maxlen = length;
- char *p = new char[maxlen + 1];
- strcpy(p,string);
- delete[] string;
- string = p;
- }
+ INLINE void tighten();
// assignment.
- void set(const char *s) {
- OKW();
-
- assert(s);
+ INLINE void set( Byte const* by_c_l, int length_i );
- length = strlen (s);
- remax(length);
- strcpy(string,s);
- }
+ INLINE void set( char const* ch_c_l );
/// concatenation.
- void operator += (const char *s) {
- OK();
- OKW();
- int old = length;
-
- length += strlen(s);
- remax (length);
- strcpy(string + old, s);
- }
-
- /// the array itself
- operator const char *() const { return string; }
+ INLINE void append( Byte const* by_c_l, int length_i );
+
+ INLINE void operator += ( char const* ch_c_l );
+
+ INLINE char const* ch_c_l() const;
+
+ INLINE char* ch_l();
+
+ INLINE Byte const* by_c_l() const;
// idem, non const
- char *array_for_modify() {
- OKW();
- return string;
- }
- void trunc(int j) {
- OKW();
- assert(j >= 0 && j <= length);
- string[j] = 0;
- length = j;
- }
-
- /** access a char. not really safe. Can alter length without
- *StringData knowing it. */
- char &operator [](int j) {
- assert(j >= 0 && j <= length);
- return string[j] ;
- }
-
- char operator [](int j) const {
- assert(j >= 0 && j <= length);
- return string[j];
- }
+ INLINE Byte* by_l();
+
+ INLINE void trunc(int j);
+
+ /** not really safe. Can alter length_i_ without StringData knowing it.
+ */
+ INLINE Byte &operator [](int j);
+ INLINE Byte operator [](int j) const;
};
-/** ref. counting for strings.
- handles ref. counting, and provides a very thin
- interface using char *
- */
+
+/**
+ Reference counting for strings.
+
+ handles ref. counting, and provides a very thin interface using
+ Byte *
+
+ */
class String_handle {
StringData* data;
/// decrease ref count. Named kind of like a Tanenbaum semafore
- void down() { if (!(--data->references)) delete data; data = 0; }
+ INLINE void down();
/// increase ref count
- void up(StringData *d) { data=d; data->references ++; }
+ INLINE void up(StringData *d);
/** make sure data has only one reference.
POST: data->references == 1
*/
- void copy() {
- if (data->references !=1){
- StringData *newdata = new StringData(*data);
- down();
- up(newdata);
- }
- }
+ INLINE void copy();
public:
-
- String_handle() {
- up(new StringData);
- }
- ~String_handle() {
- down();
- }
- String_handle(String_handle const & src) {
- up(src.data);
- }
-
- /// retrieve the actual array.
- operator const char *() const { return *data; }
- char *array_for_modify() {
- copy();
- return data->array_for_modify();
- }
-
- void operator =(String_handle const &src) {
- if (this == &src)
- return;
- down();
- up(src.data);
- }
-
- void operator += (const char *s) {
- copy();
- *data += s;
- }
-
-
- char operator[](int j) const { return (*data)[j]; }
-
- // !NOT SAFE!
- // don't use this for loops. Use array_for_modify()
- char &operator[](int j) {
- copy(); // hmm. Not efficient
- return data->array_for_modify()[j];
- }
-
- void operator = (char const *p) {
- copy();
- data->set(p);
- }
-
- void trunc(int j) { copy(); data->trunc(j); }
- int len() const { return data->length; }
+ INLINE String_handle();
+ INLINE ~String_handle();
+ INLINE String_handle(String_handle const & src);
+
+ INLINE Byte const* by_c_l() const;
+ INLINE char const* ch_c_l() const;
+ INLINE Byte* by_l();
+ INLINE char* ch_l();
+
+ INLINE void operator =(String_handle const &src);
+ INLINE void operator += (char const *s);
+ INLINE Byte operator[](int j) const;
+
+ /** Access elements. WARNING: NOT SAFE
+ don't use this for loops. Use by_c_l()
+ */
+ INLINE Byte &operator[](int j);
+ INLINE void append( Byte const* by_c_l, int length_i );
+ INLINE void set( Byte const* by_c_l, int length_i );
+ INLINE void operator = (char const *p);
+ INLINE void trunc(int j);
+ INLINE int length_i() const;
};
+#if 0
#ifdef NDEBUG
#if (NDEBUG == BLONDE)
#undef NDEBUG
#endif
#endif
+#endif
+#ifdef STRING_UTILS_INLINED
+#include "stringutil.cc"
+#endif
-
-#endif // STRINGUTIL_HH
+#endif // __STRING_UTIL_HH //
#ifndef TEXTDB_HH
#define TEXTDB_HH
-#include "textstr.hh"
+#include "datafile.hh"
/**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */
+++ /dev/null
-
-#ifndef TEXTSTR_HH
-#define TEXTSTR_HH
-
-#include <stdio.h>
-#include <ctype.h>
-#include "string.hh"
-#include "varray.hh"
-
-/** line counting input stream.
- a stream for textfiles. linecounting. Thin interface getchar and
- ungetchar. (ungetc is unlimited)
-
- should protect get and unget against improper use
-*/
-
-
-class Text_stream
-{
- int line_no;
-
- // could just have used streams.
- FILE *f;
- Array<char> pushback;
- String name;
-
- public:
- Text_stream(String fn);
- String get_name() { return name; }
- bool eof() {
- return feof(f);
- }
- bool eol() {
- return (peek() == '\n');
- }
- char peek() {
- char c = get();
- unget(c);
- return c;
- }
- int line(){
- return line_no;
- }
-
- char get() {
- char c;
-
- if (pushback.empty())
- c = getc(f);
- else
- c = pushback.pop();
-
- if (c =='\n')
- line_no++;
- return c;
- }
- void unget(char c) {
- if (c =='\n')
- line_no--;
- pushback.push(c);
- }
- ~Text_stream (){
- if (!eof())
- cerr <<__FUNCTION__<< ": closing unended file";
-
- fclose(f);
- }
-
- /// GNU format message.
- void message(String s);
-};
-/// read a data file
-class Data_file : private Text_stream
-{
-
- public:
- bool rawmode;
-
- Text_stream::line;
- Text_stream::eof;
- Text_stream::get_name;
-
- char data_get();
- void data_unget(char c) {
- unget(c);
- }
-
- /// read line, eat #\n#
- String get_line();
-
- /// read a word till next space, leave space. Also does quotes
- String get_word();
-
- /// gobble horizontal white stuff.
- void gobble_white();
-
- /// gobble empty stuff before first field.
- void gobble_leading_white();
- Data_file(String s) : Text_stream(s) {
- //*mlog << "(" << s << flush;
- rawmode= false;
- }
-
- ~Data_file() {
- // *mlog << ")"<<flush;
- }
-
- warning(String s) {
- message("warning: " + s);
- }
- error(String s){
- message(s);
- exit(1);
- }
-};
-#endif
--- /dev/null
+#include "textstream.hh"
+
+Text_stream::Text_stream(String fn)
+{
+ ios::sync_with_stdio();
+ if (fn == "")
+ {
+ name = "<STDIN>";
+ f = stdin;
+ }
+
+ else
+ {
+ name = fn;
+ f = fopen(fn, "r");
+ }
+
+ if (!f) {
+ cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n";
+ exit(1);
+ }
+
+ line_no = 1;
+ }
+
+void
+Text_stream::message(String s)
+{
+ cerr << "\n"<<get_name() << ": " << line()<<": "<<s<<endl;
+}
+
--- /dev/null
+
+#ifndef TEXTSTR_HH
+#define TEXTSTR_HH
+
+#include <stdio.h>
+#include <ctype.h>
+#include "string.hh"
+#include "varray.hh"
+
+/**
+ line counting input stream.
+ a stream for textfiles. linecounting. Thin interface getchar and
+ ungetchar. (ungetc is unlimited)
+
+ should protect get and unget against improper use
+*/
+
+
+class Text_stream
+{
+ int line_no;
+
+ // could just have used streams.
+ FILE *f;
+ Array<char> pushback;
+ String name;
+
+ public:
+ Text_stream(String fn);
+ String get_name() { return name; }
+ bool eof() {
+ return feof(f);
+ }
+ bool eol() {
+ return (peek() == '\n');
+ }
+ char peek() {
+ char c = get();
+ unget(c);
+ return c;
+ }
+ int line(){
+ return line_no;
+ }
+
+ char get() {
+ char c;
+
+ if (pushback.empty())
+ c = getc(f);
+ else
+ c = pushback.pop();
+
+ if (c =='\n')
+ line_no++;
+ return c;
+ }
+ void unget(char c) {
+ if (c =='\n')
+ line_no--;
+ pushback.push(c);
+ }
+ ~Text_stream (){
+ if (!eof())
+ cerr <<__FUNCTION__<< ": closing unended file";
+
+ fclose(f);
+ }
+
+ /// GNU format message.
+ void message(String s);
+};
+
+#endif
/** draw a (repeat)-bar. This something different than #Barcheck_req#,
the latter should only happen at the start of a measure. */
struct Bar_req : Nonmusical_req {
- String type;
+ String type_str_;
Bar_req(String);
+ int compare(const Bar_req&)const;
REQUESTMETHODS(Bar_req,bar);
};
struct Terminate_voice_req : Nonmusical_req {
extern ostream *mlog;
// debugging
-extern Dstream monitor; // monitor
+extern Dstream *monitor; // monitor
#ifdef NPRINT
-#define mtor if (0) monitor // clever hack
+#define mtor if (0) *monitor // clever hack
#else
-#define mtor if (check_debug) monitor.identify_as(__PRETTY_FUNCTION__)
+#define mtor if (check_debug) monitor->identify_as(__PRETTY_FUNCTION__)
#endif
extern bool check_debug;
*/
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 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(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);
};
/// paper_, staffs_ and commands_ form the problem definition.
Paperdef *paper_p_;
+ Mididef* midi_p_;
IPointerList<Input_staff*> staffs_;
Input_music * score_wide_music_p_;
~Input_score();
/// construction
void set(Paperdef*);
+ void set(Mididef* midi_p);
void print() const;
Score*parse();
void set(Input_music*);
Assoc<String, Identifier*> *the_id_tab;
Keyword_table * keytable;
Notename_tab * defaulttab;
- char const* data_ch_c_l_;
int errorlevel_i_;
/* *************** */
int ret_notename(int *p, String text, int octave_mod);
//
// lyriccolumn.hh -- declare Lyric_column
//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.nl>
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
-#ifndef LYRICCOLUMN_HH
-#define LYRICCOLUMN_HH
+#ifndef LYRIC_COLUMN_HH
+#define LYRIC_COLUMN_HH
#include "key.hh"
#include "stcol.hh"
Lyric_column(Lyric_staff*rs);
};
-#endif // LYRICSTAFF_HH
+#endif // LYRIC_COLUMN_HH
//
// lyricitem.hh -- part of LilyPond
//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.nl>
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
#ifndef LYRIC_ITEM_HH
#define LYRIC_ITEM_HH
};
-#endif // LYRICITEM_HH
+#endif // LYRIC_ITEM_HH //
/*
lyricstaff.hh -- part of LilyPond
- copyright 1997 Jan Nieuwenhuizen <jan@digicash.nl>
+ copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
*/
#ifndef LYRICSTAFF_HH
-/*
- lyricwalker.hh -- declare Lyric_walker
-
- (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen <jan@digicash.nl>
-*/
+//
+// lyricwalker.hh -- declare Lyric_walker
+//
+// (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen <jan@digicash.com>
+//
#ifndef LYRICWALKER_HH
#define LYRICWALKER_HH
/// 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);
};
+/// 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
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);
struct Meter_change_req;
struct Meter;
struct Meter_register;
+struct Midi_column;
+struct Mididef;
+struct Midi_duration;
+struct Midi_header;
+struct Midi_item;
+struct Midi_pitch;
+struct Midi_staff;
+struct Midi_stream;
+struct Midi_track;
+struct Midi_walker;
struct Mixed_qp;
struct Molecule;
struct Musical_req;
struct Offset;
struct Output;
struct PCol;
+struct Plet_req;
struct PScore;
struct PStaff;
struct Paperdef;
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; }
struct Score {
/// paper_, staffs_ and commands_ form the problem definition.
Paperdef *paper_p_;
+ Mididef *midi_p_;
IPointerList<Staff*> staffs_;
/// "runtime" fields for setting up spacing
/// output to file
void output(String fn);
+ /// do midi stuff
+ void midi();
+
+ ///
+ void set(Mididef* midi_p);
+
// standard
void OK() const;
void print() const;
//
// source.hh -- part of LilyPond
//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.nl>
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
#ifndef SOURCE_HH
#define SOURCE_HH
//
// sourcefile.hh -- declare Source_file
//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.nl>
+// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
#ifndef SOURCE_FILE_HH
#define SOURCE_FILE_HH
/// 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();
Moment start;
/* *************** */
- Moment when(const Voice_element*)const;
- Moment last() const;
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);
};
/** one horizontal bit. Apart from being a container for the requests, Voice_element is nothing
/* *************** */
- void add(Request*);
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);
+ /// return true when done
};
#endif
DFILES=dutch.ini table_sixteen.ini table_twenty.ini\
- english.ini script.ini symbol.ini bare.ini
+ english.ini script.ini symbol.ini bare.ini swedish.ini
default:
echo huh?
--- /dev/null
+%
+% common Swedish names for notes. "-ess" means flat, "-iss" means sharp
+%
+% by Mats Bengtsson.
+
+swedish_names =
+notenames {
+ "cessess" 0 -2 "cess" 0 -1 "c" 0 0 "ciss" 0 1 "cississ" 0 2
+ "dessess" 1 -2 "dess" 1 -1 "d" 1 0 "diss" 1 1 "dississ" 1 2
+ "essess" 2 -2 "ess" 2 -1 "e" 2 0 "eiss" 2 1 "eississ" 2 2
+ "fessess" 3 -2 "fess" 3 -1 "f" 3 0 "fiss" 3 1 "fississ" 3 2
+ "gessess" 4 -2 "gess" 4 -1 "g" 4 0 "giss" 4 1 "gississ" 4 2
+ "assess" 5 -2 "ass" 5 -1 "a" 5 0 "aiss" 5 1 "aississ" 5 2
+ "hessess" 6 -2 "b" 6 -1 "h" 6 0 "hiss" 6 1 "hississ" 6 2
+}
+
+
+notenames { swedish_names }
+
DISTFILES=Makefile kortjakje.ly pavane.ly maartje.ly\
cadenza.ly scales.ly standchen.ly twinkle.ly\
- wohltemperirt.ly error.ly\
+ wohltemperirt.ly\
+ error.ly midi.ly plet.ly\
martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\
coriolan-alto.ly rhythm.ly \
standchen.tex pavane.tex scsii-menuetto.tex scsii-menuetto.ly\
\duration{16} [d cis d e]
f4()[f e d c]
`b4
- \octave{} \plet{2/3} ['d8 'c8 a8] \plet{1/1}
+ \octave{} ['d8 'c8 a8]2/3
g2
\bar \empty
[g c e g] ['c e g 'c]\octave{'}
music { cad }
}
commands {
- cadenza $1$
+ cadenza {1}
grouping{1*4}
}
-}
+ midi { tempo 4:80 }
+ staff { midi music { cad } }
+}
\ No newline at end of file
alto = music {
$
\duration{ 8 }
- \key {$bes es as$}
+ \key {bes es as}
- } \clef "alto"
+ \clef "alto"
% these are chords (i.e. non-divisi)
% that-s why i-d rather type chords,
% but how to type slurs?
+include "this-is-hopefully-a-nonexisting-file"
+
mwa = music {
$
[ a8 a8 a8 a8 a8 ] %
[ a8 ] %
+% segfault
+% { \music{ [ bes^"1"( )a bes-. g-. ] a4-.^"4" } \music{ [ e ] } \music{ [ c ] } } |
a ) b ] c % warning
& % ok; error
a b ) ] % ok; error
% more of this.
begeleiding =
-$ \clef "bass" % bass-clef
- \music { % as you can see, the $ sign obliges
+% $\clef bass % bass-clef
+% \music { % as you can see, the $ sign obliges
% you to precede keyword by a backslash: \
+ music { $
+ \clef "bass"
\octave { ` } % default octave: 1 below the first octave.
%%% theme
}
commands {
meter {2*4}
- key $fis$
+% key $fis$
skip 56*2
- key $bes es as$
+% key $bes es as$
skip 8*2
meter {6*8}
skip 48*8
meter {2*4}
skip 16*2
- key $fis$
+% key $fis$
}
paper {
% unitspace 16mm
width 195mm
output "martien.out"
}
+ staff {
+ midi_track
+ music { alto }
+ }
+ staff {
+ midi_track
+ music { violin1 }
+ }
+ staff {
+ midi_track
+ music { violin2 }
+ }
+ staff {
+ midi_track
+ music { cello }
+ }
+ midi {
+ tempo 4:80
+ }
}
--- /dev/null
+% midi.ly
+% test source for lilypond-s midi output
+
+
+% BUG: 2e noot van begeleiding bij g2 niet gespeeld.
+% BUG: rust (5e maat) niet gespeeld.
+melodie = music {
+ $\clef\violin
+ c c | g g | a a | g2 | r2
+ f f | e e | d d8.( e16 | )c2 | % :|
+ $
+}
+
+begeleiding = music {
+ $
+ \clef \bass
+ \octave{`}
+ c 'c | 'e 'c | 'f 'c | 'e 'c | r2
+ 'd b | 'c a | f g | c2 |
+ $
+}
+
+mstaf = staff {
+ melodic
+ music { melodie }
+}
+
+bass_staf = staff {
+ melodic
+ music { begeleiding }
+}
+
+score {
+% staff { mstaf }
+% staff { bass_staf }
+% paper { unitspace 2.5cm }
+ % in own audio { } block iso score { } ?
+ % allow no score { } block ?
+
+ staff { midi music { melodie } }
+ staff { midi music { begeleiding } }
+% staff { midi music { bla } }
+ midi {
+ tempo 4:120
+ }
+ commands {
+ meter { 2 * 4 }
+ }
+}
+
\duration{16}
\clef\alto
\octave{}
+ \key{fis}
%1
[ `b8. `a ] [ `g8 `b c ] |
%2
%44
[ `b8. c32 `b32 ] `a4 |
%45
- \plet{ 4/6 } [ `g `a `g `a `g `a ] \plet{ 1/1 } \plet{ 4/6 } [ `g `b c d e fis ] \plet{ 1/1 } |
+ [ `g `a `g `a `g `a ]4/6 [ `g `b c d e fis ]4/6 |
%46
- \plet{ 4/6 } [ g fis e d `b `g ] \plet{ 1/1 } [ `a8 `g8 ] |
+ [ g fis e d `b `g ]4/6 [ `a8 `g8 ] |
%47
- \plet{ 4/6 } [ g fis e d c `b ] \plet{ 1/1 } \plet{ 4/6 } [ e d c `b `a `g ] \plet{ 1/1 } |
+ [ g fis e d c `b ]4/6 [ e d c `b `a `g ]4/6 |
%48
- \plet{ 4/6 } [ d e d d `b `g ] \plet{ 1/1 } [ `a8 `g8 ] |
+ [ d e d d `b `g ]4/6 [ `a8 `g8 ] |
%theme 2
\duration{8}
%49
- \plet{ 2/3 } [ f e d ] \plet{ 1/1 } f4 |
+ [ f e d ]2/3 f4 |
%50
- \plet{ 2/3 } [ e d c ] \plet{ 1/1 } e4 |
+ [ e d c ]2/3 e4 |
%51
- \plet{ 2/3 } [ d g `g ] \plet{ 1/1 } \plet{ 2/3 } [ `g `a `b ] \plet{ 1/1 } |
+ [ d g `g ]2/3 [ `g `a `b ]2/3 |
%52
d4 e4 |
%53
- \plet{ 2/3 } [ f e d ] \plet{ 1/1 } f4 |
+ [ f e d ]2/3 f4 |
%54
- \plet{ 2/3 } [ e d c ] \plet{ 1/1 } e4 |
+ [ e d c ]2/3 e4 |
%55
- \plet{ 2/3 } [ d g `g ] \plet{ 1/1 } \plet{ 2/3 } [ `g `a `b ] \plet{ 1/1 } |
+ [ d g `g ]2/3 [ `g `a `b ]2/3 |
%56
- `b4 c4 | % || \key\Es
+ `b4 c4 \key{bes es as} | % || \key\Es
%57
[ `b d ] [ `g `b ] |
%58
`b2 |
%88
\textstyle "italic"
- c2_"dacapo" |
+ c2_"dacapo" \key{fis} |
\textstyle "roman"
%\scoreverb{\mulooseness=1}
% \key\G ||
$
\clef"bass" \octave{`}
\duration{4}
+ \key{fis}
%%1
g `g |
%%2
%%49
\textstyle "italic"
r4_"arco"
- \plet{ 2/3 } [ `g `g `g ] \plet{ 1/1 } |
+ [ `g `g `g ]2/3 |
\textstyle "roman"
%%50
- r4 \plet{ 2/3 } [ c c c ] \plet{ 1/1 } |
+ r4 [ c c c ]2/3 |
%%51
g2 |
%%52
c2 |
%%53
- r4 \plet{ 2/3 } [ `g `g `g ] \plet{ 1/1 } |
+ r4 [ `g `g `g ]2/3 |
%%54
- r4 \plet{ 2/3 } [ c c c ] \plet{ 1/1 } |
+ r4 [ c c c ]2/3 |
%%55
g2 |
%%56
- `g4 `c4 |
+ `g4 `c4 \key{bes es as}|
% \key\`es ||
%%57
g r g r |
d |
%%88
\textstyle "italic"
- d_"dacapo"
+ d_"dacapo" \key{fis} |
\textstyle "roman"
% \key\`g ||
$
%
violin1 = music {
$
-\clef "violin"
+ \clef "violin"
\octave{}
\duration{4}
+ \key{fis}
%1
g [ b8. a16 ] |
%2
%theme 2
%49
\textstyle "italic"
- r4_"arco" \plet{ 2/3 } [ b8 b b ] \plet{ 1/1 }
+ r4_"arco" [ b8 b b ]2/3
\textstyle "roman" |
%50
- r4 \plet{ 2/3 } [ g g g ] \plet{ 1/1 } |
+ r4 [ g g g ]2/3 |
%51
b2 |
%52
'c2 |
%53
- r4 \plet{ 2/3 } [ b b b ] \plet{ 1/1 } |
+ r4 [ b b b ]2/3 |
%54
- r4 \plet{ 2/3 } [ g g g ] \plet{ 1/1 } |
+ r4 [ g g g ]2/3 |
%55
b2 |
%56
- g2 |
+ g2 \key{bes es as}|
% \key\Es ||
%57
f r f r |
'c r 'c4 |
%61
\duration{16}
- \plet{ 4/6 } [ as f d f as 'd ] \plet{ 1/1 } \plet{ 4/6 } [ as f d `as d f ] \plet{ 1/1 } |
+ [ as f d f as 'd ]4/6 [ as f d `as d f ]4/6 |
%62
- \plet{ 4/6 } [ g es c `g c es ] \plet{ 1/1 } \plet{ 4/6 } [ g 'c 'es 'c g es ] \plet{ 1/1 } |
+ [ g es c `g c es ]4/6 [ g 'c 'es 'c g es ]4/6 |
%63
- \plet{ 4/6 } [ g d g bes 'd 'g ] \plet{ 1/1 } \plet{ 4/6 } [ 'f 'd bes g f d ] \plet{ 1/1 } |
+ [ g d g bes 'd 'g ]4/6 [ 'f 'd bes g f d ]4/6 |
%64
\duration{8}
[ c g ] g4 |
'c r 'c4 |
%77
\duration{16}
- \plet{ 4/6 } [ as f d f as 'd ] \plet{ 1/1 } \plet{ 4/6 } [ as f d `as d f ] \plet{ 1/1 } |
+ [ as f d f as 'd ]4/6 [ as f d `as d f ]4/6 |
%78
- \plet{ 4/6 } [ g es c `g c es ] \plet{ 1/1 } \plet{ 4/6 } [ f 'c 'es 'c g es ] \plet{ 1/1 } |
+ [ g es c `g c es ]4/6 [ f 'c 'es 'c g es ]4/6 |
%79
- \plet{ 4/6 } [ g d f b 'd 'g ] \plet{ 1/1 } \plet{ 4/6 } [ 'f 'd b g f d ] \plet{ 1/1 } |
+ [ g d f b 'd 'g ]4/6 [ 'f 'd b g f d ]4/6 |
%80
[ c8 g8 ] g4 |
%81
\textstyle "italic"
a_"dacapo"
\textstyle "roman"
+ \key{fis} |
% \key\G ||
$
}
$
\clef "violin" \octave{}
\duration{4}
+ \key{fis}
%1
d2 |
%2
%35
[ g8 e e ] [ e8 g g ] |
%36
- b4 fis4 |
+ b4 fis4 |
%37
[ a8 a a ] [ a8 a a ] |
%38
\textstyle "italic"
r4_"arco"
\textstyle "roman"
- \plet{ 2/3 } [ d8 d d ] \plet{ 1/1 } |
+ [ d8 d d ]2/3 |
%50
- r4 \plet{ 2/3 } [ g8 g g ] \plet{ 1/1 } |
+ r4 [ g8 g g ]2/3 |
%51
d2 |
%52
c2 |
%53
- r4 \plet{ 2/3 } [ d8 d d ] \plet{ 1/1 } |
+ r4 [ d8 d d ]2/3 |
%54
- r4 \plet{ 2/3 } [ e e e ] \plet{ 1/1 } |
+ r4 [ e e e ]2/3 |
%55
d2 |
%56
- f4 e4 |
+ f4 e4 \key{bes es as}|
% \key\Es ||
%57
d r `b r |
%74
`g r es r |
%75
- g r g r |
+ g r g r |
%76
- g r es4 |
+ g r es4 |
%77
\duration{2}
f |
% = g |
%88
\textstyle "italic"
- fis_"dacapo" |
+ fis_"dacapo" \key{fis}|
\textstyle "roman"
% \key\G ||
$
%
horn =
-staff {
- melodic
- music{ $
+music {
+ $
\octave { ' }
\key{ fis cis }
\duration { 8 }
r1^"1er mouvement"
\duration {8}
| r2 [c-.( e-. c-. )`a-. ]
- \plet {2/3}\octave{} |
- | [c e a ] \plet{1/1} b4-> () [b c-- e-- a--] |
+ \octave{} |
+ | [c e a ]2/3 b4-> () [b c-- e-- a--] |
b4. b8()g2 |
r1 |
r2 [f a f d]
- \plet {2/3}
- | [f a 'c] \plet{1/1} 'e4-^ () ['e f-> a-> 'c->] |
+ | [f a 'c]2/3 'e4-^ () ['e f-> a-> 'c->] |
'e4._"sf" 'e8()'c4 r4 |
r1 |
\meter {2 *4}
)b [fis a b ] 'cis4 b4 |
fis2 r2 |
r1-\fermata
- $}
+ $
}
score {
- staff {
- horn
+ staff { melodic music { horn }
}
paper {
output "pavane.out"
}
commands {
meter {4 *4}
- skip 39*1
+ skip {39*1}
bar "|:"
- skip 10*1
+ skip {10*1}
bar ":|"
- skip 13*1
+ skip {13*1}
bar "||"
}
-}
\ No newline at end of file
+ midi { tempo 4:70 }
+ staff { midi music { horn } }
+}
--- /dev/null
+
+melanie = music {
+ $
+ \duration{8}
+ [ c d ] { [ d 'd } { c 'c ] } |
+ [ c d ] [ e { d g } c ]2/3 |
+ [ c d ] [ c16 d16 'e16 'e16 d16 c16 ]4/6 |
+ [ c d e e d c ]4/6 |
+ [c d ] { \music{ [ c d e ]2/3 } \music{ [ f g a ]2/3 } } |
+ [ c d ] [ d c ] |
+ $
+}
+
+michelle = music {
+ $
+ \duration{8}
+ [ c c c c ] |
+ [ c c c c ] |
+ [ c c c c ] |
+ [ c c c c ] |
+ [ c c c c ] |
+ [ c c c c ] |
+ $
+}
+
+mireille = music {
+ @
+ \duration{8}
+ o o o o |
+ o o [ o o o ]2/3 |
+ [ o o o ]2/3 [ o16 o16 o16 o16 o16 o16 ]4/6 |
+ [ o o o o o o]4/6 |
+ o o [ o o o ]2/3 |
+ o o o o |
+ @
+}
+
+score {
+ staff { lyric music { mireille } }
+ staff { melodic music { melanie } }
+ staff { melodic music { michelle } }
+ commands{
+ meter {2*4}
+ }
+}
$ }
+ %
+ % The commands section takes the same stuff that music { } takes;
+ % the commands issued below could have been issued inside the above
+ % music block;
+ %
+
commands { % override "commands" section of Score.
- partial 1*8
+ partial {1*8} % doesn't have to be here.
meter{ 4*4}
}
}
another = staff {
melodic
music { $
- c1 c1 c1 c4 c4 c4 c4 {\meter 4*4} c1 c1 c1
+ c1 c1 c1 c4 c4 c4 c4 \meter{ 4*4} c1 c1 c1
$ }
}
unitspace 2cm
geometric 1.3
}
-}
\ No newline at end of file
+}
music{ $
\duration { 8 }
\octave{ }
- \plet { 6/9 } |[ a a a a a a a a a ] \plet { 1/1 }
+ |[ a a a a a a a a a ]
\octave{ ' }
- \plet { 6/9 } |[ a a a a a a a a a ] \plet { 1/1 }
+ |[ a a a a a a a a a ]
\octave { ` }
- \plet { 6/9 } [ `c `g d a 'e 'b ''f '''c '''g ] \plet { 1/1 }
- \plet { 6/9 } [ '''g '''c ''f 'b 'e a d `g `c ] \plet { 1/1 }
+ [ `c `g d a 'e 'b ''f '''c '''g ]
+ [ '''g '''c ''f 'b 'e a d `g `c ]
\octave{ ' }
- \plet { 6/9 } [ `c `g d a 'e 'b ''f '''c '''g ] \plet { 1/1 }
- \plet { 6/9 } [ '''g '''c ''f 'b 'e a d `g `c ] \plet { 1/1 }
+ [ `c `g d a 'e 'b ''f '''c '''g ]
+ [ '''g '''c ''f 'b 'e a d `g `c ]
\octave { }
- \plet { 2/3 } [ c g 'd ] \plet { 1/1 }
- \plet { 2/3 } [ 'd g c ] \plet { 1/1 }
- \plet { 2/3 } [ f 'c 'g ] \plet { 1/1 }
- \plet { 2/3 } [ 'g 'c f ] \plet { 1/1 }
+ [ c g 'd ]2/3
+ [ 'd g c ]2/3
+ [ f 'c 'g ]2/3
+ [ 'g 'c f ]2/3
\octave{ ' }
- \plet { 2/3 } [ c g 'd ] \plet { 1/1 }
- \plet { 2/3 } [ 'd g c ] \plet { 1/1 }
- \plet { 2/3 } [ f 'c 'g ] \plet { 1/1 }
- \plet { 2/3 } [ 'g 'c f ] \plet { 1/1 }
+ [ c g 'd ]2/3
+ [ 'd g c ]2/3
+ [ f 'c 'g ]2/3
+ [ 'g 'c f ]2/3
c1
\duration { 8}
% { 'e4-.-\downbow g4 `g4\stemdown } |
{ 'e4-.-\downbow g4 `g4 } |
%%8
-% { 'cis2.-\upbow e2. `a2.\stemdown } :||:
- { 'cis2.-\upbow e2. `a2. } | % :||:
+% { 'cis2.-\upbow e2. `a2.\stemdown } :|:%%sorry!!
+ { 'cis2.-\upbow e2. `a2. } \bar ":|:"%%!! sorry!
%%9
\clef "violin"
% { 'e2 a2_f\stemdown }
{ a2^"0" fis2_"3" } bes4 |
%%%18
%% [ { 'c( es } ) bes 'c a ] fis4^\tr |
- { [ 'c es } bes 'c a ] fis4 |
+ { \music{ [ 'c( )bes 'c a ] } \music{ [ es ] } } fis4 |
%%%19
-%% { 'd4-\downbow g4 `bes4\stemdown } { 'c4-\upbow g4 c4\stemdown } [ { bes d } a ] |
{ 'd4-\downbow g4 `bes4 } { 'c4-\upbow g4 c4 } { [ bes d } a ] |
%%%20
%% [ { 'c( d `g } bes a ) bes g ( ) bes ] |
- { [ 'c d `g } bes a bes g( )bes ] |
+ { \music{ [ 'c( bes a )bes g( )bes ] } \music{ [ d ] } \music{ [ g ] } } |
%%%21
%% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } |
-% { 'd4 g2 } 'cis4 { 'd4 f4 } |
{ \multivoice \music {\stem{1} 'd4(\stem{1} ) 'cis4 'd4 } \music { \stem{-1} g2 f4 } } |
%%%22
%% [ { g( cis } )f g e ] { f4 d4 } |
- { [ g cis } f g e ] { f4 d4 } |
+ { \music{ [ g( )f g e ] } \music{ [ cis ] } } { f4 d4 } |
%%%23
%% [ `g g ] { e4.\stemup^\tr `a4.\stemdown } d\stemup-\upbow |
[ `g g ] { e4. `a4. } d-\upbow |
%%%24
%% { d2.^{fine} `a2. `d2.\stemup_{ }_{ }_{3 mins.}} s4 :||
%% { \textstyle "italic" d2.^"fine" `a2. \textstyle "roman" `d2._"3 mins."} | % :||
- { d2.^"fine" `a2. `d2._"3 mins."} | % :||
+ { d2.^"fine" `a2. `d2._"3 mins."} \bar ":||"
%% \tighten % use one line less
$
}
}
commands {
meter {3 * 4}
- skip {24 * 4}% 8 measures
- bar ":|:"
-
- skip {15 * 4} % 5 meas.
-
- skip {36*4}
- bar ":||"
}
paper {
symboltables { table_sixteen }
geometric 1.4
output "scsii-menuetto.out"
}
-o}
+ staff {
+ midi music { ii_menuetto }
+ }
+ midi {
+ tempo 4:120
+ output "scsii-menuetto.midi"
+ }
+}
% comments with # note missing stuff
% heu, make that %#%
%
-% thanks to \music "2" group changing, all notes
+% thanks to \music group changing, all notes
% (except for grace notes) are printed
%
%#%\duration8
%%1
melodie = music { $ \clef\violin
+ \key{bes}
\duration{ 8 }
r_"\pp" { [ d `a-| } f-| { d `a-| } f-| { d `a-| ] } |
%%2
r { [ `a cis } e { `a cis } e { `a cis ] } |
%#%:|
%%5
- \plet{ 2/3 } [ a()bes a ] \plet{ 1/1 } 'd4. a |
+ [ a()bes a ]2/3 'd4. a |
%%6
- \plet{ 2/3 } [ g()a g ] \plet{ 1/1 } 'd4 a r |
+ [ g()a g ]2/3 'd4 a r |
%#%\tighten
%#%\newline
%%7
- a4.^> g \plet{ 2/3 } [ g( f )e ] \plet{ 1/1 } |
+ a4.^> g [ g( f )e ]2/3 |
%%8
f2 r4 |
%%9
- { \music{ 'a4.( )'g \plet{ 2/3 } [ 'g( 'f )'e ] \plet{ 1/1 } }
- \music{ 'cis4. 'e_"dolce" \plet{ 2/3 } 'e \plet{ 1/1 } } } |
+% { \music{ 'a4.( )'g [ 'g( 'f )'e ]2/3 } \music{ 'cis4. 'e_"dolce" [ 'e ] 2/3 } } |
+ { \music{ 'a4.( )'g [ 'g( 'f )'e ]2/3 } \music{ 'cis4. 'e_"dolce" \plet{ 2/3 } 'e \plet{ 1/1 } } } |
%%10
{ 'f2. 'd2. } |
%%11
- \plet { 2/3 } [ a_"\pp"( )bes a ] \plet { 1/1 } 'f4. a |
+ [ a_"\pp"( )bes a ]2/3 'f4. a |
%%12
- \plet { 2/3 } [ g( ) a g ] \plet { 1/1 } 'e4. 'd |
+ [ g( ) a g ]2/3 'e4. 'd |
%%13
- 'c4. bes \plet { 2/3 } [ bes( ) a g ] \plet { 1/1 } |
+ 'c4. bes [ bes( ) a g ]2/3 |
%%14
a2 r
- { \music{ 'd( | )'c4. g \plet { 2/3 } [ bes a g ] \plet { 1/1 } }
- \music{ f_"\p"( | )e4._"dolce" bes \plet { 2/3 } [ g ] \plet { 1/1 } } } |
+% { \music{ 'd( | )'c4. g [ bes a g ]2/3 } \music{ f_"\p"( | )e4._"dolce" bes [ g ]2/3 } } |
+ { \music{ 'd( | )'c4. g [ bes a g ]2/3 } \music{ f_"\p"( | )e4._"dolce" bes \plet{ 2/3 } g \plet{ 1/1 } } } |
%%16
{ a2. f2. } |
%%17
[ 'd8. a16 ] f4. d |
%%19
%#% 'c\grace\stemup
- \plet { 2/3 } [ bes_"\pp"( ) a bes ] \plet { 1/1 } 'd4. bes |
+ [ bes_"\pp"( ) a bes ]2/3 'd4. bes |
%%20
a2. |
%%21
%#% a\grace
- \plet { 2/3 } [ g( )fis g ] \plet { 1/1 } bes4.^> g |
+ [ g( )fis g ]2/3 bes4.^> g |
%%22
%#% =f2. |
f2. |
[ 'd8. a16 ] fis4. d |
%%25
%#% 'cis\grace\stemup
- \plet { 2/3 } [ b_"\mf"( ) ais b ] \plet { 1/1 } 'd4. b |
+ [ b_"\mf"( ) ais b ]2/3 'd4. b |
%%26
{ a2. fis2. } |
%#%\tighten\newline
%%27
- \plet { 2/3 } [ 'e_"\f"( )'dis 'e ] \plet { 1/1 } 'g4. 'cis |
+ [ 'e_"\f"( )'dis 'e ]2/3 'g4. 'cis |
%%28
{ 'd2. fis2. } |
%#%\volta1
%%40
'cis2 r4 |
%%41
-%#% { > 'fis4. 'cis4._f } 'e [ 'e( ) 'd >! 'cis ] \plet { 1/1 } |
- { 'fis4. 'cis4._"\f" } 'e \plet { 2/3 } [ 'e( )'d 'cis ] \plet { 1/1 } |
+%#% { > 'fis4. 'cis4._f } 'e [ 'e( ) 'd >! 'cis ] |
+ { 'fis4. 'cis4._"\f" } 'e [ 'e( )'d 'cis ]2/3 |
%%42
[ b8. 'cis16 ] 'd4^> b r |
%%43
[ b8. 'cis16 ] 'd4^> b r |
%%45
%#% 'cis\grace\stemup
- \plet { 2/3 } [ b_"\p"( )ais b ] \plet { 1/1 } 'd4. b |
+ [ b_"\p"( )ais b ]2/3 'd4. b |
%%46
%#% { =a2. fis2. } |
{ a2. fis2. } |
%%47
- \plet { 2/3 } [ 'e_"\f"( )'dis 'e ] \plet { 1/1 } 'g4.^> 'cis |
+ [ 'e_"\f"( )'dis 'e ]2/3 'g4.^> 'cis |
%%48
%#% { fis2.(v ='d2.\stemup(^ }
% { fis2. 'd2. } |
%%49
%#% { ) 'd4 ) =f2._> } { r4 s4_{decr} } 'd4\stemup
\textstyle "italic"
- { \multivoice \music{ \stem{ 1 } fis2.( | \stem{ -1 } )f2. } \music { \stem{ 1 } 'd2.( | \stem{ 1 } )'d4 r4_"decresc." 'd4 } }
+ { \multivoice \music{ \stem{ 1 } fis2.( | \stem{ -1 } )f2. } \music { \stem{ 1 } 'd2.( | \stem{ 1 } )'d4 r4_"decresc." 'd4 } }
\textstyle "roman" |
%%50
{ bes2. e2. } |
$ }
begeleiding = music { $
-\clef\bass
-\duration{2}
- `d r4
+ \key{bes}
+ \clef\bass
+ \duration{2}
+ `d r4 |
%%2
- ``bes r4
+ ``bes r4 |
%%3
- ``g r4
+ ``g r4 |
%%4
- ``a r4
+ ``a r4 |
%#%:|
%%5
%#%\stemlength2
\duration{ 8 }
%#% { =`f `d2 } `a d `a { d r4 } `a
- { \multivoice \music{ \stem{1}[ `f `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `f `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
%%6
- { \multivoice \music{\stem{1} [ `d `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } |
%%7
% this (one note missing) fails with assertion:
-% lilypond: src/beam.cc:144: void Beam::set_grouping(struct Rhythmic_grouping,
-% struct Rhythmic_grouping): Assertion `cur.children.size() == stems.size()' failed.
-
-%% seems fixed now, HWN
-% { \multivoice \music{ \stem{1}[ `cis `e `g `e `g ] } \music { \stem{ -1 } ``a2 r4 } } |
- { \multivoice \music{\stem{1} [ `cis `e `g `e `g e ] } \music { \stem{ -1 } ``a2 r4 } } |
+% lilypond: src/beam.cc:144: void Beam::set_grouping(struct Rhythmic_grouping, struct Rhythmic_grouping): Assertion `cur.children.size() == stems.size()' failed.
+% { \multivoice \music{ \stem{ 1 } [ `cis `e `g `e `g ] } \music { \stem{ -1 } ``a2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `cis `e `g `e `g e ] } \music { \stem{ -1 } ``a2 r4 } } |
%%8
- { \multivoice \music{ \stem{1}[ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
%%9
[ `a e f e f e ] |
%%10
[ `d `a d `a d `a ] |
%%11
- { \multivoice \music{ \stem{1} [ `f `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `f `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
%%12 == 6
- { \multivoice \music{ \stem{1}[ `d `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } |
%13
- { \multivoice \music{ \stem{1}[ `e `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } |
+ { \multivoice \music{ [ `e `e `g `e `g `e ] } \music { \stem{ -1 } ``bes2 r4 } } |
%%14
- { \multivoice \music{ \stem{1}[ `a c f c f c ] } \music { \stem{ -1 } `f2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `a c f c f c ] } \music { \stem{ -1 } `f2 r4 } } |
%%15
[ `c `g `bes `g `bes `g ] |
%%16
[ ``f `c `f `c `f `c ] |
%%17
- { \multivoice \music{ \stem{1}[ ``a `e `g `e `g `e ] } \music { \stem{ -1 } ``a2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ ``a `e `g `e `g `e ] } \music { \stem{ -1 } ``a2 r4 } } |
%%18
- { \multivoice \music{ \stem{1}[ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
%%19
- { \multivoice \music{ \stem{1}[ ``bes `f `bes `f `bes `f ] } \music { \stem{ -1 } ``bes2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ ``bes `f `bes `f `bes `f ] } \music { \stem{ -1 } ``bes2 r4 } } |
%%20
- { \multivoice \music{ \stem{1}[ ``f `c `f `c `f `c ] } \music { \stem{ -1 } ``f2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ ``f `c `f `c `f `c ] } \music { \stem{ -1 } ``f2 r4 } } |
%%21
%#% s8 % skip space of grace note
{ [ `e `c } `g c `g c `g ] |
%%22
[ `f `a c `a `f `c ] |
%%23
- { \multivoice \music{ \stem{1}[ ``a `e `g `e `g `e ] } \music { \stem{ -1 } ``a2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ ``a `e `g `e `g `e ] } \music { \stem{ -1 } ``a2 r4 } } |
%%24
- { \multivoice \music{ \stem{1}[ `d `fis `a `fis `a `fis ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `fis `a `fis `a `fis ] } \music { \stem{ -1 } `d2 r4 } } |
%%25
%#% s8 % skip space of grace note
- { \multivoice \music{ \stem{1}[ ``g `d `b `d `b `d ] } \music { \stem{ -1 } ``g2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ ``g `d `b `d `b `d ] } \music { \stem{ -1 } ``g2 r4 } } |
%%26
- { \multivoice \music{ \stem{1}[ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
%%27
{ [ `cis ``a } `e `a `e `a `e ] |
%%28
{ [ `d ``b } `fis `b `fis `b `fis ] |
%%45
%#% s8 % skip space of grace note
- { \multivoice \music{ [ ``g `d `b `d `b `d ] } \music { \stem{ -1 } ``g2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ ``g `d `b `d `b `d ] } \music { \stem{ -1 } ``g2 r4 } } |
%%46
- { \multivoice \music{ [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
+ { \multivoice \music{ \stem{ 1 } [ `d `a d `a d `a ] } \music { \stem{ -1 } `d2 r4 } } |
%%47
{ [ `cis ``a } `e `a `e `a `e ] |
%%48
_ _ _
_ _ _
% 5
- \plet{ 2/3 } Lei- se8 \plet{ 1/1 } fleh-4. en8
- \plet{ 2/3 } mei- ne8 \plet{ 1/1 } Lie- der8 _8
- Durch4. die8 \plet{ 2/3 } Nacht zu8 \plet{ 1/1 }
+ [ Lei- se8 ]2/3 fleh-4. en8
+ [ mei- ne8 ]2/3 Lie- der8 _8
+ Durch4. die8 [ Nacht zu8 ]2/3
dir;2 _
_ _ _
_ _ _
% 11
- \plet{ 2/3 } In den8 \plet{ 1/1 } stil-4. len8
- \plet{ 2/3 } Hain her-8 \plet{ 1/1 } nie-4. der,8
- Lieb4. chen,8 \plet{ 2/3 } komm zu8 \plet{ 1/1 }
+ [ In den8 ]2/3 stil-4. len8
+ [ Hain her-8 ]2/3 nie-4. der,8
+ Lieb4. chen,8 [ komm zu8 ]2/3
mir!2 _
_ _ _
_ _ _
% 17
Fl\"us-8. ternd16 schlan-4. ke8
Wip-8. fel16 rau-4. schen8
- \plet{ 2/3 } In des8 \plet{ 1/1 } Mon-4. des8
+ [ In des8 ]2/3 Mon-4. des8
Licht;2.
_ _ _
_ _ _
% 23
Des8. Ver-16 r\"a-4. ters8
feind-8. lich16 Lau-4. schen8
- \plet{ 2/3 } F\"urch- te,8 \plet{ 1/1 } Hol-4. de,8
+ [ F\"urch- te,8 ]2/3 Hol-4. de,8
nicht.2.
_ _ _
_ _ _
mich!2 _
Be-8. bend16 harr' ich8 _8
dir8. ent-16 ge- gen!8 _8
- \plet{ 2/3 } Komm, be-8 \plet{ 1/1 } gl\"u4. cke8
+ [ Komm, be-8 ]2/3 gl\"u4. cke8
mich!2.
_ _ _ _ _ _
% 47
_ _ _
_ _ _
% 5
- \plet{ 2/3 } H\"orst die8 \plet{ 1/1 } Nach-4. ti-8
- \plet{ 2/3 } gal- len8 \plet{ 1/1 } schla- gen?8 _8
- Ach!4. sie8 \plet{ 2/3 } fleh- en8 \plet{ 1/1 }
+ [ H\"orst die8 ]2/3 Nach-4. ti-8
+ [ gal- len8 ]2/3 schla- gen?8 _8
+ Ach!4. sie8 [ fleh- en8 ]2/3
dich,2 _
_ _ _
_ _ _
% 11
- \plet{ 2/3 } Mit der8 \plet{ 1/1 } T\"o-4. ne8
- \plet{ 2/3 } s\"u\ss- en8 \plet{ 1/1 } Kla-4. gen8
- Fleh-4. en8 \plet{ 2/3 } sie f\"ur8 \plet{ 1/1 }
+ [ Mit der8 ]2/3 T\"o-4. ne8
+ [ s\"u\ss- en8 ]2/3 Kla-4. gen8
+ Fleh-4. en8 [ sie f\"ur8 ]2/3
mich.2 _
_ _ _
_ _ _
% 17
Sie-8. ver-16 stehn4. des8
Bus-8. ens16 Seh-4. nen,8
- \plet{ 2/3 } Ken- nen8 \plet{ 1/1 } Lieb-4. es-8
+ [ Ken- nen8 ]2/3 Lieb-4. es-8
schmerz,2.
_ _ _
_ _ _
% 23
R\"uh-8. ren16 mit4. den8
Sil-8. ber-16 t\"o-4. nen8
- \plet{ 2/3 } Jed- es8 \plet{ 1/1 } wei-4. che8
+ [ Jed- es8 ]2/3 wei-4. che8
Herz.2.
_ _ _
_ _ _
}
score {
- staff {
- lyric
- music { tekst1 }
- music { tekst2 }
- }
- staff {
- melodic
- music { melodie }
- }
- staff {
- melodic
- music { begeleiding }
- }
+% staff {
+% lyric
+ % music { tekst1 }
+ % music { tekst2 }
+% }
+% staff {
+% melodic
+% music { melodie }
+% }
+% staff {
+% melodic
+% music { begeleiding }
+% }
commands {
- meter { 3*4 }
- key $bes$
- skip 12*4
- bar ":|"
- skip 96*4
- bar ":|"
- skip 66*4
- bar "||"
+ meter {3*4}
}
paper {
symboltables { table_sixteen }
width 195mm
- unitspace 20mm
-% unitspace 4.0 cm % leaves all text stand free
-% geometric 1.4
+
+ % on two pages...
+% unitspace 10mm
+% geometric 1.2
+ unitspace 9mm
+ geometric 1.2
output "standchen.out"
}
+ staff { midi music { melodie } }
+ staff { midi music { begeleiding } }
+ midi {
+ tempo 4:50
+ }
}
\begin{document}
\input lilyponddefs
\input titledefs
-%\def\interstaffline{\vskip10pt}
-%\def\interscoreline{\vskip12pt}
-\def\interstaffline{\vskip1mm}
-\def\interscoreline{\vskip2mm}
+\def\interstaffline{\vskip2mm}
+\def\interscoreline{\vskip3mm}
\vbox to 10mm{\vss}
\title{St\"andchen\normalsize\\[2ex](Serenade)}
\composer{Franz Schubert (1797-1828)}
c c | g g | a a | g g |
f f | e e | d d8.( e16 | )c2 % :|
+ \bar ":|"
$
}
c 'c | 'e 'c | 'f 'c | 'e 'c |
'd b | 'c a | f g | c2
+ \bar ":|"
$
}
}
commands {
meter {2 * 4}
- skip 24*2
- bar "||"
+% skip 24*2
+% bar "||"
+ }
+ staff { midi_track music { melodie } }
+ staff { midi_track music { begeleiding } }
+ midi {
+ tempo 4:120
}
}
dux = music { $
\clef \violin
\duration { \last }
- \stem{-1}
- r8-"dux" ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] |
+ r8-"dux" \stem{-1}
+ ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] |
[g 'c16 b] ['c8 'd] [f16 g] as4 [g16 f] |
[es 'c b a] [ g f es d] [c8 'es 'd 'c] |
[bes a bes 'c] [fis g a fis] |
$}
comes = music { $
- r1 r1
- \stem{1}
\octave {'}
+ r1 \stem{1}
+ |
+ r1 |
r8-"comes" [g16 fis] [g8 c] [es g16 f] [g8 a]|
[d8 g16 fis] [g8 a] [c16 d] es4 [d16 c] |
[`bes8 es16 d] [es8 `g8] [`as f16 es] [f8 `a]
bassdux = music { $
\clef \bass
- r1 r r r r r
\octave { }
+ r1 |
+ r |
+ r |
+ r |
+ r |
+ r |
r8 [c16 B] [c8 G] [As c16 B] [c8 d] |
- [G c16 B] [c8 d] [F16 G] As4 [G16 F] | $
-}
+ [G c16 B] [c8 d] [F16 G] As4 [G16 F] |
+$}
basstaf = staff { melodic
music { bassdux }
grouping {2*2}
key {$bes es as$}
}
+ staff { midi music { dux } }
+ staff { midi music { comes } }
+ staff { midi music { bassdux } }
+ midi {
+ tempo 4:80
+ }
}
{
if (bar_req_l_ ) {
- bar_p_ = new Bar(bar_req_l_->type);
+ bar_p_ = new Bar(bar_req_l_->type_str_);
} else if (!walk_l_->time_.whole_in_measure_) {
bar_p_ = new Bar("|");
}
mtor << on_b;
}
+int
+Bar_req::compare(const Bar_req &c1)const
+{
+ return type_str_ == c1.type_str_;
+}
+
void
Bar_req::do_print() const
{
- mtor << type;
+ mtor << type_str_;
+}
+
+Bar_req::Bar_req(String s)
+{
+ type_str_ = s;
}
Partial_measure_req::Partial_measure_req(Moment m)
void
Barcheck_req::do_print() const{}
-Bar_req::Bar_req(String s)
-{
- type = s;
-}
/* *************** */
void
Clef_change_req::do_print() const
#include "dstream.hh"
#include "vector.hh"
-Dstream monitor(&cout,".dstreamrc");
+Dstream *monitor=0;
ostream * nulldev =0;
struct _Dinit {
- _Dinit() { nulldev = new ofstream("/dev/null");}
- ~_Dinit() { delete nulldev; }
+ _Dinit() {
+ nulldev = new ofstream("/dev/null");
+ monitor = new Dstream(&cout,".dstreamrc");
+ }
+ ~_Dinit() {
+ delete nulldev;
+ delete monitor;
+ }
} dinit;
#ifndef NDEBUG
set_new_handler(&mynewhandler);
#endif
- set_matrix_debug(monitor);
+ set_matrix_debug(*monitor);
signal(SIGFPE, float_handler);
}
#include "voice.hh"
#include "musicalrequest.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.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.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_.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);
+}
/* *************** */
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
c = elts.bottom();
Simple_music *s = c->simple();
s->add(v);
+
+ check_plet(v);
}
Moment
Simple_music*vs = new Simple_music;
vs->add(v);
elts.bottom().add(vs);
+
+ check_plet(v);
}
void
#include "inputmusic.hh"
#include "score.hh"
#include "paperdef.hh"
+#include "mididef.hh"
#include "staff.hh"
paper_p_ = p;
}
+void
+Input_score::set(Mididef* midi_p)
+{
+ delete midi_p_;
+ midi_p_ = midi_p;
+}
+
Input_score::Input_score(Input_score const&s)
{
paper_p_ = (s.paper_p_)? new Paperdef(*s.paper_p_) :0;
Score *s_p = new Score(paper_p);
s_p->defined_ch_c_l_= defined_ch_c_l_;
s_p->errorlevel_i_ = errorlevel_i_;
+ s_p->set(midi_p_);
+ midi_p_ = 0;
for (iter_top(staffs_,i); i.ok(); i++) {
Staff* staf_p=i->parse(s_p, score_wide_music_p_);
{
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;
}
+/*
+ inputstaff.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 "inputmusic.hh"
#include "inputstaff.hh"
#include "staff.hh"
#include "complexstaff.hh"
-#include "lexer.hh"
#include "lyricstaff.hh"
+#include "midistaff.hh"
+#include "lexer.hh"
Input_staff::Input_staff(String s)
p = new Complex_staff;
else if (type == "lyric")
p = new Lyric_staff;
- else
- error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_);
+ else if (type == "midi")
+ p = new Midi_staff;
+ else {
+ error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_ );
+ exit( 1 );
+ }
p->score_l_ = score_l;
<lyrics>{LYRICS} {
String s (YYText());
int i = 0;
- while ((i=s.pos("_")) != 0)// ugh. Whats this.
- *((char*)s.cptr() + i - 1) = ' ';
- if ((i=s.pos("\\,")) !=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 "
{
- *((char*)s.cptr() + i) = 'c';
+ *(s.ch_l() + i) = 'c';
s = s.left(i+1) + " " + s.right(s.len()-i-1);
}
yylval.string = new String(s);
source file of the LilyPond music typesetter
- (c) 1997 Jan Nieuwenhuizen <jan@digicash.nl>
+ (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
*/
#include "musicalrequest.hh"
--- /dev/null
+#include "musicalrequest.hh"
+#include "voice.hh"
+#include "staffwalker.hh"
+#include "debug.hh"
+#include "staff.hh"
+#include "midistaff.hh"
+#include "midicolumn.hh"
+#include "midiitem.hh"
+#include "sccol.hh"
+#include "pscore.hh"
+#include "main.hh"
+
+Midi_column::Midi_column(Midi_staff* mstaff_l)
+{
+ mstaff_l_ = mstaff_l;
+}
+
+void
+Midi_column::setup_one_request(Request*req_l)
+{
+ if ( req_l->melodic() )
+ melreq_l_array_.push( req_l->melodic() );
+}
+
+void
+Midi_column::note_off( Midi_track* midi_track_l, Moment next )
+{
+ Moment delta_t = next - when();
+ for ( int i = 0; i < melreq_l_array_.size(); i++ ) {
+ Midi_note midi_note( melreq_l_array_[ i ], midi_track_l->number_i_, false );
+ midi_track_l->add( delta_t, &midi_note );
+ delta_t = 0.0;
+ }
+}
+
+void
+Midi_column::note_on( Midi_track* midi_track_l )
+{
+ Moment delta_t = 0.0;
+ for ( int i = 0; i < melreq_l_array_.size(); i++ ) {
+ Midi_note midi_note( melreq_l_array_[ i ], midi_track_l->number_i_, true );
+ midi_track_l->add( delta_t, &midi_note );
+ }
+}
--- /dev/null
+#include "musicalrequest.hh"
+#include "voice.hh"
+#include "staffwalker.hh"
+#include "debug.hh"
+#include "staff.hh"
+#include "midistaff.hh"
+#include "midicolumn.hh"
+#include "midiwalker.hh"
+#include "midiitem.hh"
+#include "midistream.hh"
+
+Midi_staff::Midi_staff()
+{
+}
+
+Staff_column*
+Midi_staff::create_col()
+{
+ return new Midi_column(this);
+}
+
+Staff_walker*
+Midi_staff::get_walker_p()
+{
+ return new Midi_walker(this);
+}
+
+void
+Midi_staff::midi( Midi_stream* midi_stream_l, int track_i )
+{
+ Midi_track midi_track( track_i );
+ Midi_column* last_mcol_l = 0;
+ for ( Midi_walker w( this ); w.ok(); w++ ) {
+ Midi_column* mcol_l = (Midi_column*)*w;
+ if ( last_mcol_l )
+ last_mcol_l->note_off( &midi_track, w->when() );
+ mcol_l->note_on( &midi_track );
+ last_mcol_l = mcol_l;
+ }
+ if ( last_mcol_l )
+ last_mcol_l->note_off( &midi_track, last() );
+ *midi_stream_l << midi_track;
+}
+
+void
+Midi_staff::set_output(PScore*pscore_l)
+{
+ //i don-t want no pscore!
+}
+
"key", KEY,
"meter", METER,
+ "midi", MIDI,
"mm", MM_T,
"multivoice", MULTIVOICE,
"octave", OCTAVECOMMAND,
"table", TABLE,
"symboltables", SYMBOLTABLES,
"notenames", NOTENAMES,
+ "tempo", TEMPO,
"texid", TEXID,
"textstyle", TEXTSTYLE,
"unitspace", UNITSPACE,
{
text.lower();
char const* ch_c_l = here_ch_c_l();
- ch_c_l--;
- while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
+ if ( ch_c_l ) {
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;
if (p[0] < 0) {
errorlevel_i_ |= 1;
- warning( String( "notename does not exist: " ) + YYText(), ch_c_l );
+ error( String( "notename does not exist: " ) + YYText(), ch_c_l );
p[0] = p[1] = 0;
}
return NOTENAME;
keytable = new Keyword_table(the_key_tab);
the_id_tab = new Assoc<String, Identifier*>;
defaulttab = 0;
- data_ch_c_l_ = 0;
errorlevel_i_ = 0;
}
char const*
My_flex_lexer::here_ch_c_l()
{
- return data_ch_c_l_ ? data_ch_c_l_ + yyin->tellg() : 0;
+ return include_stack.top()->sourcefile_l_->ch_c_l() + yyin->tellg();
}
void
ch_c_l++;
}
errorlevel_i_ |= 1;
- warning( s, ch_c_l );
+ error( s, ch_c_l );
}
}
Input_file *newin = new Input_file(s);
include_stack.push(newin);
switch_streams(newin->is);
- if ( newin->sourcefile_l_ )
- data_ch_c_l_ = newin->sourcefile_l_->ch_c_l();
- else
- data_ch_c_l_ = 0;
yylineno = 1;
}
#include "varray.hh"
#include "textdef.hh"
#include "parseconstruct.hh"
+#include "inputmusic.hh"
int default_duration = 4, default_dots=0, default_octave=0;
int default_plet_type = 1, default_plet_dur = 1;
}
/* triplet is '2/3' */
-void set_plet(int num,int den)
+void
+set_plet(int num,int den)
{
assert(num >0&& den>0);
default_plet_dur = num;
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)
{
#include "misc.hh"
#include "lexer.hh"
#include "paperdef.hh"
+#include "mididef.hh"
#include "inputscore.hh"
#include "main.hh"
#include "keyword.hh"
String *string;
const char *consstr;
Paperdef *paper;
+ Mididef* midi;
Input_music *music;
Music_general_chord *chord;
Music_voice *mvoice;
%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 <i> DOTS INT
%type <real> unit
%type <melreqvec> pitch_list
-%type <c> open_request_parens close_request_parens
+%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
$$->set($4);
}
| score_body paper_block { $$->set($2); }
+ | score_body midi_block { $$->set($2); }
| score_body error {
}
}
;
+/*
+ MIDI
+*/
+midi_block:
+ MIDI
+
+ '{' midi_body '}' { $$ = $3; }
+ ;
+
+midi_body: {
+ $$ = new Mididef;
+ }
+ | 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
*/
$$ = new Input_staff(*$1);
delete $1;
}
+ | MIDI {
+ $$ = new Input_staff("midi");
+ }
;
staff_body:
;
-
/*
VOICE ELEMENTS
*/
add_requests($2, post_reqs);
$$ = $2;
}
- | lyrics_elt
+ | pre_requests lyrics_elt post_requests {
+ add_requests($2, pre_reqs);
+ add_requests($2, post_reqs);
+ $$ = $2;
+ }
| command_elt
;
command_elt:
- command_req {
+/* empty */ {
$$ = new Voice_element;
- $$->add($1);
- $1-> defined_ch_c_l_ = lexer->here_ch_c_l();
+ $$-> defined_ch_c_l_ = lexer->here_ch_c_l();
+ }
+/* cont: */
+ command_req {
+ $2-> defined_ch_c_l_ = $$->defined_ch_c_l_;
+ $$->add($2);
+
}
-/* can't do this, since "| |" has shift/reduce conflict. :
- command_elt command_req { .. }
-*/
;
command_req:
'|' {
$$ = new Barcheck_req;
}
- | BAR STRING {
+ | BAR STRING {
$$ = new Bar_req(*$2);
delete $2;
}
m->set($3,$5);
$$ = m;
}
- | SKIP duration_length {
+ | SKIP '{' duration_length '}' {
Skip_req * skip_p = new Skip_req;
- skip_p->duration_ = *$2;
- delete $2;
+ skip_p->duration_ = *$3;
+ delete $3;
$$ = skip_p;
}
- | CADENZA int {
- $$ = new Cadenza_req($2);
+ | CADENZA '{' int '}' {
+ $$ = new Cadenza_req($3);
}
- | PARTIAL duration_length {
- $$ = new Partial_measure_req(*$2);
- delete $2;
+ | PARTIAL '{' duration_length '}' {
+ $$ = new Partial_measure_req(*$3);
+ delete $3;
}
| STEM '{' int '}' {
$$ = get_stemdir_req($3);
$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:
| textscript_req
;
+close_plet_parens:
+ ']' {
+ req_defined_ch_c_l = lexer->here_ch_c_l();
+ $$ = ']';
+ }
+ ;
+
close_request_parens:
'(' {
$$='(';
set_default_octave(*$3);
delete $3;
}
- | TEXTSTYLE STRING {
+ | TEXTSTYLE STRING {
set_text_style(*$2);
delete $2;
}
lexer = new My_flex_lexer;
#ifdef YYDEBUG
- yydebug = !monitor.silence("InitParser") && check_debug;
- lexer->set_debug( !monitor.silence("InitLexer") && check_debug);
+ yydebug = !monitor->silence("InitParser") && check_debug;
+ lexer->set_debug( !monitor->silence("InitLexer") && check_debug);
#endif
lexer->new_input(init);
yyparse();
#ifdef YYDEBUG
- yydebug = !monitor.silence("Parser") && check_debug;
- lexer->set_debug( !monitor.silence("Lexer") && check_debug);
+ yydebug = !monitor->silence("Parser") && check_debug;
+ lexer->set_debug( !monitor->silence("Lexer") && check_debug);
#endif
lexer->new_input(s);
{
mtor << "next " << next << "dist " << distance << "strength\n";
}
+
void
Blank_req::do_print()const
{
void
Melodic_req::do_print() const
{
- mtor << "notename: " << notename_i_ << " oct: "<< octave_i_;
+ mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
}
int
return notename_i_ + octave_i_*7;
}
+/*
+ should be settable from input to allow "viola"-mode
+ */
+static Byte pitch_by_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;
+}
+
+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)
Lyric_req::Lyric_req(Text_def* def_p)
:Text_req(0, def_p)
{
- def_p->align_i_ = 1; // raggedright
+ def_p->align_i_ = 0; // centre
dir_i_ = -1; // lyrics below (invisible) staff
}
#include "source.hh"
#include "sourcefile.hh"
#include "scorewalker.hh"
+#include "mididef.hh"
+#include "midiitem.hh"
+#include "midistream.hh"
+#include "midicolumn.hh"
+#include "midistaff.hh"
+#include "midiwalker.hh"
void
Score::setup_music()
{
*mlog << "\nSetting up music ..." << flush;
if (last() == Moment(0)) {
- warning("Need to have music in a score.", defined_ch_c_l_);
+ errorlevel_i_ |= 1;
+ error("Need to have music in a score.", defined_ch_c_l_);
}
pscore_p_ = new PScore(paper_p_);
*mlog << "Processing music ..." << flush;
for (Score_walker w(this); w.ok(); w++) {
w.process();
- }
+ }
}
void
Score::process()
{
setup_music();
+
process_music();
// do this after processing, staffs first have to generate PCols.
return l;
}
+void
+Score::set(Mididef* midi_p)
+{
+ delete midi_p_;
+ midi_p_ = midi_p;
+}
+
void
Score::OK() const
{
{
pscore_p_=0;
paper_p_ = paper_p;
+ midi_p_ = 0;
errorlevel_i_ = 0;
defined_ch_c_l_ = 0;
}
{
delete pscore_p_;
delete paper_p_;
+ delete midi_p_;
}
void
pscore_p_->output(the_output);
}
+void
+Score::midi()
+{
+ if (!midi_p_)
+ return;
+
+ *mlog << "midi output to " << midi_p_->outfile_str_ << "...\n";
+
+ int track_i = 0;
+ for ( PCursor<Staff*> staff_l_pcur( staffs_.top() ); staff_l_pcur.ok(); staff_l_pcur++ ) {
+ Midi_staff* mstaff_l = (Midi_staff*)*staff_l_pcur;
+ if ( !mstaff_l->pscore_l_ ) // we _are_ a midi-staff, ugh
+ track_i++;
+ }
+ Midi_stream midi_stream( midi_p_->outfile_str_, track_i, midi_p_->get_tempo_i( Moment( 1, 4 ) ) );
+
+ track_i = 0;
+ for ( PCursor<Staff*> staff_l_pcur( staffs_.top() ); staff_l_pcur.ok(); staff_l_pcur++ ) {
+ Midi_staff* mstaff_l = (Midi_staff*)*staff_l_pcur;
+ if ( !mstaff_l->pscore_l_ ) // we _are_ a midi-staff, ugh
+ mstaff_l->midi( &midi_stream, track_i++ );
+ }
+}
void
Score::add(Staff*s)
s_p->print ();
s_p->process();
s_p->output(outfn);
+ s_p->midi();
delete s_p;
}
score_array_global.set_size(0);
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
+#include "plist.hh"
#include "musicalrequest.hh"
#include "complexwalker.hh"
#include "slurreg.hh"
Source_file*
Source::sourcefile_l( char const* ch_c_l )
{
- PCursor<Source_file*> sourcefile_p_pcur( sourcefile_p_iplist_.top() );
- for ( ; sourcefile_p_pcur.ok(); sourcefile_p_pcur++ )
- if ( sourcefile_p_pcur->in_b( ch_c_l ) )
- return *sourcefile_p_pcur;
+ 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;
}
#include "debug.hh"
#include "musicalrequest.hh"
#include "commandrequest.hh" // todo
+#include "midistream.hh"
void
Staff::add(PointerList<Voice*> const &l)
}
}
+// Midi_track*
+// Staff::midi_track_p()
+// {
+// Midi_track_p midi_track_p = new Midi_track;
+// Midi_walker( *this );
+// }
+
Staff_column *
Staff::get_col(Moment w, PCursor<Staff_column*> *last)
{
return l;
}
-
void
Staff::print() const
{
#include "voice.hh"
#include "musicalrequest.hh"
#include "commandrequest.hh"
+#include "midiitem.hh"
+#include "midistream.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(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->melodic())
+ mtor << (char)('c' + req_l_pcur->melodic()->height()) << "\n";
+ 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)
{
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);
+ if (req_l_pcur->melodic())
+ mtor << (char)('c' + req_l_pcur->melodic()->height()) << "\n";
+ }
+}
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
+#include "plist.hh"
#include "musicalrequest.hh"
#include "voicegroup.hh"
#include "register.hh"
head_reg_->set_dir(i);
slur_reg_->set_dir(i);
}
+
error( String message_str, char const* context_ch_c_l )
{
message( message_str, context_ch_c_l );
- exit( 1 );
+ // 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 );
}