LEFT | RIGHT |
1 ;;;; This file is part of LilyPond, the GNU music typesetter. | 1 ;;;; This file is part of LilyPond, the GNU music typesetter. |
2 ;;;; | 2 ;;;; |
3 ;;;; Copyright (C) 1998--2015 Jan Nieuwenhuizen <janneke@gnu.org> | 3 ;;;; Copyright (C) 1998--2015 Jan Nieuwenhuizen <janneke@gnu.org> |
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 ;;;; | 5 ;;;; |
6 ;;;; LilyPond is free software: you can redistribute it and/or modify | 6 ;;;; LilyPond is free software: you can redistribute it and/or modify |
7 ;;;; it under the terms of the GNU General Public License as published by | 7 ;;;; it under the terms of the GNU General Public License as published by |
8 ;;;; the Free Software Foundation, either version 3 of the License, or | 8 ;;;; the Free Software Foundation, either version 3 of the License, or |
9 ;;;; (at your option) any later version. | 9 ;;;; (at your option) any later version. |
10 ;;;; | 10 ;;;; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 'duration (ly:music-property music 'duration)) | 384 'duration (ly:music-property music 'duration)) |
385 music)) | 385 music)) |
386 | 386 |
387 (define-public (notes-to-clusters music) | 387 (define-public (notes-to-clusters music) |
388 (music-map note-to-cluster music)) | 388 (music-map note-to-cluster music)) |
389 | 389 |
390 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 390 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
391 ;; repeats. | 391 ;; repeats. |
392 | 392 |
393 (define-public (unfold-repeats types music) | 393 (define-public (unfold-repeats types music) |
394 "Replace repeats of the types given by @var{types} with unfolded repeats." | 394 "Replace repeats of the types given by @var{types} with unfolded repeats. |
| 395 If @var{types} is an empty list, @code{repeated-music} is taken, unfolding all." |
395 (let* ((types-list | 396 (let* ((types-list |
396 (if (list? types) types (list types))) | 397 (if (or (null? types) (not (list? types))) |
397 (repeat-types | 398 (list types) |
398 (if (null? types) | 399 types)) |
399 '(repeated-music) | 400 (repeat-types-alist |
400 (map | 401 '((volta . volta-repeated-music) |
401 (lambda (type) | 402 (percent . percent-repeated-music) |
402 (string->symbol (format #f "~a-repeated-music" type))) | 403 (tremolo . tremolo-repeated-music) |
403 types-list))) | 404 (() . repeated-music))) |
404 ;; we need to work with a copy of 'music', otherwise a direct call like | 405 (repeat-types-hash (alist->hash-table repeat-types-alist))) |
405 ;; (unfold-repeats '(tremolo volta) music) | |
406 ;; would destructively change 'music' | |
407 (mus (ly:music-deep-copy music))) | |
408 (for-each | 406 (for-each |
409 (lambda (type) | 407 (lambda (type) |
410 (let ((es (ly:music-property mus 'elements)) | 408 (let ((repeat-type (hashq-ref repeat-types-hash type))) |
411 (e (ly:music-property mus 'element))) | 409 (if repeat-type |
412 (if (music-is-of-type? music type) | 410 (let ((es (ly:music-property music 'elements)) |
413 (set! mus (make-music 'UnfoldedRepeatedMusic mus))) | 411 (e (ly:music-property music 'element))) |
414 (if (pair? es) | 412 (if (music-is-of-type? music repeat-type) |
415 (set! (ly:music-property mus 'elements) | 413 (set! music (make-music 'UnfoldedRepeatedMusic music))) |
416 (map (lambda (x) (unfold-repeats types x)) es))) | 414 (if (pair? es) |
417 (if (ly:music? e) | 415 (set! (ly:music-property music 'elements) |
418 (set! (ly:music-property mus 'element) | 416 (map (lambda (x) (unfold-repeats types x)) es))) |
419 (unfold-repeats types e))))) | 417 (if (ly:music? e) |
420 repeat-types) | 418 (set! (ly:music-property music 'element) |
421 mus)) | 419 (unfold-repeats types e)))) |
| 420 (ly:warning "unknown repeat-type ~a, ignoring." type)))) |
| 421 types-list) |
| 422 music)) |
422 | 423 |
423 (define-public (unfold-repeats-fully music) | 424 (define-public (unfold-repeats-fully music) |
424 "Unfolds repeats and expands the resulting @code{unfolded-repeated-music}." | 425 "Unfolds repeats and expands the resulting @code{unfolded-repeated-music}." |
425 (map-some-music | 426 (map-some-music |
426 (lambda (m) | 427 (lambda (m) |
427 (and (music-is-of-type? m 'unfolded-repeated-music) | 428 (and (music-is-of-type? m 'unfolded-repeated-music) |
428 (make-sequential-music | 429 (make-sequential-music |
429 (ly:music-deep-copy (make-unfolded-set m))))) | 430 (ly:music-deep-copy (make-unfolded-set m))))) |
430 (unfold-repeats '() music))) | 431 (unfold-repeats '() music))) |
431 | 432 |
(...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 (memq tags music-tags) | 2676 (memq tags music-tags) |
2676 (not (any (lambda (t) (eq? (tag-group-get t) group)) music-tags))))
)) | 2677 (not (any (lambda (t) (eq? (tag-group-get t) group)) music-tags))))
)) |
2677 (let ((groups (delete-duplicates (map tag-group-get tags) eq?))) | 2678 (let ((groups (delete-duplicates (map tag-group-get tags) eq?))) |
2678 (lambda (m) | 2679 (lambda (m) |
2679 (let ((music-tags (ly:music-property m 'tags))) | 2680 (let ((music-tags (ly:music-property m 'tags))) |
2680 (or | 2681 (or |
2681 (null? music-tags) ; redundant but very frequent | 2682 (null? music-tags) ; redundant but very frequent |
2682 (any (lambda (t) (memq t tags)) music-tags) | 2683 (any (lambda (t) (memq t tags)) music-tags) |
2683 ;; if no tag matches, no tag group should match either | 2684 ;; if no tag matches, no tag group should match either |
2684 (not (any (lambda (t) (memq (tag-group-get t) groups)) music-tags))
)))))) | 2685 (not (any (lambda (t) (memq (tag-group-get t) groups)) music-tags))
)))))) |
LEFT | RIGHT |