From 3ea702c329ba2121da532904a86e63f58c47a6ef Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 20 Sep 2002 22:48:50 +0000 Subject: [PATCH] lots of changes (see diff :-) --- ChangeLog | 4 ++ lily/include/lily-guile.hh | 3 - lily/include/ly-modules.hh | 21 ++++++ lily/input-file-results.cc | 1 + lily/key-performer.cc | 4 ++ lily/lily-guile.cc | 58 --------------- lily/ly-module.cc | 115 ++++++++++++++++++++++++++++++ lily/midi-item.cc | 4 ++ lily/music-output-def.cc | 9 +-- lily/my-lily-lexer.cc | 19 ++--- lily/note-head.cc | 11 +-- lily/paper-def.cc | 4 +- lily/paper-outputter.cc | 5 ++ lily/parser.yy | 1 + lily/score.cc | 4 +- lily/staff-performer.cc | 6 +- ly/init.ly | 4 +- ly/paper-init.ly | 2 +- scm/c++.scm | 20 +++--- scm/clef.scm | 2 +- scm/font.scm | 2 +- scm/grob-description.scm | 1 + scm/grob-property-description.scm | 2 + scm/lily.scm | 19 ++--- scm/midi.scm | 33 +++++---- scm/music-functions.scm | 21 +++--- scm/output-lib.scm | 10 +-- scm/pdf.scm | 2 +- scm/pdftex.scm | 3 + scm/ps.scm | 9 ++- scm/sketch.scm | 2 +- scm/tex.scm | 6 +- 32 files changed, 258 insertions(+), 149 deletions(-) create mode 100644 lily/include/ly-modules.hh create mode 100644 lily/ly-module.cc diff --git a/ChangeLog b/ChangeLog index 0c59df7488..f84ff1a77a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-09-20 Han-Wen Nienhuys + + * lily/ly-module.cc: new file. + 2002-09-17 Rune Zedeler * lily/accidental-engraver.cc: Also work with partial measures. diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index f311dd250a..c0aed3729c 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -227,9 +227,6 @@ SCM ly_split_list (SCM s, SCM list); SCM ly_unique (SCM list); -SCM ly_make_anonymous_module (); -void ly_copy_module_variable (SCM dest, SCM src); -SCM ly_module_to_alist (SCM mod); /* snarfing. diff --git a/lily/include/ly-modules.hh b/lily/include/ly-modules.hh new file mode 100644 index 0000000000..a96d0a13b0 --- /dev/null +++ b/lily/include/ly-modules.hh @@ -0,0 +1,21 @@ +/* + ly-modules.hh -- declare module related helper functions + + source file of the GNU LilyPond music typesetter + + (c) 2002 Han-Wen Nienhuys + + */ + +#ifndef LY_MODULES_HH +#define LY_MODULES_HH + +SCM ly_make_anonymous_module (); +void ly_copy_module_variables (SCM dest, SCM src); +SCM ly_module_to_alist (SCM mod); +SCM ly_module_lookup (SCM module, SCM sym); +SCM ly_module_symbols (SCM mod); +void ly_reexport_module (SCM mod); + +#endif /* LY_MODULES_HH */ + diff --git a/lily/input-file-results.cc b/lily/input-file-results.cc index 718bdcd308..7bf1e3324f 100644 --- a/lily/input-file-results.cc +++ b/lily/input-file-results.cc @@ -30,6 +30,7 @@ #include "source.hh" #include "lily-version.hh" #include "scm-hash.hh" +#include "ly-modules.hh" LY_DEFINE(ly_set_point_and_click_x, "set-point-and-click!", 1, 0, 0, diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 7401a637de..bb4094a1e6 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -44,6 +44,10 @@ Key_performer::create_audio_elements () { if (key_req_) { + + /* + UGH. primitive-eval. + */ SCM pitchlist = key_req_->get_mus_property ("pitch-alist"); SCM proc = scm_primitive_eval (ly_symbol2scm ("accidentals-in-key")); SCM acc = gh_call1 (proc, pitchlist); diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index d7b7bbebac..5f483c4fc7 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -193,16 +193,6 @@ void add_scm_init_func (void (*f) ()) scm_init_funcs_->push (f); } -#if 0 -SCM -ly_use_module (SCM module) -{ - scm_call_1 (SCM_VARIABLE_REF (process_use_modules_var), - scm_list_1 (scm_list_1 (convert_module_name (name)))); - return SCM_UNSPECIFIED; -} -#endif - void ly_init_ly_module (void *data) { @@ -714,51 +704,3 @@ robust_list_ref(int i, SCM l) return gh_car(l); } -static int module_count; - -void -ly_init_anonymous_module (void * data) -{ - scm_c_use_module ("lily"); -} - -SCM -ly_make_anonymous_module () -{ - String s = "*anonymous-ly-" + to_string (module_count++) + "*"; - SCM mod = scm_c_define_module (s.to_str0(), ly_init_anonymous_module, 0); - scm_module_define (mod, ly_symbol2scm ("symbols-defined-here"), SCM_EOL); - return mod; -} - -void -ly_copy_module_variable (SCM dest, SCM src) -{ - SCM defd = ly_symbol2scm ("symbols-defined-here"); - SCM dvar = scm_module_lookup (src, ly_symbol2scm ("symbols-defined-here")); - SCM lst = scm_variable_ref (dvar); - for (SCM s =lst; gh_pair_p (s); s = gh_cdr (s)) - { - SCM var = scm_module_lookup (src, gh_car (s)); - scm_module_define (dest, gh_car (s), - scm_variable_ref (var)); - } - - scm_module_define (dest, defd, lst); -} - -SCM -ly_module_to_alist (SCM mod) -{ - SCM defd = ly_symbol2scm ("symbols-defined-here"); - SCM dvar = scm_module_lookup (mod, defd); - SCM lst = scm_variable_ref (dvar); - - SCM alist = SCM_EOL; - for (SCM s =lst; gh_pair_p (s); s = gh_cdr (s)) - { - SCM var = scm_module_lookup (mod, gh_car (s)); - alist= scm_cons (scm_cons (gh_car(s), scm_variable_ref (var)), alist); - } - return alist; -} diff --git a/lily/ly-module.cc b/lily/ly-module.cc new file mode 100644 index 0000000000..632ea229f4 --- /dev/null +++ b/lily/ly-module.cc @@ -0,0 +1,115 @@ +/* +ly-module.cc -- implement guile module stuff. + +source file of the GNU LilyPond music typesetter + +(c) 2002 Han-Wen Nienhuys + + */ + +#include "string.hh" +#include "lily-guile.hh" +#include "ly-modules.hh" + +static int module_count; + +void +ly_init_anonymous_module (void * data) +{ + scm_c_use_module ("lily"); +} + +SCM +ly_make_anonymous_module () +{ + String s = "*anonymous-ly-" + to_string (module_count++) + "*"; + SCM mod = scm_c_define_module (s.to_str0(), ly_init_anonymous_module, 0); + return mod; +} + +void +ly_copy_module_variables (SCM dest, SCM src) +{ + SCM obarr= SCM_MODULE_OBARRAY(src); + SCM syms = SCM_EOL; + + for (int i = 0; i < SCM_VECTOR_LENGTH (obarr); i++) + { + for( SCM s = scm_vector_ref(obarr, SCM_MAKINUM (i)); + gh_pair_p (s); s = gh_cdr (s)) + { + scm_module_define (dest, gh_caar (s), scm_variable_ref (gh_cdar(s))); + } + } +} + +SCM +ly_module_symbols (SCM mod) +{ + SCM obarr= SCM_MODULE_OBARRAY(mod); + SCM syms = SCM_EOL; + + for (int i = 0; i < SCM_VECTOR_LENGTH (obarr); i++) + { + for( SCM s = scm_vector_ref(obarr, SCM_MAKINUM (i)); + gh_pair_p (s); s = gh_cdr (s)) + { + syms = scm_cons (gh_caar (s), syms); + } + } + return syms; +} + + + +SCM +ly_module_to_alist (SCM mod) +{ + SCM obarr= SCM_MODULE_OBARRAY(mod); + SCM alist = SCM_EOL; + + for (int i = 0; i < SCM_VECTOR_LENGTH (obarr); i++) + { + for( SCM s = scm_vector_ref(obarr, SCM_MAKINUM (i)); + gh_pair_p (s); s = gh_cdr (s)) + { + alist = scm_acons (gh_caar (s), scm_variable_ref (gh_cdar (s)), + alist); + } + } + return alist; +} + +/* + Lookup SYM, but don't give error when it is not defined. + */ +SCM +ly_module_lookup (SCM module, SCM sym) +{ + SCM var; +#define FUNC_NAME __FUNCTION__ + SCM_VALIDATE_MODULE (1, module); + + var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); + return var; +} + +SCM export_function ; + +void +ly_export (SCM module, SCM namelist) +{ + if (!export_function) + { + export_function = scm_permanent_object (scm_c_lookup ("module-export!")); + } + + scm_call_2 (SCM_VARIABLE_REF (export_function), + module, namelist); +} + +void +ly_reexport_module (SCM mod) +{ + ly_export (mod, ly_module_symbols (mod)); +} diff --git a/lily/midi-item.cc b/lily/midi-item.cc index f13edbbd0a..2a0b6a274f 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -135,6 +135,10 @@ Midi_instrument::string () const { Byte program_byte = 0; bool found = false; + + /* + UGH. don't use eval. + */ SCM proc = scm_primitive_eval (ly_symbol2scm ("midi-program")); SCM program = gh_call1 (proc, ly_symbol2scm (audio_->str_.to_str0 ())); found = (program != SCM_BOOL_F); diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 401bcb0810..089cdb5cf4 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -16,6 +16,7 @@ #include "main.hh" #include "file-path.hh" #include "lily-guile.hh" +#include "ly-modules.hh" #include "ly-smobs.icc" @@ -58,8 +59,7 @@ Music_output_def::Music_output_def (Music_output_def const &s) scaled_fonts_ = scm_list_copy (s.scaled_fonts_); scope_= ly_make_anonymous_module (); - ly_copy_module_variable (scope_, s.scope_); - + ly_copy_module_variables (scope_, s.scope_); } @@ -167,15 +167,12 @@ void Music_output_def::set_variable (SCM sym, SCM val) { scm_module_define (scope_, sym, val); - - SCM var = scm_module_lookup (scope_, ly_symbol2scm ("symbols-defined-here")); - scm_variable_set_x (var, gh_cons (sym, scm_variable_ref (var))); } SCM Music_output_def::lookup_variable (SCM sym) const { - SCM var = scm_module_lookup (scope_, sym); + SCM var = ly_module_lookup (scope_, sym); return scm_variable_ref (var); } diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 5dcab4430b..ce77d49cc6 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -23,6 +23,8 @@ #include "main.hh" #include "input.hh" #include "moment.hh" +#include "ly-modules.hh" + static Keyword_ent the_key_tab[]={ {"alias", ALIAS}, @@ -108,9 +110,13 @@ My_lily_lexer::My_lily_lexer () void My_lily_lexer::add_scope (SCM module) { + ly_reexport_module (scm_current_module()); scm_set_current_module (module); for (SCM s = scopes_; gh_pair_p (s); s = gh_cdr (s)) { + /* + UGH. how to do this more neatly? + */ SCM expr = scm_list_n (ly_symbol2scm ("module-use!"), module, scm_list_n (ly_symbol2scm ("module-public-interface"), gh_car (s), SCM_UNDEFINED), @@ -120,7 +126,6 @@ My_lily_lexer::add_scope (SCM module) } scopes_ = scm_cons (module, scopes_); - scm_display (scm_current_module(), scm_current_output_port()); } SCM @@ -145,10 +150,11 @@ My_lily_lexer::lookup_identifier (String s) { SCM sym = ly_symbol2scm (s.to_str0()); for (SCM s = scopes_; gh_pair_p (s); s = gh_cdr (s)) - { - SCM var = scm_module_lookup (gh_car (s), sym); - return scm_variable_ref (var); - } + { + SCM var = ly_module_lookup (gh_car (s), sym); + if (var != SCM_BOOL_F) + return scm_variable_ref(var); + } return SCM_UNSPECIFIED; } @@ -175,11 +181,8 @@ My_lily_lexer::set_identifier (SCM name, SCM s) SCM sym = scm_string_to_symbol (name); SCM mod = gh_car (scopes_); - SCM var = scm_module_lookup (mod, ly_symbol2scm ("symbols-defined-here")); - scm_variable_set_x (var, gh_cons (sym, scm_variable_ref (var))); scm_module_define (mod, sym, s); - scm_c_export (ly_symbol2string(sym).to_str0(), NULL); } My_lily_lexer::~My_lily_lexer () diff --git a/lily/note-head.cc b/lily/note-head.cc index 16c58ebaea..f8abf0e057 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -111,16 +111,9 @@ internal_brew_molecule (Grob *me, bool ledger_take_space) return Molecule(); } - /* - ugh: use gh_call () / scm_apply (). - - UGH: use grob-property. - */ SCM log = gh_int2scm (Note_head::get_balltype (me)); - SCM exp = scm_list_n (ly_symbol2scm ("find-notehead-symbol"), log, - ly_quote_scm (style), - SCM_UNDEFINED); - SCM scm_font_char = scm_primitive_eval (exp); + SCM proc = me->get_grob_property ("glyph-name-procedure"); + SCM scm_font_char = scm_call_2 (proc, log, style); String font_char = "noteheads-" + ly_scm2string (scm_font_char); Font_metric * fm = Font_interface::get_default_font (me); diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 8cc0f7ada5..82a4ade8a7 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -20,6 +20,8 @@ #include "scm-hash.hh" #include "input-file-results.hh" // urg? header_global #include "paper-outputter.hh" +#include "ly-modules.hh" + /* This is an almost empty thing. The only substantial thing this class @@ -128,7 +130,7 @@ Paper_def::find_font (SCM fn, Real m) } else { - SCM var = scm_module_lookup (scope_, ly_symbol2scm ("outputscale")); + SCM var = ly_module_lookup (scope_, ly_symbol2scm ("outputscale")); m /= gh_scm2double (scm_variable_ref (var)); f = all_fonts_global->find_font (ly_scm2string (fn)); diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 796f94079c..e914793377 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -23,6 +23,8 @@ #include "lily-version.hh" #include "paper-def.hh" #include "input-file-results.hh" +#include "ly-modules.hh" + /* @@ -94,6 +96,9 @@ Paper_outputter::output_scheme (SCM scm) void Paper_outputter::output_scope (SCM mod, String prefix) { + if (!SCM_MODULEP (mod)) + return ; + SCM al = ly_module_to_alist (mod); for (SCM s = al ; gh_pair_p (s); s = ly_cdr (s)) { diff --git a/lily/parser.yy b/lily/parser.yy index 2754f6dd79..9e8574733d 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -60,6 +60,7 @@ this. #include "auto-change-iterator.hh" #include "un-relativable-music.hh" #include "chord.hh" +#include "ly-modules.hh" bool regular_identifier_b (SCM id) diff --git a/lily/score.cc b/lily/score.cc index 650d7da8ea..b1bf3dc749 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -21,6 +21,8 @@ #include "cpu-timer.hh" #include "main.hh" #include "paper-def.hh" +#include "ly-modules.hh" + /* @@ -58,7 +60,7 @@ Score::Score (Score const &s) defs_.push (s.defs_[i]->clone ()); errorlevel_ = s.errorlevel_; header_ = ly_make_anonymous_module (); - ly_copy_module_variable (header_, s.header_); + ly_copy_module_variables (header_, s.header_); } Score::~Score () diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 56d31210b1..0d64b09cec 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -88,7 +88,11 @@ Staff_performer::create_audio_elements () void Staff_performer::stop_translation_timestep () { - SCM proc = scm_primitive_eval (ly_symbol2scm ("percussion-p")); + /* + UGH. -> don't use eval. + */ + + SCM proc = scm_primitive_eval (ly_symbol2scm ("percussion?")); SCM drums = gh_call1 (proc, ly_symbol2scm (instrument_string_.to_str0 ())); audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1 ); if (name_) diff --git a/ly/init.ly b/ly/init.ly index 67a55d1bc9..1d6a26434b 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -1,5 +1,7 @@ % Toplevel initialisation file. -#(use-modules (lily)) + +#(define-public point-and-click #f) +#(define-public midi-debug #f) \version "1.5.68" diff --git a/ly/paper-init.ly b/ly/paper-init.ly index 04a4eb881d..26ec0b7233 100644 --- a/ly/paper-init.ly +++ b/ly/paper-init.ly @@ -10,6 +10,6 @@ linewidth = \hsize - 2.\cm % Leave the textheight calculation to the geometry package. /MB %textheight = \vsize - 4.\cm - +raggedright = ##f indent = \linewidth / 14.0 diff --git a/scm/c++.scm b/scm/c++.scm index 41bd34139e..9cd9d8cd91 100644 --- a/scm/c++.scm +++ b/scm/c++.scm @@ -7,30 +7,30 @@ ;;; Note: this file can't be used without LilyPond executable -(define (number-pair? x) +(define-public (number-pair? x) (and (pair? x) (number? (car x)) (number? (cdr x)))) -(define (number-or-grob? x) +(define-public (number-or-grob? x) (or (ly-grob? x) (number? x)) ) -(define (grob-list? x) +(define-public (grob-list? x) (list? x)) -(define (moment-pair? x) +(define-public (moment-pair? x) (and (pair? x) (moment? (car x)) (moment? (cdr x)))) -(define (boolean-or-symbol? x) +(define-public (boolean-or-symbol? x) (or (boolean? x) (symbol? x))) -(define (number-or-string? x) +(define-public (number-or-string? x) (or (number? x) (string? x))) -(define (markup? x) +(define-public (markup? x) (or (string? x) (list? x))) -(define (scheme? x) #t) +(define-public (scheme? x) #t) (define type-p-name-alist `( @@ -120,7 +120,7 @@ is the first to satisfy CRIT " ; Make a function that checks score element for being of a specific type. -(define (make-type-checker symbol) +(define-public (make-type-checker symbol) (lambda (elt) ;;(display symbol) ;;(eq? #t (ly-get-grob-property elt symbol)) @@ -132,7 +132,7 @@ is the first to satisfy CRIT " (cdr cell) (car cell))) -(define (repeat-name-to-ctor name) +(define-public (repeat-name-to-ctor name) (let* ((supported-reps `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor) diff --git a/scm/clef.scm b/scm/clef.scm index 50d853c0df..45e6edcd50 100644 --- a/scm/clef.scm +++ b/scm/clef.scm @@ -88,7 +88,7 @@ ) ) -(define (clef-name-to-properties cl) +(define-public (clef-name-to-properties cl) (let ((e '()) (c0 0) (oct 0) diff --git a/scm/font.scm b/scm/font.scm index 116382de82..b45ccc8266 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -224,7 +224,7 @@ paper20-style-sheet-alist)) font-list-alist))) -(define (make-style-sheet sym) +(define-public (make-style-sheet sym) `((fonts . ,(append paper-style-sheet-alist (cdr (assoc sym font-list-alist)))) (font-defaults diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 169118c832..ea627e1d35 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -555,6 +555,7 @@ . ( (style . default) (molecule-callback . ,Note_head::brew_molecule) + (glyph-name-procedure . ,find-notehead-symbol) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (stem-attachment-function . ,note-head-style->attachment-coordinates) (meta . ((interfaces . (rhythmic-head-interface font-interface note-head-interface staff-symbol-referencer-interface item-interface )))) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 28bdce85bf..7c7f299833 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -221,6 +221,8 @@ beaming style: stems stop at innermost beams.") (grob-property-description 'glyph string? "a string determining what (style) of glyph is typeset. Valid choices depend on the function that is reading this property. .") (grob-property-description 'glyph-name string? "a name of character within font.") +(grob-property-description 'glyph-name-procedure procedure? "Return +name of character within font.") (grob-property-description 'gap number? "Size of a gap in a variable symbol.") diff --git a/scm/lily.scm b/scm/lily.scm index e96acb9dcc..c5e67c2e20 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -12,7 +12,7 @@ (use-modules (ice-9 regex)) ; (use-modules (lily)) -(display "hallo\n") +;;(display "hallo\n") ;;(display (make-duration 1 2)) ;;(write standalone (current-error-port)) @@ -20,15 +20,12 @@ ;;; General settings ;; debugging evaluator is slower. -;(debug-enable 'debug) +(debug-enable 'debug) ;(debug-enable 'backtrace) -;(read-enable 'positions) +(read-enable 'positions) - -(define point-and-click #f) -(define security-paranoia #f) -(define midi-debug #f) +(define-public security-paranoia #f) (define (line-column-location line col file) "Print an input location, including column number ." @@ -46,19 +43,15 @@ (define ifndef "First run this through cpp.") (define-public default-script-alist '()) -(define font-name-alist '()) (if (not (defined? 'standalone)) (define standalone (not (defined? 'ly-gulp-file)))) ;; The regex module may not be available, or may be broken. -(define use-regex +(define-public use-regex (let ((os (string-downcase (vector-ref (uname) 0)))) (not (equal? "cygwin" (substring os 0 (min 6 (string-length os))))))) -;; If you have trouble with regex, define #f -(define use-regex #t) -;;(define use-regex #f) ;;; Un-assorted stuff @@ -155,7 +148,7 @@ output-alist) )) -(define (find-dumper format ) +(define-public (find-dumper format ) (let* ((d (assoc format output-alist))) diff --git a/scm/midi.scm b/scm/midi.scm index e4b57135ef..0f85275124 100644 --- a/scm/midi.scm +++ b/scm/midi.scm @@ -26,7 +26,7 @@ ) absolute-volume-alist)) -(define (default-dynamic-absolute-volume s) +(define-public (default-dynamic-absolute-volume s) (let ((entry (assoc s absolute-volume-alist))) (if entry (cdr entry)))) @@ -246,22 +246,26 @@ ) -(define (default-instrument-equalizer s) +(define-public (default-instrument-equalizer s) (let ((entry (assoc s instrument-equalizer-alist))) (if entry (cdr entry)))) -;; returns whether the instrument should use midi channel 9 -(define (percussion-p instrument) + +(define-public (percussion? instrument) + " +returns whether the instrument should use midi channel 9 +" (let* ((inst (symbol->string instrument)) (entry (assoc inst instrument-names-alist)) ) (and entry (>= (cdr entry) 32768)) ) ) - -;; returns the program of the instrument -(define (midi-program instrument) +(define-public (midi-program instrument) +" +returns the program of the instrument +" (let* ((inst (symbol->string instrument)) (entry (assoc inst instrument-names-alist)) ) @@ -271,16 +275,17 @@ ;; 90 == 90/127 == 0.71 is supposed to be the default value ;; urg: we should set this at start of track -(define dynamic-default-volume 0.71) +(define-public dynamic-default-volume 0.71) -;; Count number of sharps minus number of flats -(define (accidentals-in-key pitch-list) +(define-public (accidentals-in-key pitch-list) + "Count number of sharps minus number of flats" (apply + (map cdr pitch-list))) -;; Characterise the key as major if the alteration of the -;; third scale note is the same as that of the main note. -;; Note: MIDI cannot handle other tonalities than major/minor. -(define (major-key pitch-list) +(define-public (major-key pitch-list) + "Characterise the key as major if the alteration of the +third scale note is the same as that of the main note. +Note: MIDI cannot handle other tonalities than major/minor. +" ;; This charactersition is only true for a scale that starts at `c'. (if (not (equal? (car pitch-list) '(0 . 0))) (begin diff --git a/scm/music-functions.scm b/scm/music-functions.scm index f9d0d9da1f..9849a22e21 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -123,7 +123,7 @@ Fingering_engraver." ;;;;;;;;;;;;;;;; -(define (make-grob-property-set grob gprop val) +(define-public (make-grob-property-set grob gprop val) "Make a M-exp that sets GPROP to VAL in GROBS. Does a pop first, i.e. this is not an override " @@ -138,8 +138,9 @@ this is not an override m )) - -(define (make-grob-property-revert grob gprop) + + +(define-public (make-grob-property-revert grob gprop) "Revert the grob property GPROP for GROB." (let* ((m (ly-make-music "Music"))) (ly-set-mus-property! m 'iterator-ctor Pop_property_iterator::constructor) @@ -150,7 +151,7 @@ this is not an override )) -(define (make-voice-props-set n) +(define-public (make-voice-props-set n) (make-sequential-music (append (map (lambda (x) (make-grob-property-set x 'direction @@ -160,7 +161,7 @@ this is not an override ) )) -(define (make-voice-props-revert) +(define-public (make-voice-props-revert) (make-sequential-music (list (make-grob-property-revert 'Tie 'direction) @@ -171,7 +172,7 @@ this is not an override )) ) -(define (context-spec-music m context . rest) +(define-public (context-spec-music m context . rest) "Add \context CONTEXT = foo to M. " (let* ((cm (ly-make-music "Context_specced_music"))) @@ -183,19 +184,19 @@ this is not an override cm )) -(define (make-sequential-music elts) +(define-public (make-sequential-music elts) (let* ((m (ly-make-music "Sequential_music"))) (ly-set-mus-property! m 'elements elts) m )) -(define (make-simultaneous-music elts) +(define-public (make-simultaneous-music elts) (let* ((m (ly-make-music "Simultaneous_music"))) (ly-set-mus-property! m 'elements elts) m )) -(define (music-separator? m) +(define-public (music-separator? m) "Is M a separator." (let* ((n (ly-get-mus-property m 'name ))) (and (symbol? n) (equal? 'separator n)) @@ -335,7 +336,7 @@ this is not an override m ) -(define toplevel-music-functions +(define-public toplevel-music-functions (list check-start-chords voicify-music diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 8db3a6f1f6..71eb4129a2 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -117,7 +117,7 @@ ;; do nothing in .scm output (define (comment s) "") -(define (numbers->string l) +(define-public (numbers->string l) (apply string-append (map ly-number->string l))) ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x)) @@ -131,12 +131,12 @@ (number->string n8) (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8))))) -(define (inexact->string x radix) +(define-public (inexact->string x radix) (let ((n (inexact->exact x))) (number->string n radix))) -(define (control->string c) +(define-public (number-pair->string c) (string-append (number->string (car c)) " " (number->string (cdr c)) " ")) @@ -150,7 +150,7 @@ ;; silly, use alist? -(define (find-notehead-symbol duration style) +(define-public (find-notehead-symbol duration style) (case style ((xcircle) "2xcircle") ((harmonic) "0neo_mensural") @@ -213,7 +213,7 @@ centered, X==1 is at the right, X == -1 is at the left." '(1.0 . 0.0) ))) -(define (string-encode-integer i) +(define-public (string-encode-integer i) (cond ((= i 0) "o") ((< i 0) (string-append "n" (string-encode-integer (- i)))) diff --git a/scm/pdf.scm b/scm/pdf.scm index 62ee967d7a..6e91201bea 100644 --- a/scm/pdf.scm +++ b/scm/pdf.scm @@ -24,7 +24,7 @@ (define currentpoint (cons 0 0)) (define (showcp) - (string-append (control->string currentpoint) " ")) + (string-append (number-pair->string currentpoint) " ")) (define (moveto x y) (set! currentpoint (cons x y)) (string-append (showcp) "m ")) diff --git a/scm/pdftex.scm b/scm/pdftex.scm index a3bd441da5..944f071b6d 100644 --- a/scm/pdftex.scm +++ b/scm/pdftex.scm @@ -18,6 +18,9 @@ (ice-9 string-fun) ) + +(define font-name-alist '()) + (define this-module (current-module)) (define (unknown) "%\n\\unknown%\n") diff --git a/scm/ps.scm b/scm/ps.scm index ab2520e3b1..4be3fecf8b 100644 --- a/scm/ps.scm +++ b/scm/ps.scm @@ -10,6 +10,8 @@ (define-module (scm ps) ) +(define font-name-alist '()) + (define this-module (current-module)) (debug-enable 'backtrace) @@ -26,6 +28,7 @@ (use-modules (guile) + (lily) ) @@ -123,7 +126,7 @@ ;; what the heck is this interface ? (define (dashed-slur thick dash l) (string-append - (apply string-append (map control->string l)) + (apply string-append (map number-pair->string l)) (ly-number->string thick) " [ " (ly-number->string dash) @@ -235,14 +238,14 @@ ;; two beziers (define (bezier-sandwich l thick) (string-append - (apply string-append (map control->string l)) + (apply string-append (map number-pair->string l)) (ly-number->string thick) " draw_bezier_sandwich ")) ;; two beziers with round endings (define (bezier-bow l thick) (string-append - (apply string-append (map control->string l)) + (apply string-append (map number-pair->string l)) (ly-number->string thick) " draw_bezier_sandwich " (bezier-ending (list-ref l 3) (list-ref l 0) (list-ref l 5)) diff --git a/scm/sketch.scm b/scm/sketch.scm index e5b2cd7a54..70e84d592e 100644 --- a/scm/sketch.scm +++ b/scm/sketch.scm @@ -183,7 +183,7 @@ ;; what the heck is this interface ? (define (dashed-slur thick dash l) (string-append - (apply string-append (map control->string l)) + (apply string-append (map number-pair->string l)) (ly-number->string thick) " [ " (ly-number->string dash) diff --git a/scm/tex.scm b/scm/tex.scm index d6e6c9d543..30195baac7 100644 --- a/scm/tex.scm +++ b/scm/tex.scm @@ -13,13 +13,17 @@ (ice-9 string-fun) (ice-9 format) (guile) + (lily) ) (define this-module (current-module)) ;;;;;;;; ;;;;;;;; DOCUMENT ME! -;;;;;;;; +;;;;;;;; + +(define font-name-alist '()) + (define (tex-encoded-fontswitch name-mag) (let* ((iname-mag (car name-mag)) (ename-mag (cdr name-mag))) -- 2.39.5