Autor Thema: Ich kann das Code Snippet nicht anlegen  (Gelesen 4453 mal)

Manuela

  • Member
Ich kann das Code Snippet nicht anlegen
« am: Mittwoch, 3. August 2016, 18:50 »
Hi,

ich wollte ein Code-Snippet anlegen.

Titel: Drawing a keyboard with scalable size and correct positions of the black keys
Description:
Often people think that the black keys are centered to the white keys    <br>
even in piano teaching books keyboards are drawn this way<br>
black keys are positioned surprisingly excentric<br>
<a href="http://lsr.di.unimi.it/LSR/Item?id=791">Creating keyboard diagrams with chords or scales</a> inspired me
to draw a keyboard with following features:<br><br>
-- scalable<br>
-- correct positioning of the black keys

\version "2.18.0"
\language "deutsch"

%% often people think that the black keys are centered to the white keys
%% even in piano teaching books keyboards are drawn this way
%% this is not the case, black keys are positioned surprisingly excentric
%% http://lsr.di.unimi.it/LSR/Item?id=791 inspired me
%% to draw a keyboard with following features:
%% -- scalable
%% -- correct positioning of the black keys

%% created by Manuela
%% feel free to modify and distribute

%% all values are measured by myself on my piano

#(define white-key-width 23.5) %% the width of a white piano key
#(define white-key-height 150) %% the height of a white piano key
#(define black-key-width 15)   %% the width of a black piano key
#(define black-key-height 95)  %% the height of a black piano key
#(define black-key-y-start (- white-key-height black-key-height)) %% the y-coordinate of black keys

%% left coordinate of black keys cis/des fis/ges
%% n=0 oder n=3
#(define black-key-x1-start 13)
#(define black-key-cis-start 13)
%% left coordinate of centered black keys gis/as
%% n=4
#(define black-key-x2-start 16)
#(define black-key-gis-start 16)
%% left coordinate of right black keys dis/es ais/b
%% n=1 oder n=5
#(define black-key-x3-start 19)
#(define black-key-dis-start 19)
#(define octav-distance (* 7 white-key-width))

%% routine to move and scale a markup
%% you can add y-offset if you like
#(define-markup-command (move-and-scale layout props mymark faktor x-offset)
   (markup? number? number?)
   (ly:stencil-translate
    (ly:stencil-scale
     (interpret-markup layout props mymark)
     faktor faktor)
    (cons x-offset 0))
   )

%% single white key
wh-taste =
#(make-connected-path-stencil
  ;; creates a square which is transformed
  ;; according to width and height of a white key
  '((0 0) (1 0) (1 1) (0 1) )
  0.1 ;; thickness
  white-key-width
  white-key-height
  #t  ;; close path
  #f  ;; do not fill path
  )

%% combining 7 single white keys to an octave
w-tasten=
#(ly:stencil-add
  wh-taste
  (ly:stencil-translate
   wh-taste (cons white-key-width 0))
  (ly:stencil-translate
   wh-taste (cons (* 2 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 3 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 4 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 5 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 6 white-key-width) 0))
  )

%% combining two octaves
dos-w-octavas=
#(ly:stencil-add
  w-tasten
  (ly:stencil-translate
   w-tasten (cons octav-distance 0)))

%% defining single black key
bl-taste=
#(make-connected-path-stencil
  '((0 0) (1 0) (1 1) (0 1) )
  0.1
  black-key-width
  black-key-height
  #t  ;; close path
  #t  ;; fill path
  )

%% combining 5 black keys for one octave
b-tasten =
#(ly:stencil-add
  (ly:stencil-translate
   bl-taste
   (cons black-key-cis-start black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-dis-start white-key-width ) black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-cis-start (* white-key-width 3) ) black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-gis-start (* white-key-width 4) ) black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-dis-start (* white-key-width 5) ) black-key-y-start)))

%% combining to octaves black keys
dos-b-octavas=
#(ly:stencil-add
  b-tasten
  (ly:stencil-translate
   b-tasten (cons octav-distance 0)))

complete-keyboard-two-octaves=
#(ly:stencil-add
  dos-w-octavas
  dos-b-octavas)

ZweiOktaven=
\markup {
  \combine \stencil \dos-w-octavas
  \stencil \dos-b-octavas
}

%% two different kinds of using the keyboard
\markup \move-and-scale \ZweiOktaven #0.2 #0

\relative c'' {
  c^\markup \move-and-scale \stencil \complete-keyboard-two-octaves  #0.1 #0
  d e f
}

erzeugt folgende Fehlermeldung:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Mit Lilybin compiliert der Code.

harm6

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #1 am: Mittwoch, 3. August 2016, 20:21 »
Hallo Manuela,

es liegt nicht am LilyPond-code, sondern das Problem liegt in der Beschreibung.
Es scheint so zu sein, daß "--" ein Problem produziert. "-" aber nicht.
Keine Ahnung welches html-Protokol da gerade querschießt.

Siehe http://lsr.di.unimi.it/LSR/Item?u=1&id=1041
Dort habe ich Dein snippet mal eingegeben.

Aber bitte lade es selber hoch, es ist nicht meins und sich möchte auch nicht als Autor fungieren. Das andere werde ich löschen.

Gruß,
  Harm

Manuela

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #2 am: Mittwoch, 3. August 2016, 21:23 »
es liegt nicht am LilyPond-code, sondern das Problem liegt in der Beschreibung.
Es scheint so zu sein, daß "--" ein Problem produziert. "-" aber nicht.

Ich bin ein echtes Genie, wenn es darum, ungewollt EDV-Systeme zum Absturz zu bringen.  ::)

Inzwischen habe ich das Snippet noch ein erweitert und ein paar Fehler entfernt.

Update: ich habe das Snippet angelegt, es kompiliert aber etwas anders als auf meinem Computer.

So sollte es nach meiner Vorstellung aussehen:
« Letzte Änderung: Mittwoch, 3. August 2016, 21:35 von Manuela »

fugenkomponist

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #3 am: Mittwoch, 3. August 2016, 21:48 »
Update: ich habe das Snippet angelegt, es kompiliert aber etwas anders als auf meinem Computer.
Das liegt daran, dass das LSR Version 2.18.0 nutzt, du aber 2.18.2, anscheinend wurde da was gefixt ;) Vielleicht wär das ein Grund, das LSR auf die neuste stabile Version (2.18.2) zu bringen. Du kannst aber vor das \relative in der drittletzten Zeile noch ein \new Staff schreiben, dann legt auch Version 2.18.0 keinen (überflüssigen) zweiten Staff an.

Hätte nicht gedacht, dass ich die 2.18.0 oder 2.18.1 jemals nochmal installiere, wo es doch die 2.18.2 gibt :D

Edit: Magst du vielleicht noch die Namen der Funktionen von drei Sprachen („dos“ für zwei, „taste“ für Taste, „bl“ für schwarz) auf eine bringen? ;)
« Letzte Änderung: Mittwoch, 3. August 2016, 21:55 von fugenkomponist »

Manuela

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #4 am: Mittwoch, 3. August 2016, 22:01 »
Edit: Magst du vielleicht noch die Namen der Funktionen von drei Sprachen („dos“ für zwei, „taste“ für Taste, „bl“ für schwarz) auf eine bringen? ;)

Heute nicht mehr  ;)

BTW, ich verwende 2.19.37 und verwende Lilybin zum Überprüfen, ob eine ältere Version kompiliert. Ich würde öfter updaten, mich nervt jedoch ein wenig, dass ich nicht einfach drüberinstallieren kann, sondern deinstallieren muss (verwende Windoofs)

fugenkomponist

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #5 am: Mittwoch, 3. August 2016, 22:06 »
Wie aufwendig ist denn so ne Deinstallation? Unter Linux ist das „sudo uninstall-lilypond“ ins Terminal tippen, Passwort eingeben, < 10 Sekunden warten, fertig ;)
Installation ähnlich, da kommt nur das Runterladen und zusätzlich --prefix installiere/in/dieses/Verzeichnis eingeben dazu (wenn man mehrere Versionen behalten will). Ach ja, und Frescobaldi auf die neue Version hinweisen.
« Letzte Änderung: Mittwoch, 3. August 2016, 22:11 von fugenkomponist »

Arnold

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #6 am: Donnerstag, 4. August 2016, 09:43 »
Apropos Doofe-Winstallation:

a) Installationverzeicnis umbenennen
b) neue Version im gleichen Verzeichnisnamen installieren
c) um zur anderen Version zurückzukehren, die Installtionsverzeichnisse umbenennen

oder, nur ein bischen aufwändiger:

1. Ich installiere immer in einen benutzerspezifischen Pfad, es sei hier D:\meine_programme\Lilypond genannt.
2. Danach benenne ich das installtionsverzeichnis um! z. Bsp. in D:\meine_programme\Lilypond.2.18.0.
3. in diesem Verzeichnis erstelle ich noch eine Bat-Datei, welche eine symbolische Verknüpfung erstellt, z. Bsp.: del D:\meine_programm\Lilypond
mklink /d D:\meine_programme\Lilypond D:\meine_programme\Lilypond.2.18.0
Diese BAT-Datei, wenn sie ausgeführt wird, löscht dann erst die alte Verzeichnisverknüpfung, und erstellt dann die neue Verzeichnisverknüpfung zur gewünschten Version.
4. Schritte 1 bis 3 für jede weitere Version wiederholen.

Meine BAT-Datei ist noch ein bischen aufwändiger, sie prüft erst welche Verzeichnisverknüpfung aktuell existiert, um nur dann die Umverlinkung zu starten, wenn wirklich etwas geädnert werden muß.

Arnold

P.S. Ich weiß, diese Information sollte (auch) unter "betriebssystemabhängig - Windows" abgelegt werden.

Manuela

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #7 am: Donnerstag, 4. August 2016, 11:49 »
Wie aufwendig ist denn so ne Deinstallation?

Aufwendig nicht, aber lästig.

Danke für die Installationshinweise  :)

harm6

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #8 am: Donnerstag, 4. August 2016, 12:52 »
Hallo Manuela,

ich habe mal eine review von http://lsr.di.unimi.it/LSR/Item?u=1&id=1042 gemacht.
Meine Kommentare in rot, Dein Code ist hier nicht verändert.
Mein Vorschlag im Anhang.

Gruß,
  Harm

Zitat
%% Keine \version für LSR-snippets, wird intern geregelt
\version "2.18.0"
\language "deutsch"

%% often people think that the black keys are centered to the white keys
%% even in piano teaching books keyboards are drawn this way
%% this is not the case, black keys are positioned surprisingly excentric
%% http://lsr.di.unimi.it/LSR/Item?id=791 inspired me
%% to draw a keyboard with following features:
%% - scalable
%% - correct positioning of the black keys
%% - entering of a chord which notes are represented by dots

%% created by Manuela
%% feel free to modify and distribute

%% all values are measured by myself on my piano

#(define white-key-width 23.5) %% the width of a white piano key
#(define white-key-height 150) %% the height of a white piano key
#(define black-key-width 15)   %% the width of a black piano key
#(define black-key-height 95)  %% the height of a black piano key
#(define black-key-y-start (- white-key-height black-key-height)) %% the y-coordinate of black keys

%% left coordinate of black keys cis/des fis/ges
%% Erkläre was Du mit "n" meinst
%% n=0 oder n=3
#(define black-key-x1-start 13)
#(define black-key-cis-start 13)
%% left coordinate of centered black keys gis/as
%% n=4
#(define black-key-x2-start 16)
#(define black-key-gis-start 16)
%% left coordinate of right black keys dis/es ais/b
%% n=1 oder n=5
#(define black-key-x3-start 19)
#(define black-key-dis-start 19)
#(define octav-distance (* 7 white-key-width))
%% define circle diameter for the dots
%% just try what looks fine
%% Berechnung ist umständlich
%% Ist dasselbe wie (* black-key-width 0.5)

#(define kreis-dm (/ (* 1.5 black-key-width) 3)) %% circle diameter

%% routine to move and scale a markup
%% you can add y-offset if you like
%% Aber Verschiebung in X-Achse ist hard-coded
%% Du könntest ein property verwenden oder ly:stencil-translate-axis

#(define-markup-command (move-and-scale layout props mymark faktor x-offset)
   (markup? number? number?)
   (ly:stencil-translate
    (ly:stencil-scale
     (interpret-markup layout props mymark)
     faktor faktor)
    (cons x-offset 0))
   )

%% single white key
wh-taste =
#(make-connected-path-stencil
  ;; creates a square which is transformed
  ;; according to width and height of a white key
  '((0 0) (1 0) (1 1) (0 1) )
  0.1 ;; thickness
  white-key-width
  white-key-height
  #t  ;; close path
  #f  ;; do not fill path
  )

%% combining 7 single white keys to an octave
%% Besser verwende (apply ly:stencil-add ...) und ly:stencil-translate-axis
w-tasten=
#(ly:stencil-add
  wh-taste
  (ly:stencil-translate
   wh-taste (cons white-key-width 0))
  (ly:stencil-translate
   wh-taste (cons (* 2 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 3 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 4 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 5 white-key-width) 0))
  (ly:stencil-translate
   wh-taste (cons (* 6 white-key-width) 0))
  )

%% combining two octaves
%% ly:stencil-translate-axis
dos-w-octavas=
#(ly:stencil-add
  w-tasten
  (ly:stencil-translate
   w-tasten (cons octav-distance 0)))

%% defining single black key
bl-taste=
#(make-connected-path-stencil
  '((0 0) (1 0) (1 1) (0 1) )
  0.1
  black-key-width
  black-key-height
  #t  ;; close path
  #t  ;; fill path
  )

%% combining 5 black keys for one octave
b-tasten =
#(ly:stencil-add
  (ly:stencil-translate
   bl-taste
   (cons black-key-cis-start black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-dis-start white-key-width ) black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-cis-start (* white-key-width 3) ) black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-gis-start (* white-key-width 4) ) black-key-y-start))
  (ly:stencil-translate
   bl-taste
   (cons (+ black-key-dis-start (* white-key-width 5) ) black-key-y-start)))

%% combining to octaves black keys
%% ly:stencil-translate-axis
dos-b-octavas=
#(ly:stencil-add
  b-tasten
  (ly:stencil-translate
   b-tasten (cons octav-distance 0)))

complete-keyboard-two-octaves=
#(ly:stencil-add
  dos-w-octavas
  dos-b-octavas)

#(define (music-name x)
   (if (not (ly:music? x))
       #f
       (ly:music-property x 'name)))

#(define (naturalize-pitch p)
   (let ((o (ly:pitch-octave p))
         (a (* 4 (ly:pitch-alteration p)))
         ;; alteration, a, in quarter tone steps,
         ;; for historical reasons
         (n (ly:pitch-notename p)))
     (cond
      ((and (> a 1) (or (eq? n 6) (eq? n 2)))
       (set! a (- a 2))
       (set! n (+ n 1)))
      ((and (< a -1) (or (eq? n 0) (eq? n 3)))
       (set! a (+ a 2))
       (set! n (- n 1))))
     (cond
      ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
      ((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
     (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
     (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
     (ly:make-pitch o n (/ a 4))))

#(define (white-key? p)
   (let
    ((a (ly:pitch-alteration (naturalize-pitch p))))
    (if (= a 0)
        #t
        #f)))

%% Streich die deutschen Kommentare
#(define (start-point-key p)
   ;; calculation the starting point of a key
   ;; depending on the pitch p
   ;; result (x . y)
   ;; wir berechnen den Startpunkt der Taste
   ;; abhängig vom Pitch
   (let*
    ((m (naturalize-pitch p))
     (o (ly:pitch-octave m))
     (a (ly:pitch-alteration m))
     ;; we must naturalize pitch otherwise wrong result for eis e.g.
     ;; we subtract the alteration from the notename and add a half
     ;; so we end up at the same note despite flat oder sharp
     ;; cis is drawn the same as des e.g.
     ;; wir subtrahieren die Erhöhung vom Notennamen und addieren 1/2
     ;; das hat den Sinn, dass ich immer auf die gleiche Note komme
     ;; des z.B. n=1, a=-1/2 (des) ==> n=0
     (n  (ly:pitch-notename m))
     (n1 (+ n a -0.5))
     (x-shift (* o 7 white-key-width))
     )
    (cond
     ((eq? a 0)
      ;; alteration eq 0
      ;; no alteration ==> white key
      ;; kein Vorzeichen ==> weiße Taste
      (cons (+ (* n white-key-width) x-shift) 0 ))
     ((or (= n1 0) (= n1 3))
      ;; "left" black keys cis/des and fis/ges
      ;; notename=0 or 3 and alteration
      ;; links angeordnete Tasten
      ;; cis/des und fis/ges
      ;; n=0 oder n=3
      (cons (+ (* n1 white-key-width) black-key-x1-start x-shift ) black-key-y-start ))
     ((or (= n1 1) (= n1 5))
      ;; "right" black keys dis/es and ais/b
      ;; notename=0 or 3 and alteration
      ;; rechts angeordnete Tasten
      ;; dis/es und ais/b
      ;, n=1 oder n=5
      (cons (+ (* n1 white-key-width) black-key-x3-start x-shift ) black-key-y-start ))
     (else
      ;; only one left, the centered black key gis/as
      ;; jetzt bleibt nur noch gis/as übrig
      ;; die einzige mittig angeordnete schwarze Taste
      (cons (+ (* n1 white-key-width) black-key-x2-start x-shift) black-key-y-start )))))

%% creating a dot for pitch p
%% Ich würde dieselbe Größe für schwarze und weiße Tasten bevorzugen, ist aber Geschmackssache
#(define (make-dot p)
   (let* ((start-p (start-point-key p))
;; Klammer/Leerzeile
          )
     (if (white-key? p)
         (ly:stencil-in-color
          (ly:stencil-translate
           (make-circle-stencil  kreis-dm 0 #t)
           (cons
            (+ (car start-p) (/ white-key-width 2 ))
            (+ (cdr start-p) (/ (- white-key-height black-key-height) 1.5))
            )
           )
          0.2 0.5 0.5) ;; color petrol
         (ly:stencil-in-color
          (ly:stencil-translate
           (make-circle-stencil (/ kreis-dm 1.5) 0 #t)
           (cons
            (+ (car start-p) (/ black-key-width 2 ))
;; (* 1 ...) ist natürlich überflüssig
            (+ (cdr start-p) (/ (* 1 black-key-height) 8))
            )
           )
;; kann nicht dasselbe `petrol' sein wie zuvor. Absicht?
          0.4 0.7 0.7) ;; color petrol
         )))

%% creating a stencil list of dots
%% Keine Rekursion nötig
%% Verwende (apply ly:stencil-add ...)

#(define (make-dot-list l1)
   (if (null? l1)
       empty-stencil
       (ly:stencil-add
        (make-dot (car l1))
        (make-dot-list (cdr l1)))))

%% Unbenutzt, streichen
#(define (sort-white-black-key-pitches pitch-list)
   (call-with-values
    (lambda ()
      (partition
       (lambda (p) (= 0 (ly:pitch-alteration p)))
       pitch-list))
    (lambda (a b) (list a b))))

#(define-markup-command
  (make-dots layout props the-chord)
  (ly:music?)
  (let*
   ((chord
     (map
      (lambda (m) (ly:music-property m 'pitch))
      (extract-named-music the-chord 'NoteEvent)))
;; Unbenutzt, streichen
    (sorted-chord-pitches
     (sort-white-black-key-pitches (map naturalize-pitch chord)))
;; Unbenutzt, streichen
    (mycolor (x11-color 'honeydew)) ;GhostWhite))
    )
;; ly:stencil-add ist übeflüssig, da make-dot-list einen einzigen stencil ausgibt, streichen
   (ly:stencil-add
    (make-dot-list chord))))

meinAkkord = \chordmode { b:sus4 }

ZweiOktaven=
\markup {
  \combine \stencil \dos-w-octavas
  \combine \stencil \dos-b-octavas
  %\combine \make-dots #meinAkkord
  \null
}

ZweiOktavenwithChord=
\markup {
  \combine \ZweiOktaven
  \make-dots #meinAkkord
}

\markup "Keyboard with 2 octaves"
\markup \move-and-scale \ZweiOktaven #0.3 #0

\markup { \null \vspace #4 "Keyboard with a chord" }

KeyboardScaled=\markup \move-and-scale \ZweiOktavenwithChord #0.1 #0

\score {
  <<
    \new ChordNames \meinAkkord
    \relative c'' { \meinAkkord s s s^\KeyboardScaled  }
  >>
}

Manuela

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #9 am: Donnerstag, 4. August 2016, 15:02 »
Harm, danke für deine Vorschläge (die ich gerne übernehme  :) ) und die viele Mühe, die du dir machst.

Schade, dass du die deutschen Kommentare nicht drin haben willst. Die Punktgröße ist jetzt identisch für schwarze und weiße Tasten.
Die überflüssigen Sachen kommen natürlich von der Entwicklung des ganzen, ich habe übersehen, sie wegzulöschen.

Wenn es möglich wäre, einen Aufruf der Form

meinAkkord = \chordmode { b:sus4 }
\meinAkkord^\keyboard-mit-notenpunkten \meinAkkord
zu generieren, dann wäre es perfekt  :)

Ich schaffe es nicht, einen Akkord mit einem Markup zu versehen,

meinAkkord = \chordmode { b:sus4 }
\meinAkkord-\markup "test"

kompiliert nicht, wurde sicher schon an einer anderen Stelle hier im Forum besprochen.
« Letzte Änderung: Donnerstag, 4. August 2016, 15:04 von Manuela »

harm6

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #10 am: Donnerstag, 4. August 2016, 15:21 »
Zitat
Schade, dass du die deutschen Kommentare nicht drin haben willst.
Das LSR ist international und daher wird nunmal english "gesprochen".

Zitat
Wenn es möglich wäre, einen Aufruf der Form

meinAkkord = \chordmode { b:sus4 }
\meinAkkord^\keyboard-mit-notenpunkten \meinAkkord

zu generieren, dann wäre es perfekt
Ich weiß nicht was `keyboard-mit-notenpunkten' ist, solang kann ich da nichts zu sagen.

Zitat
Ich schaffe es nicht, einen Akkord mit einem Markup zu versehen,
TextScript ist in chordmode nicht erlaubt, denn die normalen direction-modifier, i.e. "^", "-" und "_" haben hier eine andere Bedeutung.
Es gibt workarounds, ich würde folgenden vorschlagen:
meinAkkord = \chordmode { b:sus4 }
{ <>-\markup "test" \meinAkkord }

Gruß,
  Harm

Manuela

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #11 am: Donnerstag, 4. August 2016, 16:11 »

Ich weiß nicht was `keyboard-mit-notenpunkten' ist, solang kann ich da nichts zu sagen.

meinAkkord = \chordmode { b:sus4 }
{ <>-\markup "test" \meinAkkord }


ok danke. Mit keyboard-mit-notenpunkten meinte ich eine Funktion, die das 2oktavige Keyboard mit den im Akkord enthaltenen Noten als Punkte zeichnet. Ich werde mal probieren, ob ich das selber zustande bringe mit Hilfe des Workarounds.

Update: Ich habe es inzwischen hingekriegt (der Code kompiliert nur als Anhang an den LSR-Code, ich mag jetzt nicht das ganze Snippet nochmals einfügen), es schaut bei mir so aus:

#(define-markup-command
  (complete layout props the-chord)
  (ly:music?)
  (ly:stencil-scale
   (ly:stencil-add
    dos-w-octavas
    dos-b-octavas
    (make-dot-list (music-pitches the-chord))
    ) 0.03 0.03)
  )

ChordwithKeyboard=
#(define-music-function
  (the-chord)
  (ly:music?)
  #{ <>^\markup \complete #the-chord
     $the-chord
    #}
  )

\ChordwithKeyboard \chordmode { b:sus4 }
« Letzte Änderung: Freitag, 5. August 2016, 10:46 von Manuela »

harm6

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #12 am: Samstag, 6. August 2016, 15:51 »
Zitat von: Manuela
Update: Ich habe es inzwischen hingekriegt ...

Hast Du es auch schon ins snippet geschrieben?
Sag Bescheid, dann schau ich noch mal drüber und winke es ggfs durch.

Gruß,
  Harm

Manuela

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #13 am: Samstag, 6. August 2016, 19:07 »

Hast Du es auch schon ins snippet geschrieben?
Sag Bescheid, dann schau ich noch mal drüber und winke es ggfs durch.

Ist im Snippet, mit dem Erfolg, dass es keinen Output mehr erzeugt. Ich habe die Zeile auskommentiert, um speichern zu können.

harm6

  • Member
Re: Ich kann das Code Snippet nicht anlegen
« Antwort #14 am: Samstag, 6. August 2016, 19:45 »
Im wesentlichen hast Du vergessen mit 2.18. zu arbeiten ;)
In 2.18. braucht eine music-function die beiden default-Argumente parser und location.
`music-pitches' ist ebenfalls noch nicht in 2.18.
Darüberhinaus waren die markup-commands `softnote' und `make-dots' jetzt überflüssig. Habe ich gestrichen.

Es ist jetzt approved als:
"Drawing a keyboard with scalable size and correct positions of the black keys"
http://lsr.di.unimi.it/LSR/Item?id=1042

Falls Du noch etwas ergänzt haben möchtest, melde Dich.

Gruß und Dank für das snippet,
  Harm