You will need to modify the attach file (instrument_ranges.ly) since you are 
only interested in one instrument. 

 

A numeric pitch can be constructed from three components of the lilypond pitch p

 

1.      The octave o obtained from  (ly:pitch-octave p))  
2.      The note n obtained from (ly:pitch-notename p))  
3.      The semitone  a  obtained from the alteration  (* 4 
(ly:pitch-alteration p))  note alteration is in quarter tone steps

 

The numeric pitch (op) is calculated by (define op (+ (* 14 o) (* n 2) (/ a 
2)))  “op is a unique number representing the pitch of the note”

 

The procedure contains the instrument ranges as numeric pitches derived as 
above. 

 

See ;; clarinet range e to f#'  -1 2 0  to 2 3 0  (-10 to 35)

 

The current pitch is compared with the ranges and the octave 
increased/decreased as needed to bring the pitch into the range.

 

The note head and colour is modified to make all the changes visible on the 
score.

 

You can prune the procedure or add your instrument.

 

To call the procedure              

 

At top of the music file 

 

  \include "./instrument_ranges.ly"  (assumes the file is in the includes 
folder specified in Frescobaldi properties)

 

In a score block

 

\score {

              {

                \naturalizeInstrumentRange "flute" {

                \include "Boufill_Op8No3_Cc_M2_L1.ly" } }  (or sequential music)

              }

            } % end of score block 

 

I hope this helps.

 

From: Gianmaria Lari [mailto:gianmarial...@gmail.com] 
Sent: 25 June 2017 16:25
To: Peter Gentry <peter.gen...@sunscales.co.uk>
Cc: Lilypond <lilypond-user@gnu.org>
Subject: Re: : Re: transpose range

 

Yes, I'm very much interested. I will use it with left hand bass note for 
standard bass accordion notation; for that we use only one octave range so jump 
are normal.

 

Have a look to the attached file in case you want understand better....

 

Thanks a lot, g.

 

 

 

On 25 June 2017 at 13:58, Peter Gentry <peter.gen...@sunscales.co.uk 
<mailto:peter.gen...@sunscales.co.uk> > wrote:

Yes there is a way but it has disadvantages. 

 

Often the result is awkward jumps. I indicate changed notes by note head style 
and colour so that it is easier to edit the results.

 

If you are still interested let me know and I will send you the scheme 
procedure and an example. I allow for different instruments having different 
ranges.

 

\version "2.19.15"
% -------------------------------------------------------------------------------------------------
% useage
% include this file --> \include "./instrument_ranges.ly"
% best to save the file in the same folder as any other includes
% call -->    \naturalizeInstrumentRange "instrument" music
% this function will confine all pitches to the individual instruments range
% Note the ranges refer to music transposed for each instrument not the true pitches.
% use % for comment outside scheme function -  use ; inside scheme functions
% -------------------------------------------------------------------------------------------------

#(define (naturalize-instrument-range p instrument )
  (let ((o (ly:pitch-octave p))
  (a (* 4 (ly:pitch-alteration p)))
;; alteration, a, in quarter tone steps, for historical reasons
  (n (ly:pitch-notename p)))
(define np 0)
(define op (+ (* 14 o) (* n 2) (/ a 2)))



;; clarinet range e to f#'  -1 2 0  to 2 3 0  (-10 to 35)
(cond
   ((equal? instrument "clarinet" )
   (if  (< op -38)  (begin (set! o (+ o 1))) )
   (if  (< op -24)  (begin (set! o (+ o 1))) )
   (if  (< op -10)  (begin (set! o (+ o 1))) )
   (if  ( > op 62)  (begin (set! o (- o 1))) )
   (if  ( > op 48)  (begin (set! o (- o 1))) )
   (if  ( > op 35)  (begin (set! o (- o 1))) )
)
; bass clarinet range eb to f'  -1 2 -2  to 2 3 0 (-11 to 34)

   ((equal? instrument "bass clarinet eb" )
   (if  (< op -39)  (begin (set! o (+ o 1))) )
   (if  (< op -25)  (begin (set! o (+ o 1))) )
   (if  (< op -11)  (begin (set! o (+ o 1))) )
   (if  ( > op 62)  (begin (set! o (- o 1))) )
   (if  ( > op 48)  (begin (set! o (- o 1))) )
   (if  ( > op 34)  (begin (set! o (- o 1))) )
 )
; bass clarinet range c to f'  -1 0  0 to 2 3 0 (-14 to 34)

((equal? instrument "bass clarinet c" )
    (if  (< op -42)  (begin (set! o (+ o 1))) )
    (if  (< op -28)  (begin (set! o (+ o 1))) )
    (if  (< op -14)  (begin (set! o (+ o 1))) )
    (if  ( > op 62)  (begin (set! o (- o 1))) )
    (if  ( > op 48)  (begin (set! o (- o 1))) )
    (if  ( > op 34)  (begin (set! o (- o 1))) )
)
;; flute range c to c''  0 0 0   to 2 3 0  (0 to 41)

((equal? instrument "flute")
    (if   (< op -28)  (begin (set! o (+ o 1))) )
    (if   (< op -14)  (begin (set! o (+ o 1))) )
    (if   (< op 0)    (begin (set! o (+ o 1))) )
    (if  ( > op 62)   (begin (set! o (- o 1))) )
    (if  ( > op 48)   (begin (set! o (- o 1))) )
    (if  ( > op 42)   (begin (set! o (- o 1))) )
)
;; alto range d to c''  0 1 0   to 1 3 0 (2 to 36)

 ((equal? instrument "alto")
    (if  (< op -28)  (begin (set! o (+ o 1))) )
    (if  (< op -14)  (begin (set! o (+ o 1))) )
    (if  (< op   0)  (begin (set! o (+ o 1))) )
    (if  ( > op 62)  (begin (set! o (- o 1))) )
    (if  ( > op 48)  (begin (set! o (- o 1))) )
    (if  ( > op 34)  (begin (set! o (- o 1))) )
) )

(ly:make-pitch o n (/ a 4))

))

% -------------------------------------------------------------------------------------------------
% a variable for the notehaed color on pitch change
% -------------------------------------------------------------------------------------------------

my-color = #(x11-color 'red)

% -------------------------------------------------------------------------------------------------
% this function rebuilds the music object optionally changing pitch and notehead color
% -------------------------------------------------------------------------------------------------
#(define (instrumentrange music instrument )

; extract the various portions of the music object
(let ((es (ly:music-property music 'elements))
           (e   (ly:music-property music 'element))
           (p   (ly:music-property music 'pitch)))

; rebuild any 'elements unchanged
(if (pair? es)
   (ly:music-set-property! music 'elements
   (map (lambda (x) (instrumentrange x instrument)) es)))

; rebuild any 'element unchanged
 (if (ly:music? e) (ly:music-set-property! music 'element
                            (instrumentrange e instrument )))

;rebuild the pitch and if a changed pitch add the color tweak
(if (ly:pitch? p)
          (let ((new-pitch (naturalize-instrument-range p instrument)))
          (ly:music-set-property! music 'pitch new-pitch)
          (if (and (not (equal? p new-pitch)) (color? my-color))
              (ly:music-set-property! music 'tweaks
              (acons  'color my-color
               (acons 'style 'harmonic-mixed
                 (ly:music-property music 'tweaks)))))))

     music))

naturalizeInstrumentRange =
#(define-music-function (parser location  instrument m )
  ( string? ly:music? )
  (instrumentrange m instrument ))

% -------------------------------------------------------------------------------------------------
% the Lily test file calling function \naturalizeInstrumentRange  "alto"  followed by sequential music
% -------------------------------------------------------------------------------------------------
%{

\score {
  \naturalizeInstrumentRange "alto"
  \new Staff \relative c' {
   c,,8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces

  }
}
\score {
 \new Staff \relative c' {
   c,,8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces
   c8  cis des d dis ees e eis fes f fis ges g gis aes a ais bes b bis ces

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

Reply via email to