lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fw: définition d'un nouveau contexte


From: Germain G. Ivanoff-Trinadtzaty
Subject: Re: Fw: définition d'un nouveau contexte
Date: Fri, 13 Jun 2008 21:03:02 +0200


----- Original Message ----- From: "Mats Bengtsson" <address@hidden>
To: "Germain G. Ivanoff-Trinadtzaty" <address@hidden>
Cc: "Lilypond users" <address@hidden>
Sent: Friday, June 13, 2008 11:38 AM
Subject: Re: Fw: définition d'un nouveau contexte


Germain G. Ivanoff-Trinadtzaty wrote:
Hello,
 I've got two problems defining a new context \StaffSA, based on \Staff.

Your code below defines a new context type StaffSA which does not contain any engravers and it's not based on the Staff context type (the description in the manual of what \alias does is very simplified and it seems that you have misinterpreted it).


Indeed.


Unfortunately, there is no good explanation anywhere in the manual on how to make a new context type based on an existing one. However, you can find some examples in the mailing list archives, for example http://lists.gnu.org/archive/html/lilypond-user/2008-02/msg00837.html I also recommend you to take a look at the file ly/engraver-init.ly, where all the default contexts are defined. For example, if you look at the definition of
the PianoStaff context, you will see how to base a new context definition
on an already existing one.



Thank you very much. It's great to get such pedagogic links, rather than a simple answer. ly/engraver-init.ly teaches me a lot. I usually give up browsing LP files before finding what i need. I'm about to install a grep command on my win laptop, cause the integrated windows search certainly does search my files, but does not find anything... I also found this thread on lilypond-user : "Tip: defing new contexts ... starting from existing contexts"
http://lists.gnu.org/archive/html/lilypond-user/2007-07/msg00526.html
which I should have checked first.

So, adding \Staff (as a template) in the begining of my new context definition, I ensure that it inherits all engravers and settings from the template. But I still don't see what commands get permitted by \alias. I'll use it it, of course, but I remain somewhat hungry.



What is it really that you try to obtain? What should the new context type do that
Staff doesn't?

  /Mats



In this very first attempt, I only want to integrate voice names in the staff definition (\StaffSA stands for \StaffSopranoAlto). As a matter of fact, I put together many little SA-TB scores, and I want to save some typing and get smaller, smarter \score blocks. In the future, I want to define a new type of staff, for the so called Kievian notation (used from 17-18 centuries to translate the old neumatic chants). It looks a little like gregorian music. It will involve new scale, new glyphs, bars, etc... Not for today.

Germain



I followed instruction from NR 6.2.5 Defining new contexts.
http://lilypond.org/doc/v2.11/Documentation/user/lilypond/Defining-new-contexts#Defining-new-contexts
 With the definitions that follow :
1) I get two staves for one  \new \StaffSA
2) their instrumentName don't print
 What's wrong ?
 Thanks,
Germain
 ps: btw, are de sharps (#) well suited ? (i mean : in the right place ?)
 at : "test-newcontext.png"
 %% Test de définition d'un nouveau contexte
 \version "2.11.47"
\include "english.ly"
 Global = { \key f \major }
NotesDiscantus = { a'4 a'1 }
NotesCantus =  { f'4 f'1 }
NotesFiller =  { c'4 c'1 }
NotesBassus =  { f4 f1 }
Words = \lyricmode { Ta __ daa }
 %---------------%
StaffVoiceNames =  %% for Staff context
#(define-music-function  (parser location n-max-width s-one s-two)
                         (number? string? string?)
  "Format and print voice names for one staff"
  #{
   \set Staff . instrumentName = \markup { \column {
            \hcenter-in #$n-max-width $s-one
            \hcenter-in #$n-max-width $s-two } }
  #})
%---------------%
StaffSAVoiceNames =  %% same as above, but for StaffSA context
#(define-music-function  (parser location n-max-width s-one s-two)
                         (number? string? string?)
  "Format and print voice names for one staff"
  #{
   \set StaffSA . instrumentName = \markup { \column {
            \hcenter-in #$n-max-width $s-one
            \hcenter-in #$n-max-width $s-two } }
  #})
%---------------%
\layout % commun
{
 \context { \Score
            \remove  Bar_number_engraver }
 \context { \ChoirStaff  %% si placé après déf. de StaffSA : idem
            \consists Instrument_name_engraver
            \override InstrumentName #'self-alignment-X = #LEFT
            \accepts  StaffSA }
 \context { \Staff
            \remove   Time_signature_engraver
            \override InstrumentName #'self-alignment-X = #RIGHT }
 \context { \name  StaffSA
            \type  "Engraver_group"
            \alias Staff }
}
%---------------%
\score % 1
{
 \new ChoirStaff
 <<
  \set ChoirStaff . instrumentName = "N°1 Strange behaviour :"
  \new StaffSA
  <<
   \StaffSAVoiceNames #3 #"S." #"A."  %% ne donne rien
%   \StaffVoiceNames #3 #"S." #"A."    %% ne marche pas non plus
   \clef "G" \Global
   \new Voice = "one" { \voiceOne \NotesDiscantus }
   \new Voice         { \voiceTwo \NotesCantus }
  >>
 \new Lyrics = thewords { s }
 \new Staff
  <<
   \StaffVoiceNames #3 #"T." #"B." \clef "F" \Global
   \new Voice { \voiceOne \NotesFiller }
   \new Voice { \voiceTwo \NotesBassus }
  >>
 \context Lyrics = thewords \lyricsto "one" { \Words }
 >>
 \layout { indent = 65\mm }
}

------------------------------------------------------------------------

------------------------------------------------------------------------

_______________________________________________
lilypond-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/lilypond-user


--
=============================================
Mats Bengtsson
Signal Processing
School of Electrical Engineering
Royal Institute of Technology (KTH)
SE-100 44  STOCKHOLM
Sweden
Phone: (+46) 8 790 8463 Fax:   (+46) 8 790 7260
Email: address@hidden
WWW: http://www.s3.kth.se/~mabe
=============================================






reply via email to

[Prev in Thread] Current Thread [Next in Thread]