Subject: Scordatura

From: Jean Abou Samra <[email-masked]>
Date: Sat, 4 Jun 2022 19:33:41 +0200

Bonjour Martial,

Suite à ta question à la fondue Lily en visio tout à l'heure,
je propose une solution pour obtenir un rendu MIDI adapté à
la scordatura :

\version "2.23.9"

#(set-object-property! 'scordaturaTuning 'translation-type? list?)

%% Converted from articulations.cc
#(use-modules (ice-9 match))
#(define (articulation-list note-events articulation-events type)
    (let loop ((note-events note-events)
               (articulation-events articulation-events)
               (acc '()))
      (match note-events
        (()
         (reverse! acc))
        ((note-event . rest)
         (let ((found (find (lambda (ev)
                              (memq type (ly:event-property ev 'class)))
                            (ly:event-property note-event 'articulations))))
           (cond
            (found
             (loop rest
                   articulation-events
                   (cons found acc)))
            ((pair? articulation-events)
             (loop rest
                   (cdr articulation-events)
                   (cons (car articulation-events)
                         acc)))
            (else
             (loop rest
                   '()
                   (cons '() acc)))))))))

#(define (Scordaturize_performer context)
    (let ((note-evs '())
          (string-number-evs '())
          (fingering-evs '()))
      (make-performer
       (listeners
        ((note-event engraver event)
         (set! note-evs (cons event note-evs)))
        ((string-number-event engraver event)
         (set! string-number-evs (cons event string-number-evs)))
        ((fingering-event engraver event)
         (set! fingering-evs (cons event fingering-evs))))
       ((pre-process-music engraver)
        (let* ((tab-strings (articulation-list note-evs
string-number-evs 'string-number-event))
               (defined-fingers (articulation-list note-evs
fingering-evs 'fingering-event))
               (func (ly:context-property context 'noteToFretFunction))
               (string-fret-finger (func context note-evs (list
tab-strings defined-fingers)))
               (scordatura-tuning (ly:context-property context
'scordaturaTuning)))
          (for-each
           (lambda (ev elems)
             (match-let*
                   (((string-number fret-number _) elems)
                    (tuning-base (list-ref scordatura-tuning (1-
string-number)))

                    ;; Don't care about enharmony, it's about MIDI.
                    (fret-diff (ly:make-pitch 0 0 (* 1/2 fret-number)))
                    (sounding-pitch (ly:pitch-transpose tuning-base
fret-diff)))
               (ly:event-set-property! ev 'pitch sounding-pitch)))
           note-evs
           string-fret-finger)))
       ((stop-translation-timestep engraver)
        (set! note-evs '())
        (set! string-number-evs '())
        (set! fingering-evs '())))))

\midi {
   \context {
     \Voice
     \consists #Scordaturize_performer
     noteToFretFunction = #determine-frets
     predefinedDiagramTable = ##f
     stringTunings = #guitar-tuning
   }
}

mus = {
   \clef bass
   e, fis, a, b, d e g a b cis' e' fis'
   a,\6
}

\score {
   \new Staff \with {
     scordaturaTuning = \stringTuning <e fis b e' b' e''>
   } \mus
   \midi { }
   \layout { }
}

\new TabStaff \mus

Cordialement,
Jean

---

From: Martial R <[email-masked]>
Date: Sat, 4 Jun 2022 20:25:09 +0200

Merci bcp
je teste :-)

-- 
Martial Rameaux

---

From: Martial R <[email-masked]>
Date: Sat, 4 Jun 2022 21:22:41 +0200

Magnifique !
Je n'ai eu juste qu'à préciser une corde dans Saltarin.
Trop fort !
Là ça me dépasse complètement.
et hop en include "scordatura2midi.ly"

Je ne sais pas si d'autres en auront besoin mais ça mérite d'être sur le LSR :-)

Encore merci beaucoup !

-- 
Martial Rameaux

---

From: Jean Abou Samra <[email-masked]>
Date: Sat, 4 Jun 2022 22:18:10 +0200

> Je ne sais pas si d'autres en auront besoin mais ça mérite d'être sur le LSR :-)

Pas encore pour l'instant malheureusement, car cela repose sur des
fonctionnalités de la version 2.23 alors que la LSR est en 2.22.
Cela deviendra possible le jour où la prochaine version stable, 2.24,
paraîtra et où la LSR sera mise à jour.

Cordialement,
Jean