Dear Benkő and list,

Your example of comma tuning was indeed the ticket I needed!!  I knew
about the makam example in the lilypond manual for ages, but it didn't
click in my brain that it was actually specifying the pitch bends in
the midi output, and that I could tie any glyphs to any pitch shifts I
wanted.  WOW :)

I've adapted your file to 31 equal temperament. (The files are
attached for anyone who is interested.)  The only bug I have is that
is seems to be adding naturals to notes as if they were alterations
(i.e. with no key signature, a 'c' is typeset with a natural sign next
to it.)  I suppose I need to go to lilypond-user if I need help with
that, but if anyone wants to let me know if I've missed something
obvious, please do.

Now... I assume that the midi is still being handled with pitch bends.
 Any chance that it will work with the MIDI tuning standard anytime
soon?  Pretty please?  ;)


On 22 January 2011 16:45, Benkő Pál <benko....@gmail.com> wrote:
>> I am wondering if there is a way to hack the source to change the midi
>> pitch values which are output when it renders.  I want to do this so
>> that I can remap those values to arbitrary frequencies for microtonal
>> playback in a retunable software synth like puredata.
>
> I hope the attachment can give a start.
> I use it for generating pythagorean or meantone tuning,
> by defining komma to
> #(define komma -349/1700)
> for meantone or
>  #(define komma 139/1185)
> for pythagorean.
>
> p
>
\version "2.12.3"

\include "thirtyonetones.ly"

\score {
  \relative c' {
    \time 4/4
    %{adf4 bdf cdf ddf edf fdf gdf
    asqf, bsqf csqf dsqf esqf fsqf gsqf
    af, bf cf df ef ff gf
    asf, bsf csf dsf esf fsf gsf
    a, b c d e f g
    ass, bss css dss ess fss gss
    as, bs cs ds es fs gs
    asqs, bsqs csqs dsqs esqs fsqs gsqs
    ax, bx cx dx ex fx gx
    %}
    
    a8 ass as asqs ax
    b bss bs
    c css cs csqs cx
    d dss ds dsqs dx
    e ess es
    f fss fs fsqs fx
    g gss gs gsqs gx
    a
    
    r1
    
    %Why the unnecessary accidentals?
    c4 d e f
    c d e f


  }
  \midi {}
  \layout {}
}
\version "2.12.3"

%our maximum is 100 cents, or half of a 12et tone
#(define-public MAX_SHIFT (/ -1 2))

%define accidental shifts (for midi) as a fraction of a 12et tone
#(define-public SEMISHARP (/ (/ 1200 31) 200))
#(define-public SEMIFLAT (* -1 SEMISHARP))
#(define-public SHARP (* 2 SEMISHARP))
#(define-public FLAT (* 2 SEMIFLAT))
#(define-public SESQUISHARP (* 3 SEMISHARP))
#(define-public SESQUIFLAT (* 3 SEMIFLAT))
#(define-public DOUBLESHARP (* 4 SEMISHARP))
#(define-public DOUBLEFLAT (* 4 SEMIFLAT))

thirtyonePitchNames = #`(
  (c . ,(ly:make-pitch -1 0 (* -3/31 MAX_SHIFT)))
  (d . ,(ly:make-pitch -1 1 (* -1/31 MAX_SHIFT)))
  (e . ,(ly:make-pitch -1 2 (* 1/31 MAX_SHIFT)))
  (f . ,(ly:make-pitch -1 3 (* -4/31 MAX_SHIFT)))
  (g . ,(ly:make-pitch -1 4 (* -2/31 MAX_SHIFT)))
  (a . ,(ly:make-pitch -1 5 0))
  (b . ,(ly:make-pitch -1 6 (* 2/31 MAX_SHIFT)))

  (css . ,(ly:make-pitch -1 0 (+ SEMISHARP (* -3/31 MAX_SHIFT))))
  (dss . ,(ly:make-pitch -1 1 (+ SEMISHARP (* -1/31 MAX_SHIFT))))
  (ess . ,(ly:make-pitch -1 2 (+ SEMISHARP (* 1/31 MAX_SHIFT))))
  (fss . ,(ly:make-pitch -1 3 (+ SEMISHARP (* -4/31 MAX_SHIFT))))
  (gss . ,(ly:make-pitch -1 4 (+ SEMISHARP (* -2/31 MAX_SHIFT))))
  (ass . ,(ly:make-pitch -1 5 (+ SEMISHARP 0)))
  (bss . ,(ly:make-pitch -1 6 (+ SEMISHARP (* 2/31 MAX_SHIFT))))

  (csf . ,(ly:make-pitch -1 0 (+ SEMIFLAT (* -3/31 MAX_SHIFT))))
  (dsf . ,(ly:make-pitch -1 1 (+ SEMIFLAT (* -1/31 MAX_SHIFT))))
  (esf . ,(ly:make-pitch -1 2 (+ SEMIFLAT (* 1/31 MAX_SHIFT))))
  (fsf . ,(ly:make-pitch -1 3 (+ SEMIFLAT (* -4/31 MAX_SHIFT))))
  (gsf . ,(ly:make-pitch -1 4 (+ SEMIFLAT (* -2/31 MAX_SHIFT))))
  (asf . ,(ly:make-pitch -1 5 (+ SEMIFLAT 0)))
  (bsf . ,(ly:make-pitch -1 6 (+ SEMIFLAT (* 2/31 MAX_SHIFT))))

  (cs . ,(ly:make-pitch -1 0 (+ SHARP (* -3/31 MAX_SHIFT))))
  (ds . ,(ly:make-pitch -1 1 (+ SHARP (* -1/31 MAX_SHIFT))))
  (es . ,(ly:make-pitch -1 2 (+ SHARP (* 1/31 MAX_SHIFT))))
  (fs . ,(ly:make-pitch -1 3 (+ SHARP (* -4/31 MAX_SHIFT))))
  (gs . ,(ly:make-pitch -1 4 (+ SHARP (* -2/31 MAX_SHIFT))))
  (as . ,(ly:make-pitch -1 5 (+ SHARP 0)))
  (bs . ,(ly:make-pitch -1 6 (+ SHARP (* 2/31 MAX_SHIFT))))

  (cf . ,(ly:make-pitch -1 0 (+ FLAT (* -3/31 MAX_SHIFT))))
  (df . ,(ly:make-pitch -1 1 (+ FLAT (* -1/31 MAX_SHIFT))))
  (ef . ,(ly:make-pitch -1 2 (+ FLAT (* 1/31 MAX_SHIFT))))
  (ff . ,(ly:make-pitch -1 3 (+ FLAT (* -4/31 MAX_SHIFT))))
  (gf . ,(ly:make-pitch -1 4 (+ FLAT (* -2/31 MAX_SHIFT))))
  (af . ,(ly:make-pitch -1 5 (+ FLAT 0)))
  (bf . ,(ly:make-pitch -1 6 (+ FLAT (* 2/31 MAX_SHIFT))))

  (csqs . ,(ly:make-pitch -1 0 (+ SESQUISHARP (* -3/31 MAX_SHIFT))))
  (dsqs . ,(ly:make-pitch -1 1 (+ SESQUISHARP (* -1/31 MAX_SHIFT))))
  (esqs . ,(ly:make-pitch -1 2 (+ SESQUISHARP (* 1/31 MAX_SHIFT))))
  (fsqs . ,(ly:make-pitch -1 3 (+ SESQUISHARP (* -4/31 MAX_SHIFT))))
  (gsqs . ,(ly:make-pitch -1 4 (+ SESQUISHARP (* -2/31 MAX_SHIFT))))
  (asqs . ,(ly:make-pitch -1 5 (+ SESQUISHARP 0)))
  (bsqs . ,(ly:make-pitch -1 6 (+ SESQUISHARP (* 2/31 MAX_SHIFT))))

  (csqf . ,(ly:make-pitch -1 0 (+ SESQUIFLAT (* -3/31 MAX_SHIFT))))
  (dsqf . ,(ly:make-pitch -1 1 (+ SESQUIFLAT (* -1/31 MAX_SHIFT))))
  (esqf . ,(ly:make-pitch -1 2 (+ SESQUIFLAT (* 1/31 MAX_SHIFT))))
  (fsqf . ,(ly:make-pitch -1 3 (+ SESQUIFLAT (* -4/31 MAX_SHIFT))))
  (gsqf . ,(ly:make-pitch -1 4 (+ SESQUIFLAT (* -2/31 MAX_SHIFT))))
  (asqf . ,(ly:make-pitch -1 5 (+ SESQUIFLAT 0)))
  (bsqf . ,(ly:make-pitch -1 6 (+ SESQUIFLAT (* 2/31 MAX_SHIFT))))

  (cx . ,(ly:make-pitch -1 0 (+ DOUBLESHARP (* -3/31 MAX_SHIFT))))
  (dx . ,(ly:make-pitch -1 1 (+ DOUBLESHARP (* -1/31 MAX_SHIFT))))
  (ex . ,(ly:make-pitch -1 2 (+ DOUBLESHARP (* 1/31 MAX_SHIFT))))
  (fx . ,(ly:make-pitch -1 3 (+ DOUBLESHARP (* -4/31 MAX_SHIFT))))
  (gx . ,(ly:make-pitch -1 4 (+ DOUBLESHARP (* -2/31 MAX_SHIFT))))
  (ax . ,(ly:make-pitch -1 5 (+ DOUBLESHARP 0)))
  (bx . ,(ly:make-pitch -1 6 (+ DOUBLESHARP (* 2/31 MAX_SHIFT))))

  (cdf . ,(ly:make-pitch -1 0 (+ DOUBLEFLAT (* -3/31 MAX_SHIFT))))
  (ddf . ,(ly:make-pitch -1 1 (+ DOUBLEFLAT (* -1/31 MAX_SHIFT))))
  (edf . ,(ly:make-pitch -1 2 (+ DOUBLEFLAT (* 1/31 MAX_SHIFT))))
  (fdf . ,(ly:make-pitch -1 3 (+ DOUBLEFLAT (* -4/31 MAX_SHIFT))))
  (gdf . ,(ly:make-pitch -1 4 (+ DOUBLEFLAT (* -2/31 MAX_SHIFT))))
  (adf . ,(ly:make-pitch -1 5 (+ DOUBLEFLAT 0)))
  (bdf . ,(ly:make-pitch -1 6 (+ DOUBLEFLAT (* 2/31 MAX_SHIFT))))
)

pitchnames = \thirtyonePitchNames
#(ly:parser-set-note-names parser thirtyonePitchNames)

#(define (accidental-list pitchlist shift glyphname)
  (map (lambda (x) (cons (+ shift (* (/ x 31) MAX_SHIFT)) glyphname)) pitchlist))

thirtyoneGlyphs =
#(append
  (accidental-list '(-4 -3 -2 -1 0 1 2) 0 "accidentals.natural")
  (accidental-list '(-4 -3 -2 -1 0 1 2) SEMISHARP "accidentals.sharp.slashslash.stem")
  (accidental-list '(-4 -3 -2 -1 0 1 2) SEMIFLAT "accidentals.mirroredflat")
  (accidental-list '(-4 -3 -2 -1 0 1 2) SHARP "accidentals.sharp")
  (accidental-list '(-4 -3 -2 -1 0 1 2) FLAT "accidentals.flat")
  (accidental-list '(-4 -3 -2 -1 0 1 2) SESQUISHARP "accidentals.sharp.slashslash.stemstemstem")
  (accidental-list '(-4 -3 -2 -1 0 1 2) SESQUIFLAT "accidentals.mirroredflat.flat")
  (accidental-list '(-4 -3 -2 -1 0 1 2) DOUBLESHARP "accidentals.doublesharp")
  (accidental-list '(-4 -3 -2 -1 0 1 2) DOUBLEFLAT "accidentals.flatflat"))

\layout {
  \context {
    \Score
    \override KeySignature #'glyph-name-alist = \thirtyoneGlyphs
    \override Accidental #'glyph-name-alist = \thirtyoneGlyphs
    \override AccidentalCautionary #'glyph-name-alist = \thirtyoneGlyphs
    \override TrillPitchAccidental #'glyph-name-alist = \thirtyoneGlyphs
    \override AmbitusAccidental #'glyph-name-alist = \thirtyoneGlyphs
  }
}
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to