Re: Help defining commands

2003-11-30 Thread Paul Scott
Guy Shaviv wrote:

That's correct, I'm interested in how you can set up a command that takes a
parameter. I actually even need two parameters as a partial barre has two
parameters, on what fret and on how many strings. While for the full barre I
can setup 12 commands (e.g. \barreI \barreII ...), its impractical to setup
all the permutations for the partial barre, that would take 60 commands).
 

I am trying to solve the same problem.  I have gotten this far:

#(define textPad( lambda( pad ) \property Score.TextScript \override 
#'padding = pad ))

with several guessed variations of

(textPad 3)

Can someone help me finish the syntax?

TIA,

Paul Scott



___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


Re: Help defining commands

2003-11-30 Thread Nicolas Sceaux

Sun, 30 Nov 2003 11:24:53 -0700, Paul a dit : 

  Guy Shaviv wrote:
  That's correct, I'm interested in how you can set up a command that takes a
  parameter. I actually even need two parameters as a partial barre has two
  parameters, on what fret and on how many strings. While for the full barre I
  can setup 12 commands (e.g. \barreI \barreII ...), its impractical to setup
  all the permutations for the partial barre, that would take 60 commands).
  
  I am trying to solve the same problem.  I have gotten this far:

  #(define textPad( lambda( pad ) \property Score.TextScript \override
  #'padding = pad ))

  with several guessed variations of

  (textPad 3)

  Can someone help me finish the syntax?

In the following snippet, functions nthcdr and group are general
utilities. Macros mus:make-music and mus:context-override are
part of a LilyPond-specific toolkit. Function text-pad finally does
what you may want: it takes the padding value as a mandatory argument,
and a second optional argument which, if true, means that the property
override will happen only once. An example shows some variations of
its use.

 toto.ly 
#(use-modules (ice-9 optargs))

#(define-public (nthcdr n source)
  (do ((rest source (if (pair? rest) (cdr rest)))
   (i 0 (1+ i)))
  ((= i n) rest)))

#(define-public (group source n)
  (if (zero? n) (error zero length))
  (letrec ((rec (lambda (source acc)
  (let ((rest (nthcdr n source)))
(if (pair? rest)
(rec rest (cons (list-head source n) acc))
(reverse! (cons source acc)))
(if (null? source) '() (rec source '()

#(defmacro*-public mus:make-music (name #:rest props)
  Make a music expression, of type `name' (a non quoted symbol).
`props' describe the music expression properties. For isntance:
  (mus:make-music PropertySet 
  symbol 'autoBeaming
  value #f)
  (let ((prop-clauses (group props 2))
(gmus (gensym)))
`(let ((,gmus (make-music-by-name ',name)))
   ,@(map (lambda (clause)
 `(ly:set-mus-property! ,gmus ',(car clause) 
,(cadr clause)))
   prop-clauses)
   ,gmus)))

#(defmacro*-public mus:context-override (context property setting
 value #:key (once #f))
  Make a ContextSpeccedMusic with OverrideProperty element, similar
  to:
  [\\once] \\property context.property \override #'setting = #value
  `(context-spec-music  
(mus:make-music OverrideProperty 
once ,once
symbol ',property
grob-property ',setting
grob-value ,value)
',context))

#(define*-public (text-pad pad #:optional once)
  (ly:export (mus:context-override Voice TextScript padding pad 
   #:once once)))

\score { \notes { c'^salut c' #(text-pad 3.0 #t) c'^salut
  c'^salut c' #(text-pad 3.0) c'^salut c'^salut }}
 toto.ly 

You might take a look at 
http://nicolas.sceaux.free.fr/schemingly/scheme-hacks.html
where you will find few other utilities of that kind, that may help
you build other functions for LilyPond. Lily 2.0 is required.

Best regards,
Nicolas




___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


Re: Help defining commands

2003-11-30 Thread Nicolas Sceaux

Mon, 24 Nov 2003 22:10:39 -0800, Guy a dit : 

  I'm trying to typeset music for classical guitar for which I need
  to be able to produce the barre  
  symbol. I've managed to acheive the desired output with text
  spanners via the code: 

  \property Voice.TextSpanner \set #'edge-text = #'(C II  . )
  \property Voice.TextSpanner \set #'direction = #1
  \property Voice.TextSpanner \set #'style = #'line
  \property Voice.TextSpanner \set #'edge-height = #'(0 . 0.5)
  \property Voice.TextSpanner \set #'padding = #1
  \property Voice.TextSpanner \set #'enclose-bounds = ##t

  c''\startTextSpan . \stopTextSpan

  I'de like to define this as a pair of commands. The first would be
  \statBarre which would take as  
  a parameter the barre position, say \startBarre IV. The position
  has to be concatinated with the  
  C symbol and replaced as the first parameter in the edge-text
  property. The second command  
  is a simple \stopBarre which I think I can do by just defining:

  stopBarre = \stopTextSpan.

  Thanks. 

Supposing one is using the extra lib[1] that I mentionned in a reply to
Paul Scott, here what it could look like :


#(use-modules (ice-9 optargs)
  (srfi srfi-13)
  (lilypond music))

#(define (barre str)
  (ly:export 
(mus:seq
 (mus:context-override Voice TextSpanner edge-text 
   (cons (string-concatenate (list C  str)) ) #:once #t)
 (mus:context-override Voice TextSpanner direction 1 #:once #t)
 (mus:context-override Voice TextSpanner style 'line #:once #t)
 (mus:context-override Voice TextSpanner edge-height '(0 . 0.5)
   #:once #t) 
 (mus:context-override Voice TextSpanner padding 1 #:once #t)
 (mus:context-override Voice TextSpanner enclose-bounds #t 
   #:once #t 

\score { \notes {
c' c'#(barre II) c'\startTextSpan c'\stopTextSpan
c' c'#(barre IV) c'\startTextSpan c'\stopTextSpan }}


I don't think that it is possible to put property overrides between
the note and the span event, that's why the `barre' function only sets
the properties.

[1] http://nicolas.sceaux.free.fr/schemingly/scheme-hacks.html


Regards,
nicolas



___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


Re: Help defining commands

2003-11-30 Thread Paul Scott
Nicolas Sceaux wrote:

Sun, 30 Nov 2003 11:24:53 -0700, Paul a dit : 

 I am trying to solve the same problem.  I have gotten this far:

 #(define textPad( lambda( pad ) \property Score.TextScript \override
 #'padding = pad ))
 with several guessed variations of

 (textPad 3)



Thank you very much for your answer.  text-pad worked right away.  It 
will take some study before I can write my own functions.

Paul



___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


Re: Help defining commands

2003-11-25 Thread Mats Bengtsson
Simple, just say something like

startBarre = \notes{
 \property blabla.blabla \override #'blalba  = #blablabla
 ...
 \startTextSpan
}
 /Mats

Guy Shaviv wrote:

I'm trying to typeset music for classical guitar for which I need to be able to produce the barre 
symbol. I've managed to acheive the desired output with text spanners via the code:

\property Voice.TextSpanner \set #'edge-text = #'(C II  . )
\property Voice.TextSpanner \set #'direction = #1
\property Voice.TextSpanner \set #'style = #'line
\property Voice.TextSpanner \set #'edge-height = #'(0 . 0.5)
\property Voice.TextSpanner \set #'padding = #1
\property Voice.TextSpanner \set #'enclose-bounds = ##t
c''\startTextSpan . \stopTextSpan

I'de like to define this as a pair of commands. The first would be \statBarre which would take as 
a parameter the barre position, say \startBarre IV. The position has to be concatinated with the 
C symbol and replaced as the first parameter in the edge-text property. The second command 
is a simple \stopBarre which I think I can do by just defining:

stopBarre = \stopTextSpan.

Thanks. 

--
Guy Shaviv
+++The information transmitted is intended only for the person or entity to which it 
is addressed and may contain confidential and/or privileged material. Any review, 
retransmission, dissemination or other use of, or taking of any action in reliance 
upon, this information by persons or entities other than the intended recipient is 
prohibited. If you received this in error, please contact the sender and destroy any 
copies of this document.+++


___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user
 





___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


Re: Help defining commands

2003-11-25 Thread rtml
Hi Mats and all

At 09:21 25/11/2003 +0100, Mats Bengtsson wrote:
Simple, just say something like

startBarre = \notes{
 \property blabla.blabla \override #'blalba  = #blablabla
 ...
 \startTextSpan
}
That's fine, but I think you have missed one part ogf Guy's question. Is it 
possible to pass a parameter
to the startBarre macro/function ? Because the text must be variable. It's 
a C followed by roman numerals of the fret (I to XII or more)
It would be nice to state \startBarre{VII} or something similar. Other way 
would be to define 12 or more functions :-(


Guy Shaviv wrote:

I'm trying to typeset music for classical guitar for which I need to be 
able to produce the barre symbol. I've managed to acheive the desired 
output with text spanners via the code:

\property Voice.TextSpanner \set #'edge-text = #'(C II  . )
\property Voice.TextSpanner \set #'direction = #1
\property Voice.TextSpanner \set #'style = #'line
\property Voice.TextSpanner \set #'edge-height = #'(0 . 0.5)
\property Voice.TextSpanner \set #'padding = #1
\property Voice.TextSpanner \set #'enclose-bounds = ##t
c''\startTextSpan . \stopTextSpan

I'de like to define this as a pair of commands. The first would be 
\statBarre which would take as a parameter the barre position, say 
\startBarre IV. The position has to be concatinated with the C symbol 
and replaced as the first parameter in the edge-text property. The second 
command is a simple \stopBarre which I think I can do by just defining:

stopBarre = \stopTextSpan.

Thanks.
--
Guy Shaviv
+++The information transmitted is intended only for the person or entity 
to which it is addressed and may contain confidential and/or privileged 
material. Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you received 
this in error, please contact the sender and destroy any copies of this 
document.+++



___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user




___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user


Re: Help defining commands

2003-11-25 Thread Guy Shaviv
That's correct, I'm interested in how you can set up a command that takes a
parameter. I actually even need two parameters as a partial barre has two
parameters, on what fret and on how many strings. While for the full barre I
can setup 12 commands (e.g. \barreI \barreII ...), its impractical to setup
all the permutations for the partial barre, that would take 60 commands).

--
Guy Shaviv

-- Original Message ---
From: rtml [EMAIL PROTECTED]
To: Mats Bengtsson [EMAIL PROTECTED]
Cc: lilypond-user [EMAIL PROTECTED]
Sent: Tue, 25 Nov 2003 10:44:48 +0100
Subject: Re: Help defining commands

 Hi Mats and all
 
 At 09:21 25/11/2003 +0100, Mats Bengtsson wrote:
 Simple, just say something like
 
 startBarre = \notes{
   \property blabla.blabla \override #'blalba  = #blablabla
   ...
   \startTextSpan
 }
 
 That's fine, but I think you have missed one part ogf Guy's question. Is it 
 possible to pass a parameter
 to the startBarre macro/function ? Because the text must be variable. It's 
 a C followed by roman numerals of the fret (I to XII or more)
 It would be nice to state \startBarre{VII} or something similar. Other way 
 would be to define 12 or more functions :-(
 
 Guy Shaviv wrote:
 
 I'm trying to typeset music for classical guitar for which I need to be 
 able to produce the barre symbol. I've managed to acheive the desired 
 output with text spanners via the code:
 
 \property Voice.TextSpanner \set #'edge-text = #'(C II  . )
 \property Voice.TextSpanner \set #'direction = #1
 \property Voice.TextSpanner \set #'style = #'line
 \property Voice.TextSpanner \set #'edge-height = #'(0 . 0.5)
 \property Voice.TextSpanner \set #'padding = #1
 \property Voice.TextSpanner \set #'enclose-bounds = ##t
 
 c''\startTextSpan . \stopTextSpan
 
 I'de like to define this as a pair of commands. The first would be 
 \statBarre which would take as a parameter the barre position, say 
 \startBarre IV. The position has to be concatinated with the C symbol 
 and replaced as the first parameter in the edge-text property. The second 
 command is a simple \stopBarre which I think I can do by just defining:
 
 stopBarre = \stopTextSpan.
 
 Thanks.
 --
 Guy Shaviv
 +++The information transmitted is intended only for the person or entity 
 to which it is addressed and may contain confidential and/or privileged 
 material. Any review, retransmission, dissemination or other use of, or 
 taking of any action in reliance upon, this information by persons or 
 entities other than the intended recipient is prohibited. If you received 
 this in error, please contact the sender and destroy any copies of this 
 document.+++
 
 
 
 ___
 Lilypond-user mailing list
 [EMAIL PROTECTED]
 http://mail.gnu.org/mailman/listinfo/lilypond-user
 
 
 
 
 
 ___
 Lilypond-user mailing list
 [EMAIL PROTECTED]
 http://mail.gnu.org/mailman/listinfo/lilypond-user
 
 ___
 Lilypond-user mailing list
 [EMAIL PROTECTED]
 http://mail.gnu.org/mailman/listinfo/lilypond-user
--- End of Original Message ---

+++The information transmitted is intended only for the person or entity to which it 
is addressed and may contain confidential and/or privileged material. Any review, 
retransmission, dissemination or other use of, or taking of any action in reliance 
upon, this information by persons or entities other than the intended recipient is 
prohibited. If you received this in error, please contact the sender and destroy any 
copies of this document.+++



___
Lilypond-user mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-user