Thanks for the information. I read Valentin's example of a circular staff and I was astonished. It was practically perfect in every detail!! The problem is that for me is too difficult to understand (there are more than 500 lines of code, even excluding the Staff block). That's why I'm trying to adopt an easier approach. I summarize it here: -define lists that contain stencils, linear x-coord and linear y-coord, they are declared as global variables
-let lilypond draws the linear staff (one line)
-use <grob>.after-line-breaking callback to populate the lists
-draw the circular staff
-recover stencils and coords from the global lists
-convert coords from rectangular to polar
-draw the stencils in the circular staff

My first issue was to be able to fetch data from the global lists at the step of drawing the circular staff. I tried to write code like this:
-declare lists and function to populate them
-draw linear staff and set <grob>.after-line-breaking
-outside the staff block use markup to draw the circular staff
-fetch values from lists and write stencils at the right positions

The problem is that lilypond first draws all the graphics (linear and circular staff) and after that executes the callbacks that populates the lists. So when I'm writing the circular staff I still get the lists empty!! I solved the problem adding a dummy staff at the beginning in a separate book (maybe this is not the most elegant solution but it works).

Now I'm stuck again when I try to draw the stencils in the circular staff with \markup \stencil <stencil>. The error is strange because if I check (ly:stencil? <stencil>) I get TRUE! I copy here my code. It compiles correctly, except if you uncomment line 28 or 34. You can also see that my code by now is less than 40 lines, I think at the end it will not be more than 100.
For the sake of simplicity I will declare only the stencil list.

\version "2.24.4"
\language "italiano"

\book { \bookpart { \score { \new Staff \new Voice { s1 } } } } % Dummy staff

#(define stncl 0) % Declare stncl as global variable

#(define (func grob)
  (set! stncl (ly:grob-property grob 'stencil))
(display (ly:stencil-expr stncl))(newline) ; stncl in this case is the KeySignature F major (1 flat)
)

\layout { \context { \Staff \override KeySignature.after-line-breaking = #func } } % Callback for KeySignature

\book { \bookpart { \score { \new Staff { \new Voice { \key fa \major do'1 } } } } } % Real staff

\markup {
  \fill-line {
    \overlay {
      \center-align \vcenter \with-color "red" "X" % Test markup

% Try some test with scheme code
#(begin
  (display (ly:stencil? stncl))(newline) ; stncl really is a stencil
(display (ly:stencil-expr stncl))(newline) ; stncl really is the KeySignature F major (1 flat)
  (markup "OOOO") ; it doesn't display, but this is not the main problem
  (markup #:stencil (make-circle-stencil 10 1 #f)) ; OK
  ;(markup #:stencil stncl) ; WHY ERROR?
)

      % Try some tests with lilypond code
      "++++" % OK
      \stencil #(make-circle-stencil 20 1 #f) % OK
      %\stencil #(stncl) % WHY ERROR?
    }
  }
}






Il 2025-09-01 18:59 David Wright ha scritto:
On Mon 01 Sep 2025 at 17:08:51 (+0200), [email protected] wrote:
I'm trying to write code that convert a linear staff in a circular one.

I haven't read your post in detail, but you might want to check out:

https://lists.gnu.org/archive/html/lilypond-user/2023-04/msg00282.html

has a working example. The thread starts at:

https://lists.gnu.org/archive/html/lilypond-user/2023-04/msg00277.html

This refers to:


https://forums.steinberg.net/t/what-software-can-make-circular-notation/845654/25

Search on "lilypond" to get past the early stuff.

It also refers back to:

https://lists.gnu.org/archive/html/lilypond-user/2010-02/msg00150.html

whose thread starts at:

https://lists.gnu.org/archive/html/lilypond-user/2010-02/msg00146.html

Cheers,
David.

Reply via email to