lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Microtonal midi output


From: brahim.pro
Subject: Re: Microtonal midi output
Date: Sat, 08 May 2021 21:58:18 +0000

This script is great and contains exactly what I want. I would have never found 
that by my own.
Thanks a lot.

Is there a way to call it twice in the same score? Imagine I have two musical 
phrases that I want to tune differently, can I use this script?


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday 8 May 2021 23:19, Jean Abou Samra <jean@abou-samra.fr> wrote:

> Le 08/05/2021 à 20:33, brahim.pro a écrit :
>
> > Hello,
> > I would like to define a scale, let's say A minor, and slightly change
> > the frequency of the notes in the output MIDI file. I have trouble
> > finding this feature in the documentation. So does this feature exist
> > and how to do that?
> > Thanks,
> > Brahim
>
> Hello,
>
> You can always implement it in Scheme... Something like this,
> tampering with the pitches:
>
> \version "2.22.0"
>
> tuneMIDI =
> #(define-music-function (scale music) (list? ly:music?)
>    (for-some-music
>      (lambda (m)
>        (let ((pitch (ly:music-property m 'pitch)))
>          (if (ly:pitch? pitch)
>              (let* ((tones (ly:pitch-tones pitch))
>                     (r (ly:moment-main
>                          (ly:moment-mod
>                            (ly:make-moment tones 0)
>                            (ly:make-moment 6 0))))
>                     (offset (assv-ref scale r)))
>                (ly:message "~s" r)
>                (if offset
>                    (let* ((transpose-pitch (ly:make-pitch 0 0 offset))
>                           (new-pitch (ly:pitch-transpose pitch
> transpose-pitch)))
>                      (ly:music-set-property! m 'pitch new-pitch)
>                      #t)
>                    #f))
>              #f)))
>      music)
>    music)
>
> myNotes = \relative { a b c d e f gis a b c d e f gis a }
>
> { \myNotes }
>
> \score {
>   \tuneMIDI
>     #'(
>        ; Lower F (5/2 tones above C) by 1/10 tone.
>        (5/2 . -1/10)
>        ; Raise G# by 1/10 tone.
>        (4 . 1/10)
>        )
>     \myNotes
>   \midi { }
> }
>
> Note how this requires separating out MIDI generation in
> a dedicated \score block.
>
> I was told that my email client inserts non-breaking
> spaces in my code examples. If this happens and you
> can't compile the file, please use the attachment.
>
> Best,
> Jean





reply via email to

[Prev in Thread] Current Thread [Next in Thread]