From 389fcb53035ac07383abf597eb86c55e18d34891 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 21 Feb 1997 00:15:12 +0100 Subject: [PATCH] release: 0.0.33 --- .dstreamrc | 5 +- Documentation/CodingStyle.pod | 37 ++-- Documentation/README.pod | 51 ++--- Documentation/faq.pod | 10 + Documentation/lilygut.pod | 12 +- Documentation/lilyinput.pod | 11 +- Documentation/make_website | 9 +- Makefile | 3 +- NEWS | 80 +++++++- README | 10 +- Sources.make | 7 +- TODO | 20 +- Variables.make | 8 +- configure | 31 ++- flower/NEWS | 17 +- flower/Sources.make | 12 +- flower/Variables.make | 10 +- flower/{dataf.cc => datafile.cc} | 29 +-- flower/datafile.hh | 59 ++++++ flower/dstream.cc | 2 +- flower/matdebug.cc | 18 +- flower/scalar.cc | 3 +- flower/string.cc | 238 +++++++++++++--------- flower/string.hh | 62 ++++-- flower/stringconversion.cc | 88 ++++++++ flower/stringconversion.hh | 29 +++ flower/stringtest.cc | 43 ++++ flower/stringutil.cc | 340 +++++++++++++++++++++++++++++++ flower/stringutil.hh | 264 ++++++++---------------- flower/textdb.hh | 2 +- flower/textstr.hh | 116 ----------- flower/textstream.cc | 31 +++ flower/textstream.hh | 74 +++++++ hdr/commandrequest.hh | 3 +- hdr/debug.hh | 6 +- hdr/inputmusic.hh | 7 + hdr/inputscore.hh | 2 + hdr/lexer.hh | 1 - hdr/lyriccolumn.hh | 8 +- hdr/lyricitem.hh | 4 +- hdr/lyricstaff.hh | 2 +- hdr/lyricwalker.hh | 10 +- hdr/musicalrequest.hh | 13 ++ hdr/parseconstruct.hh | 1 + hdr/proto.hh | 11 + hdr/request.hh | 1 + hdr/score.hh | 7 + hdr/source.hh | 2 +- hdr/sourcefile.hh | 2 +- hdr/staff.hh | 3 + hdr/voice.hh | 14 +- init/Makefile | 2 +- init/swedish.ini | 19 ++ input/Makefile | 3 +- input/cadenza.ly | 8 +- input/coriolan-alto.ly | 4 +- input/error.ly | 4 + input/kortjakje.ly | 6 +- input/martien.ly | 25 ++- input/midi.ly | 50 +++++ input/mlalt.ly | 25 +-- input/mlcello.ly | 13 +- input/mlvio1.ly | 26 +-- input/mlvio2.ly | 19 +- input/pavane.ly | 27 ++- input/plet.ly | 45 ++++ input/rhythm.ly | 12 +- input/scales.ly | 28 +-- input/scsii-menuetto.ly | 30 ++- input/standchen.ly | 180 ++++++++-------- input/standchen.tex | 6 +- input/twinkle.ly | 11 +- input/wohltemperirt.ly | 26 ++- src/barreg.cc | 2 +- src/commandrequest.cc | 17 +- src/debug.cc | 14 +- src/inputmusic.cc | 47 +++++ src/inputscore.cc | 12 ++ src/inputstaff.cc | 19 +- src/lexer.l | 8 +- src/lyricwalker.cc | 2 +- src/midicolumn.cc | 44 ++++ src/midistaff.cc | 50 +++++ src/mylexer.cc | 21 +- src/note.cc | 14 +- src/parser.y | 95 ++++++--- src/request.cc | 29 ++- src/score.cc | 44 +++- src/scores.cc | 1 + src/slurreg.cc | 1 + src/source.cc | 8 +- src/staff.cc | 9 +- src/voice.cc | 21 ++ src/voiceelt.cc | 32 +++ src/voicegroup.cc | 1 + src/voiceregs.cc | 1 + src/warn.cc | 7 +- 97 files changed, 2064 insertions(+), 832 deletions(-) rename flower/{dataf.cc => datafile.cc} (75%) create mode 100644 flower/datafile.hh create mode 100644 flower/stringconversion.cc create mode 100644 flower/stringconversion.hh create mode 100644 flower/stringtest.cc create mode 100644 flower/stringutil.cc delete mode 100644 flower/textstr.hh create mode 100644 flower/textstream.cc create mode 100644 flower/textstream.hh create mode 100644 init/swedish.ini create mode 100644 input/midi.ly create mode 100644 input/plet.ly create mode 100644 src/midicolumn.cc create mode 100644 src/midistaff.cc diff --git a/.dstreamrc b/.dstreamrc index b4d6029922..b2c6cfc5da 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -38,8 +38,9 @@ Input_cursor 1 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 diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index fdbab0668b..02b580c602 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -45,6 +45,7 @@ http://www.zib.de/Visual/software/doc++/index.html /** short description. Long class documentation. + (Hungarian postfix) */ class Class { /** short description. @@ -89,9 +90,9 @@ Standard methods: 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 @@ -109,22 +110,17 @@ Notation>. =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 @@ -203,6 +199,9 @@ with the parts of the names separated by underscores. =over 5 +=item C +unsigned cher. (The postfix _by is ambiguous) + =item C bool @@ -276,7 +275,7 @@ Temporary variable: an unsigned integer =item C Variable Test: a character -=item C +=item C Variable first_name: a String class object =item C diff --git a/Documentation/README.pod b/Documentation/README.pod index 87e2b65fbe..a837d6a070 100644 --- a/Documentation/README.pod +++ b/Documentation/README.pod @@ -21,6 +21,9 @@ music. LilyPond has these features: 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. @@ -33,7 +36,7 @@ triplets, general n-plet (triplet, quadruplets, etc.), lyrics =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 @@ -95,8 +98,6 @@ LilyPond does not display notes directly, nor will it be rehacked to be 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 @@ -115,21 +116,21 @@ broken systems. =over 5 -=item B<-I,--include>=F +=item B<-I,--include>=F, add F 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!) -=item B<-o,--output=>F, +=item B<-o,--output=>F, Set the default output file to F. @@ -139,10 +140,10 @@ Show a summary of usage =item B<-i,--init=>F -set init file (default: F) +set init file to F (default: F) -=item B<--include, -I> -add to file search path. +=item B<--include, -I>=F +add F to the search path for input files. =back @@ -157,7 +158,7 @@ the GNU General Public License, which is in the file F =head1 PREREQUISITES -Compilation: +For compilation you need. =over 5 @@ -174,17 +175,18 @@ or better recommended. I doubt if it will compile with AT&T CC. 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 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 @@ -194,14 +196,16 @@ LilyPond does use a lot of resources. For operation you need the following: =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 @@ -216,7 +220,7 @@ Do: 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 @@ -298,15 +302,15 @@ This is what the output looks like over here: hw:~/musix/spacer$ xdvi test& [1] 855 -Check out F, 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..) @@ -346,7 +350,6 @@ among others: lilygut, lilyinput, error, faq, LilyPond has no connection with the music package RoseGarden, other than the names being similar :-) - =head1 HISTORY (for a detailed changelog, see F) diff --git a/Documentation/faq.pod b/Documentation/faq.pod index df28977c5c..fac6903cb1 100644 --- a/Documentation/faq.pod +++ b/Documentation/faq.pod @@ -4,6 +4,7 @@ FAQ - LilyPond FAQs =head1 DESCRIPTION +Some questions that have been answered before. Q: Why are [] around the notes, and () inbetween? @@ -31,3 +32,12 @@ please :). 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. + + diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod index e348b644d0..1ac0c5290d 100644 --- a/Documentation/lilygut.pod +++ b/Documentation/lilygut.pod @@ -25,8 +25,10 @@ No difficult algorithms. Associated datastructures have prefix Input =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: @@ -140,11 +142,11 @@ should not be shared. The judge in this "allocation" problem is Staff (actually, it's child C). It uses the C to do most of the -work class. For each request C queries so-called +work. For each request C queries so-called Cs if they want to accept a request eg, the C will accept Cs, and turn down -Cs. If C cannot find a register wants the -request, it is junked (with a warning message). +Cs. If C 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 or diff --git a/Documentation/lilyinput.pod b/Documentation/lilyinput.pod index b7d4888006..58a4378d4b 100644 --- a/Documentation/lilyinput.pod +++ b/Documentation/lilyinput.pod @@ -70,7 +70,10 @@ Not really crystallized; you can use '#' or '%' as line comment 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. diff --git a/Documentation/make_website b/Documentation/make_website index 4b1a9aaf4a..1aede35367 100755 --- a/Documentation/make_website +++ b/Documentation/make_website @@ -11,7 +11,7 @@ sub local $base="lilypond/"; local @examples=("wohltemperirt"); -system 'make html'; +system 'pod2html'; print "resetting refs.\n"; @@ -31,7 +31,6 @@ foreach $a (@examples) { "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;" diff --git a/Makefile b/Makefile index f34bcbc4ca..830b08c360 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ distclean: clean 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: diff --git a/NEWS b/NEWS index 34f241725c..ce2cca67ca 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,58 @@ +******* +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 @@ -20,12 +66,12 @@ pl 32-1 - 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 @@ -33,7 +79,7 @@ Examples - standchen updated Bugfix - calcideal assertion bugfix - +******* pl 30 Features @@ -58,7 +104,7 @@ Bugfix pl 29 - multiplatform Makefile (JN) - context errors: bugfixes (JN) - +******* pl 28 Internal @@ -72,7 +118,7 @@ Bugfix - stupid typo in Staff_elem::post_processing() - init of hpos in PCol::PCol - Word_wrap::solve() bug - +******* pl 27 - preliminary WIN32 support (JN) Features @@ -98,7 +144,7 @@ Examples Internal: - Text_reg and Script_reg - +******* pl 26 - Documentation/lelie_logo.png - 8-bit chars for input (see ltest.tex) (MB) @@ -110,14 +156,16 @@ Internal: - 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. @@ -134,6 +182,7 @@ Bugfixes: - unconnected columns +******* pl 22: - doco from mpp - repeat signs @@ -146,6 +195,7 @@ Bugfixes: - bug noteheadswap - huge memleak fixed; unearthed lots of bugs +******* pl 21: - scripts - texts @@ -154,6 +204,7 @@ Internal changes: - Move breaking stuff into a separate class Break_algorithm - dependencies for Staff_elem's +******* pl 20: - updated doco to .pod - include files from .ly @@ -161,33 +212,40 @@ Internal changes: - 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 diff --git a/README b/README index 8c2b831b5a..83f807a7a0 100644 --- a/README +++ b/README @@ -1,11 +1,14 @@ -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: @@ -21,8 +24,9 @@ NOTE: 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! diff --git a/Sources.make b/Sources.make index ffb0f96cd5..2312887b2a 100644 --- a/Sources.make +++ b/Sources.make @@ -12,7 +12,10 @@ hdr= bar.hh barreg.hh beam.hh boxes.hh break.hh clefreg.hh clefitem.hh\ 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\ @@ -42,6 +45,8 @@ mycc=bar.cc barreg.cc beam.cc boxes.cc break.cc calcideal.cc clefreg.cc\ 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\ diff --git a/TODO b/TODO index 1803ad21c3..4eba110c2d 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,19 @@ 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 @@ -25,6 +25,10 @@ BUGS * $cis ( | ) cis$ + * Group_feature at start of music. + + * size of Key_item + SEVERELY LACKING: * grace notes @@ -45,7 +49,9 @@ INPUTLANGUAGE SMALLISH PROJECTS - * bar numbers + * parshape + + * bar numbers/repetition marks * read from mmap directly: study yy_scan_buffer @@ -123,7 +129,7 @@ IDEAS * enter Requests directly - * itemcolumns + * itemcolumns: Use dummy items. * use an embedded language: scheme, lisp, S-lang, Perl, ? diff --git a/Variables.make b/Variables.make index 6c75665757..96aa6194dd 100644 --- a/Variables.make +++ b/Variables.make @@ -3,7 +3,7 @@ # version info MAJVER=0 MINVER=0 -PATCHLEVEL=32 +PATCHLEVEL=33 @@ -28,7 +28,7 @@ EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes # VM hardware to trap malloc/free errors. # -EXTRALIB= #+=-lefence +EXTRALIB+= #-lefence #### #### END USER CONFIGURABLE part. @@ -110,6 +110,6 @@ DODEP=rm -f $(depfile); DEPENDENCIES_OUTPUT="$(depfile) $(OBJECTDIR)/$(notdir $@ 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 diff --git a/configure b/configure index b1b21e0631..21ee567e83 100755 --- a/configure +++ b/configure @@ -1,12 +1,26 @@ #!/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 @@ -19,14 +33,23 @@ else 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 diff --git a/flower/NEWS b/flower/NEWS index b89a032048..c545441b69 100644 --- a/flower/NEWS +++ b/flower/NEWS @@ -1,3 +1,18 @@ + +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* @@ -14,4 +29,4 @@ pl 23 - win32 patches (JN) pl 22 - - Array::add -> Array::push \ No newline at end of file + - Array::add -> Array::push diff --git a/flower/Sources.make b/flower/Sources.make index 23d5164f0a..4b7cca4ec6 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,6 +1,7 @@ -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 @@ -9,5 +10,8 @@ inl=link.inl list.inl cursor.inl plist.inl 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 diff --git a/flower/Variables.make b/flower/Variables.make index 6d0cec88bd..d2a35182bd 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,12 +1,12 @@ 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 ######################################### @@ -32,7 +32,7 @@ include Sources.make 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) diff --git a/flower/dataf.cc b/flower/datafile.cc similarity index 75% rename from flower/dataf.cc rename to flower/datafile.cc index 29b366c860..e5940b4c40 100644 --- a/flower/dataf.cc +++ b/flower/datafile.cc @@ -1,34 +1,7 @@ #include #include -#include "textstr.hh" -Text_stream::Text_stream(String fn) -{ - if (fn == "") - { - name = ""; - 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"< +*/ + + +#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 << ")"<; + indentlvl = 0; if (!os) return; - indentlvl = 0; const char * fn =cfg_nm ? cfg_nm : ".dstreamrc"; { diff --git a/flower/matdebug.cc b/flower/matdebug.cc index 4c7866f093..1a5d867903 100644 --- a/flower/matdebug.cc +++ b/flower/matdebug.cc @@ -1,8 +1,10 @@ #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; @@ -10,8 +12,9 @@ void set_matrix_debug(Dstream&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 "); @@ -28,19 +31,22 @@ void 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; } @@ -49,6 +55,8 @@ void Vector::print() const { #ifndef NDEBUG + if (!dout) + return; *dout << *this<<'\n'; #endif } diff --git a/flower/scalar.cc b/flower/scalar.cc index d8e6f9e74b..044b4d0b0f 100644 --- a/flower/scalar.cc +++ b/flower/scalar.cc @@ -1,3 +1,4 @@ +#include #include #include "scalar.hh" @@ -26,7 +27,7 @@ Scalar::isnum() int conv = false; if (len()) { long l =0; - conv = sscanf(data, "%ld", &l); + conv = sscanf(strh_.ch_c_l(), "%ld", &l); } return len() && conv; } diff --git a/flower/string.cc b/flower/string.cc index 9c7f2d0801..8a53710dcb 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -5,8 +5,7 @@ Rehacked by HWN 3/nov/95 removed String & introduced Class String_handle - -*/ + */ #include #include @@ -17,7 +16,8 @@ #include "string.hh" -static char* strlwr( char* s ) +static char* +strlwr( char* s ) { char* p = s; @@ -29,7 +29,8 @@ static char* strlwr( char* s ) return s; } -static char* strupr( char* s ) +static char* +strupr( char* s ) { char* p = s; @@ -56,41 +57,51 @@ String::String(Rational r) } // 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) @@ -101,18 +112,19 @@ 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) @@ -120,39 +132,66 @@ String::String( const int i, const int n, const char c ) 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 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; @@ -179,15 +220,17 @@ String::lastPos( const char* string ) const // 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; } @@ -196,13 +239,15 @@ String::pos(char c ) const // 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; } @@ -211,13 +256,15 @@ String::pos( const char* searchfor ) const // 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; } @@ -227,7 +274,7 @@ String::posAny( const char* string ) const String String::left( int n ) const { - if (n >= len()) + if (n >= length_i()) return *this; String retval; @@ -235,7 +282,7 @@ String::left( int n ) const return retval; retval = *this; - retval.data.trunc(n); + retval.strh_.trunc(n); return retval; } @@ -244,17 +291,13 @@ String::left( int n ) const 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 ); } @@ -265,29 +308,27 @@ String::nomid( const int pos, const int n ) const 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 ); } @@ -295,24 +336,29 @@ String::mid( int pos, int n ) const 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 */ @@ -329,8 +375,8 @@ long 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; @@ -340,8 +386,8 @@ double 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; @@ -354,26 +400,26 @@ String quoteString( String msg, String quote) } -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; } diff --git a/flower/string.hh b/flower/string.hh index 420d5f959d..23608994bf 100644 --- a/flower/string.hh +++ b/flower/string.hh @@ -19,41 +19,54 @@ #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 ); @@ -69,21 +82,23 @@ public: 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; @@ -101,13 +116,13 @@ public: 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 @@ -116,8 +131,10 @@ public: /// 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; @@ -135,7 +152,12 @@ public: double fvalue() const; /// the length of the string - int len() const; + int length_i() const; + + // deprecated + int len() const { + return length_i(); + } }; @@ -176,4 +198,6 @@ operator << ( ostream& os, String d ) String quoteString(String message, String quote); +#include "stringconversion.hh" + #endif diff --git a/flower/stringconversion.cc b/flower/stringconversion.cc new file mode 100644 index 0000000000..7a9d1f4551 --- /dev/null +++ b/flower/stringconversion.cc @@ -0,0 +1,88 @@ +/* + PROJECT: FlowerSoft C++ library + FILE : stringconversion.cc + +--*/ + + +#include +#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'; +} diff --git a/flower/stringconversion.hh b/flower/stringconversion.hh new file mode 100644 index 0000000000..39b809e4c4 --- /dev/null +++ b/flower/stringconversion.hh @@ -0,0 +1,29 @@ +/* + 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 // diff --git a/flower/stringtest.cc b/flower/stringtest.cc new file mode 100644 index 0000000000..71c1557912 --- /dev/null +++ b/flower/stringtest.cc @@ -0,0 +1,43 @@ +// stringtest.cc + +#include +#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; +} diff --git a/flower/stringutil.cc b/flower/stringutil.cc new file mode 100644 index 0000000000..bca803a23e --- /dev/null +++ b/flower/stringutil.cc @@ -0,0 +1,340 @@ +// 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 +#include +#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 // diff --git a/flower/stringutil.hh b/flower/stringutil.hh index 2f62caee3d..728ce9bb30 100644 --- a/flower/stringutil.hh +++ b/flower/stringutil.hh @@ -1,244 +1,150 @@ -#ifndef STRINGUTIL_HH -#define STRINGUTIL_HH -#include - +#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 // diff --git a/flower/textdb.hh b/flower/textdb.hh index 3586c0d180..c2cff2461b 100644 --- a/flower/textdb.hh +++ b/flower/textdb.hh @@ -1,7 +1,7 @@ #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 */ diff --git a/flower/textstr.hh b/flower/textstr.hh deleted file mode 100644 index 2d648d4c19..0000000000 --- a/flower/textstr.hh +++ /dev/null @@ -1,116 +0,0 @@ - -#ifndef TEXTSTR_HH -#define TEXTSTR_HH - -#include -#include -#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 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 << ")"< +#include +#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 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 diff --git a/hdr/commandrequest.hh b/hdr/commandrequest.hh index e5419da759..f9eef852fd 100644 --- a/hdr/commandrequest.hh +++ b/hdr/commandrequest.hh @@ -84,8 +84,9 @@ struct Group_change_req : Nonmusical_req { /** 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 { diff --git a/hdr/debug.hh b/hdr/debug.hh index f6855fcabe..92715dbfdc 100644 --- a/hdr/debug.hh +++ b/hdr/debug.hh @@ -22,12 +22,12 @@ extern ostream &warnout ; 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; diff --git a/hdr/inputmusic.hh b/hdr/inputmusic.hh index 13e8f4a365..da3030f11b 100644 --- a/hdr/inputmusic.hh +++ b/hdr/inputmusic.hh @@ -29,11 +29,14 @@ struct Voice_list : public PointerList { */ 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; @@ -53,6 +56,8 @@ struct Simple_music : Input_music { 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); } @@ -69,6 +74,8 @@ struct Complex_music : Input_music { 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); }; diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh index 024c6d132c..3b84d44fdb 100644 --- a/hdr/inputscore.hh +++ b/hdr/inputscore.hh @@ -24,6 +24,7 @@ struct Input_score { /// paper_, staffs_ and commands_ form the problem definition. Paperdef *paper_p_; + Mididef* midi_p_; IPointerList staffs_; Input_music * score_wide_music_p_; @@ -36,6 +37,7 @@ struct Input_score { ~Input_score(); /// construction void set(Paperdef*); + void set(Mididef* midi_p); void print() const; Score*parse(); void set(Input_music*); diff --git a/hdr/lexer.hh b/hdr/lexer.hh index 8f1e67123e..ce760fe22d 100644 --- a/hdr/lexer.hh +++ b/hdr/lexer.hh @@ -31,7 +31,6 @@ struct My_flex_lexer : yyFlexLexer { Assoc *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); diff --git a/hdr/lyriccolumn.hh b/hdr/lyriccolumn.hh index a7202e593d..e7aaaafc86 100644 --- a/hdr/lyriccolumn.hh +++ b/hdr/lyriccolumn.hh @@ -1,11 +1,11 @@ // // lyriccolumn.hh -- declare Lyric_column // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen -#ifndef LYRICCOLUMN_HH -#define LYRICCOLUMN_HH +#ifndef LYRIC_COLUMN_HH +#define LYRIC_COLUMN_HH #include "key.hh" #include "stcol.hh" @@ -23,7 +23,7 @@ struct Lyric_column : Staff_column { Lyric_column(Lyric_staff*rs); }; -#endif // LYRICSTAFF_HH +#endif // LYRIC_COLUMN_HH diff --git a/hdr/lyricitem.hh b/hdr/lyricitem.hh index 5dcd90c889..46873d8f51 100644 --- a/hdr/lyricitem.hh +++ b/hdr/lyricitem.hh @@ -1,7 +1,7 @@ // // lyricitem.hh -- part of LilyPond // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #ifndef LYRIC_ITEM_HH #define LYRIC_ITEM_HH @@ -15,5 +15,5 @@ struct Lyric_item : Text_item { }; -#endif // LYRICITEM_HH +#endif // LYRIC_ITEM_HH // diff --git a/hdr/lyricstaff.hh b/hdr/lyricstaff.hh index 31cc62caaa..f7166bfc99 100644 --- a/hdr/lyricstaff.hh +++ b/hdr/lyricstaff.hh @@ -1,7 +1,7 @@ /* lyricstaff.hh -- part of LilyPond - copyright 1997 Jan Nieuwenhuizen + copyright 1997 Jan Nieuwenhuizen */ #ifndef LYRICSTAFF_HH diff --git a/hdr/lyricwalker.hh b/hdr/lyricwalker.hh index 5f413f2ab9..f89be76249 100644 --- a/hdr/lyricwalker.hh +++ b/hdr/lyricwalker.hh @@ -1,8 +1,8 @@ -/* - lyricwalker.hh -- declare Lyric_walker - - (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen -*/ +// +// lyricwalker.hh -- declare Lyric_walker +// +// (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen +// #ifndef LYRICWALKER_HH #define LYRICWALKER_HH diff --git a/hdr/musicalrequest.hh b/hdr/musicalrequest.hh index 2a864eb9ef..240b72afd9 100644 --- a/hdr/musicalrequest.hh +++ b/hdr/musicalrequest.hh @@ -96,6 +96,8 @@ struct Melodic_req :virtual Musical_req /// 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); @@ -144,6 +146,17 @@ struct Span_req : Musical_req { }; +/// 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 diff --git a/hdr/parseconstruct.hh b/hdr/parseconstruct.hh index 5ee82774c0..7b9e3e3ec2 100644 --- a/hdr/parseconstruct.hh +++ b/hdr/parseconstruct.hh @@ -25,6 +25,7 @@ Request* get_request(char); 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); diff --git a/hdr/proto.hh b/hdr/proto.hh index 5610e4f54b..967df3d56c 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -65,6 +65,16 @@ struct Measure_grouping_req; 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; @@ -78,6 +88,7 @@ struct Notename_tab; struct Offset; struct Output; struct PCol; +struct Plet_req; struct PScore; struct PStaff; struct Paperdef; diff --git a/hdr/request.hh b/hdr/request.hh index 56fc3e4ea5..bf94d1a02e 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -45,6 +45,7 @@ struct Request { 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; } diff --git a/hdr/score.hh b/hdr/score.hh index f48ad356df..b9555b2036 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -21,6 +21,7 @@ struct Score { /// paper_, staffs_ and commands_ form the problem definition. Paperdef *paper_p_; + Mididef *midi_p_; IPointerList staffs_; /// "runtime" fields for setting up spacing @@ -43,6 +44,12 @@ struct Score { /// output to file void output(String fn); + /// do midi stuff + void midi(); + + /// + void set(Mididef* midi_p); + // standard void OK() const; void print() const; diff --git a/hdr/source.hh b/hdr/source.hh index 063905baaa..3bdbef721e 100644 --- a/hdr/source.hh +++ b/hdr/source.hh @@ -1,7 +1,7 @@ // // source.hh -- part of LilyPond // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #ifndef SOURCE_HH #define SOURCE_HH diff --git a/hdr/sourcefile.hh b/hdr/sourcefile.hh index a52e76f66a..36c7aaa575 100644 --- a/hdr/sourcefile.hh +++ b/hdr/sourcefile.hh @@ -1,7 +1,7 @@ // // sourcefile.hh -- declare Source_file // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #ifndef SOURCE_FILE_HH #define SOURCE_FILE_HH diff --git a/hdr/staff.hh b/hdr/staff.hh index 4c507c4b5b..74b7df1340 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -44,6 +44,9 @@ public: /// 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(); diff --git a/hdr/voice.hh b/hdr/voice.hh index 4d282ddea1..4b8e258c1f 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -17,13 +17,17 @@ struct Voice { 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 @@ -36,10 +40,14 @@ struct Voice_element { /* *************** */ - 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 diff --git a/init/Makefile b/init/Makefile index 7aa3964262..83a2e5b9ae 100644 --- a/init/Makefile +++ b/init/Makefile @@ -1,5 +1,5 @@ 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? diff --git a/init/swedish.ini b/init/swedish.ini new file mode 100644 index 0000000000..b3c26940da --- /dev/null +++ b/init/swedish.ini @@ -0,0 +1,19 @@ +% +% 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 } + diff --git a/input/Makefile b/input/Makefile index 885dcf19a9..5e7ff85249 100644 --- a/input/Makefile +++ b/input/Makefile @@ -2,7 +2,8 @@ default: ; 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\ diff --git a/input/cadenza.ly b/input/cadenza.ly index 6773143fea..fb7669e3fa 100644 --- a/input/cadenza.ly +++ b/input/cadenza.ly @@ -33,7 +33,7 @@ cad = music { $ \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{'} @@ -50,7 +50,9 @@ score { music { cad } } commands { - cadenza $1$ + cadenza {1} grouping{1*4} } -} + midi { tempo 4:80 } + staff { midi music { cad } } +} \ No newline at end of file diff --git a/input/coriolan-alto.ly b/input/coriolan-alto.ly index 683141814d..2037580f13 100644 --- a/input/coriolan-alto.ly +++ b/input/coriolan-alto.ly @@ -14,9 +14,9 @@ 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? diff --git a/input/error.ly b/input/error.ly index 922f9ebefd..74924e9b25 100644 --- a/input/error.ly +++ b/input/error.ly @@ -1,7 +1,11 @@ +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 diff --git a/input/kortjakje.ly b/input/kortjakje.ly index 6da101c266..645c1f9d4b 100644 --- a/input/kortjakje.ly +++ b/input/kortjakje.ly @@ -33,9 +33,11 @@ $} % 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 diff --git a/input/martien.ly b/input/martien.ly index cf40cc9788..683f14d464 100644 --- a/input/martien.ly +++ b/input/martien.ly @@ -41,15 +41,15 @@ score { } 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 @@ -57,4 +57,23 @@ score { 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 + } } diff --git a/input/midi.ly b/input/midi.ly new file mode 100644 index 0000000000..c08b1bc348 --- /dev/null +++ b/input/midi.ly @@ -0,0 +1,50 @@ +% 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 } + } +} + diff --git a/input/mlalt.ly b/input/mlalt.ly index 51f7de8742..cbe46e0f23 100644 --- a/input/mlalt.ly +++ b/input/mlalt.ly @@ -16,6 +16,7 @@ alto = music { \duration{16} \clef\alto \octave{} + \key{fis} %1 [ `b8. `a ] [ `g8 `b c ] | %2 @@ -112,31 +113,31 @@ alto = music { %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 @@ -205,7 +206,7 @@ alto = music { `b2 | %88 \textstyle "italic" - c2_"dacapo" | + c2_"dacapo" \key{fis} | \textstyle "roman" %\scoreverb{\mulooseness=1} % \key\G || diff --git a/input/mlcello.ly b/input/mlcello.ly index cdc0b43348..558fc1fb15 100644 --- a/input/mlcello.ly +++ b/input/mlcello.ly @@ -15,6 +15,7 @@ cello = music { $ \clef"bass" \octave{`} \duration{4} + \key{fis} %%1 g `g | %%2 @@ -127,22 +128,22 @@ cello = music { %%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 | @@ -212,7 +213,7 @@ cello = music { d | %%88 \textstyle "italic" - d_"dacapo" + d_"dacapo" \key{fis} | \textstyle "roman" % \key\`g || $ diff --git a/input/mlvio1.ly b/input/mlvio1.ly index a6f2b049f4..b1d277bd31 100644 --- a/input/mlvio1.ly +++ b/input/mlvio1.ly @@ -13,9 +13,10 @@ % violin1 = music { $ -\clef "violin" + \clef "violin" \octave{} \duration{4} + \key{fis} %1 g [ b8. a16 ] | %2 @@ -123,22 +124,22 @@ violin1 = music { %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 | @@ -150,11 +151,11 @@ violin1 = music { '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 | @@ -186,11 +187,11 @@ violin1 = music { '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 @@ -212,6 +213,7 @@ violin1 = music { \textstyle "italic" a_"dacapo" \textstyle "roman" + \key{fis} | % \key\G || $ } diff --git a/input/mlvio2.ly b/input/mlvio2.ly index ad6deb44a4..c3ed9bb999 100644 --- a/input/mlvio2.ly +++ b/input/mlvio2.ly @@ -15,6 +15,7 @@ violin2 = music { $ \clef "violin" \octave{} \duration{4} + \key{fis} %1 d2 | %2 @@ -92,7 +93,7 @@ violin2 = music { %35 [ g8 e e ] [ e8 g g ] | %36 - b4 fis4 | + b4 fis4 | %37 [ a8 a a ] [ a8 a a ] | %38 @@ -126,21 +127,21 @@ violin2 = music { \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 | @@ -182,9 +183,9 @@ violin2 = music { %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 | @@ -210,7 +211,7 @@ violin2 = music { % = g | %88 \textstyle "italic" - fis_"dacapo" | + fis_"dacapo" \key{fis}| \textstyle "roman" % \key\G || $ diff --git a/input/pavane.ly b/input/pavane.ly index 4f0b3b8812..1e2c6da688 100644 --- a/input/pavane.ly +++ b/input/pavane.ly @@ -11,9 +11,8 @@ % horn = -staff { - melodic - music{ $ +music { + $ \octave { ' } \key{ fis cis } \duration { 8 } @@ -68,13 +67,12 @@ staff { 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} @@ -96,11 +94,10 @@ staff { )b [fis a b ] 'cis4 b4 | fis2 r2 | r1-\fermata - $} + $ } score { - staff { - horn + staff { melodic music { horn } } paper { output "pavane.out" @@ -110,11 +107,13 @@ score { } 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 } } +} diff --git a/input/plet.ly b/input/plet.ly new file mode 100644 index 0000000000..752a6bade6 --- /dev/null +++ b/input/plet.ly @@ -0,0 +1,45 @@ + +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} + } +} diff --git a/input/rhythm.ly b/input/rhythm.ly index c74c9d8dcd..368d04b9bf 100644 --- a/input/rhythm.ly +++ b/input/rhythm.ly @@ -29,15 +29,21 @@ ritme = staff { $ } + % + % 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 $ } } @@ -57,4 +63,4 @@ score { unitspace 2cm geometric 1.3 } -} \ No newline at end of file +} diff --git a/input/scales.ly b/input/scales.ly index fba2c9ff4d..d98c1bba43 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -4,25 +4,25 @@ staff {melodic 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} diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly index 00fde25284..932bd7d381 100644 --- a/input/scsii-menuetto.ly +++ b/input/scsii-menuetto.ly @@ -57,8 +57,8 @@ ii_menuetto = music { % { '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 } @@ -99,27 +99,25 @@ ii_menuetto = music { { 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 $ } @@ -130,13 +128,6 @@ score { } commands { meter {3 * 4} - skip {24 * 4}% 8 measures - bar ":|:" - - skip {15 * 4} % 5 meas. - - skip {36*4} - bar ":||" } paper { symboltables { table_sixteen } @@ -146,4 +137,11 @@ score { geometric 1.4 output "scsii-menuetto.out" } -o} + staff { + midi music { ii_menuetto } + } + midi { + tempo 4:120 + output "scsii-menuetto.midi" + } +} diff --git a/input/standchen.ly b/input/standchen.ly index edc487c9b0..219cb50765 100644 --- a/input/standchen.ly +++ b/input/standchen.ly @@ -12,7 +12,7 @@ % 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 % @@ -36,6 +36,7 @@ %#%\duration8 %%1 melodie = music { $ \clef\violin + \key{bes} \duration{ 8 } r_"\pp" { [ d `a-| } f-| { d `a-| } f-| { d `a-| ] } | %%2 @@ -48,30 +49,30 @@ melodie = music { $ \clef\violin 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 @@ -82,12 +83,12 @@ melodie = music { $ \clef\violin [ '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. | @@ -97,12 +98,12 @@ melodie = music { $ \clef\violin [ '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 @@ -139,8 +140,8 @@ melodie = music { $ \clef\violin %%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 @@ -151,19 +152,19 @@ melodie = music { $ \clef\violin [ 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. } | @@ -194,73 +195,71 @@ melodie = music { $ \clef\violin $ } 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 @@ -303,9 +302,9 @@ begeleiding = music { $ { [ `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 @@ -341,16 +340,16 @@ tekst1 = music { _ _ _ _ _ _ % 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 _ _ _ _ _ _ _ @@ -358,7 +357,7 @@ tekst1 = music { % 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. _ _ _ _ _ _ @@ -366,7 +365,7 @@ tekst1 = music { % 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. _ _ _ _ _ _ @@ -386,7 +385,7 @@ tekst1 = music { 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 @@ -408,17 +407,17 @@ tekst2 = music { _ _ _ _ _ _ % 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 _ _ _ _ _ _ _ @@ -426,7 +425,7 @@ tekst2 = music { % 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. _ _ _ _ _ _ @@ -434,7 +433,7 @@ tekst2 = music { % 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. _ _ _ _ _ _ @@ -465,35 +464,36 @@ tekst2 = music { } 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 + } } diff --git a/input/standchen.tex b/input/standchen.tex index 9c87c4cc90..4b19a6aef5 100644 --- a/input/standchen.tex +++ b/input/standchen.tex @@ -10,10 +10,8 @@ \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)} diff --git a/input/twinkle.ly b/input/twinkle.ly index 9b081c43fa..a356386099 100644 --- a/input/twinkle.ly +++ b/input/twinkle.ly @@ -15,6 +15,7 @@ melodie = music { c c | g g | a a | g g | f f | e e | d d8.( e16 | )c2 % :| + \bar ":|" $ } @@ -30,6 +31,7 @@ begeleiding = music { c 'c | 'e 'c | 'f 'c | 'e 'c | 'd b | 'c a | f g | c2 + \bar ":|" $ } @@ -150,8 +152,13 @@ score { } 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 } } diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index c4c0f2455e..1038169bab 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -8,9 +8,9 @@ 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] | @@ -21,9 +21,10 @@ dux = music { $ $} 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] @@ -35,11 +36,16 @@ $} 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 } @@ -58,5 +64,11 @@ score { grouping {2*2} key {$bes es as$} } + staff { midi music { dux } } + staff { midi music { comes } } + staff { midi music { bassdux } } + midi { + tempo 4:80 + } } diff --git a/src/barreg.cc b/src/barreg.cc index 03b49497b7..566b9d58a5 100644 --- a/src/barreg.cc +++ b/src/barreg.cc @@ -37,7 +37,7 @@ Bar_register::process_request() { 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("|"); } diff --git a/src/commandrequest.cc b/src/commandrequest.cc index 065f69ae53..9af17503f3 100644 --- a/src/commandrequest.cc +++ b/src/commandrequest.cc @@ -17,10 +17,21 @@ Cadenza_req::do_print()const 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) @@ -55,10 +66,6 @@ Nonmusical_req::do_print()const{} void Barcheck_req::do_print() const{} -Bar_req::Bar_req(String s) -{ - type = s; -} /* *************** */ void Clef_change_req::do_print() const diff --git a/src/debug.cc b/src/debug.cc index 228f7c7019..01a35bd140 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -6,12 +6,18 @@ #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; @@ -38,7 +44,7 @@ debug_init() #ifndef NDEBUG set_new_handler(&mynewhandler); #endif - set_matrix_debug(monitor); + set_matrix_debug(*monitor); signal(SIGFPE, float_handler); } diff --git a/src/inputmusic.cc b/src/inputmusic.cc index 05918a1a5f..8f3ca2cb93 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -3,6 +3,23 @@ #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) { @@ -36,6 +53,16 @@ Simple_music::print() const 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); +} /* *************** */ @@ -74,6 +101,22 @@ Complex_music::set_default_group(String g) 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 @@ -97,6 +140,8 @@ Music_voice::add_elt(Voice_element*v) c = elts.bottom(); Simple_music *s = c->simple(); s->add(v); + + check_plet(v); } Moment @@ -142,6 +187,8 @@ Music_general_chord::add_elt(Voice_element*v) Simple_music*vs = new Simple_music; vs->add(v); elts.bottom().add(vs); + + check_plet(v); } void diff --git a/src/inputscore.cc b/src/inputscore.cc index a8a653982c..82d7a6c96a 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -12,6 +12,7 @@ #include "inputmusic.hh" #include "score.hh" #include "paperdef.hh" +#include "mididef.hh" #include "staff.hh" @@ -28,6 +29,13 @@ Input_score::set(Paperdef*p) 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; @@ -44,6 +52,8 @@ Input_score::parse() 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_); @@ -65,6 +75,7 @@ Input_score::~Input_score() { delete paper_p_; delete score_wide_music_p_; + delete midi_p_; } Input_score::Input_score() @@ -72,6 +83,7 @@ Input_score::Input_score() score_wide_music_p_ =0; defined_ch_c_l_=0; paper_p_= 0; + midi_p_ = 0; errorlevel_i_ = 0; } diff --git a/src/inputstaff.cc b/src/inputstaff.cc index 116624574c..7fbc37dbac 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -1,11 +1,20 @@ +/* + inputstaff.cc -- implement Input_staff + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #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) @@ -29,8 +38,12 @@ Input_staff::parse(Score*score_l, Input_music *default_score_wide) 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; diff --git a/src/lexer.l b/src/lexer.l index f0652ac6c7..1e4e8488a5 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -179,11 +179,11 @@ COMMENT [%#].*\n {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); diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc index 960c1e76e0..51a2b03594 100644 --- a/src/lyricwalker.cc +++ b/src/lyricwalker.cc @@ -3,7 +3,7 @@ source file of the LilyPond music typesetter - (c) 1997 Jan Nieuwenhuizen + (c) 1997 Jan Nieuwenhuizen */ #include "musicalrequest.hh" diff --git a/src/midicolumn.cc b/src/midicolumn.cc new file mode 100644 index 0000000000..13abbd03d5 --- /dev/null +++ b/src/midicolumn.cc @@ -0,0 +1,44 @@ +#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 ); + } +} diff --git a/src/midistaff.cc b/src/midistaff.cc new file mode 100644 index 0000000000..c63ac9688b --- /dev/null +++ b/src/midistaff.cc @@ -0,0 +1,50 @@ +#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! +} + diff --git a/src/mylexer.cc b/src/mylexer.cc index 7af820ae44..ea86b3094b 100644 --- a/src/mylexer.cc +++ b/src/mylexer.cc @@ -26,6 +26,7 @@ static Keyword_ent the_key_tab[]={ "key", KEY, "meter", METER, + "midi", MIDI, "mm", MM_T, "multivoice", MULTIVOICE, "octave", OCTAVECOMMAND, @@ -43,6 +44,7 @@ static Keyword_ent the_key_tab[]={ "table", TABLE, "symboltables", SYMBOLTABLES, "notenames", NOTENAMES, + "tempo", TEMPO, "texid", TEXID, "textstyle", TEXTSTYLE, "unitspace", UNITSPACE, @@ -59,10 +61,12 @@ My_flex_lexer::ret_notename(int *p, String text, int octave_mod) { 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; @@ -70,7 +74,7 @@ My_flex_lexer::ret_notename(int *p, String text, int 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; @@ -81,7 +85,6 @@ My_flex_lexer::My_flex_lexer() keytable = new Keyword_table(the_key_tab); the_id_tab = new Assoc; defaulttab = 0; - data_ch_c_l_ = 0; errorlevel_i_ = 0; } @@ -103,7 +106,7 @@ My_flex_lexer::lookup_identifier(String s) 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 @@ -144,7 +147,7 @@ My_flex_lexer::LexerError(const char *s) ch_c_l++; } errorlevel_i_ |= 1; - warning( s, ch_c_l ); + error( s, ch_c_l ); } } @@ -161,10 +164,6 @@ My_flex_lexer::new_input(String s) 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; } diff --git a/src/note.cc b/src/note.cc index 2a89743e95..95a7d8313d 100644 --- a/src/note.cc +++ b/src/note.cc @@ -14,6 +14,7 @@ #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; @@ -36,7 +37,8 @@ last_duration(int n) } /* 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; @@ -193,6 +195,16 @@ set_default_octave(String d) 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) { diff --git a/src/parser.y b/src/parser.y index 6c471fc95f..f761069e3e 100644 --- a/src/parser.y +++ b/src/parser.y @@ -5,6 +5,7 @@ #include "misc.hh" #include "lexer.hh" #include "paperdef.hh" +#include "mididef.hh" #include "inputscore.hh" #include "main.hh" #include "keyword.hh" @@ -38,6 +39,7 @@ int fatal_error_i = 0; String *string; const char *consstr; Paperdef *paper; + Mididef* midi; Input_music *music; Music_general_chord *chord; Music_voice *mvoice; @@ -69,6 +71,7 @@ int fatal_error_i = 0; %token PARTIAL MUSIC GROUPING CADENZA %token END SYMBOLTABLES TEXID TABLE NOTENAMES SCRIPT TEXTSTYLE PLET %token GOTO +%token MIDI TEMPO %token IDENTIFIER %token PITCHMOD DURATION RESTNAME @@ -79,10 +82,11 @@ int fatal_error_i = 0; %token DOTS INT %type unit %type pitch_list -%type open_request_parens close_request_parens +%type open_request_parens close_request_parens close_plet_parens %type declaration %type declarable_identifier %type paper_block paper_body +%type midi_block midi_body %type dim real %type default_duration explicit_duration notemode_duration mudela_duration %type notename @@ -214,6 +218,7 @@ score_body: { $$->set($4); } | score_body paper_block { $$->set($2); } + | score_body midi_block { $$->set($2); } | score_body error { } @@ -252,6 +257,30 @@ paper_body: } ; +/* + 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 */ @@ -271,6 +300,9 @@ staff_init: $$ = new Input_staff(*$1); delete $1; } + | MIDI { + $$ = new Input_staff("midi"); + } ; staff_body: @@ -340,7 +372,6 @@ music_chord_body: ; - /* VOICE ELEMENTS */ @@ -349,26 +380,32 @@ full_element: pre_requests voice_elt post_requests { 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; } @@ -377,18 +414,18 @@ command_req: 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); @@ -416,6 +453,11 @@ post_requests: $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: @@ -426,6 +468,13 @@ post_request: | textscript_req ; +close_plet_parens: + ']' { + req_defined_ch_c_l = lexer->here_ch_c_l(); + $$ = ']'; + } + ; + close_request_parens: '(' { $$='('; @@ -529,7 +578,7 @@ voice_command: set_default_octave(*$3); delete $3; } - | TEXTSTYLE STRING { + | TEXTSTYLE STRING { set_text_style(*$2); delete $2; } @@ -743,16 +792,16 @@ parse_file(String init, String s) 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); diff --git a/src/request.cc b/src/request.cc index 72b8a3544a..bce34a8575 100644 --- a/src/request.cc +++ b/src/request.cc @@ -71,6 +71,7 @@ Spacing_req::do_print()const { mtor << "next " << next << "dist " << distance << "strength\n"; } + void Blank_req::do_print()const { @@ -88,7 +89,7 @@ Melodic_req::Melodic_req() void Melodic_req::do_print() const { - mtor << "notename: " << notename_i_ << " oct: "<< octave_i_; + mtor << "notename: " << notename_i_ << " acc: " <align_i_ = 1; // raggedright + def_p->align_i_ = 0; // centre dir_i_ = -1; // lyrics below (invisible) staff } diff --git a/src/score.cc b/src/score.cc index 3084f90c90..368188bbc1 100644 --- a/src/score.cc +++ b/src/score.cc @@ -17,13 +17,20 @@ #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_); @@ -45,13 +52,14 @@ Score::process_music() *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. @@ -158,6 +166,13 @@ Score::last() const return l; } +void +Score::set(Mididef* midi_p) +{ + delete midi_p_; + midi_p_ = midi_p; +} + void Score::OK() const { @@ -197,6 +212,7 @@ Score::Score(Paperdef*paper_p) { pscore_p_=0; paper_p_ = paper_p; + midi_p_ = 0; errorlevel_i_ = 0; defined_ch_c_l_ = 0; } @@ -205,6 +221,7 @@ Score::~Score() { delete pscore_p_; delete paper_p_; + delete midi_p_; } void @@ -230,7 +247,30 @@ Score::output(String s) 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_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_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) diff --git a/src/scores.cc b/src/scores.cc index 59b6f6670d..2788fe062a 100644 --- a/src/scores.cc +++ b/src/scores.cc @@ -17,6 +17,7 @@ do_scores() s_p->print (); s_p->process(); s_p->output(outfn); + s_p->midi(); delete s_p; } score_array_global.set_size(0); diff --git a/src/slurreg.cc b/src/slurreg.cc index 48f60878be..d1eb312d85 100644 --- a/src/slurreg.cc +++ b/src/slurreg.cc @@ -4,6 +4,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "plist.hh" #include "musicalrequest.hh" #include "complexwalker.hh" #include "slurreg.hh" diff --git a/src/source.cc b/src/source.cc index 34f1a8808f..519a6fe96a 100644 --- a/src/source.cc +++ b/src/source.cc @@ -28,9 +28,9 @@ Source::add( Source_file* sourcefile_p ) Source_file* Source::sourcefile_l( char const* ch_c_l ) { - PCursor 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 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; } diff --git a/src/staff.cc b/src/staff.cc index a69f625aed..c93ca997cc 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -8,6 +8,7 @@ #include "debug.hh" #include "musicalrequest.hh" #include "commandrequest.hh" // todo +#include "midistream.hh" void Staff::add(PointerList const &l) @@ -39,6 +40,13 @@ Staff::clean_cols() } } +// 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 *last) { @@ -123,7 +131,6 @@ Staff::last() const return l; } - void Staff::print() const { diff --git a/src/voice.cc b/src/voice.cc index 3dd4becf21..718e7cb6d1 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -10,6 +10,8 @@ #include "voice.hh" #include "musicalrequest.hh" #include "commandrequest.hh" +#include "midiitem.hh" +#include "midistream.hh" void Voice::set_default_group(String s) @@ -17,6 +19,25 @@ 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++) diff --git a/src/voiceelt.cc b/src/voiceelt.cc index 72ba0a77d5..670dcdfaaa 100644 --- a/src/voiceelt.cc +++ b/src/voiceelt.cc @@ -53,6 +53,20 @@ Voice_element::Voice_element(Voice_element const&src) add(i->clone()); } +bool +Voice_element::find_plet_start_bo(char c, Moment& moment_r) +{ + assert( c == ']' ); + moment_r += duration; + for ( PCursor 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) { @@ -63,3 +77,21 @@ 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 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"; + } +} diff --git a/src/voicegroup.cc b/src/voicegroup.cc index 4f622c9384..0674ee08c8 100644 --- a/src/voicegroup.cc +++ b/src/voicegroup.cc @@ -6,6 +6,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "plist.hh" #include "musicalrequest.hh" #include "voicegroup.hh" #include "register.hh" diff --git a/src/voiceregs.cc b/src/voiceregs.cc index 4eba8c55f7..d6c24cd674 100644 --- a/src/voiceregs.cc +++ b/src/voiceregs.cc @@ -66,3 +66,4 @@ Voice_registers::set_dir(int i) head_reg_->set_dir(i); slur_reg_->set_dir(i); } + diff --git a/src/warn.cc b/src/warn.cc index 46d779e10f..63490de581 100644 --- a/src/warn.cc +++ b/src/warn.cc @@ -72,5 +72,10 @@ void 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 ); } -- 2.39.5