Hi Lukas,

You might want to set restrainOpenStrings to #t in case the sounding pitch is 
in fact an open 
string (else minimumFret would be ignored), see appended file.

The order requirement to string tuning is most likely a bug, I guess Lilypond 
tries to 
minimize the used fret by traversing the string tuning list backwards and using 
the first 
string that is tuned lower, thus assuming this order. This could probably be 
fixed quite easily.

Artificial harmonics is hard to do, custom noteheads for that are possible. I 
did this for some 
bass score like this

But the hard part would be getting Staff Notation and TabStaff-Notation right 
at the same 
time, because you usually want to notate this like this

Or similar to this. So you would need different functions for Tabnotation and 
regular 
Notation. This having a specific engraver for harmonics would probably be the 
cleanest way 
to do this.

Valentin
harmonicByFret = #(define-music-function (fret music) (number? ly:music?)
  (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble
harmonics played on a fretted instrument by touching the strings at @var{fret}.")
  #{
    \set harmonicDots = ##t
    \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (number->string fret))
    \temporary \override NoteHead.Y-extent = #grob::always-Y-extent-from-stencil
    \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
                                            (ly:note-head::print grob))
    
    \set restrainOpenStrings = ##t
    \set minimumFret = #(ly:pitch-semitones
                         (ly:prob-property
                          (calc-harmonic-pitch (fret->pitch (number->string fret))
                                               (make-music 'NoteEvent 'pitch (ly:make-pitch 0 0)))
                          'pitch))
    
    #(make-harmonic
       (calc-harmonic-pitch (fret->pitch (number->string fret)) music))
    
    \unset restrainOpenStrings
    \unset minimumFret
    
    \unset harmonicDots
    \revert TabNoteHead.stencil
    \revert NoteHead.Y-extent
    \revert NoteHead.stencil
  #})

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to