[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to limit customized graceSettings?
From: |
Thomas Morley |
Subject: |
Re: How to limit customized graceSettings? |
Date: |
Tue, 20 Aug 2013 21:19:24 +0200 |
2013/8/18 Thomas Morley <address@hidden>:
> 2013/8/18 Pierre Perol-Schneider <address@hidden>:
>> 2013/8/17 Thomas Morley <address@hidden>
>>>
>>>
>>> > 2) property setting music objs. in music-functions.scm
>>>
>>> Here I don't understand.
>>> Could you c/p what you did?
>>
>>
>> OK.
>> In LilyPond scm files, there is one named music-functions.scm.
>> If you open it, at the end of the first quater you'll see :
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> ;; property setting music objs.
>>
>> .... bla bla
>>
>> (define-safe-public (make-voice-props-set n)
> [...]
>
> Hi Pierre,
>
> thanks for the hint.
> After a quick glance, this code is aargh!
> It's the hardcoded impossipility to use $(add-grace-property ...)
> _and_ \voiceXxx
> I see no way to workaround with custom-functions/definitions in a lily-file.
Hi,
after some more thinking about it, I have to say this code _is_ horrible.
David K tackled it already in different ways, see issue 630.
Though, I've found sort of in-file-work-around.
There's one big issue with it: If a specified voiceX is followed
immediately by a grace, customized grace-settings are ignored and/or
other unexpected things may happen.
This is related to issue 630
http://code.google.com/p/lilypond/issues/detail?id=630
See: comment 14 and 25
http://code.google.com/p/lilypond/issues/detail?id=630#c14
http://code.google.com/p/lilypond/issues/detail?id=630#c25
Right now I have to state that my work-around has to be inserted at
least one note before the grace appears.
Though, this not only a very annoying bug with my code, it's the same
with default \voiceOne etc.
I plan to provide a patch doing some clean-up in music-function.scm.
Though, it will not change any output, nor kill the bug, nor offer new
possibilities of input or output, for now.
Best I hope is to do some preliminary work.
I tried to create some user-interface to insert custom
voiced-grace-settings, without success so far.
Will ask more detailed on -devel.
What I currently do, is to redefine \voiceXxx:
\version "2.14.2"
%% c/p from music-functions.scm, adding some Grobs.
#(define direction-polyphonic-grobs
'(AccidentalSuggestion
DotColumn
Dots
DynamicText ;; added
DynamicLineSpanner ;; added
Fingering
Hairpin ;; added
LaissezVibrerTie
LigatureBracket
MultiMeasureRest
PhrasingSlur
RepeatTie
Rest
Script
Slur
Stem
TextScript
Tie
TupletBracket
TrillSpanner))
%% c/p out of 'make-voice-props-set' from music-functions.scm, naming it.
#(define general-grace-settings
`(
(Voice Stem font-size -3)
(Voice Flag font-size -3)
(Voice NoteHead font-size -3)
(Voice TabNoteHead font-size -4)
(Voice Dots font-size -3)
(Voice Stem length-fraction 0.8)
(Voice Stem no-stem-extend #t)
(Voice Beam beam-thickness 0.384)
(Voice Beam length-fraction 0.8)
(Voice Accidental font-size -4)
(Voice AccidentalCautionary font-size -4)
(Voice Script font-size -3)
(Voice Fingering font-size -8)
(Voice StringNumber font-size -8)
))
%% Modified copy of 'make-voice-props-set' from 'music-functions.scm.
%%
%% An additional argument @var{l}, supposed to be an alist, is added.
%% @var{l} is processed by @code{get-list-entries}, defined later.
%% The result is appended to @code{general-grace-settings}, used to fill
%% 'graceSettings.
#(define (custom-make-voice-props-set l n)
(make-sequential-music
(append
(map (lambda (x) (make-grob-property-set x 'direction
(if (odd? n) -1 1)))
direction-polyphonic-grobs)
(list
(make-property-set 'graceSettings
(append
(get-list-entries l n)
general-grace-settings))
(make-grob-property-set 'NoteColumn 'horizontal-shift (quotient n 2))))))
%% A little procedure to get the entries from @var{lst}, depending on @var{n}
#(define (get-list-entries lst n)
(cond ((and (= n 0) (assoc-ref lst 'voiceOne))
(cadr (assoc-ref lst 'voiceOne)))
((and (= n 1) (assoc-ref lst 'voiceTwo))
(cadr (assoc-ref lst 'voiceTwo)))
((and (= n 2) (assoc-ref lst 'voiceThree))
(cadr (assoc-ref lst 'voiceThree)))
((and (= n 3) (assoc-ref lst 'voiceFour))
(cadr (assoc-ref lst 'voiceFour)))
(else '())))
%% Procedure to define custom-voices.
%% @var{l} is supposed to be a list containing grace-settings
#(define (define-voice l n)
(context-spec-music
(custom-make-voice-props-set l n)
'Voice))
%% This list, containing the custom-settings for different voices, is used to
%% redefine @code{voiceOne} etc.
#(define custom-voiced-grace-settings
`(
(voiceTwo . `(
(Voice Flag color (1 0 0))
(Voice NoteHead style cross)
)
)
(voiceOne . `(
(Voice Flag color (0 1 0))
(Voice NoteHead style mensural)
)
)
(voiceThree . `(
(Voice Flag color (0 0 1))
(Voice NoteHead style diamond)
)
)
(voiceFour . `(
(Voice Flag color (0 1 1))
(Voice NoteHead style slash)
)
)
)
)
%% Redefining and renaming @code{voiceOne}
customVoiceOne = #(define-voice custom-voiced-grace-settings 0)
customVoiceTwo = #(define-voice custom-voiced-grace-settings 1)
customVoiceThree = #(define-voice custom-voiced-grace-settings 2)
customVoiceFour = #(define-voice custom-voiced-grace-settings 3)
%% Duplicates the settings in property-init.ly
% voiceOne = #(define-voice '() 0)
% voiceTwo = #(define-voice '() 1)
% voiceThree = #(define-voice '() 2)
% voiceFour = #(define-voice '() 3)
% The new @code{add-grace-property}. Thanks David Kastrup.
% As default usable since 2.17.25
#(define-public (add-grace-property context-name grob sym val)
"Set @address@hidden for @var{grob} in @var{context-name}."
(define (set-prop context)
(let* ((current (ly:context-property context 'graceSettings))
(new-settings (append current
(list (list context-name grob sym val)))))
(ly:context-set-property! context 'graceSettings new-settings)))
(make-apply-context set-prop))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% NOTE: If a specified voiceX is followed immediately by a grace, customized
%% grace-settings are ignored and/or other unexpected things may happen.
%% Related to issue 630
%% http://code.google.com/p/lilypond/issues/detail?id=630
%% See: comment 25
%% http://code.google.com/p/lilypond/issues/detail?id=630#c25
\new Staff \with { $(add-grace-property 'Voice 'NoteHead 'style 'cross) }
{
<<
\new Voice
{ \customVoiceOne c'''1\< \grace d'''8 c'''1\! }
\new Voice
{ \customVoiceTwo c1\> \grace d8 c1\! }
\new Voice
{ \customVoiceThree c''1 \grace d''8 c''1 }
\new Voice
{ \customVoiceFour c'1 \grace d'8 c'1 }
>>
\oneVoice c'1 \grace d'8 c'1
\displayMusic \customVoiceOne c'1 \grace d'8 c'1
\voiceOne c'1 \grace d'8 c'1
}
\new Voice \with { $(add-grace-property 'Voice 'NoteHead 'style 'cross) }
{
\grace d''8 c''4
\acciaccatura d''8 c''4
}
Also attaching the code and image.
Cheers,
Harm
voiced-grace-settings-01.ly
Description: Binary data
voiced-grace-settings-01.preview.png
Description: PNG image