Re: ly:pitch and string

2014-10-12 Thread Simon Albrecht

Hello Paul,

Thanks for your help in improving the helper functions; however, 
‘inverting’ string-append and cond seems to be based on a 
misunderstanding. It needs to be


%%
\version 2.19.12
\language deutsch

pitch-to-key-string-german =
#(define-scheme-function
   (parser location p mode)
   (ly:pitch? string?)
   (let*
((major? (equal? mode major))
 (nn (ly:pitch-notename p))
 (nn-string (if major?
(list-ref '(C D E F G A H) nn)
(list-ref '(c d e f g a h) nn)))
 (alt (ly:pitch-alteration p))
 (alt-num (+ 2 (* 2 (ly:pitch-alteration p
 (alt-string (list-ref '(eses es  is isis) alt-num))
 ;pitch without octave
 (na (cons nn alt))
 ;helper functions for exceptions in german note naming
 (test (lambda (n a) (equal? na (cons n a
 (exc (lambda (ma mi) (if major? ma mi

(string-append nn-string
  (cond
   ((test 2 -1) (exc Eses eses))
   ((test 2 -1/2) (exc Es es))
   ((test 5 -1) (exc Asas asas))
   ((test 5 -1/2) (exc As as))
   ((test 6 -1/2) (exc B b))
   (else alt-string)


(cond

((test 2 -1) (exc Eses eses))

((test 2 -1/2) (exc Es es))

((test 5 -1) (exc Asas asas))

((test 5 -1/2) (exc As as))

((test 6 -1/2) (exc B b))

(else (string-append nn-string alt-string)



newTonic = disis'

newTonicString = \pitch-to-key-string-german \newTonic major

% for testing:
#(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%

and then it works very well.

Yours, Simon
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-12 Thread Paul Morris
Simon Albrecht-2 wrote
 Thanks for your help in improving the helper functions; however, 
 ‘inverting’ string-append and cond seems to be based on a 
 misunderstanding. It needs to be

Ah, I see now... I was missing the forest for the trees.  

Cheers,
-Paul



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/ly-pitch-and-string-tp167397p167491.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-11 Thread David Kastrup
Simon Albrecht simon.albre...@mail.de writes:

 Hello,

 consider the following setup:
 %%
 \version 2.19.12

 newTonic = d

 newTonicString = d

 \bookOutputSuffix #(string-append in- newTonicString)

 \score { \transpose c \newTonic { c' } }

 %%

 For easy handling of different transpositions the ‘destination pitch’
 is stored in a variable. It is of type ly:pitch?.
 At the same time, I want to flag the output file with the key to which
 the music has been transposed, and for this I need the destination
 pitch notename as a string.
 I’d like to avoid having to synchronise newTonic and newTonicString
 manually, but I’ve been unable to find a convenient way to convert one
 into the other. Can anybody help?

(use-modules (scm display-lily))
newTonicString = #(value-lily-string newTonic parser)

Note that the conversion requires the availability of parser since it
depends on the current value of the note name language.

-- 
David Kastrup


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-11 Thread Simon Albrecht

Hello David,

thanks, that’s exactly the kind of brief and elegant solution I was 
hoping for.


Yours,
Simon

Am 11.10.2014 um 16:52 schrieb David Kastrup:

Simon Albrecht simon.albre...@mail.de writes:


Hello,

consider the following setup:
%%
\version 2.19.12

newTonic = d

newTonicString = d

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%

For easy handling of different transpositions the ‘destination pitch’
is stored in a variable. It is of type ly:pitch?.
At the same time, I want to flag the output file with the key to which
the music has been transposed, and for this I need the destination
pitch notename as a string.
I’d like to avoid having to synchronise newTonic and newTonicString
manually, but I’ve been unable to find a convenient way to convert one
into the other. Can anybody help?

(use-modules (scm display-lily))
newTonicString = #(value-lily-string newTonic parser)

Note that the conversion requires the availability of parser since it
depends on the current value of the note name language.




___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-11 Thread Paul Morris
Simon Albrecht-2 wrote
 well, now I did try and make a function for german note names, which 
 discerns major and minor also. Actually it works – the transposition is 
 applied correctly and there are no unexpected messages – but at testing 
 there seemed to be a memory problem: from some point onwards, the 
 newTonicString was always eses regardless of the input. Perhaps the 
 computer and I ought to go to sleep. (what a mad sentence that is…)
 And thanks again for your input, Paul.

Hi Simon, I see David has showed a better way.  In the meantime, with a few
edits, I got your function working, so just for good measure, here it is.
Cheers,
-Paul

%%
\version 2.19.12
\language deutsch

pitch-to-key-string-german =
#(define-scheme-function
  (parser location p mode)
  (ly:pitch? string?)
  (let*
   ((major? (equal? mode major))
(nn (ly:pitch-notename p))
(nn-string (if major?
   (list-ref '(C D E F G A H) nn)
   (list-ref '(c d e f g a h) nn)))
(alt (ly:pitch-alteration p))
(alt-num (+ 2 (* 2 (ly:pitch-alteration p
(alt-string (list-ref '(eses es  is isis) alt-num))
;pitch without octave
(na (cons nn alt))
;helper functions for exceptions in german note naming
(test (lambda (n a) (equal? na (cons n a
(exc (lambda (ma mi) (if major? ma mi

   (string-append nn-string
 (cond
  ((test 2 -1) (exc Eses eses))
  ((test 2 -1/2) (exc Es es))
  ((test 5 -1) (exc Asas asas))
  ((test 5 -1/2) (exc As as))
  ((test 6 -1/2) (exc B b))
  (else alt-string)

newTonic = disis'

newTonicString = \pitch-to-key-string-german \newTonic major

% for testing:
#(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/ly-pitch-and-string-tp167397p167425.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-10 Thread Paul Morris
Simon Albrecht-2 wrote
 I’d like to avoid having to synchronise newTonic and newTonicString 
 manually, but I’ve been unable to find a convenient way to convert one 
 into the other. Can anybody help?

Hi Simon, 
This does the job.  I might contribute it to the LSR.
Cheers,
-Paul

%%
\version 2.19.12

pitch-to-string =
#(define-scheme-function (parser location p) (ly:pitch?)
   (let*
((pitch-num (ly:pitch-notename p))
 (pitch-string (list-ref '(C D E F G A B) pitch-num))
 (alt-num (+ 2 (* 2 (ly:pitch-alteration p
 (alt-string (list-ref '(-Double-Flat -Flat  -Sharp
-Double-Sharp) alt-num))
 (note-string (string-append pitch-string alt-string)))
;; for testing:
;; (display note-string)
note-string))

newTonic = d

newTonicString = \pitch-to-string \newTonic

% for testing:
% #(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/ly-pitch-and-string-tp167397p167404.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-10 Thread Paul Morris
Just for fun, another version, more compact, probably more cryptic:

%%
\version 2.19.12

pitch-to-string =
#(define-scheme-function (parser location p) (ly:pitch?)
   (string-append
(list-ref '(C D E F G A B) 
  (ly:pitch-notename p))
(list-ref '(-Double-Flat -Flat  -Sharp -Double-Sharp) 
  (+ 2 (* 2 (ly:pitch-alteration p))

newTonic = d

newTonicString = \pitch-to-string \newTonic

% for testing:
#(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/ly-pitch-and-string-tp167397p167405.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-10 Thread Simon Albrecht

Hello Paul,

thanks a lot! I thought along the same lines also, but (1) my less 
elegant coding and (2) the complications brought along by German 
notenames would’ve made it too tedious.


Am 10.10.2014 um 23:44 schrieb Paul Morris:

Just for fun, another version, more compact, probably more cryptic:

%%
\version 2.19.12
If you were to make an LSR snippet, I’d suggest making a Dutch version 
pitch-to-string-dutch also (same for both coding variants):


pitch-to-string =
#(define-scheme-function (parser location p) (ly:pitch?)
(string-append
 (list-ref '(C D E F G A B)
   (ly:pitch-notename p))
 (list-ref '(-Double-Flat -Flat  -Sharp -Double-Sharp)

replace the latter list by '(eses es  is isis)

   (+ 2 (* 2 (ly:pitch-alteration p))

newTonic = d

newTonicString = \pitch-to-string \newTonic

% for testing:
#(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%


Best regards, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: ly:pitch and string

2014-10-10 Thread Simon Albrecht

Hello again,

well, now I did try and make a function for german note names, which 
discerns major and minor also. Actually it works – the transposition is 
applied correctly and there are no unexpected messages – but at testing 
there seemed to be a memory problem: from some point onwards, the 
newTonicString was always eses regardless of the input. Perhaps the 
computer and I ought to go to sleep. (what a mad sentence that is…)

And thanks again for your input, Paul.

Best, Simon

Am 10.10.2014 um 23:55 schrieb Simon Albrecht:

Hello Paul,

thanks a lot! I thought along the same lines also, but (1) my less 
elegant coding and (2) the complications brought along by German 
notenames would’ve made it too tedious.


Am 10.10.2014 um 23:44 schrieb Paul Morris:

Just for fun, another version, more compact, probably more cryptic:

%%
\version 2.19.12
If you were to make an LSR snippet, I’d suggest making a Dutch version 
pitch-to-string-dutch also (same for both coding variants):


pitch-to-string =
#(define-scheme-function (parser location p) (ly:pitch?)
(string-append
 (list-ref '(C D E F G A B)
   (ly:pitch-notename p))
 (list-ref '(-Double-Flat -Flat  -Sharp -Double-Sharp)

replace the latter list by '(eses es  is isis)

   (+ 2 (* 2 (ly:pitch-alteration p))

newTonic = d

newTonicString = \pitch-to-string \newTonic

% for testing:
#(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%


Best regards, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


%%
\version 2.19.12
\language deutsch

pitch-to-key-string-german =
#(define-scheme-function
  (parser location p mode)
  (ly:pitch? string?)
  (let*
   ((major? (equal? mode major))
(nn (ly:pitch-notename p))
(nn-string (if major?
   (list-ref '(C D E F G A H) nn)
   (list-ref '(c d e f g a h) nn)))
(alt (ly:pitch-alteration p))
(alt-num (+ 2 (* 2 (ly:pitch-alteration p
(alt-string (list-ref '(eses es  is isis) alt-num))
;pitch without octave
(na (cons nn alt))
;helper function for exceptions in german note naming
(exc (lambda (n a ma mi)
   ((equal? na (cons n a))
(if major? ma mi)
   
   (cond
(exc 2 -1 Eses eses)
(exc 2 -1/2 Es es)
(exc 5 -1 Asas asas)
(exc 5 -1/2 As as)
(exc 6 -1/2 B b)
(else (string-append nn-string alt-string)

newTonic = disis'

newTonicString = \pitch-to-key-string-german \newTonic major

% for testing:
#(display (string-append in- newTonicString))

\bookOutputSuffix #(string-append in- newTonicString)

\score { \transpose c \newTonic { c' } }

%%___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user