]> git.donarmstrong.com Git - lilypond.git/commitdiff
reorganisation, cleanups.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 21 Sep 2002 12:48:01 +0000 (12:48 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 21 Sep 2002 12:48:01 +0000 (12:48 +0000)
28 files changed:
ChangeLog
lily/include/ly-modules.hh
lily/include/ly-smobs.icc
lily/input-file-results.cc
lily/ly-module.cc
lily/music-output-def.cc
lily/my-lily-lexer.cc
lily/note-head.cc
lily/score.cc
scm/auto-beam.scm
scm/basic-properties.scm
scm/bass-figure.scm
scm/beam.scm
scm/c++.scm
scm/chord-name.scm
scm/context-description.scm
scm/drums.scm
scm/font.scm
scm/grob-description.scm
scm/grob-property-description.scm
scm/lily.scm
scm/molecule.scm
scm/music-functions.scm
scm/music-property-description.scm
scm/output-lib.scm
scm/pdftex.scm
scm/tex.scm
scm/translator-property-description.scm

index 91929ecc0f45c5bdb95151005d354665a7a0e788..2a6dead7f0a6a67dac0144b49e724737c6eecf94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2002-09-21  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * scm/lily.scm: reorganisation, cleanups.
+
        * lily/main.cc: small cleanups.
 
 2002-09-20  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
index 30a501b5bc5f3f68021f96d4548ab8b8eb5b37b6..10384d24d572a00dc16ee6d1f27d452432216c2c 100644 (file)
@@ -19,6 +19,7 @@ SCM ly_module_lookup (SCM module, SCM sym);
 SCM ly_module_symbols (SCM mod);
 void  ly_reexport_module (SCM mod);
 inline bool ly_module_p (SCM x) { return SCM_MODULEP(x); }
+void ly_clear_anonymous_modules ();
 
 #endif /* LY_MODULES_HH */
 
index 9dbf3698c686446f7b7f49229a51260d2233ebe9..19d054df3249fb28366fb8f406c6e80e843a28e3 100644 (file)
@@ -18,6 +18,7 @@ void init_type_ ## CL ()\
 {\
   scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
   ly_add_function_documentation (FUNCNAME, "(SCM x)", "Check if @var{x} is a " #CL " object");\
+  scm_c_export (FUNCNAME, NULL);\
 }\
 ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL)
 
index 7bf1e3324f27d10afafa1f9300c7aa38d9312173..1f9362bf480440359df470c5d588dba004146c6f 100644 (file)
@@ -146,9 +146,12 @@ Input_file_results::~Input_file_results ()
     header_ = SCM_EOL;
 
   global_input_file =0;
+
+  ly_clear_anonymous_modules();
 }
 
 
+
 Input_file_results* global_input_file;
 
 Input_file_results::Input_file_results (String init_string, String file_string)
index e6610e28be26319952be01497dec72a12440f26a..8286533f50d1f3dab1161d80302b97f82c2d8d15 100644 (file)
@@ -10,6 +10,8 @@ source file of the GNU LilyPond music typesetter
 #include "string.hh"
 #include "lily-guile.hh"
 #include "ly-modules.hh"
+#include "protected-scm.hh"
+
 #define FUNC_NAME __FUNCTION__
 
 static int module_count;
@@ -20,18 +22,35 @@ ly_init_anonymous_module (void * data)
   scm_c_use_module ("lily");  
 }
 
+Protected_scm anon_modules;
+
 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);
+
+  anon_modules = scm_cons (mod, anon_modules);
   return mod;
 }
 
+void
+ly_clear_anonymous_modules ()
+{
+  SCM s = anon_modules;
+  anon_modules = SCM_EOL;
+
+  for (; gh_pair_p (s) ; s = gh_cdr (s))
+    {
+      scm_vector_fill_x (SCM_MODULE_OBARRAY(gh_car(s)), SCM_EOL);
+    }
+}
+
+#define FUNC_NAME __FUNCTION__
+
 void
 ly_copy_module_variables (SCM dest, SCM src)
 {
- #define FUNC_NAME __FUNCTION__
   SCM_VALIDATE_MODULE (1, src);
 
   SCM obarr= SCM_MODULE_OBARRAY(src);
index 089cdb5cf4df4d220fada9bae719b39207f90d59..ee064079abc4871182a7f854dc01316d08ea5168 100644 (file)
@@ -59,12 +59,12 @@ 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_variables (scope_, s.scope_);
+  if (ly_module_p (s.scope_))
+    ly_copy_module_variables (scope_, s.scope_);
 }
 
 
 IMPLEMENT_SMOBS (Music_output_def);
-
 IMPLEMENT_DEFAULT_EQUAL_P (Music_output_def);
 
 SCM
index ce77d49cc65575066d4022bcc4e772cff06e324f..925cc607d8ff917f765c86e3e2e38ece97e6b9e7 100644 (file)
@@ -103,6 +103,7 @@ My_lily_lexer::My_lily_lexer ()
   scopes_ = SCM_EOL;
   
   add_scope(ly_make_anonymous_module());
+  errorlevel_ =0; 
 
   main_input_b_ = false;
 }
index f8abf0e057a4b05dc4ab2e7559cd02034f98cac3..a95827d98d837b0e8d1f0aa470b7dc216726c001 100644 (file)
@@ -252,5 +252,5 @@ Note_head::get_balltype (Grob*me)
 
 ADD_INTERFACE (Note_head,"note-head-interface",
   "Note head",
-  "accidental-grob style stem-attachment-function");
+  "glyph-name-procedure accidental-grob style stem-attachment-function");
 
index b1bf3dc749280cc2250621676f39751b7463cbd9..83ef6ed05ad10235c2ffee69a74855ce8b44f83f 100644 (file)
@@ -59,8 +59,10 @@ Score::Score (Score const &s)
   for (int i=0; i < s.defs_.size (); i++)
     defs_.push (s.defs_[i]->clone ());
   errorlevel_ = s.errorlevel_;
+
   header_ = ly_make_anonymous_module ();
-  ly_copy_module_variables (header_, s.header_);
+  if (ly_module_p (s.header_))
+    ly_copy_module_variables (header_, s.header_);
 }
 
 Score::~Score ()
index 0b526a0273210d615ef7a281aa910fa65d2e37b5..13fa296a41bf353def983f35942384e9bc78fd35 100644 (file)
      ((end 1 16 12 8) . ,(make-moment 3 8))
      ((end 1 32 12 8) . ,(make-moment 1 8))
      ))
-
-;;; Users may override in most cases, simply by issuing
-;;;
-;;;    % from here on consider ending beam every 1 4 note
-;;;    \property Voice.autoBeamSettings \override #'(end * * * *) = #(make-moment 1 4)
-;;;
-;;;    % no autobeaming
-;;;    \property Voice.beamAuto = ##f  
-;;;
-;;; or, more globally, by doing:
-;;;
-;;; \paper{
-;;;        \translator{
-;;;            \VoiceContext
-;;;            % consider ending beam at every 1 2 note
-;;;            autoBeamSettings \override #'(end * * * *) = #(make-moment 1 2)
-;;;        }
-;;;    }
-;;;
-;;; see also input test auto-beam-override.ly
-
index f70fb195c2afbc2a91becb4b7a1a5273293966da..85eb346bf4be9c924f667cef05787db82eed4ef4 100644 (file)
@@ -1,49 +1,2 @@
 ; Definition of backend properties (aka. element properties).
 
-;; See documentation of Item::visibility_lambda_
-(define-public (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
-(define-public (end-of-line-visible d) (if (= d -1) '(#f . #f) '(#t . #t)))
-(define-public (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
-
-(define-public (all-visible d) '(#f . #f))
-(define-public (all-invisible d) '(#t . #t))
-(define-public (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
-(define-public (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Bar lines.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;
-; How should a  bar line behave at a break? 
-;
-;; Why prepend `default-' to every scm identifier?
-(define-public (default-break-barline glyph dir)
-   (let ((result (assoc glyph 
-                       '((":|:" . (":|" . "|:"))
-                         ("||:" . ("||" . "|:"))
-                         ("|" . ("|" . ()))
-                         ("||:" . ("||" . "|:"))
-                         ("|s" . (() . "|"))
-                         ("|:" . ("|" . "|:"))
-                         ("|." . ("|." . ()))
-
-                         ;; hmm... should we end with a barline here?
-                         (".|" . ("|" . ".|"))
-                         (":|" . (":|" . ()))
-                         ("||" . ("||" . ()))
-                         (".|." . (".|." . ()))
-                         ("" . ("" . ""))
-                         ("empty" . (() . ()))
-                         ("brace" . (() . "brace"))
-                         ("bracket" . (() . "bracket"))  
-                         )
-                       )))
-
-     (if (equal? result #f)
-        (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
-        (index-cell (cdr result) dir))
-     )
-   )
-     
index 3b84c6d7c90eb86a4cde5a578d015f5bbc8c4d03..13b454b6b936a872a42d759d3855db2c62dbf785 100644 (file)
@@ -29,9 +29,6 @@
        )
     mol))
 
-
-
-
 (define (brew-bass-figure grob)
   "Make a molecule for a Figured Bass grob"
   (let* (
@@ -45,8 +42,6 @@
                    )
         )
 
-
-
     (define (brew-complete-figure grob figs mol)
       "recursive function: take some stuff from FIGS, and add it to MOL." 
       (define (end-bracket? fig)
index 6698e1fd623339236d1902ae655ada2774c02e60..0b615e9fa8a738947a26f58cdabb25b95a87d581 100644 (file)
@@ -9,7 +9,7 @@
 ;;
 ;; width in staff space.
 ;;
-(define (default-beam-flag-width-function type)
+(define (beam-flag-width-function type)
   (cond
    ((eq? type 1) 1.98) 
    ((eq? type 1) 1.65) ;; FIXME: check what this should be and why
index 9cd9d8cd914f13058acbdfebd9d970cbcb808b58..f5b95b4ec24c16ea26964ae2dbbe0425d7c2d11d 100644 (file)
@@ -7,6 +7,9 @@
 
 ;;; Note: this file can't be used without LilyPond executable
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; type predicates.
 (define-public (number-pair?  x)
   (and (pair? x)
        (number? (car x)) (number? (cdr x))))
@@ -32,6 +35,8 @@
 
 (define-public (scheme? x) #t)
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
 (define type-p-name-alist
   `(
    (,dir? . "direction")
@@ -64,6 +69,7 @@
    ))
 
 
+
 (define (match-predicate obj alist)
   (if (null? alist)
       "Unknown type"
          )
       ))
 
-(define (object-type obj)
+(define-public (object-type obj)
   (match-predicate obj type-p-name-alist))
 
-(define (type-name  predicate)
+(define-public (type-name  predicate)
   (let ((entry (assoc predicate type-p-name-alist)))
     (if (pair? entry) (cdr entry)
        "unknown"
        )))
-
-(define (uniqued-alist  alist acc)
-  (if (null? alist) acc
-      (if (assoc (caar alist) acc)
-         (uniqued-alist (cdr alist) acc)
-         (uniqued-alist (cdr alist) (cons (car alist) acc)))))
-
-
-;; used in denneboom.ly
-(define (cons-map f x)
-  (cons (f (car x)) (f (cdr x))))
-
-;; used where?
-(define (reduce operator list)
-  "reduce OP [A, B, C, D, ... ] =
-   A op (B op (C ... ))
-"
-      (if (null? (cdr list)) (car list)
-         (operator (car list) (reduce operator (cdr list)))))
-
-
-
-(define (take-from-list-until todo gathered crit?)
-  "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
-is the  first to satisfy CRIT "
-  (if (null? todo)
-      (cons gathered todo)
-      (if (crit? (car todo))
-         (cons (cons (car todo) gathered) (cdr todo))
-         (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
-      )
-  ))
-; test:
-; (take-from-list-until '(1 2 3  4 5) '() (lambda (x) (eq? x 3)))
-; ((3 2 1) 4 5)
-
-
-
-; Make a function that checks score element for being of a specific type. 
-(define-public (make-type-checker symbol)
-  (lambda (elt)
-    ;;(display  symbol)
-    ;;(eq? #t (ly-get-grob-property elt symbol))
-    (not (eq? #f (memq symbol (ly-get-grob-property elt 'interfaces))))))
-
-
-(define (index-cell cell dir)
-  (if (equal? dir 1)
-      (cdr cell)
-      (car cell)))
-
-(define-public (repeat-name-to-ctor name)
-  (let*
-      ((supported-reps
-       `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor)
-                     (start-moment-function .  ,Repeated_music::first_start)
-                     (length . ,Repeated_music::volta_music_length)))
-         
-           ("unfold" . ((iterator-ctor . ,Unfolded_repeat_iterator::constructor)
-                        (start-moment-function .  ,Repeated_music::first_start)                         
-                        (length . ,Repeated_music::unfolded_music_length)))
-           ("fold" . ((iterator-ctor  . ,Folded_repeat_iterator::constructor)
-                      (start-moment-function .  ,Repeated_music::minimum_start)                         
-                      (length . ,Repeated_music::folded_music_length)))
-           ("percent" . ((iterator-ctor . ,Percent_repeat_iterator::constructor)
-                         (start-moment-function .  ,Repeated_music::first_start)
-                         (length . ,Repeated_music::unfolded_music_length)))
-           ("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
-                         (start-moment-function .  ,Repeated_music::first_start)
-
-                         ;; the length of the repeat is handled by shifting the note logs
-                         (length . ,Repeated_music::folded_music_length)))))
-         
-       (handle (assoc name supported-reps)))
-
-    (if (pair? handle)
-       (cdr handle)
-       (begin
-         (ly-warn
-          (string-append "Unknown repeat type `" name "'\nSee scm/c++.scm for supported repeats"))
-         '(type . 'repeated-music)))))
index c47b803a284e3e3b05636ae5a9e322f41068eb8c..337235adf95dc26e49a3ffee24d3987ecdd4f892 100644 (file)
@@ -22,6 +22,8 @@
 
 
 ;; TODO
+
+;; Ugh : naming chord::... ; this is scheme not C++
 ;;
 ;; * easier tweakability:
 ;;    - split chord::names-alists up into logical bits,
@@ -36,7 +38,7 @@
 ;;
 ;; * doc strings
 
-(define chord::names-alist-banter '())
+(define-public chord::names-alist-banter '())
 (set! chord::names-alist-banter
       (append 
        '(
   (+ (* (car pitch) 7) (cadr pitch)))
 
 (define (chord::text? text)
-  (not (or (not text) (empty? text) (unspecified? text))))
+  (not (or (not text) (null? text) (unspecified? text))))
 
 ;; FIXME: remove need for me, use text-append throughout
 (define (chord::text-cleanup dirty)
       l
       (if (not (chord::text? l))
          r
-         (if (empty? (cdr r))
+         (if (null? (cdr r))
              (list 'columns l (car r))
              (text-append (list 'columns l (car r)) (cdr r))))))
           
                                   (!= 0 a)))))
                      steps))
        (highest (let ((h (car (last-pair steps))))
-                  (if (and (not (empty? h))
+                  (if (and (not (null? h))
                            (or (> 4 (cadr h))
                                (!= 0 (caddr h))))
                       (list (list h))
       (list (pitch-octave p) (pitch-notename p) (pitch-alteration p))
       #f))
 
-(define (chord::name-banter tonic exception-part unmatched-steps
+(define-public (chord::name-banter tonic exception-part unmatched-steps
                            bass-and-inversion steps)
    (let ((additions (chord::additions unmatched-steps))
         (subtractions (chord::subtractions unmatched-steps)))
@@ -702,12 +704,12 @@ Compose text of all additions
   * list all steps that are below an chromatically altered step
   "
   (text-append
-   (if (not (empty? subtractions)) "add" '())
+   (if (not (null? subtractions)) "add" '())
    (let ((radds (reverse additions)))
      (reverse (chord::additions>5->text-jazz-helper
               radds
               subtractions
-              (if (or (empty? subtractions) (empty? radds))
+              (if (or (null? subtractions) (null? radds))
                   #f (car radds)))))))
 
 (define (chord::additions>5->text-jazz-helper additions subtractions list-step)
@@ -749,7 +751,7 @@ If we encounter a chromatically altered step, turn on list-step
 (define (chord::get-create-step steps n)
   (let* ((i (if (< n 0) (+ n 7) n))
         (found (filter-list (lambda (x) (= i (cadr x))) steps)))
-    (if (empty? found)
+    (if (null? found)
        (if (!= i 6)
            (list 0 i 0)
            (list 0 6 -1))
index f0ff06f2701376b51056510ff3fca1ab763c4fb9..649a600e04e93c4db19f6d402f797938d7530cc4 100644 (file)
@@ -1,7 +1,7 @@
 
 ;; todo: move this to engraver-init.ly 
 
-(define context-description-alist
+(define-public context-description-alist
   '(
     (Grace . "
    DEPRECATED; this is a 1.4 construct.
index b3151aa99415b01b2e82ce56d67376a169851356..9554dab8b7686f26831918107638491fbc06954e 100644 (file)
@@ -4,7 +4,8 @@
 ;;;; changed eval to primitive-eval for guile 1.4/1.4.1 compatibility --jcn
 
 
-(define drum-pitch-names `(
+;; ugh. Should make separate module?
+(define-public drum-pitch-names `(
        (acousticbassdrum bda   ,(make-pitch -3 6 0 ))
        (bassdrum         bd    ,(make-pitch -2 0 0 ))
        (hisidestick      ssh   ,(make-pitch -3 6 2))
@@ -81,7 +82,7 @@
        (fivedown         de    ,(make-pitch -1 2 0))
 ))
 
-(define drums `(
+(define-public drums `(
        (acousticbassdrum default       #f        ,(make-pitch -1 4 0))
        (bassdrum         default       #f        ,(make-pitch -1 4 0))
        (sidestick        cross         #f        ,(make-pitch 0 1 0))
        (ridecymbalb      cross         #f        ,(make-pitch 0 5 0))
  ))
 
-(define timbales `(
+(define-public timbales `(
        (losidestick      cross         #f        ,(make-pitch -1 6 0))
        (lotimbale        default       #f        ,(make-pitch -1 6 0))
        (cowbell          triangle      #f        ,(make-pitch 0 2 0))
        (hitimbale        default       #f        ,(make-pitch 0 1 0))
  ))
 
-(define congas `(
+(define-public congas `(
        (losidestick      cross         #f        ,(make-pitch -1 6 0))
        (loconga          default       #f        ,(make-pitch -1 6 0))
        (openloconga      default       "open"    ,(make-pitch -1 6 0))
   
  ))
 
-(define bongos `(
+(define-public bongos `(
        (losidestick      cross         #f        ,(make-pitch -1 6 0))
        (lobongo          default       #f        ,(make-pitch -1 6 0))
        (openlobongo      default       "open"    ,(make-pitch -1 6 0))
  ))
 
 
-(define percussion `(
+(define-public percussion `(
        (opentriangle     cross         "open"    ,(make-pitch 0 0 0))
        (mutetriangle     cross         "stopped" ,(make-pitch 0 0 0))
        (triangle         cross         #f        ,(make-pitch 0 0 0))
  ))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;
+;;
 
 (define (make-articulation-script x) 
      (let* (  (m (ly-make-music "Articulation_req"))
 (define (make-head-type-elem t)
    (let* ( (m (ly-make-music "Music"))
          )
-     (ly-set-mus-property! m 'iterator-ctor Push_property_iterator::constructor)
-     (ly-set-mus-property! m 'symbol 'NoteHead)
-     (ly-set-mus-property! m 'grob-property 'style)
-     (ly-set-mus-property! m 'grob-value t)
-     (ly-set-mus-property! m 'pop-first #t)
-     m
+     (set-mus-properties!
+      m
+      `((iterator-ctor . ,Push_property_iterator::constructor)
+       (symbol . NoteHead)
+       (grob-property . style)
+       (grob-value . ,t)
+       (pop-first  . #t)))
+      m
    )
  )
 
 (define (make-head-type t)
-   (let* ( (m (ly-make-music "Context_specced_music"))
-           (e (make-head-type-elem t))
-         )
-     (ly-set-mus-property! m 'element e)
-     (ly-set-mus-property! m 'context-type "Thread")
-     m
-   )
- )
+  (context-spec-music (make-head-type-elem t) "Thread"))
 
 (define (make-thread-context thread-name element)
-   (let* ( (m (ly-make-music "Context_specced_music")))
-     (ly-set-mus-property! m 'element element)
-     (ly-set-mus-property! m 'context-type "Thread")
-     (ly-set-mus-property! m 'context-id (symbol->string thread-name))
-     m
-   )
- )
+  (context-spec-music element "Thread" thread-name))
 
 ;; makes a sequential-music of thread-context, head-change and note
 (define (make-drum-head kit req-ch )
 
 
 ;; converts a midi-pitched (ly/drumpitch.ly) file to paper output.
-(define ((drums->paper kit) music)
+(define-public ((drums->paper kit) music)
   (begin
    (if (equal? (ly-music-name music) "Request_chord")
     (set! music (make-drum-head kit music))
index b45ccc8266fbb3d876779dc40bb37530b278612d..92722172ba4aa00c35863a9d70fd5a4377af7462 100644 (file)
@@ -61,6 +61,7 @@
 ;;
 ;; (font-relative-size font-series font-shape font-family 
 ;; font-design-size)
+
 (define paper20-style-sheet-alist
   '(
     ;; why are font file names strings, not symbols?
index ea627e1d3558fc12daf6f08ba38a47a230db3a5e..5f942e35fa857215db0884b9cff10870d95bd5a8 100644 (file)
        
        (outer-stem-length-limit . 0.2)
        (slope-limit . 0.2)
-       (flag-width-function . ,default-beam-flag-width-function)
+       (flag-width-function . ,beam-flag-width-function)
        (damping . 1)
        (auto-knee-gap . 5.5)
        (font-name . "cmr10")
index 7c7f299833345993ea3ea89e23d898d7109494c3..24d99eddb0383a8cd4751012aaa7b16aecdf3578 100644 (file)
@@ -7,7 +7,7 @@
 
 
 
-(define all-backend-properties '())
+(define-public all-backend-properties '())
 
 (define (grob-property-description symbol type? description)
   (if (not (equal? (object-property symbol 'backend-doc) #f))
index 8c53b13cceca776ed18841ae9afe9dc0ebafe3bb..f85bf2387156d39a28708f8394f9a09a26ae18bb 100644 (file)
@@ -7,15 +7,7 @@
 
 ;;; Library functions
 
-; (top-repl)
-
 (use-modules (ice-9 regex))
-; (use-modules (lily))
-
-;;(display "hallo\n")
-;;(display (make-duration 1  2))
-;;(write standalone (current-error-port))
-
 
 ;;; General settings
 ;; debugging evaluator is slower.
@@ -25,7 +17,6 @@
 (read-enable 'positions)
 
 
-(define-public security-paranoia #f)
 
 (define-public (line-column-location line col file)
   "Print an input location, including column number ."
 ;; cpp hack to get useful error message
 (define ifdef "First run this through cpp.")
 (define ifndef "First run this through cpp.")
-  
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define X 0)
+(define Y 1)
+(define LEFT -1)
+(define RIGHT 1)
+(define UP 1)
+(define DOWN -1)
+(define CENTER 0)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; lily specific variables.
 (define-public default-script-alist '())
 
+(define-public security-paranoia #f)
 (if (not (defined? 'standalone))
-    (define standalone (not (defined? 'ly-gulp-file))))
+    (define-public standalone (not (defined? 'ly-gulp-file))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Unassorted utility functions.
+
+(define (uniqued-alist  alist acc)
+  (if (null? alist) acc
+      (if (assoc (caar alist) acc)
+         (uniqued-alist (cdr alist) acc)
+         (uniqued-alist (cdr alist) (cons (car alist) acc)))))
+
+(define (other-axis a)
+  (remainder (+ a 1) 2))
+  
+
+(define-public (widen-interval iv amount)
+   (cons (- (car iv) amount)
+         (+ (cdr iv) amount))
+)
 
-;; The regex module may not be available, or may be broken.
-(define-public use-regex
-  (let ((os (string-downcase (vector-ref (uname) 0))))
-    (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
 
 
+(define (index-cell cell dir)
+  (if (equal? dir 1)
+      (cdr cell)
+      (car cell)))
 
-;;; Un-assorted stuff
+(define (cons-map f x)
+  "map F to contents of X"
+  (cons (f (car x)) (f (cdr x))))
 
-;; URG guile-1.4/1.4.x compatibility
-(if (not (defined? 'primitive-eval))
-    (define (primitive-eval form)
-      (eval2 form #f)))
+;; used where?
+(define (reduce operator list)
+  "reduce OP [A, B, C, D, ... ] =
+   A op (B op (C ... ))
+"
+      (if (null? (cdr list)) (car list)
+         (operator (car list) (reduce operator (cdr list)))))
+
+(define (take-from-list-until todo gathered crit?)
+  "return (G, T), where (reverse G) + T = GATHERED + TODO, and the last of G
+is the  first to satisfy CRIT
+
+ (take-from-list-until '(1 2 3  4 5) '() (lambda (x) (eq? x 3)))
+=>
+ ((3 2 1) 4 5)
+
+"
+  (if (null? todo)
+      (cons gathered todo)
+      (if (crit? (car todo))
+         (cons (cons (car todo) gathered) (cdr todo))
+         (take-from-list-until (cdr todo) (cons (car todo) gathered) crit?)
+      )
+  ))
 
 (define (sign x)
   (if (= x 0)
   (newline)
   x)
 
-(define (empty? x)
-  (equal? x '()))
-
 (define (!= l r)
   (not (= l r)))
 
          (uniqued-alist (cdr alist) acc)
          (uniqued-alist (cdr alist) (cons (car alist) acc)))))
 
-(define (uniq-list list)
+(define-public (uniq-list list)
   (if (null? list) '()
       (if (null? (cdr list))
          list
              (uniq-list (cdr list))
              (cons (car list) (uniq-list (cdr list)))))))
 
-(define (alist<? x y)
+(define-public (alist<? x y)
   (string<? (symbol->string (car x))
            (symbol->string (car y))))
 
+(define-public (pad-string-to str wid)
+  (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
+  )
+
 (define (ly-load x)
   (let* ((fn (%search-load-path x)))
     (if (ly-verbose)
     (primitive-load fn)))
 
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  output
 (use-modules (scm tex)
             (scm ps)
             (scm pysk)
     ("pdftex" . ("PDFTeX output. Was last seen nonfunctioning." ,pdftex-output-expression))
     ))
 
-(define (pad-string-to str wid)
-  (string-append str (make-string (max (- wid (string-length str)) 0) #\ ))
-  )
 
 (define (document-format-dumpers)
   (map
        (scm-error "Could not find dumper for format ~s" format))
     ))
 
-(define X 0)
-(define Y 1)
-(define LEFT -1)
-(define RIGHT 1)
-(define UP 1)
-(define DOWN -1)
-(define CENTER 0)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; other files.
 
 (if (not standalone)
     (map ly-load
index f0ee68c9023e06a1349d93544b1f0d81242c2232..da52f15c307c496dc8b89d6e69b700398d170ba0 100644 (file)
@@ -1,5 +1,5 @@
 
-(define (stack-molecules axis dir padding mols)
+(define-public (stack-molecules axis dir padding mols)
   "Stack molecules MOLS in direction AXIS,DIR, using PADDING."
   (if (null? mols)
       '()
 
 
 
-(define (fontify-text font-metric text)
+(define-public (fontify-text font-metric text)
   "Set TEXT with font FONT-METRIC, returning a molecule."
   (let* ((b  (ly-text-dimension font-metric text)))
     (ly-make-molecule
      (ly-fontify-atom font-metric `(text ,text)) (car b) (cdr b))
     ))
 
-(define (other-axis a)
-  (remainder (+ a 1) 2))
-  
-(define (bracketify-molecule mol axis thick protusion padding)
+(define-public (bracketify-molecule mol axis thick protusion padding)
   "Add brackets around MOL, producing a new molecule."
 
   (let* (
@@ -39,7 +36,7 @@
 
 
 
-(define (box-molecule xext yext)
+(define-public (box-molecule xext yext)
   "Make a filled box."
   
   (ly-make-molecule
       xext yext)                      
 )
 
-(define (widen-interval iv amount)
-   (cons (- (car iv) amount)
-         (+ (cdr iv) amount))
-)
-
-
-(define (box-grob-molecule grob)
+(define-public (box-grob-molecule grob)
   "Make a box of exactly the extents of the grob.  The box precisely
 encloses the contents.
 "
index 9849a22e21dd7e5e7f16c4981ef591d2c2051954..60fe590d09d16cce75a1c50b7615ff95e4411354 100644 (file)
@@ -1,3 +1,5 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; tuplets.
 
 (define-public (denominator-tuplet-formatter mus)
   (number->string (ly-get-mus-property mus 'denominator)))
@@ -7,6 +9,7 @@
                 ":"
                 (number->string (ly-get-mus-property mus 'denominator))
                 ))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; repeats.
+
+(define-public (repeat-name-to-ctor name)
+  (let*
+      ((supported-reps
+       `(("volta" . ((iterator-ctor . ,Volta_repeat_iterator::constructor)
+                     (start-moment-function .  ,Repeated_music::first_start)
+                     (length . ,Repeated_music::volta_music_length)))
+         
+           ("unfold" . ((iterator-ctor . ,Unfolded_repeat_iterator::constructor)
+                        (start-moment-function .  ,Repeated_music::first_start)                         
+                        (length . ,Repeated_music::unfolded_music_length)))
+           ("fold" . ((iterator-ctor  . ,Folded_repeat_iterator::constructor)
+                      (start-moment-function .  ,Repeated_music::minimum_start)                         
+                      (length . ,Repeated_music::folded_music_length)))
+           ("percent" . ((iterator-ctor . ,Percent_repeat_iterator::constructor)
+                         (start-moment-function .  ,Repeated_music::first_start)
+                         (length . ,Repeated_music::unfolded_music_length)))
+           ("tremolo" . ((iterator-ctor . ,Chord_tremolo_iterator::constructor)
+                         (start-moment-function .  ,Repeated_music::first_start)
+
+                         ;; the length of the repeat is handled by shifting the note logs
+                         (length . ,Repeated_music::folded_music_length)))))
+         
+       (handle (assoc name supported-reps)))
+
+    (if (pair? handle)
+       (cdr handle)
+       (begin
+         (ly-warn
+          (string-append "Unknown repeat type `" name "'\nSee scm/c++.scm for supported repeats"))
+         '(type . 'repeated-music)))))
+
 (define-public (unfold-repeats music)
 "
 This function replaces all repeats  with unfold repeats. It was 
@@ -118,11 +154,8 @@ Fingering_engraver."
     music))
 
 
-;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;
-
-
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; property setting music objs.
 (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 
@@ -196,6 +229,13 @@ this is not an override
     m
     ))
 
+(define-public (set-mus-properties! m alist)
+  (if (pair? alist)
+      (begin
+       (ly-set-mus-property! m (caar alist) (cdar alist))
+       (set-mus-properties! m (cdr alist)))
+  ))
+
 (define-public (music-separator? m)
   "Is M a separator."
   (let* ((n (ly-get-mus-property m 'name )))
@@ -215,6 +255,13 @@ this is not an override
       ))
 
 (define (split-list l sep?)
+  "
+
+(display (split-list '(a b c / d e f / g) (lambda (x) (equal? x '/))) )
+=>
+ ...
+
+"
   (if (null? l)
       '()
       (let* ((c (split-one sep? l '())))
@@ -223,10 +270,6 @@ this is not an override
       )
   )
 
-;; test code
-; (display (split-list '(a b c / d e f / g) (lambda (x) (equal? x '/))) )
-
-
 ;;; splitting chords into voices.
 
 (define (voicify-list lst number)
@@ -284,8 +327,16 @@ this is not an override
 
 ;;;
 
-;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;
+; Make a function that checks score element for being of a specific type. 
+(define-public (make-type-checker symbol)
+  (lambda (elt)
+    ;;(display  symbol)
+    ;;(eq? #t (ly-get-grob-property elt symbol))
+    (not (eq? #f (memq symbol (ly-get-grob-property elt 'interfaces))))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; warn for bare chords at start.
 
 (define (has-request-chord elts)
   (reduce (lambda (x y) (or x y)) (map (lambda (x) (equal? (ly-music-name x)
@@ -329,8 +380,11 @@ this is not an override
      )
 
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; switch it on here, so parsing and init isn't checked (too slow!)
 
+;; automatic music transformations.
+
 (define (switch-on-debugging m)
   (set-debug-cell-accesses! 15000)
   m
@@ -342,3 +396,4 @@ this is not an override
 
 ; switch-on-debugging
        ))
+
index 726aa92d4e1d0cf956f38a0d8b6a2ace3e434778..f1eaf73f7f8bb722faf989d3325355bf2b4eca7c 100644 (file)
@@ -6,7 +6,7 @@
 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
 
 
-(define all-music-properties '())
+(define-public all-music-properties '())
 
 (define (music-property-description symbol type? description)
  (if (not (equal? #f (object-property symbol 'music-doc)))
index 71eb4129a2c33fc180120a5cdad4a3eeaa65c9ba..fe67ac11203b8c1050dad7e25f569cc0a30f340d 100644 (file)
@@ -225,3 +225,50 @@ centered, X==1 is at the right, X == -1 is at the left."
 (define ((every-nth-bar-number-visible n) barnum) (= 0 (modulo barnum n)))
 
 (define-public (default-bar-number-visibility barnum) (> barnum 1))
+
+;; See documentation of Item::visibility_lambda_
+(define-public (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
+(define-public (end-of-line-visible d) (if (= d -1) '(#f . #f) '(#t . #t)))
+(define-public (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
+
+(define-public (all-visible d) '(#f . #f))
+(define-public (all-invisible d) '(#t . #t))
+(define-public (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
+(define-public (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Bar lines.
+
+;
+; How should a  bar line behave at a break? 
+;
+;; Why prepend `default-' to every scm identifier?
+(define-public (default-break-barline glyph dir)
+   (let ((result (assoc glyph 
+                       '((":|:" . (":|" . "|:"))
+                         ("||:" . ("||" . "|:"))
+                         ("|" . ("|" . ()))
+                         ("||:" . ("||" . "|:"))
+                         ("|s" . (() . "|"))
+                         ("|:" . ("|" . "|:"))
+                         ("|." . ("|." . ()))
+
+                         ;; hmm... should we end with a barline here?
+                         (".|" . ("|" . ".|"))
+                         (":|" . (":|" . ()))
+                         ("||" . ("||" . ()))
+                         (".|." . (".|." . ()))
+                         ("" . ("" . ""))
+                         ("empty" . (() . ()))
+                         ("brace" . (() . "brace"))
+                         ("bracket" . (() . "bracket"))  
+                         )
+                       )))
+
+     (if (equal? result #f)
+        (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
+        (index-cell (cdr result) dir))
+     )
+   )
+     
index 944f071b6dd4b5bb2469227d1c7e49882a8628b5..a62c2137518a2c084443e1c52ff6d3a295cf8465 100644 (file)
@@ -17,8 +17,6 @@
             (ice-9 regex)
             (ice-9 string-fun)   
             )
-
-
 (define font-name-alist  '())
 
 (define this-module (current-module))
 ;;
 (define (output-tex-string s)
   (if security-paranoia
-      (if use-regex
-         (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
-         (begin (display "warning: not paranoid") (newline) s))
+      (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
       s))
 
 (define (lily-def key val)
   (let ((tex-key
-        (if use-regex
-            (regexp-substitute/global 
-             #f "_" (output-tex-string key) 'pre "X" 'post)      
-            (output-tex-string key)))
+        (regexp-substitute/global 
+             #f "_" (output-tex-string key) 'pre "X" 'post)
+            
+        ))
        (tex-val (output-tex-string val)))
     (if (equal? (sans-surrounding-whitespace tex-val) "")
        (string-append "\\let\\" tex-key "\\undefined\n")
-       (string-append "\\def\\" tex-key "{" tex-val "}\n"))))
+       (string-append "\\def\\" tex-key "{" tex-val "}\n")))
 
 (define (number->dim x)
   (string-append
index 30195baac7189b281a5f49e072e853b338b027e8..84ae0ba65ce552f7aaec8ef5a20878343b83fdd3 100644 (file)
    "\\special{\\string! "
    
    ;; URG: ly-gulp-file: now we can't use scm output without Lily
-   (if use-regex
-       ;; fixed in 1.3.4 for powerpc -- broken on Windows
-       (regexp-substitute/global #f "\n"
+   (regexp-substitute/global #f "\n"
                                 (ly-gulp-file "music-drawing-routines.ps") 'pre " %\n" 'post)
-       (ly-gulp-file "music-drawing-routines.ps"))
-;   (if (defined? 'ps-testing) "/testing true def%\n" "")
    "}"
    "\\input lilyponddefs \\outputscale=\\lilypondpaperoutputscale \\lilypondpaperunit"
    "\\turnOnPostScript"))
 ;;
 (define-public (output-tex-string s)
   (if security-paranoia
-      (if use-regex
-         (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
-         (begin (display "warning: not paranoid") (newline) s))
+      (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
       s))
 
 (define (lily-def key val)
   (let ((tex-key
-        (if use-regex
-            ;; fixed in 1.3.4 for powerpc -- broken on Windows
-            (regexp-substitute/global
-             #f "_" (output-tex-string key) 'pre "X" 'post)
-            (output-tex-string key)))
+        (regexp-substitute/global
+             #f "_" (output-tex-string key) 'pre "X" 'post))
+        
        (tex-val (output-tex-string val)))
     (if (equal? (sans-surrounding-whitespace tex-val) "")
        (string-append "\\let\\" tex-key "\\undefined\n")
-       (string-append "\\def\\" tex-key "{" tex-val "}\n"))))
+       (string-append "\\def\\" tex-key "{" tex-val "}\n"))
+    )
+  )
+
 
 (define (number->dim x)
   (string-append
index 14043e67887dc946e054915799efcf8a6294d7a7..729986f9781dd12224b633e23a15dc62803714d7 100644 (file)
@@ -1,5 +1,5 @@
 
-(define all-translation-properties '())
+(define-public all-translation-properties '())
 
 (define (translator-property-description symbol type? description)
  (if (not (equal? #f (object-property symbol 'translation-doc)))