Re: Extracting pitch of first note, then assign duration

2021-03-08 Thread Matthew Fong
Hello Silvain,

That's super interesting -- thank you for your link. I will take time to
read through your code. When I have access to a piano sometime, I think
Bach will certainly make the list.


Many thanks,
mattfong


Re: Extracting pitch of first note, then assign duration

2021-03-08 Thread David Kastrup
Silvain Dupertuis  writes:

> Hello everyone,
>
> You might find some hints in a piece I have done lately:
> a score of  J.S. Bach's
> Well-Tempered
> Clavier Praeludium I
> Where I wrote functions to create the score programmatically

Personally, I prefer synthesizing rather than analyzing music.  In
particular, it makes it easy to explicitly code exceptions.  Check out
the second example in input/regression/make-relative.ly for a sketch.
It includes all the exceptions for the prelude, and you can easily
copy much of your note entry to provide the rest.  I probably have
it somewhere in complete form on disk, too.

-- 
David Kastrup



Re: Extracting pitch of first note, then assign duration

2021-03-07 Thread Silvain Dupertuis

Hello everyone,

You might find some hints in a piece I have done lately:
a score of  J.S. Bach's 
Well-Tempered Clavier 
Praeludium I

Where I wrote functions to create the score programmatically

(like extract groups of five notes, create patterns, manipulating durations,
no extraction of pitch in this example, but it is the same principle to 
manipulate a note,
pitch being defined by its position in an octave and the octave)

You might have to treat your note as a sequence to manipulate its pitch,,,

You can find here 
 
description of musical properties as scheme expressions


Sincerely
Silvain


Le 07.03.21 à 20:03, Matthew Fong a écrit :

Hello everyone,

I am in the process of writing a note replacement function that allows me to place a 
custos anywhere I might need.


I am stuck on writing a function that extracts the pitch of the first note, given a list 
of notes, and then forcing a duration of 1/4. Any pointers would be appreciated.


For example given the list of notes below, I would like a function to output c4.
{
  \clef treble
  c2 d e f
  g4 a b c
}


Many thanks,
mattfong



--
Silvain Dupertuis
Route de Lausanne 335
1293 Bellevue (Switzerland)
tél. +41-(0)22-774.20.67
portable +41-(0)79-604.87.52
web: silvain-dupertuis.org 


Re: Extracting pitch of first note, then assign duration

2021-03-07 Thread Matthew Fong
Hello Lucas,

Yes, this works perfectly. I did not know *first* existed!

I stole the example from
https://lilypond.org/doc/v2.20/Documentation/notation/substitution-function-examples

However, I still need to find a way to automagically manage the stem
direction of the custos, since the notes may be transposed. This method
below assigns a glyph manually.

addCustos =
#(define-music-function (noteList)
(ly:music?)
#{
\tweak NoteHead.stencil #ly:text-interface::print
\tweak NoteHead.font-size #3
\tweak NoteHead.text \markup {
\musicglyph "custodes.vaticana.u2"
}
\tweak Stem.stencil ##f
$(first (music-pitches noteList)) 4
#}
)

Many thanks,
mattfong

On Sun, Mar 7, 2021 at 11:54 AM Lukas-Fabian Moser  wrote:

> Hi Matthew,
>
> Am 07.03.21 um 20:03 schrieb Matthew Fong:
> > I am in the process of writing a note replacement function that allows
> > me to place a custos anywhere I might need.
> >
> > I am stuck on writing a function that extracts the pitch of the first
> > note, given a list of notes, and then forcing a duration of 1/4. Any
> > pointers would be appreciated.
> >
> > For example given the list of notes below, I would like a function to
> > output c4.
> > {
> >   \clef treble
> >   c2 d e f
> >   g4 a b c
> > }
> >
> Something like this?
>
> \version "2.22.0"
>
> test = \relative c' {
>\clef treble
>c2 d e f
>g4 a b c
> }
>
> firstnote =
> #(define-music-function (mus dur) (ly:music? ly:duration?)
> #{ $(first (music-pitches test)) $dur #})
>
> \score {
>\firstnote \test 8
> }
>
> Lukas
>
>


Re: Extracting pitch of first note, then assign duration

2021-03-07 Thread Lukas-Fabian Moser

Hi Matthew,

Am 07.03.21 um 20:03 schrieb Matthew Fong:
I am in the process of writing a note replacement function that allows 
me to place a custos anywhere I might need.


I am stuck on writing a function that extracts the pitch of the first 
note, given a list of notes, and then forcing a duration of 1/4. Any 
pointers would be appreciated.


For example given the list of notes below, I would like a function to 
output c4.

{
  \clef treble
  c2 d e f
  g4 a b c
}


Something like this?

\version "2.22.0"

test = \relative c' {
  \clef treble
  c2 d e f
  g4 a b c
}

firstnote =
#(define-music-function (mus dur) (ly:music? ly:duration?)
   #{ $(first (music-pitches test)) $dur #})

\score {
  \firstnote \test 8
}

Lukas




Extracting pitch of first note, then assign duration

2021-03-07 Thread Matthew Fong
Hello everyone,

I am in the process of writing a note replacement function that allows me
to place a custos anywhere I might need.

I am stuck on writing a function that extracts the pitch of the first note,
given a list of notes, and then forcing a duration of 1/4. Any pointers
would be appreciated.

For example given the list of notes below, I would like a function to
output c4.
{
  \clef treble
  c2 d e f
  g4 a b c
}


Many thanks,
mattfong