Re: possible bug: putting accordion register symbol in title section leads to an error

2021-01-31 Thread Davide Bonetti

Thanks Harm for the workaround.

As you pointed it works only putting

#(use-modules (scm accreg))

in every header where is needed, so in a book with multiple scores it's
a quite tedious.

I think accordion registers is the only markup that need use-modules.

Is there a way to get rid of use-modules for accordion registers?

Thanks again (and sorry for the bad english)

Cheers

Davide

Il 31/01/2021 16:20, Thomas Morley ha scritto:

The used module (scm accreg) is not present in any header.
This holds for other modules as well.

Not sure if I'd call it a bug.

You could workaround with instantiating the module in every header:

\version "2.22.0"

#(use-modules (scm accreg))

\header {
   #(use-modules (scm accreg))
   title = \markup \discant "1"
}

\score {
  { c4 d e f}
  \header {
   #(use-modules (scm accreg))
subtitle = \markup \discant "1"
  }
}

\markup \discant "1"

Tedious, but working.

Cheers,
   Harm


--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus




possible bug: putting accordion register symbol in title section leads to an error

2021-01-31 Thread Davide Bonetti

Hi!

we know that accordion register symbols works as markup and also as a 
music function.


One can put accordion symbols everywhere in a markup block, but if you 
try to put accordion symbol in a title section this leads to an error:



\version "2.22.0"

#(use-modules (scm accreg))

\score {
 { c4 d e f}
  \header {
    title =
    \markup
    \discant "1"
}}

fails to compile, and the console returns:


error: syntax error, unexpected MUSIC_FUNCTION
\discant "1"

Is this to be reported as a bug?

thanks

Davide



--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus




Re: Fwd: list of accordion registers as a single markup

2021-01-23 Thread Davide Bonetti

Thanks to both of you!

Davide

Il 23/01/2021 21:01, Jean Abou Samra ha scritto:



Hi!
I need to obtain a list of accordion registers.


I know I can engrave them using:


#(use-modules (scm accreg))

\markup \line {
\discant "1"
\discant "10"
\discant "101"
\discant "121"
\discant "21"
\discant "11"
\discant "120"
\discant "110"
\discant "1+0"
\discant "100"
\discant "11+0"
}


But I want to pass them in a markup function as a list.

regList = #'("1" "10" "101" "121" "21" "11" "120" "110" "1+0" "100" 
"11+0")



I've tried map, for-each, do, let loop but I can't find a way to 
do this.

Someone can help me?

thanks
Davide


Hi,

Just to add to Harm's answer, there is list splicing, like this:

\version "2.23.0"

#(use-modules (scm accreg))

regList = #'("1" "10" "101" "121" "21" "11" "120" "110" "1+0" "100" 
"11+0")


\markup \line {
  #@(map (lambda (s) #{ \markup \discant #s #}) regList)
  \eyeglasses
}

% Alternate method
% 
(https://lilypond.org/doc/v2.22/Documentation/extending/how-markups-work-internally)


\markup \line {
  #@(map make-discant-markup regList)
  \eyeglasses
}

The advantage is that you can have more than just this list of 
arguments in the \line (I put \eyeglasses for the sake of example).


See 
https://lilypond.org/doc/v2.22/Documentation/extending/lilypond-scheme-syntax


Best,
Jean




--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


Fwd: list of accordion registers as a single markup

2021-01-23 Thread Davide Bonetti


Hi!
I need to obtain a list of accordion registers.


I know I can engrave them using:


#(use-modules (scm accreg))

\markup \line {
\discant "1"
\discant "10"
\discant "101"
\discant "121"
\discant "21"
\discant "11"
\discant "120"
\discant "110"
\discant "1+0"
\discant "100"
\discant "11+0"
}


But I want to pass them in a markup function as a list.


regList = #'("1" "10" "101" "121" "21" "11" "120" "110" "1+0" "100"
"11+0")



I've tried map, for-each, do, let loop but I can't find a way to do
this.
Someone can help me?

thanks
Davide



--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


Re: help needed with horizontal spacing between notes

2021-01-19 Thread Davide Bonetti

Yes, I solved with:

\score{
   \new Staff{
 \time 3/4
 \repeat unfold 16 {c'2*1/2 c'4 4}
 }
   \layout{
 \context {
 \Staff
 \omit TimeSignature
 }
   }
}

Il 19/01/2021 16:44, Carl Sorensen ha scritto:



On Tue, Jan 19, 2021 at 4:35 AM Davide Bonetti <mailto:d...@davidebonetti.it>> wrote:


Hello!

I have some music with half - quarter - quarter sequence.

I want the horizontal spacing of the halves to be equal of the
quarters.


Are you asking for each measure to contain three equally-spaced notes, 
or for the space taken up by the two quarter notes to be exactly equal 
to the space taken up by the one half note?


Carl




--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


help needed with horizontal spacing between notes

2021-01-19 Thread Davide Bonetti

Hello!

I have some music with half - quarter - quarter sequence.

I want the horizontal spacing of the halves to be equal of the quarters.

I tried:


\version "2.22.0"

pippo = \repeat unfold 16 {c'2 c'4 4}

{\pippo}

{
\override Score.SpacingSpanner.spacing-increment = #.1
\pippo
}

but at the beginning of every bar now there is an extra space.

Someone know a solution?

Thanks



--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
\version "2.22.0"

pippo = \repeat unfold 16 {c'2 c'4 4}

{\pippo}

{
\override Score.SpacingSpanner.spacing-increment = #.1
\pippo
}

spacing-increment.pdf
Description: Adobe PDF document


print italian NoteNames context in Uppercase

2021-01-15 Thread Davide Bonetti

Hi everybody.

I'm trying to find a way to print italian note names in uppercase.

\new NoteNames {
  \set printNotesLanguage = "italiano"
  c d e
  }

prints:

do re mi

I wish to have:

Do Re Mi


Thank you

Davide


--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus




Re: Automatic cross-staff chords - testing help

2021-01-10 Thread Davide Bonetti

woops, I used % instead of ; in scheme

here the right code :)

Davide

\version "2.20.0"

#(define (split-music dir music ref)
   (let ((es (ly:music-property music 'elements))
 (e (ly:music-property music 'element))
 (p (ly:music-property music 'pitch)))
 (if (pair? es)
 (ly:music-set-property!
  music 'elements
  (map (lambda (x) (split-music dir x ref)) es)))
 (if (ly:music? e)
 (ly:music-set-property!
  music 'element
  (split-music dir e ref)))
 (if (ly:pitch? p)
 (if ((if (> dir 0) >= <)
  (ly:pitch-steps p) (ly:pitch-steps ref))
 p
 (ly:music-set-property! music 'name 'SkipEvent) ; works, 
but produces warnings

 ))
 music
 ))

splitMusic =
#(define-music-function (parser location dir ref music )
   ((ly:dir? 1) (ly:pitch? (ly:make-pitch 0 0)) ly:music? )
   (split-music dir music ref))

Il 10/01/2021 22:12, Davide Bonetti ha scritto:

I did it!

the code works, but produces warnings.

Cheers

Davide

\version "2.20.0"

#(define (split-music dir music ref)
   (let ((es (ly:music-property music 'elements))
 (e (ly:music-property music 'element))
 (p (ly:music-property music 'pitch)))
 (if (pair? es)
 (ly:music-set-property!
  music 'elements
  (map (lambda (x) (split-music dir x ref)) es)))
 (if (ly:music? e)
 (ly:music-set-property!
  music 'element
  (split-music dir e ref)))
 (if (ly:pitch? p)
 (if ((if (> dir 0) >= <)
  (ly:pitch-steps p) (ly:pitch-steps ref))
 p
 (ly:music-set-property! music 'name 'SkipEvent) ; works, 
but produces warnings

 ))
 music
 ))

splitMusic =
#(define-music-function (parser location dir ref music )
   ((ly:dir? 1) (ly:pitch? (ly:make-pitch 0 0)) ly:music? )
   (split-music dir music ref))

%%%
%Examples

someMusic = {
  c d e g c' d' c''
  
  \chordmode{d:7/a}
  << {c' d' e' f'} \\ {c d e f}>>
  d'2.
  \relative c' {c1 b a g}
  << \chordmode { c4 d e f} \\ \transpose c c, \chordmode {c d e f}>>
  << {c' b e' f'} \\ {c, e, c2} \\ {g2 a4 b}>>
}

\markup "Some music"
{\someMusic}

\markup "\SplitMusic result on piano staff"
\new PianoStaff
<<
  \new Staff {\splitMusic \someMusic}
  \new Staff {
    \clef bass
    \splitMusic #DOWN \someMusic
  }
>>

\markup "\SplitMusic result on SATB (with arbitrary split-points)"
\new StaffGroup
<<
  \new Staff {
    \clef soprano
    \splitMusic #UP f' \someMusic
  }
  \new Staff {
    \clef alto
    \splitMusic #DOWN f' \splitMusic #UP a \someMusic
  }
  \new Staff {
    \clef tenor
    \splitMusic #DOWN a \splitMusic #UP d \someMusic
  }
  \new Staff {
    \clef baritone
    \splitMusic #DOWN d \someMusic
  }
>>


Il 08/01/2021 00:55, Thomas Morley ha scritto:
Am Do., 7. Jan. 2021 um 13:08 Uhr schrieb Davide Bonetti 
:

Hi,

Great work.

I've done some testing and found some bugs. Below the code I've tested,
attached the PDF with the result (on second page, first page are your
examples).

\autoSplitChord doesn't works with curly braces, it returns blank 
output

(like a blank space in the score), so it's not possible to work with:
- chordmode
- more than one chord a time
- moltiple voices

Also, \autoSplitChord doesn't works with single notes, it returns blank
space.

It accepts variables, but the result is the same.

Pippo = 1
PippoDue = \chordmode {c1:/g}
PippoTre = c1
PippoQuattro = {}

\new PianoStaff
\with { \consists #Span_stem_engraver }
<<
    \new Staff = "up"
    {
  \key c\major
  %chord with stem up
  \autoSplitChord #UP 2 %works
  %chord without stem
  \autoSplitChord 4    %works
  %chord with stem down
  \autoSplitChord #DOWN     %works
  %chord, whole note
  \autoSplitChord 1    %works
  %chordmode
  \autoSplitChord \chordmode {c:/g} %blank output
  %chord entered in curly braces
  \autoSplitChord {} %blank output
  %more than one chord, in curly braces
  \autoSplitChord { } %blank output
  %single note
  \autoSplitChord c %blank output
  %single note in a chord
  \autoSplitChord     %works
  %chord entered in polyphonic style
  \autoSplitChord <> %works
  %polyphonic style, different durations
  \autoSplitChord <> %warning & strange output
  %polyphonic style, with some curly braces
  \autoSplitChord <> %notes in curly braces are
not printed
  %polyphonic style, with curly braces
  \autoSplitChord &l

Re: Automatic cross-staff chords - testing help

2021-01-10 Thread Davide Bonetti

I did it!

the code works, but produces warnings.

Cheers

Davide

\version "2.20.0"

#(define (split-music dir music ref)
   (let ((es (ly:music-property music 'elements))
 (e (ly:music-property music 'element))
 (p (ly:music-property music 'pitch)))
 (if (pair? es)
 (ly:music-set-property!
  music 'elements
  (map (lambda (x) (split-music dir x ref)) es)))
 (if (ly:music? e)
 (ly:music-set-property!
  music 'element
  (split-music dir e ref)))
 (if (ly:pitch? p)
 (if ((if (> dir 0) >= <)
  (ly:pitch-steps p) (ly:pitch-steps ref))
 p
 (ly:music-set-property! music 'name 'SkipEvent) % works, 
but produces warnings

 ))
 music
 ))

splitMusic =
#(define-music-function (parser location dir ref music )
   ((ly:dir? 1) (ly:pitch? (ly:make-pitch 0 0)) ly:music? )
   (split-music dir music ref))

%%%
%Examples

someMusic = {
  c d e g c' d' c''
  
  \chordmode{d:7/a}
  << {c' d' e' f'} \\ {c d e f}>>
  d'2.
  \relative c' {c1 b a g}
  << \chordmode { c4 d e f} \\ \transpose c c, \chordmode {c d e f}>>
  << {c' b e' f'} \\ {c, e, c2} \\ {g2 a4 b}>>
}

\markup "Some music"
{\someMusic}

\markup "\SplitMusic result on piano staff"
\new PianoStaff
<<
  \new Staff {\splitMusic \someMusic}
  \new Staff {
    \clef bass
    \splitMusic #DOWN \someMusic
  }
>>

\markup "\SplitMusic result on SATB (with arbitrary split-points)"
\new StaffGroup
<<
  \new Staff {
    \clef soprano
    \splitMusic #UP f' \someMusic
  }
  \new Staff {
    \clef alto
    \splitMusic #DOWN f' \splitMusic #UP a \someMusic
  }
  \new Staff {
    \clef tenor
    \splitMusic #DOWN a \splitMusic #UP d \someMusic
  }
  \new Staff {
    \clef baritone
    \splitMusic #DOWN d \someMusic
  }
>>


Il 08/01/2021 00:55, Thomas Morley ha scritto:

Am Do., 7. Jan. 2021 um 13:08 Uhr schrieb Davide Bonetti 
:

Hi,

Great work.

I've done some testing and found some bugs. Below the code I've tested,
attached the PDF with the result (on second page, first page are your
examples).

\autoSplitChord doesn't works with curly braces, it returns blank output
(like a blank space in the score), so it's not possible to work with:
- chordmode
- more than one chord a time
- moltiple voices

Also, \autoSplitChord doesn't works with single notes, it returns blank
space.

It accepts variables, but the result is the same.

Pippo = 1
PippoDue = \chordmode {c1:/g}
PippoTre = c1
PippoQuattro = {}

\new PianoStaff
\with { \consists #Span_stem_engraver }
<<
\new Staff = "up"
{
  \key c\major
  %chord with stem up
  \autoSplitChord #UP 2 %works
  %chord without stem
  \autoSplitChord 4%works
  %chord with stem down
  \autoSplitChord #DOWN %works
  %chord, whole note
  \autoSplitChord 1%works
  %chordmode
  \autoSplitChord \chordmode {c:/g} %blank output
  %chord entered in curly braces
  \autoSplitChord {} %blank output
  %more than one chord, in curly braces
  \autoSplitChord { }  %blank output
  %single note
  \autoSplitChord c %blank output
  %single note in a chord
  \autoSplitChord %works
  %chord entered in polyphonic style
  \autoSplitChord <>%works
  %polyphonic style, different durations
  \autoSplitChord <>%warning & strange output
  %polyphonic style, with some curly braces
  \autoSplitChord <>%notes in curly braces are
not printed
  %polyphonic style, with curly braces
  \autoSplitChord <<
{c4 d e f}
\\
{c' d' e' f'}
  >>%blank output
  %chord in a variable
  \autoSplitChord \Pippo%works
  %chord in a variable with chordmode
  \autoSplitChord \PippoDue%blank output
  %single note in a variable
  \autoSplitChord \PippoTre%blank output
  %chord in curly braces in a variable
  \autoSplitChord \PippoQuattro%blank output
}
\new Staff = "down"
{
  \key c\major
  \clef bass
  s1
}
  >>

Thank you for the work.

Cheers

Davide

Hi Davide,

many thanks for testing.

Though, `autoSplitChord` is meant ot be a tool applied to chords, i.e.
event-chords.
All of:
\chordmode { c:/g }
{  }
<<
   {c4 d e f}
   \\
   {c' d' e' f'}
is sequential or simultaneous music.
A single note-event like c'4 is not an event-chord as well.

In all those cases `autoSplitChord` is not expected to work.
\autoSplitChord &l

split chord in two staves, split multiple voices in two staves

2021-01-10 Thread Davide Bonetti

I did it!

the code works but produces warnings.

Testers are welcome!

Cheers

Davide

\version "2.20.0"

#(define (split-music dir music ref)
   (let ((es (ly:music-property music 'elements))
 (e (ly:music-property music 'element))
 (p (ly:music-property music 'pitch)))
 (if (pair? es)
 (ly:music-set-property!
  music 'elements
  (map (lambda (x) (split-music dir x ref)) es)))
 (if (ly:music? e)
 (ly:music-set-property!
  music 'element
  (split-music dir e ref)))
 (if (ly:pitch? p)
 (if ((if (> dir 0) >= <)
  (ly:pitch-steps p) (ly:pitch-steps ref))
 p
 (ly:music-set-property! music 'name 'SkipEvent) % works, 
but produces warnings

 ))
 music
 ))

splitMusic =
#(define-music-function (parser location dir ref music )
   ((ly:dir? 1) (ly:pitch? (ly:make-pitch 0 0)) ly:music? )
   (split-music dir music ref))

%%%
%Examples

someMusic = {
  c d e g c' d' c''
  
  \chordmode{d:7/a}
  << {c' d' e' f'} \\ {c d e f}>>
  d'2.
  \relative c' {c1 b a g}
  << \chordmode { c4 d e f} \\ \transpose c c, \chordmode {c d e f}>>
  << {c' b e' f'} \\ {c, e, c2} \\ {g2 a4 b}>>
}

\markup "Some music"
{\someMusic}

\markup "\SplitMusic result on piano staff"
\new PianoStaff
<<
  \new Staff {\splitMusic \someMusic}
  \new Staff {
    \clef bass
    \splitMusic #DOWN \someMusic
  }
>>

\markup "\SplitMusic result on SATB (with arbitrary split-points)"
\new StaffGroup
<<
  \new Staff {
    \clef soprano
    \splitMusic #UP f' \someMusic
  }
  \new Staff {
    \clef alto
    \splitMusic #DOWN f' \splitMusic #UP a \someMusic
  }
  \new Staff {
    \clef tenor
    \splitMusic #DOWN a \splitMusic #UP d \someMusic
  }
  \new Staff {
    \clef baritone
    \splitMusic #DOWN d \someMusic
  }
>>



--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
\version "2.20.0"

#(define (split-music dir music ref)
   (let ((es (ly:music-property music 'elements))
 (e (ly:music-property music 'element))
 (p (ly:music-property music 'pitch)))
 (if (pair? es)
 (ly:music-set-property!
  music 'elements
  (map (lambda (x) (split-music dir x ref)) es)))
 (if (ly:music? e)
 (ly:music-set-property!
  music 'element
  (split-music dir e ref)))
 (if (ly:pitch? p)
 (if ((if (> dir 0) >= <)
  (ly:pitch-steps p) (ly:pitch-steps ref))
 p
 (ly:music-set-property! music 'name 'SkipEvent) % works, but produces warnings
 ))
 music
 ))

splitMusic =
#(define-music-function (parser location dir ref music )
   ((ly:dir? 1) (ly:pitch? (ly:make-pitch 0 0)) ly:music? )
   (split-music dir music ref))

%%%
%Examples

someMusic = {
  c d e g c' d' c''
  
  \chordmode{d:7/a}
  << {c' d' e' f'} \\ {c d e f}>>
  d'2.
  \relative c' {c1 b a g}
  << \chordmode { c4 d e f} \\ \transpose c c, \chordmode {c d e f}>>
  << {c' b e' f'} \\ {c, e, c2} \\ {g2 a4 b}>>
}

\markup "Some music"
{\someMusic}

\markup "\SplitMusic result on piano staff"
\new PianoStaff
<<
  \new Staff {\splitMusic \someMusic}
  \new Staff {
\clef bass
\splitMusic #DOWN \someMusic
  }
>>

\markup "\SplitMusic result on SATB (with arbitrary split-points)"
\new StaffGroup
<<
  \new Staff {
\clef soprano
\splitMusic #UP f' \someMusic
  }
  \new Staff {
\clef alto
\splitMusic #DOWN f' \splitMusic #UP a \someMusic
  }
  \new Staff {
\clef tenor
\splitMusic #DOWN a \splitMusic #UP d \someMusic
  }
  \new Staff {
\clef baritone
\splitMusic #DOWN d \someMusic
  }
>>

splitMusic.pdf
Description: Adobe PDF document


re: Automatic cross-staff chords - testing help

2021-01-09 Thread Davide Bonetti

Update:

\autoSplitChord \chordmode { c:/g}

doesn't work, but:

\chordmode { \autoSplitChord c:/g}

works.

So, if we can make \autoSplitChord accept sequences of music, that can 
include chords or succession of chords, we'll have  our goal.


Cheers

Davide


--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus




Re: Automatic cross-staff chords - testing help

2021-01-08 Thread Davide Bonetti

Hi Harm,


many thanks for testing.

thanks to you for the reply.


Below is an improved function which will simply returns the input, if
it's not an event-chord, avoiding the blank space.
\autoSplitChord << b \\ e' \\ g'' >> will stop working as well, all
notes are returned unchanged.

I see you've put an if condition to exclude input that is not event-chord.

There is now a problem: the below staff  is not printed when there is 
not an event-chord, and when an event-chord returns, a new staff is 
printed (with treble clef).


Pippo = 1
PippoDue = \chordmode {c1:/g}
PippoTre = c1
PippoQuattro = {}

\new PianoStaff
\with { \consists #Span_stem_engraver }
<<
  \new Staff = "up"
  {
    \key c\major
    \autoSplitChord #UP 2
    \autoSplitChord 4
    \autoSplitChord #DOWN 
    \autoSplitChord 1
    \autoSplitChord \chordmode {c:/g}
    \autoSplitChord {}
    \autoSplitChord { }
    \autoSplitChord c
    \autoSplitChord 
    \autoSplitChord <>
    \autoSplitChord <>
    \autoSplitChord <>
    \autoSplitChord <<
  {c4 d e f}
  \\
  {c' d' e' f'}
    >>
    \autoSplitChord \Pippo
    \autoSplitChord \PippoDue
    \autoSplitChord \PippoTre
    \autoSplitChord \PippoQuattro
  }
  \new Staff = "down"
  {
    \key c\major
    \clef bass
    s1 %bass staff appear only at the beginning, then reappears as 
another staff with treble clef

  }
>>

To avoid the problem, one can declare the lenght of the bass staff:

[...]
  \new Staff = "down"
  {
    \key c\major
    \clef bass
    \repeat unfold 16 s1 %bass staff is shown correctly
  }
>>

As shown in the attached files.

Perhaps there is a method to let the second staff to be printed without 
having to declare it's lenght.



\autoSplitChord is supposed to work on a single chord of a single
Voice. Like \autochange works an single notes of  a single Voice.
Maybe there's a recursive (or something similar) method so 
\autoSplitChord can work with chord sequences.

\autochange accepts sequential input.


Best would be a combination, I'll continue thinking about it.


Me too. Scheme is not so intuitive for me, but sometimes I find a solution.

Thank you

Davide





--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus

\version "2.20.0"

#(define (make-autosplit-chord chord . ref-pitch)
   "Return a pair of lists, containing the pitches of @var{chord}, splitted at
a reference pitch.  The reference pitch is derived from @var{ref-pitch}.
If @var{ref-pitch} is empty, @code{c'} is regarded as reference.
  "
   (define ref-pitch-steps
 (if (and (pair? ref-pitch) (car ref-pitch))
 (ly:pitch-steps (car ref-pitch))
 0))

   (call-with-values
(lambda ()
  (partition
   (lambda (note)
 (> (ly:pitch-steps (ly:music-property note 'pitch))
ref-pitch-steps))
   (event-chord-notes chord)))
(lambda (x y) (cons x y

autoSplitChord =
#(define-music-function (stem-dir staff-names pitch chord)
   ((ly:dir? 0) (pair? '("up" . "down")) (ly:pitch?) ly:music?)
   (_i "Split @var{chord} at optional @var{pitch}.  The default of @var{pitch} is
@code{#f}, which is interpreted by the called procedure
@code{make-autosplit-chord} as @code{c'}.

The splitted chords are distributed to named staves, relying on optional
@var{staff-names}.

The optional @var{stem-dir}, determines the direction of the stems and whether
the chords may be connected by a cross-staff stem.
The default results in unconnected chords.
If the @code{Span_stem_engraver} is consisted, the chords may be connected by a
cross-staff stem.")
   (if (music-is-of-type? chord 'event-chord)
   (let* ((skip (make-duration-of-length (ly:music-length chord)))
  (devided-pitches (make-autosplit-chord chord pitch))
  (upper-chord
   (if (pair? (car devided-pitches))
   (make-event-chord (car devided-pitches))
   (make-skip-music skip)))
  (lower-chord
   (if (pair? (cdr devided-pitches))
   (make-event-chord (cdr devided-pitches))
   (make-skip-music skip
 #{
   <<
 \context Staff = #(car staff-names)
 \context Voice {
   $(if (negative? stem-dir)
#{
  \once \override Stem.cross-staff = #cross-staff-connect
  \once \override Flag.style = #'no-flag
  <>\noBeam
#})
   $(if (not (zero? stem-dir))
#{ \once \override Stem.direction = #stem-dir #})
   #upper-chord
 }

 \context Staff = #(cdr staff-names)
 \context Voice {
   $(if (positive? stem-dir)
#{
  \once \override Stem.cross-staff = #cross-staff-connect
  \once \override Flag.style = #'no-flag
  <>\noBeam
 

Automatic cross-staff chords - testing help

2021-01-07 Thread Davide Bonetti

Hi,

Great work.

I've done some testing and found some bugs. Below the code I've tested, 
attached the PDF with the result (on second page, first page are your 
examples).


\autoSplitChord doesn't works with curly braces, it returns blank output 
(like a blank space in the score), so it's not possible to work with:

- chordmode
- more than one chord a time
- moltiple voices

Also, \autoSplitChord doesn't works with single notes, it returns blank 
space.


It accepts variables, but the result is the same.

Pippo = 1
PippoDue = \chordmode {c1:/g}
PippoTre = c1
PippoQuattro = {}

\new PianoStaff
\with { \consists #Span_stem_engraver }
<<
  \new Staff = "up"
  {
    \key c\major
    %chord with stem up
    \autoSplitChord #UP 2         %works
    %chord without stem
    \autoSplitChord 4            %works
    %chord with stem down
    \autoSplitChord #DOWN         %works
    %chord, whole note
    \autoSplitChord 1        %works
    %chordmode
    \autoSplitChord \chordmode {c:/g}         %blank output
    %chord entered in curly braces
    \autoSplitChord {}         %blank output
    %more than one chord, in curly braces
    \autoSplitChord { }  %blank output
    %single note
    \autoSplitChord c                 %blank output
    %single note in a chord
    \autoSplitChord             %works
    %chord entered in polyphonic style
    \autoSplitChord <>        %works
    %polyphonic style, different durations
    \autoSplitChord <>    %warning & strange output
    %polyphonic style, with some curly braces
    \autoSplitChord <>    %notes in curly braces are 
not printed

    %polyphonic style, with curly braces
    \autoSplitChord <<
  {c4 d e f}
  \\
  {c' d' e' f'}
    >>                        %blank output
    %chord in a variable
    \autoSplitChord \Pippo            %works
    %chord in a variable with chordmode
    \autoSplitChord \PippoDue            %blank output
    %single note in a variable
    \autoSplitChord \PippoTre            %blank output
    %chord in curly braces in a variable
    \autoSplitChord \PippoQuattro        %blank output
  }
  \new Staff = "down"
  {
    \key c\major
    \clef bass
    s1
  }
>>

Thank you for the work.

Cheers

Davide



--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus

\version "2.20.0"

#(define (make-autosplit-chord chord . ref-pitch)
   "Return a pair of lists, containing the pitches of @var{chord}, splitted at
a reference pitch.  The reference pitch is derived from @var{ref-pitch}.
If @var{ref-pitch} is empty, @code{c'} is regarded as reference.
  "
   (define ref-pitch-steps
 (if (and (pair? ref-pitch) (car ref-pitch))
 (ly:pitch-steps (car ref-pitch))
 0))

   (call-with-values
(lambda ()
  (partition
   (lambda (note)
 (> (ly:pitch-steps (ly:music-property note 'pitch))
ref-pitch-steps))
   (event-chord-notes chord)))
(lambda (x y) (cons x y

autoSplitChord =
#(define-music-function (stem-dir staff-names pitch chord)
   ((ly:dir? 0) (pair? '("up" . "down")) (ly:pitch?) ly:music?)
   (_i "Split @var{chord} at optional @var{pitch}.  The default of @var{pitch} is
@code{#f}, which is interpreted by the called procedure
@code{make-autosplit-chord} as @code{c'}.

The splitted chords are distributed to named staves, relying on optional
@var{staff-names}.

The optional @var{stem-dir}, determines the direction of the stems and whether
the chords may be connected by a cross-staff stem.
The default results in unconnected chords.
If the @code{Span_stem_engraver} is consisted, the chords may be connected by a
cross-staff stem.")
   (let* ((skip (make-duration-of-length (ly:music-length chord)))
  (devided-pitches (make-autosplit-chord chord pitch))
  (upper-chord
   (if (pair? (car devided-pitches))
   (make-event-chord (car devided-pitches))
   (make-skip-music skip)))
  (lower-chord
   (if (pair? (cdr devided-pitches))
   (make-event-chord (cdr devided-pitches))
   (make-skip-music skip
 #{
   <<
 \context Staff = #(car staff-names)
 \context Voice {
   $(if (negative? stem-dir)
#{
  \once \override Stem.cross-staff = #cross-staff-connect
  \once \override Flag.style = #'no-flag
  <>\noBeam
#})
   $(if (not (zero? stem-dir))
#{ \once \override Stem.direction = #stem-dir #})
   #upper-chord
 }

 \context Staff = #(cdr staff-names)
 \context Voice {
   $(if (positive? stem-dir)
#{
  \once \override Stem.cross-staff = #cross-staff-connect
  \once \override Flag.style = #'no-flag
  <>\noBeam
#})
   $(if (not (zero? stem-dir))
#{ \once \override Stem.direction = #st

split chord in two staves, split multiple voices in two staves

2021-01-07 Thread Davide Bonetti

Hi,

I am working on accordion left-hand educational scores;

I need to split chords (entered with chordmode) in two staves, and I 
also need to split multiple voices (4 or more) in two staves.


I am trying to find a way to do this automatically, because I have much 
material to work with.


I have tried \autochange, but the result is not what I am searching.

Attached is a minimal example, just to have an idea.

\version "2.20.0"

% autochange example with a chord
\markup "autochange example with a chord"
\score {
  \new PianoStaff
  \with {instrumentName = #"1"}
  \autochange
  \chordmode {c:/g}
}

% autochange example with multiple voices
\markup "autochange example with multiple voices"
\score {
  \new PianoStaff
  \with {instrumentName = #"2"}
  \autochange
  <<
    \autochange {e'}
    \\
    \autochange {g}
    \\
    \autochange {c'}
  >>
}

% desidered result
\markup "desidered result"
\score{
  \new PianoStaff
  \with {instrumentName = #"3"}
  \autochange
  <<
    \autochange 
    \\
    \autochange {g}
  >>
}

Thank you and best regards.

Davide Bonetti



--
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
\version "2.20.0"


% autochange example with a chord
\markup "autochange example with a chord"
\score {
  \new PianoStaff
  \with {instrumentName = #"1"}
  \autochange 
  \chordmode {c:/g}
}

% autochange example with multiple voices
\markup "autochange example with multiple voices"
\score {
  \new PianoStaff
  \with {instrumentName = #"2"}
  \autochange
  <<
\autochange {e'}
\\
\autochange {g}
\\
\autochange {c'}
  >>
}

% desidered result
\markup "desidered result"
\score{
  \new PianoStaff
  \with {instrumentName = #"3"}
  \autochange 
  <<
\autochange 
\\
\autochange {g}
  >>
}

autochange minimal example.pdf
Description: Adobe PDF document


Re: select a note in a chord

2019-01-29 Thread Davide Bonetti

Ok, now it works well!

D.

Il 28/01/2019 21:11, Valentin Villenave ha scritto:

On 1/28/19, Davide Bonetti  wrote:

It reminds me something that happens when a variable in lilypond is
called with $ instead of # , but in scheme I don't see this difference.
Could it be something like that?

Nope, it turned out to be a lot more idiotic: I was modifying the
'octavation property of some notes… then not taking that into account
when sorting the pitches. (And, as David noted, I was displacing the
pitches onto the notes without moving any articulations they might
have attached.)

Here’s the new updated function, now it sort of works!

#(define-public (move-chord-note n direction)
(_i "Transpose a note (numbered as @var{n}) by one octave in
@var{direction}.")
(lambda (music)
  (let* ((elts (ly:music-property music 'elements))
 (l (length elts))
 ;; if direction is up, count from the bottom note upward,
 ;; if direction is down, count from the top note downward.
 (count-from (cond ((= direction UP) (- n 1))
   ((= direction DOWN) (- l n
 ;; Notes may not have been entered from bottom to top;
 ;; extract the pitches and their possible octavation.
 (pitches (map
   (lambda (x)
 (let ((oct (ly:music-property x 'octavation))
   (p (ly:music-property x 'pitch)))
   (if (null? oct) p
   (ly:pitch-transpose p
 (ly:make-pitch oct 0 0)
   (filter
(lambda (y)
  (music-is-of-type? y 'note-event))
elts
(if (and (music-is-of-type? music 'event-chord)
 (not (zero? n)) (>= l n))
(begin
 ;; Sort the actual notes, depending on their pitch.
 (set! elts
   (sort elts
 (lambda (a b)
   (ly:pitch

---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: select a note in a chord

2019-01-28 Thread Davide Bonetti

Hi Valentin and everybody.

So, now the chord name is preserved when \dropNote or \raiseNote is 
applied once, but not when is applied twice or more.


It reminds me something that happens when a variable in lilypond is 
called with $ instead of # , but in scheme I don't see this difference.


Could it be something like that?

BTW I prefeer \riseNote instead of \raiseNote .

Regards

Davide

Il 23/01/2019 23:10, Valentin Villenave ha scritto:

On 1/19/19, Davide Bonetti  wrote:

For the sake of the discussion, I copy there the code as it now is:

Greetings Davide and everybody,
although these chord-transform functions were only intended for
written voicings (i.e. not ChordNames), David K. had a brilliant idea:
by setting the 'octavation property for every transposed pitch, we can
print the intended voicing *without* causing the chord to loose its
name.

Problem: the version I tried to modify (see below) works nicely for
primary \dropNote and \raiseNote commands, but when they’re nested
(e.g. with \invertChords) it gives erratic results. There’s obviously
something I missed; could anybody give it a try and tell me where it’s
going off the rails?

%

\version "2.21.0"

#(define-public (move-chord-note n direction)
(_i "Transpose a note (numbered as @var{n}) by one octave in
@var{direction}.")
(lambda (music)
  (let* ((elts (ly:music-property music 'elements))
 (l (length elts))
 ;; if direction is up, count from the bottom note upward,
 ;; if direction is down, count from the top note downward.
 (count-from (cond ((= direction UP) (- n 1))
   ((= direction DOWN) (- l n
 ;; Notes may not have been entered from bottom to top;
 ;; extract the pitches and put them in order.
 (pitches (map (lambda (x) (ly:music-property x 'pitch))
(filter
 (lambda (y)
   (music-is-of-type? y 'note-event))
 elts)))
 (sorted (sort pitches ly:pitch= l n))
(begin
 ;; first apply the sorted pitches
 ;; to the actual notes.
 (map (lambda (e p)
(ly:music-set-property! e 'pitch p))
   elts sorted)
 ;; then transpose the note up or
 ;; down, depending on direction.
 (let* ((note (list-ref elts count-from))
(oct (ly:music-property note 'octavation)))
   (list-set! elts count-from
 (ly:music-transpose note
   (ly:make-pitch
(cond
 ((= direction UP) +1)
 ((= direction DOWN) -1))
0)))
   (ly:music-set-property! note 'octavation
 (+ (cond
 ((= direction UP) 1)
 ((= direction DOWN) -1))
   (if (null? oct) 0 oct
 ))
music)))

dropNote =
#(define-music-function (parser location num music) (integer? ly:music?)
(_i "Drop a note of any chords in @var{music}, in @var{num}
position from above.")
(music-map (move-chord-note num down) music))

raiseNote =
#(define-music-function (parser location num music) (integer? ly:music?)
(_i "Raise a note of any chords in @var{music}, in @var{num}
position from below.")
(music-map (move-chord-note num up) music))

invertChords =
#(define-music-function (num music) (integer? ly:music?)
(_i "Invert any chords in @var{music} into their @var{num}-th position.
(Chord inversions may be directed downwards using negative integers.)")
(let loop ((num num) (music music))
  (cond ((zero? num) music)
((negative? num) (loop (1+ num) (dropNote 1 music)))
(else (loop (1- num) (raiseNote 1 music))


ac =
\chordmode {
   \dropNote 2 c:maj
   \raiseNote 1 d:m7
   \invertChords 2 e:m7
}

<<
   \chords { \ac }
   {
 <>^\markup \sans "(should be: C△, Dm7 and Em7)"
 \ac  \bar "||"
   }
%

Thanks!

V.


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: select a note in a chord

2019-01-19 Thread Davide Bonetti

For the sake of the discussion, I copy there the code as it now is:

(thanks to Valentin and David)

D.

%%

#(define-public (move-chord-note n direction)
   (_i "Transpose a note (numbered as @var{n}) by one octave in 
@var{direction}."

 )
   (lambda (music)
 (let* ((elts (ly:music-property music 'elements))
    (l (length elts))
    ;; if direction is up, count from the bottom note upward,
    ;; if direction is down, count from the top note downward.
    (count-from (cond ((= direction UP) (- n 1))
  ((= direction DOWN) (- l n
    ;; Notes may not have been entered from bottom to top;
    ;; extract the pitches and put them in order.
    (pitches (map (lambda (x) (ly:music-property x 'pitch))
   (filter
    (lambda (y)
  (music-is-of-type? y 'note-event))
    elts)))
    (sorted (sort pitches ly:pitch= l n))
   (begin
    ;; first apply the sorted pitches
    ;; to the actual notes.
    (map (lambda (e p)
   (ly:music-set-property! e 'pitch p))
  elts sorted)
    ;; then transpose the note up or
    ;; down, depending on direction.
    (list-set! elts count-from
  (ly:music-transpose
   (list-ref elts count-from)
   (ly:make-pitch
    (cond
 ((= direction UP) +1)
 ((= direction DOWN) -1))
    0)
   music)))

%% drop a note of a chord, in num position from above
dropNote =
#(define-music-function (parser location num music) (integer? ly:music?)
   (_i "Drop a note of any chords in @var{music}, in @var{num} position 
from abo

  ve.")
   (music-map (move-chord-note num down) music))

%% rise a note of a chord, in num position from below
riseNote =
#(define-music-function (parser location num music) (integer? ly:music?)
   (_i "Rise a note of any chords in @var{music}, in @var{num} position 
from bel

  ow.")
   (music-map (move-chord-note num up) music))

%% invert chords
invertChords =
#(define-music-function (num music) (integer? ly:music?)
   (_i "Invert any chords in @var{music} into their @var{num}-th position.
       (Chord inversions may be directed downwards using negative 
integers.)")

   (let loop ((num num) (music music))
 (cond ((zero? num) music)
   ((negative? num) (loop (1+ num) (dropNote 1 music)))
   (else (loop (1- num) (riseNote 1 music))


ac = \relative c' {2  \chordmode {c:maj es:6}}

{
  <>^\markup "chords"
  \ac
  \bar "||"
  <>^\markup "drop 2"
  \dropNote 2 \ac
  \bar "||"
  <>^\markup "drop 4"
  \dropNote 4 \ac
  \bar "||"
  <>^\markup "drop 2 and 4"
  \dropNote 2 \dropNote 4 \ac
  \bar "||"
  <>^\markup "rise 1"
  \riseNote 1 \ac
  \bar "||"
  <>^\markup "rise 3"
  \riseNote 3 \ac
  \bar "||"
  <>^\markup "2nd inversion"
  \invertChords 2 \ac
  \bar "||"
  <>^\markup "\"down\" inversion"
  \invertChords -1 \ac
  \bar "||"
}

%


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: select a note in a chord

2019-01-19 Thread Davide Bonetti

Il 19/01/2019 08:36, Valentin Villenave ha scritto:

On 1/18/19, David Kastrup  wrote:

Music functions share the same namespace as all other Scheme functions
and variables

OK, perhaps a better name would be \dropNote then (much like \hideNotes etc.).

Good choice.

Anyway, I like these functions (thanks to both of you guys) and I
wonder if they could be made part of the default distribution?

I like them too, and many thanks to you and David.

D.


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: select a note in a chord

2019-01-18 Thread Davide Bonetti
Great!
Everything very interesting.
In this case, drop is a lilypond music function, so I assume it will not 
interfere with slri (but I don't know what slri is) 

Cheers
D. 



Il 18 gennaio 2019 01:21:31 CET, David Kastrup  ha scritto:
>David Kastrup  writes:
>
>> Valentin Villenave  writes:
>>
>>> On 1/18/19, David Kastrup  wrote:
 This is not really an issue for string-manipulation.
>>>
>>> Agreed. Nevertheless, I was pleasantly surprised to see that
>>> ly:parser-include-string could accept an incomplete expression.
>>> (Previously, ly:parser-parse-string would have been much less
>flexible
>>> here.)
>>>
 Let's rather do this in a sane manner:
>>>
>>> Indeed, a named "let" loop is clearly the preferred way to go!
>>>
>>> That being said, I still wonder if there’d be any way of making it
>>> work with either iota or make-list without having to go through
>string
>>> manipulations. (It would remove the need for a loop with an
>>> incremented counter.)
>>
>> You can use something like
>> (fold (if (negative? num) drop rise)
>>   music
>>   (make-list (abs num) 1))
>>
>> but I don't like creating lists for the sake of controlling loop
>size.
>
>By the way: `drop' is a function imported from (slri slri-1) and it's
>probably not a good idea to redefine it.
>
>-- 
>David Kastrup

-- 
Inviato dal mio dispositivo Android con K-9 Mail. Perdonate la brevità.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: select a note in a chord

2019-01-17 Thread Davide Bonetti

I worked on your example, and here is the result.

The "\drop n" function drop the nth note from above, an can be nested 
(to do drop 2 drop 4)


The funcion "\rise n" function rise the nth note from below, an can be 
nested too


The "\inversion n" function do the inversions of the chord.

I'm sure there is a better way to write the inversion function, but I 
haven't find a way to program the repetition of a function in scheme.


%


#(define (move-a-note n direction)
   (lambda (music)
 (let* ((elts (ly:music-property music 'elements))
    (l (length elts))
    ;; if the direction is up, we count from the bottom note 
upward,
    ;; if the direction is down, we count from the top note 
downward

    (count-from (cond ((= direction up) (- n 1))
  ((= direction down) (- l n
    ;; The user may not have entered the notes
    ;; from the lowest to the uppermost;
    ;; let’s extract the pitches…
    (pitches (map (lambda (x) (ly:music-property x 'pitch))
   (filter
    (lambda (y)
  (music-is-of-type? y 'note-event))
    elts)))
    ;; … and put them in order.
    (sorted (sort pitches ly:pitch= l n))
   (begin
    ;; first apply the sorted pitches
    ;; to the actual notes.
    (map
 (lambda (e p)
   (ly:music-set-property! e 'pitch p))
 elts sorted)
    ;; then transpose the specified note
    (list-set! elts count-from
  (ly:music-transpose
   (list-ref elts count-from)
   (ly:make-pitch (cond
   ;; transpose the note up or down,
   ;;depending on direction
   ((= direction up) +1)
   ((= direction down) -1)) 0)
   music)))

%% drop a note of a chord, in num position from above
drop =
#(define-music-function (parser location num music) (integer? ly:music?)
   #{ \musicMap #(move-a-note num down) $music #})

%% rise a note of a chord, in num position from below
rise =
#(define-music-function (parser location num music) (integer? ly:music?)
   #{ \musicMap #(move-a-note num up) $music #})

inversion =
#(define-music-function (parser location num music) (integer? ly:music?)
   (cond ((= num 1) #{ \rise 1 $music #})
 ((= num 2) #{ \rise 1 \rise 1 $music #})
 ((= num 3) #{ \rise 1 \rise 1 \rise 1 $music #})
 ((= num 4) #{ \rise 1 \rise 1 \rise 1 \rise 1 $music #})
 ((= num 5) #{ \rise 1 \rise 1 \rise 1 \rise 1 \rise 1 $music #})
 ((= num 6) #{ \rise 1 \rise 1 \rise 1 \rise 1 \rise 1 \rise 1 
$music #})

 ((= num -1) #{ \drop 1 $music #})
 ((= num -2) #{ \drop 1 \drop 1 $music #})
 ((= num -3) #{ \drop 1 \drop 1 \drop 1 $music #})
 ((= num -4) #{ \drop 1 \drop 1 \drop 1 \drop 1 $music #})
 ((= num -5) #{ \drop 1 \drop 1 \drop 1 \drop 1 \drop 1 $music #})
 ((= num -6) #{ \drop 1 \drop 1 \drop 1 \drop 1 \drop 1 \drop 1 
$music #})

 (else #{ $music #})
 ))


ac = \relative c' {2  \chordmode {c:maj es:6}}

{
  <>^\markup "chords"
  \ac
  \bar "||"
  <>^\markup "drop 2"
  \drop 2 \ac
  \bar "||"
  <>^\markup "drop 4"
  \drop 4 \ac
  \bar "||"
  <>^\markup "drop 2 and 4"
  \drop 2 \drop 4 \ac
  \bar "||"
  <>^\markup "rise 1"
  \rise 1 \ac
  \bar "||"
  <>^\markup "rise 3"
  \rise 3 \ac
  \bar "||"
  <>^\markup "2nd inversion"
  \inversion 2 \ac
  \bar "||"
  <>^\markup "\"down\" inversion"
  \inversion -1 \ac
  \bar "||"
}

%

Cheers.
Davide

Il 16/01/2019 00:15, David Kastrup ha scritto:

Valentin Villenave  writes:


On 1/15/19, Davide Bonetti  wrote:

I modified
 (if (and (music-is-of-type? music 'event-chord)
  (> l n))
with
 (if (and (music-is-of-type? music 'event-chord)
  (>= l n))

Nice catch! I’ve updated the snippet as well.

Additionally, beware that the LSR version uses
#(define-music-function (parser location music)
whereas the syntax for LilyPond 2.19 would be
#(define-music-function (music)

Not much to beware here since convert-ly knows its way around this and
2.19 will do argument counting in order to provide backwards
compatibility.




---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus

#(define (move-a-note n direction)
   (lambda (music)
 (let* ((elts (ly:music-property music 'elements))
(l (length elts

Re: select a note in a chord

2019-01-15 Thread Davide Bonetti

Hello!

Il 15/01/2019 11:46, Davide Bonetti ha scritto:
But I noticed that it doesn't work on the lowest pitch of a chord 
(drop 4 on a four note chord, drop 3 on a three note chord)



I modified

   (if (and (music-is-of-type? music 'event-chord)
    (> l n))

with

   (if (and (music-is-of-type? music 'event-chord)
    (>= l n))

and now it works even on the lowest pitch.

Here the complete code:

%%

#(define (drop-n n)

   (lambda (music)
 (let* ((elts (ly:music-property music 'elements))
    (l (length elts))
    ;; The user may not have entered the notes
    ;; from the lowest to the uppermost;
    ;; let’s extract the pitches…
    (pitches (map (lambda (x) (ly:music-property x 'pitch))
   (filter
    (lambda (y)
  (music-is-of-type? y 'note-event))
    elts)))
    ;; … and put them in order.
    (sorted (sort pitches ly:pitch= l n))
   (begin
    ;; first apply the sorted pitches
    ;; to the actual notes.
    (map
 (lambda (e p)
   (ly:music-set-property! e 'pitch p))
 elts sorted)
    ;; then transpose the specified note
    ;; (strangely, jazzmen tend to
    ;; count from the top note downward).
    (list-set! elts (- l n)
  (ly:music-transpose
   (list-ref elts (- l n))
   (ly:make-pitch -1 0)

   music)))

%

cheers

Davide


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: select a note in a chord

2019-01-15 Thread Davide Bonetti

Now it sorts the pitches too!

It can be easily converted to transpose a pitch an octave up changing 
(ly:make-pitch -1 0) to (ly:make-pitch +1 0)


But I noticed that it doesn't work on the lowest pitch of a chord (drop 
4 on a four note chord, drop 3 on a three note chord)


Cheers

Davide

Il 15/01/2019 10:35, Valentin Villenave ha scritto:

On 1/15/19, Valentin Villenave  wrote:

(It would be possible to first re-order the notes
automatically and then apply the transformation, but I’m too lazy to
add it right now :-)

OK, here’s an improved version:
http://lsr.di.unimi.it/LSR/Item?id=1082

Cheers,
V.


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


select a note in a chord

2019-01-14 Thread Davide Bonetti

Hello everyone.

I'm looking for a function to select a note in a chord.

This can be useful for automatic inversions, or to change the voicing 
(like the drop 2 in a four note chord).


Cheers.

Davide


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: note collision when in a chord there is a second above or below an unison

2019-01-13 Thread Davide Bonetti

Il 13/01/2019 00:46, Carl Sorensen ha scritto:


I think that Lilypond does the right thing.


Thank you for your opinion, but I think a collision is not a right thing.


There should never be a unison and a second in a chord.


I know that is not a very common situation. I'll show you two examples.

The notes of the Dsus4 chord on a ukulele are, in absolute notation:  g' 
d' g' a'


The resulting chord is:  ; as you can see, is a chord with 
a second above an unison.


The Ebsus4 chord has the following notes: as' es' as' bes' ; a second 
above an unison, both with accidentals.


In the cluster of whole notes without a stem, it seems harmless enough 
to move the notehead.  But if this same chord had a stem (e.g., 
half-note or shorter), you’d see that moving the notehead away to 
eliminate the collision also takes it away from the stem, which is 
musically wrong.


To properly show the notes in your example in a half-note chord, you 
will need two stems, which means you need two voices.  And if it is 
needed for half notes, it is also needed for whole notes, at least in 
my opinion.



Take a look at this examples, in the snippets:

http://lilypond.org/doc/v2.18/Documentation/snippets/simultaneous-notes#simultaneous-notes-displaying-complex-chords

To get what you want, you can manually move the note head with its 
associated accidentals.  I believe that is the proper approach, since 
it is inconsistent with standard engraving techniques.


Yes, I have found the solution for now, moving the note head and its 
associated accidentals.


I'd like however to know where in the code is the placement of the note 
in a chord, just to experiment.


regards

Davide


Sincerely,

Carl




---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: note collision when in a chord there is a second above or below an unison

2019-01-13 Thread Davide Bonetti

Hi Paolo,

your solution works but generates collision between the sharp and the 
time signature :)


I tried this:

\score {
  {
    1
  }
}

and there is no collision with time signature.

However, if the chord is  my code doesn't work well 
again.


I think that there is not an easy solution that fits all.

Thank you again, I learned something about \tweak and about extra-offset.

Cheers

Davide


Il 12/01/2019 23:22, Paolo Cantamessa ha scritto:

Hi David,
maybe this solution works but it is not really professional:

\score {
  {
    \once \override Accidental.extra-offset = #'(-1.5 . 0)
      1
  }
}

Good luck.

Paolo

Il sab 12 gen 2019, 22:00 Davide Bonetti <mailto:d...@davidebonetti.it>> ha scritto:


Thank you Paolo,

it works well for whole note without alteration.

If the note is altered, however, there is a collision with the
alteration, as you can see with this code:

\score {
   1
}

Do you (or someone else) know where in the source code is handled
the position of the notes in a chord?

Cheers

Davide

Il 09/01/2019 13:18, Paolo Cantamessa ha scritto:


Hi Davide,
try this:
\score {
   1
}

Bye.

Paolo



Mailtrack

<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;>
Sender notified by
Mailtrack

<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;>
09/01/19, 13:18:35  


    Il giorno mer 9 gen 2019 alle ore 12:43 Davide Bonetti
mailto:d...@davidebonetti.it>> ha scritto:

Hi Malte,

The output could be like in the attached image. I obtained it in
Musescore, manually moving the notes.

Cheers.

Davide

Il 08/01/2019 08:15, Malte Meyn ha scritto:
> Hi Davide,
>
> please tell us what output you expected.
Am 06.01.19 um 18:41 schrieb Malte Meyn:
>> Long answer: You can do almost anything in LilyPond. In
your case you
>> could try changing the output (f. e. extra-offset) or the
inpult (f.
>> e. use multiple voices). But you have to know what the
output should
>> look like. LilyPond cannot guess that ;)
>


---
Questa e-mail è stata controllata per individuare virus con
Avast antivirus.
https://www.avast.com/antivirus
___
lilypond-user mailing list
lilypond-user@gnu.org <mailto:lilypond-user@gnu.org>
https://lists.gnu.org/mailman/listinfo/lilypond-user




<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
Mail priva di virus. www.avast.com

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>


<#m_3208058608710158921_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>




---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: note collision when in a chord there is a second above or below an unison

2019-01-12 Thread Davide Bonetti

Thank you Paolo,

it works well for whole note without alteration.

If the note is altered, however, there is a collision with the 
alteration, as you can see with this code:


\score {
   1
}

Do you (or someone else) know where in the source code is handled the 
position of the notes in a chord?


Cheers

Davide

Il 09/01/2019 13:18, Paolo Cantamessa ha scritto:


Hi Davide,
try this:
\score {
   1
}

Bye.

Paolo



Mailtrack 
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;> 
	Sender notified by
Mailtrack 
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;> 
09/01/19, 13:18:35 	



Il giorno mer 9 gen 2019 alle ore 12:43 Davide Bonetti 
mailto:d...@davidebonetti.it>> ha scritto:


Hi Malte,

The output could be like in the attached image. I obtained it in
Musescore, manually moving the notes.

Cheers.

Davide

Il 08/01/2019 08:15, Malte Meyn ha scritto:
> Hi Davide,
>
> please tell us what output you expected.
Am 06.01.19 um 18:41 schrieb Malte Meyn:
>> Long answer: You can do almost anything in LilyPond. In your
case you
>> could try changing the output (f. e. extra-offset) or the
inpult (f.
>> e. use multiple voices). But you have to know what the output
should
>> look like. LilyPond cannot guess that ;)
>


---
Questa e-mail è stata controllata per individuare virus con Avast
antivirus.
https://www.avast.com/antivirus
___
lilypond-user mailing list
lilypond-user@gnu.org <mailto:lilypond-user@gnu.org>
https://lists.gnu.org/mailman/listinfo/lilypond-user




---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: note collision when in a chord there is a second above or below an unison

2019-01-09 Thread Davide Bonetti

Hi Malte,

The output could be like in the attached image. I obtained it in
Musescore, manually moving the notes.

Cheers.

Davide

Il 08/01/2019 08:15, Malte Meyn ha scritto:

Hi Davide,

please tell us what output you expected.

Am 06.01.19 um 18:41 schrieb Malte Meyn:

Long answer: You can do almost anything in LilyPond. In your case you
could try changing the output (f. e. extra-offset) or the inpult (f.
e. use multiple voices). But you have to know what the output should
look like. LilyPond cannot guess that ;)





---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


note collision when in a chord there is a second above or below an unison

2019-01-06 Thread Davide Bonetti

Hello everyone!

Is there a way to avoid the note collision that appears in this example?

\score {
  1
}

thanks.

Davide


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user