Scordatura

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

Merci bcp
je teste :slight_smile:

···

Le sam. 4 juin 2022 à 19:33, Jean Abou Samra <****@****> a écrit :

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

--
Martial Rameaux

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 :slight_smile:

Encore merci beaucoup !

Saltarin.ly (4.47 KB)

redoble.ly (7.41 KB)

···

Le sam. 4 juin 2022 à 20:25, Martial R <****@****> a écrit :

Merci bcp
je teste :slight_smile:

Le sam. 4 juin 2022 à 19:33, Jean Abou Samra <****@****> a écrit :
>
> 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
>

--
Martial Rameaux

--
Martial Rameaux

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

···

Le 04/06/2022 à 21:22, Martial R a écrit :

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 :slight_smile:

Bonsoir Martial,
Pourrais-tu m'envoyer ton fichier scordatura2midi.ly, s'il te plaît, le copier/coller que je fais à partir du code de Jean, me génère des erreurs dont mes modestes compétences m’empêchent d'en trouver la cause.
Merci !
Rémy

Bonjour,
ci-joint

scodatura-markup.ly (619 Octets)

ensuite il faut utiliser ainsi

% pour le midi
\score {
  \new Staff  \with {
   scordaturaTuning = \stringTuning <e, fs, b, e b e'> %my tunning
  }
  \\maMusic 
  \midi {   }
 }

cordialement

voici pour tester
test-scodatura.zip (91,3 Ko)

Super !
Merci Martial.
Je vais tester cela dans la semaine.
Rémy