Re: Book structure

2021-07-13 Thread Federico Bruni




On Tue, Jul 13 2021 at 19:50:20 +0200, John McWilliam 
 wrote:
I have been working on a Collection of Scottish bagpipe music. Each 
tune (PIECE) consists of:




Ground (basic melody)Variations (usually up to maximum four).


My strategy has been to create each individual section (ground & 
variations) within its own score and with its own header. This has 
worked well for me and given me a satisfactory result.




My problem is when I try to gather these tunes into a book. Here the 
result is scrambled and I suspect it may have something to do with my 
basic structure. I enclose a simplified (I hope!) rendering of 
“A” the structure of each tune, and “B” my book module 
structure.




If anyone would like to comment on thisI would be most grateful.



John McWilliam





Hard to tell by looking at your attachment.
I suggest you write a minimal example to show the problem.

My guess is that in this situation you should:

- place the music/variables in some .ily files (to be included) with no 
\score or \header blocks
- use .ly files to create a single file and another .ly file to create 
the book. Each of them will include the needed .ily files and use 
\score and \header blocks.







Testers wanted

2021-07-13 Thread Knut Petersen

Hi everybody,

below you find links to four lilypond installers. These installers contain LilyPond version git ee4513cb238cc (2.23.4) plus an additional patch that implements a new backend based on cairo. All installers were built with a modified version of GUB. Cairo 1.16.0 with Pixman 0.40 are used to produce  
the output files.


Mac OS X 10.4–10.14, Intel x86 CPU, 32 bit 


Windows 2000, XP, Vista, 7, 8, 10 


GNU/Linux x86, 32 bit 


GNU/Linux 64, 64 bit 


I tested the Linux installers, but I own neither a Windows nor a Mac OS X 
system. It would be nice if some people could test the installers and the 
lilypond system they provide. I'm especially interested in answers to the 
following questions:

 * Does installation work on your system?
 * Does the cairo backend produce valid output?
 * Is font handling ok? Also for asian fonts?
 * Don't forget to include a short description of your system in 
success/failure/error reports


*How to test:*

Select the desired output formats by any combination of the '--pdf', '--ps', 
'--png' and '--svg' command line options and add -dbackend=cairo'. The '--svg' 
option must precede  the '-dbackend=cairo' option.

If the cairo backend is selected lilypond produces output files with cairo.ps, 
cairo.pdf, cairo.png and cairo.svg extensions.


*Features:*

 * Faster than all other backends (at least on linux systems)
 * Files that fail with the svg backend produce valid svg output with the cairo 
backend.
 * You can produce all output files in one run of lilypond


*Known problems / limitations:*

 * The cairo backend is _experimental_ code.
 * Only setting of standard PDF metadata tags is supported ('Author', 'Title', 
'Subject', 'Keywords' and 'Creator'). 'Creation Time' and 'PDF Producer' are 
set automatically.
 * A lot of seldom used pdf features are not supported (e.g. embedding the 
lilypond source file into the pdf document). There is also no support for 
cropping, clipping, and all features that depend on ghostscripts extensions of 
the postscript language (gs-nevern-embed-fonts, music-font-encodings,
   etc ...)
 * Internal page hyperlinks: If page is a forward reference (a link to a page 
that has not been generated yet) cairo silently fails to generate correct 
hyperlink. As this behaviour is not documented I tend to believe that it is a 
cairo 1.16 bug, but I have to verify that assumption.
 * SVG files produced by the cairo backend are bigger than SVG files produced 
by the svg backend.
 * PNG: -dresolution=dpi works, but I do not care about other parameters for 
now. A rgba with transparent background and 8 bits per channel is generated.

Knut





Re: Ossia and MIDI

2021-07-13 Thread Xavier Scheuer
On Tue, 13 Jul 2021 at 19:45, Kees van den Doel  wrote:
>
> Is there a way to prevent the notes in ossia staves to show up in MIDI?
>

Hello,

I would say try to remove "Staff_performer" from your ossia Staff context.

Cheers,
Xavier

-- 
Xavier Scheuer 


Re: error :GUILE signaled an error for the expression

2021-07-13 Thread David Olson
just wondering... 

has anyone written a song about this subject? 



The Sinoglyphic implementation blues 

I've got those mean old Sinoglyphic implementation blues 
Got'em in the keyboard, 
ev'ry stroke so misconstrued. 

When the inkstone's dry, I gotta cry, 
Gotta bury my brush, hear my ancestors sigh, 

the Consortium may claim, 
but the bugs remain. 

And there ain't no digital attributes 
To solve my Sinoglyphic blues. 


(poetry unworthy of this talented group, to be sure) 
(but then, the text of ANY song operates at a level at least 30 IQ points below 
the median of the singers) 
(why is that?) 
(below the dignity of the neocortex, but lodged in the periaqueductal grey?) 

Not a fan of かな漢字変換 feature on Mac OSX (System 8 and System 9 were much 
better). 

David Olson 
Tinseltown 





From: "ming tsang"  
To: "lilypond-user"  
Cc: "c sorensen"  
Sent: Tuesday, July 13, 2021 10:36:27 AM 
Subject: Re: error :GUILE signaled an error for the expression 

Carl : Thank you for the info. How can I change your display/markup font to be 
a font that includes CJK characters? 
David Wright : 
Thank you for reminding me about my problem way back in 2015. You suggested 
using the eps image in the file name. I did not know how to create an eps image 
for the file name. So I end up not using utf-8 in the file name. It served me 
fine these years. 
Now I created a folder name with utf-8 characters without realizing it will 
affect the folder name as with file name. 
If this is the way lilypond works, I will remember not to use utf-8 characters 
in the folder and the file name. 

One strange thing is that this only affects the 
"\markup \wordwrap-string #(command-line)" --the example four. 

I have different ways to display folder/ [ http://filename.ly/ | filename.ly ] 
%%lily code 
% updated LSR 197 -- [ https://lsr.di.unimi.it/LSR/Item?id=197 | 
https://lsr.di.unimi.it/LSR/Item?id=197 ] 
\version "2.23.3" 

#(define comml (command-line)) 
#(define filen input-file-name) 
#(define siz (object->string (stat:size (stat filen 
#(define ver (lilypond-version)) 
#(define dat (strftime "%m/%d/%Y" (localtime (current-time 
#(define tim (strftime "%H:%M:%S" (localtime (current-time 
#(define modt (stat:mtime (stat filen))) 
#(define modts (strftime "%m/%d/%Y %H:%M:%S" (localtime modt))) 
\markup { ". example one ." } 
\markup \column { 
\line { "File Name = " \filen } 
\line { "File Size = " \siz } 
\line { "LilyPond Version = " \ver } 
\line { "Date Processed = " \dat } 
\line { "Time Processed = " \tim } 
\line { "Last Modified = " \modts } 
\line { "Command Line = " \comml } 
} 
% 

%% 
\version "2.23.3" % or newer 

filename = #(define-scheme-function () () 
(car (ly:input-file-line-char-column (*location* 
\markup { ". example two ." } 
\markup { "File Name =" \filename } 
\header { dedication = \markup { \filename } } 
%% 

%%% 
\version "2.23.3" 

#(define commandLine (object->string (command-line))) 
\markup { ". example three ." } 
\markup { \wordwrap-string { \commandLine } } 
%%% 

 
\version "2.23.3" 
\markup { ". example four ." } 
\markup \wordwrap #(command-line) 
 
%end of example code. 

The above test is for folder names containing utf-8 characters. 
Later today I will test the folder and filename containing utf-8 characters to 
see the effects. 

Thank you for your help. 
Shalom, 
yMing Tsang 

On Tue, Jul 13, 2021 at 12:15 PM David Wright < [ 
mailto:lily...@lionunicorn.co.uk | lily...@lionunicorn.co.uk ] > wrote: 


> Date: Tue, 13 Jul 2021 08:14:51 -0700 
> From: Knute Snortum < [ mailto:ksnor...@gmail.com | ksnor...@gmail.com ] > 
> To: ming tsang < [ mailto:ming.tsan...@gmail.com | ming.tsan...@gmail.com ] > 
> 
> I don't think the error is caused by you not having the font, I think it's 
> that the font doesn't have a glyph (character, sort of) for U+FFFD. I don't 
> think all of the UTF-8 characters will work in the music view. The problem 
> is the non-latin characters in the path of the source file you're trying to 
> compile. 

I seem to remember writing: 
[ https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00762.html | 
https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00762.html ] 
which refers back to: 
[ https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00325.html | 
https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00325.html ] 
to which my reply would be the same: 
[ https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00331.html | 
https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00331.html ] 
except for the reference, updated here to: 

NR § 1.8.2 Formatting text → § Graphic notation inside markup 

 

> On Tue, Jul 13, 2021 at 6:41 AM ming tsang wrote: 
> 
> > Hi lilponder: 
> > 
> > There is a utf-8 in the file path. When I ran the file I got the following 
> > warning message  warning: no glyph for character U+FFFD in font 
> > 

Re: error :GUILE signaled an error for the expression

2021-07-13 Thread Carl Sorensen


From: ming tsang 
Date: Tuesday, July 13, 2021 at 11:36 AM
To: lilypond-user 
Cc: Knute Snortum , Carl Sorensen 
Subject: Re: error :GUILE signaled an error for the expression

Carl :  Thank you for the info.  How can I  change your display/markup font to 
be a font that includes CJK characters?
David points out to me (in the referenced email strings) that U+FFFD is not a 
CJK character, but a utf-8 unknown character.

You can change the markup font as described in 
https://lilypond.org/doc/v2.22/Documentation/notation/fonts (see the very 
bottom of this section for what can be done with OTF fonts, which is probably 
the easiest way to do it.

I believe that there are enough different applications handling files during 
the invocation of lilypond that the best thing to do is not use utf-8 
characters in file names.

Carl



Book structure

2021-07-13 Thread John McWilliam
I have been working on a Collection of Scottish bagpipe music. Each tune (PIECE) consists of: Ground (basic melody)Variations (usually up to maximum four). My strategy has been to create each individual section (ground & variations) within its own score and with its own header. This has worked well for me and given me a satisfactory result.  My problem is when I try to gather these tunes into a book. Here the result is scrambled and I suspect it may have something to do with my basic structure. I enclose a simplified (I hope!) rendering of “A” the structure of each tune, and “B” my book module structure.  If anyone would like to comment on thisI would be most grateful. John McWilliam Sent from Mail for Windows 10 PIECE

A. Mackintosh's Lament: structure

Global declarations:
paper & font sizes etc. 
includes. (If piece included in a book, transfer
these to book module.)
variables used in scores.

\header: Mackintosh's Lament etc.
--
Score declarations:

\Score  Ground
Part I
Part II
Header

\Score  Var. I
Part I
Part II
Header

\Score  Var II
Part I
Part II
Header

\Score  Var III
Part I
Part II
Header

\Score  Abbreviations
--

B. Book Module: structure

Global Declarations:
paper & font sizes etc. 
includes. (Transfered from PIECES e.g. 
Bagpipe_new.ly)
--
Book declarations:
\header: Piobaireachd Collection etc.
\paper: Header, Table of contents
--
Bookpart declarations:
   \bookpart
\header: Black Donalds March etc.
\tocItem
\Include PIECE
\pageBreak

   \bookpart
\header: Mackintosh's Lament etc.
\tocItem
\Include PIECE
\pageBreak

   \bookpart
\header: ...
\tocItem
\Include PIECE
\pageBreak
etc.
EndBook 
---


Ossia and MIDI

2021-07-13 Thread Kees van den Doel
Is there a way to prevent the notes in ossia staves to show up in MIDI?


Re: error :GUILE signaled an error for the expression

2021-07-13 Thread ming tsang
Carl :  Thank you for the info.  How can I  change your display/markup font
to be a font that includes CJK characters?

David Wright :
Thank you for reminding me about my problem way back in 2015. You suggested
using the eps image in the file name.  I did not know how to create an eps
image for the file name.  So I end up not using utf-8 in the file name.  It
served me fine these years.
Now I created a folder name with utf-8 characters without realizing it will
affect the folder name as with  file name.
If this is the way lilypond works, I will remember not to use utf-8
characters in the folder and the file name.

One  strange thing is that this only affects the
"\markup  \wordwrap-string #(command-line)" --the example four.

I have different ways to display folder/filename.ly
%%lily code
%updated LSR 197 --https://lsr.di.unimi.it/LSR/Item?id=197
\version "2.23.3"

#(define comml(command-line))
#(define fileninput-file-name)
#(define siz  (object->string (stat:size (stat filen
#(define ver  (lilypond-version))
#(define dat  (strftime "%m/%d/%Y" (localtime (current-time
#(define tim  (strftime "%H:%M:%S" (localtime (current-time
#(define modt (stat:mtime (stat filen)))
#(define modts(strftime "%m/%d/%Y %H:%M:%S" (localtime modt)))
\markup { ". example one ." }
\markup \column {
  \line { "File Name = "\filen }
  \line { "File Size = "\siz   }
  \line { "LilyPond Version = " \ver   }
  \line { "Date Processed = "   \dat   }
  \line { "Time Processed = "   \tim   }
  \line { "Last Modified = "\modts }
  \line  { "Command Line = " \comml }
}
%

%%
\version "2.23.3" % or newer

filename = #(define-scheme-function () ()
  (car (ly:input-file-line-char-column (*location*
\markup { ". example two ." }
\markup { "File Name =" \filename }
\header { dedication = \markup { \filename } }
%%

%%%
\version "2.23.3"

#(define commandLine (object->string (command-line)))
\markup { ". example three ." }
\markup { \wordwrap-string { \commandLine } }
%%%


\version "2.23.3"
\markup { ". example four ." }
\markup \wordwrap #(command-line)

%end of example code.

The above test is for folder names containing utf-8 characters.
Later today I will test the folder and filename containing utf-8 characters
to see the effects.

Thank you for your help.
Shalom,
yMing Tsang

On Tue, Jul 13, 2021 at 12:15 PM David Wright 
wrote:

> > Date: Tue, 13 Jul 2021 08:14:51 -0700
> > From: Knute Snortum 
> > To: ming tsang 
> >
> > I don't think the error is caused by you not having the font, I think
> it's
> > that the font doesn't have a glyph (character, sort of) for U+FFFD. I
> don't
> > think all of the UTF-8 characters will work in the music view. The
> problem
> > is the non-latin characters in the path of the source file you're trying
> to
> > compile.
>
> I seem to remember writing:
> https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00762.html
> which refers back to:
> https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00325.html
> to which my reply would be the same:
> https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00331.html
> except for the reference, updated here to:
>
> NR § 1.8.2 Formatting text   →   § Graphic notation inside markup
>
> 
>
> > On Tue, Jul 13, 2021 at 6:41 AM ming tsang wrote:
> >
> > > Hi lilponder:
> > >
> > > There is a utf-8 in the file path. When I ran the file I got the
> following
> > > warning message  warning: no glyph for character U+FFFD in font
> > >
> `C:/LilyPond_2-23-3/usr/share/lilypond/current/fonts/otf/C059-Roman.otf'
> > >
> > > [image: image.png]
> > > How can I obtain the otf/C059-Roman.otf font.
> > >
> > > Shalom,
> > > yMing
>
> 
>
> On Wed, 30 Jan 2019 16:42:22 + (UTC) MING TSANG wrote:
>
> http://lsr.di.unimi.it/LSR/Snippet?id=197
>
> I copy the above snippet and name it test_file-name_info.ly and run with
> fracobaldi3.01 + lilypond2.19.82 it produces desired file infomation.
>
> Then I rename the file as test_中文.ly 
> (UTF-8 Chinese characters) and execute and the following error occurs:
>
> Starting lilypond-windows.exe 2.19.82 [test_中文.ly
> ]...
> warning: cannot find file: `C:/Users/yming/Documents/test_??.ly'
> fatal error: failed files: "C:/Users/yming/Documents/test_??.ly"
> Exited with return code 1.
>
> Question: Window 10 support UTF-8 file name and lilypond does not. Is
> there any work around?
>
> 
>
> On Thu, 12 Nov 2015 at 14:53:31 + (UTC) MING TSANG wrote:
>
> Hi, lilyponders:
>
> I ran the attach file and got the following.
> Question: can this be solved? How? Appreciate help given.
>
> Starting lilypond.exe 2.19.31 [test_ymt-曾煒明.ly
> ]...
> Processing `K:/LILY_POND/test_ymt-��.ly'
> Parsing...
> Interpreting music...
> Preprocessing graphical objects...
> Finding the ideal number of 

Re: error :GUILE signaled an error for the expression

2021-07-13 Thread David Wright
> Date: Tue, 13 Jul 2021 08:14:51 -0700
> From: Knute Snortum 
> To: ming tsang 
> 
> I don't think the error is caused by you not having the font, I think it's
> that the font doesn't have a glyph (character, sort of) for U+FFFD. I don't
> think all of the UTF-8 characters will work in the music view. The problem
> is the non-latin characters in the path of the source file you're trying to
> compile.

I seem to remember writing:
https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00762.html
which refers back to:
https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00325.html
to which my reply would be the same:
https://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00331.html
except for the reference, updated here to:

NR § 1.8.2 Formatting text   →   § Graphic notation inside markup



> On Tue, Jul 13, 2021 at 6:41 AM ming tsang wrote:
> 
> > Hi lilponder:
> >
> > There is a utf-8 in the file path. When I ran the file I got the following
> > warning message  warning: no glyph for character U+FFFD in font
> > `C:/LilyPond_2-23-3/usr/share/lilypond/current/fonts/otf/C059-Roman.otf'
> >
> > [image: image.png]
> > How can I obtain the otf/C059-Roman.otf font.
> >
> > Shalom,
> > yMing



On Wed, 30 Jan 2019 16:42:22 + (UTC) MING TSANG wrote:

http://lsr.di.unimi.it/LSR/Snippet?id=197

I copy the above snippet and name it test_file-name_info.ly and run with 
fracobaldi3.01 + lilypond2.19.82 it produces desired file infomation.

Then I rename the file as test_中文.ly (UTF-8 Chinese characters) and execute and 
the following error occurs:

Starting lilypond-windows.exe 2.19.82 [test_中文.ly]...
warning: cannot find file: `C:/Users/yming/Documents/test_??.ly'
fatal error: failed files: "C:/Users/yming/Documents/test_??.ly"
Exited with return code 1.

Question: Window 10 support UTF-8 file name and lilypond does not. Is there any 
work around?



On Thu, 12 Nov 2015 at 14:53:31 + (UTC) MING TSANG wrote:

Hi, lilyponders:

I ran the attach file and got the following.
Question: can this be solved? How? Appreciate help given.

Starting lilypond.exe 2.19.31 [test_ymt-曾煒明.ly]...
Processing `K:/LILY_POND/test_ymt-��.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
(lilypond.exe:1892): Pango-WARNING **: Invalid UTF-8 string passed to 
pango_layout_set_text()
warning: no glyph for character U+FFFD in font `C:/Windows/fonts/times.ttf'

Cheers,
David.



Re: error :GUILE signaled an error for the expression beginning here #

2021-07-13 Thread Carl Sorensen


From: lilypond-user  
on behalf of Knute Snortum 
Date: Tuesday, July 13, 2021 at 9:15 AM
To: ming tsang 
Cc: David Kastrup , Thomas Morley , 
lilypond-user , Jean Abou Samra , 
Jonas Hahnfeld 
Subject: Re: error :GUILE signaled an error for the expression beginning here #

I don't think the error is caused by you not having the font, I think it's that 
the font doesn't have a glyph (character, sort of) for U+FFFD. I don't think 
all of the UTF-8 characters will work in the music view. The problem is the 
non-latin characters in the path of the source file you're trying to compile.

Yes, a roman font is unlikely to have CJK characters.  You could change your 
display/markup font to be a font that includes CJK characters.

Carl



Re: Appending minor chords with "sus2/sus4"

2021-07-13 Thread Brent Annable
Lukas,

Aaaah, that makes sense. As a classical stiff I just assumed that
suspensions resolve downwards by default, so the 2 was in fact a suspended
tonic, not a suspended third. And since the minor third is already present
in the chord I'm dealing with, I think I'll just change it to Gm add9.

Thanks again!

Brent.

On Mon, 12 Jul 2021 at 18:10, Lukas-Fabian Moser  wrote:

> Hi Brent,
>
> > I'm currently adding chords to some music, and I can't seem to find
> > anywhere how to create a "Gmsus2" chord name. When I type "g:msus2"
> > lilypond freaks out, and as far as I can tell, this particular
> > combination of a minor chord with an added suspension never appears in
> > the documentation (at
> > https://lilypond.org/doc/v2.22/Documentation/notation/displaying-chords
> > 
>
> > ).
> >
> > I feel like I'm just missing something, is there an easy way to
> > display this chord type?
>
> It's not very common to ask for Gm-sus2 oder Gm-sus4: The sus2/sus4
> replace the third in the chord, so there's no trace of "minor" left.
>
> But you speak of _added_ suspensions: This sounds to me as if you are
> looking for Gm-add9 or Gm-add11?
>
> All of these may be forced with chordNameExceptions:
>
> \version "2.22.1"
>
> chExceptionMusic = {
>1-\markup { m\super "sus4" } % Semi-advisable? :-)
>1-\markup { m\super "sus2" } % Semi-advisable? :-)
>
>1-\markup { m\super "add9" }
>1-\markup { m\super "add11" }
>
> }
>
> % Convert music to list and prepend to existing exceptions.
> chExceptions = #(append
>(sequential-music-to-chord-exceptions chExceptionMusic #t)
>ignatzekExceptions)
>
> exampleChords = \relative {
>   
> }
>
> theMusic = {
>\mark "Standard"
>\exampleChords
>\bar "||"
>\set chordNameExceptions = #chExceptions
>\mark "Custom"
>\exampleChords
> }
>
> <<
> \new ChordNames \theMusic
> \new Voice \theMusic
>  >>
>
> Lukas
>
>


Re: Move chord name down onto staff?

2021-07-13 Thread Jean Abou Samra


> Le 13/07/2021 03:14, David Wright  a écrit :
> 
> 
> On Mon 12 Jul 2021 at 16:54:03 (-0700), Flaming Hakama by Elaine wrote:
> > > 
> > >
> > > -- Forwarded message --
> > > From: Jean Abou Samra 
> > > To: Werner LEMBERG , lilyp...@hillvisions.com
> > > Cc: m...@archsys.net, lilypond-user@gnu.org
> > > Bcc:
> > > Date: Mon, 12 Jul 2021 15:01:32 +0200 (CEST)
> > > Subject: Re: Move chord name down onto staff?
> > > As a matter of style, I'd do it slightly differently:
> > > \version "2.23.4"
> > > \layout {
> > > \context {
> > > \Staff
> > > \accepts ChordNames
> > > \override ChordName.Y-offset =
> > > #self-alignment-interface::y-aligned-on-self
> > > \override ChordName.self-alignment-Y = #CENTER
> > > }
> > > }
> > > harmony = \chordmode { a1:m s1 f1:m7 s1 }
> > > tune = { s1 s1 s1 s1 }
> > >
> > > \new Staff <<
> > > \tune
> > > \new ChordNames \harmony
> > > >>
> > 
> > I'd like to understand if I can use this layout-based approach on a
> > per-score basis.
> > 
> > This example, based on the previous approach, has in-staff chords for the
> > first score, but normal, above-the-staff chords for the second score.
> > 
> > 
> > How would one go about using the layout approach to do that?
> NR § 4.2.1 The \layout block
> explains how to do this. Either attach the \layout to the \score block
> or, more flexible, assign it to a variable, and reference the variable
> in the score's \layout. The examples in this section show how to
> construct the \layout block thus, and § 4.2.2 example "2." shows how
> to attach \layout to \score.
> 
> In this manner, you can combine global layout options with
> score-specific ones.
> 
> Cheers,
> David.


You could also put it in a \with block:

\version "2.23.4"

melodyHead = \relative c'' { c1 d e f }
melodyFours = \relative c'' { g8 a r g r a r4 | b8 8 r4 r2 | g8 a r g r a r4 | 
bes8 8 r4 r2 }
headChords = \chordmode {
c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}
foursChords = \chordmode {
c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}

chordsOnStaff = \with {
  \accepts ChordNames
  \override ChordName.Y-offset = #self-alignment-interface::y-aligned-on-self
  \override ChordName.self-alignment-Y = #CENTER
}

\book {
\score {
\new StaffGroup <<
\new Staff \melodyHead
\new Staff \with \chordsOnStaff \new ChordNames \headChords
>>
}
\score {
<<
\new ChordNames  { \foursChords }
\new Staff \melodyFours
>>
}
}


And actually, why not define a custom context type:

\version "2.23.4"

melodyHead = \relative c'' { c1 d e f }
melodyFours = \relative c'' { g8 a r g r a r4 | b8 8 r4 r2 | g8 a r g r a r4 | 
bes8 8 r4 r2 }
headChords = \chordmode {
c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}
foursChords = \chordmode {
c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}

\layout {
  \context {
\Staff
\name StaffChordNames
\type Engraver_group
\alias Staff
\alias ChordNames
\consists Chord_name_engraver
\denies Voice
\override ChordName.Y-offset = #self-alignment-interface::y-aligned-on-self
\override ChordName.self-alignment-Y = #CENTER
  }
  \inherit-acceptability StaffChordNames Staff
}

\book {
\score {
\new StaffGroup <<
\new Staff \melodyHead
\new StaffChordNames \headChords
>>
}
\score {
<<
\new ChordNames  { \foursChords }
\new Staff \melodyFours
>>
}
}


Best,
Jean