Re: Custom drum noteHead in define expression

2018-04-03 Thread Karim Haddad
Dear Thomas,

Thank you a lot. It is exactly what i was looking for and apparently no need 
for adjustment in your example. All fits well.
However will try to learn how to fix the notehead position in the case i will 
use other glyphs.

Thank you a lot

Best
K

On Wed, Apr 04, 2018 at 02:39:58AM +0200, Thomas Morley wrote:
> 2018-04-03 18:25 GMT+02:00 Karim Haddad :
> 
> > And thanx also for your snippet. I have already tried it and works 
> > marvelously.
> > But concerning customizing new note heads i think checking the code itself 
> > seems necessary.
> > Do you know if define-grobs.scm is a good place to start with ?
> 
> Well, some scheme-knowledge is needed.
> There is a scheme-tutorial in the docs. Several guile tutorials out
> there, as well as the guile manual.
> Best general training is reading this list, though, trying to
> understand the requests and trying to solve them.
> If you read someones code, try to understand what happens and why, can
> it be improved and ...
> 
> The Extending Manual is not bad as well.
> I remember as a starter I did several exercises, defining several
> custom-markup-command, markup-list-commands, substitution functions
> etc etc
> Homework, like a decade ago, but I'm still learning ;)
> 
> If you try to solve an own problem searching the archives is always a
> good starting point.
> 
> 
> 
> On topic.
> There's something annoying happening while using custom-styles. I just
> wrote a bug-report about it:
> http://lilypond.1069038.n5.nabble.com/custom-style-custom-stencil-combination-returns-warning-tt211374.html
> 
> So with the workaround, in the bug-report as well you could do:
> 
> \version "2.19.81"
> 
> #(define mydrums '(
>  (bassdrummyStyle   #f   -1)
>  (snare   myStyleII   #f   0)
>  (hihat   cross #f   1)
>  (halfopenhihat   cross "halfopen"   1)
>  (pedalhihat  xcircle   "stopped"2)
>  (lowtom  diamond   #f   3)))
> 
> #(define stencil-for-my-style
>   (lambda (grob)
> (cond
>   ((eq? 'myStyle (ly:grob-property grob 'style))
> (begin
>   (ly:grob-set-property! grob 'style '())
>   (grob-interpret-markup grob
> #{
>   \markup \vcenter \musicglyph #"pedal.*"
> #})))
>   ((eq? 'myStyleII (ly:grob-property grob 'style))
> (begin
>   (ly:grob-set-property! grob 'style '())
>   (grob-interpret-markup grob
> #{
> %% from http://lsr.di.unimi.it/LSR/Item?id=515
> %% slightly changed
>\markup \vcenter \scale #'(0.4 . 0.4) {
>\combine
>  \translate #(cons -1.25 0) \combine
>\draw-circle #0.65 #0 ##t
>\override #'(thickness . 2.5) \draw-line #'(3 . -3)
>  \translate #(cons 1.25 0) \combine
>\draw-circle #0.65 #0 ##t
>\override #'(thickness . 2.5) \draw-line #'(-3 . -3)
>  }
> #})))
>   (else (ly:note-head::print grob)
> 
> \new DrumStaff
>   \with {
> drumStyleTable = #(alist->hash-table mydrums)
> \override NoteHead.stencil = #stencil-for-my-style
>   }
>   \drummode {
> bd8
> sn
> hh
> hhho
> hhp
> toml
>   }
> 
> You may want to adjust stem-attachment.
> I leave it as an exercise ;)
> 
> 
> HTH,
>   Harm

-- 
Karim Haddad


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


Re: Custom drum noteHead in define expression

2018-04-03 Thread Thomas Morley
2018-04-03 18:25 GMT+02:00 Karim Haddad :

> And thanx also for your snippet. I have already tried it and works 
> marvelously.
> But concerning customizing new note heads i think checking the code itself 
> seems necessary.
> Do you know if define-grobs.scm is a good place to start with ?

Well, some scheme-knowledge is needed.
There is a scheme-tutorial in the docs. Several guile tutorials out
there, as well as the guile manual.
Best general training is reading this list, though, trying to
understand the requests and trying to solve them.
If you read someones code, try to understand what happens and why, can
it be improved and ...

The Extending Manual is not bad as well.
I remember as a starter I did several exercises, defining several
custom-markup-command, markup-list-commands, substitution functions
etc etc
Homework, like a decade ago, but I'm still learning ;)

If you try to solve an own problem searching the archives is always a
good starting point.



On topic.
There's something annoying happening while using custom-styles. I just
wrote a bug-report about it:
http://lilypond.1069038.n5.nabble.com/custom-style-custom-stencil-combination-returns-warning-tt211374.html

So with the workaround, in the bug-report as well you could do:

\version "2.19.81"

#(define mydrums '(
 (bassdrummyStyle   #f   -1)
 (snare   myStyleII   #f   0)
 (hihat   cross #f   1)
 (halfopenhihat   cross "halfopen"   1)
 (pedalhihat  xcircle   "stopped"2)
 (lowtom  diamond   #f   3)))

#(define stencil-for-my-style
  (lambda (grob)
(cond
  ((eq? 'myStyle (ly:grob-property grob 'style))
(begin
  (ly:grob-set-property! grob 'style '())
  (grob-interpret-markup grob
#{
  \markup \vcenter \musicglyph #"pedal.*"
#})))
  ((eq? 'myStyleII (ly:grob-property grob 'style))
(begin
  (ly:grob-set-property! grob 'style '())
  (grob-interpret-markup grob
#{
%% from http://lsr.di.unimi.it/LSR/Item?id=515
%% slightly changed
   \markup \vcenter \scale #'(0.4 . 0.4) {
   \combine
 \translate #(cons -1.25 0) \combine
   \draw-circle #0.65 #0 ##t
   \override #'(thickness . 2.5) \draw-line #'(3 . -3)
 \translate #(cons 1.25 0) \combine
   \draw-circle #0.65 #0 ##t
   \override #'(thickness . 2.5) \draw-line #'(-3 . -3)
 }
#})))
  (else (ly:note-head::print grob)

\new DrumStaff
  \with {
drumStyleTable = #(alist->hash-table mydrums)
\override NoteHead.stencil = #stencil-for-my-style
  }
  \drummode {
bd8
sn
hh
hhho
hhp
toml
  }

You may want to adjust stem-attachment.
I leave it as an exercise ;)


HTH,
  Harm

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


Re: Custom drum noteHead in define expression

2018-04-03 Thread Karim Haddad
Thanx Thomas,


And thanx also for your snippet. I have already tried it and works marvelously.
But concerning customizing new note heads i think checking the code itself 
seems necessary.
Do you know if define-grobs.scm is a good place to start with ?


Thx again
K

On Tue, Apr 03, 2018 at 03:26:55PM +0200, Thomas Morley wrote:
> 2018-04-03 2:25 GMT+02:00 Karim Haddad :
> > Hi,
> >
> >
> > Just trying to figure out if this is possible :
> >
> > When defining  a drum instrument with this expression:
> >
> >
> > #(define mydrums '(
> >  (bassdrumdefault   #f   -1)
> >  (snare   default   #f   0)
> >  (hihat   cross #f   1)
> >  (halfopenhihat   cross "halfopen"   1)
> >  (pedalhihat  xcircle   "stopped"2)
> >  (lowtom  diamond   #f   3)))
> >
> > Is there a way to define a very custom notehead in the 2nd argumrnt of the 
> > list such as any other glyph not being a notehead, like per example a pedal 
> > glyph (pedal.*)
> > or any other glyph or even eps ?
> >
> > I have searched (maybe not too thouroughly) trying to figure this out. Any 
> > help or idea will be just great. this will prevent me to use an override 
> > NoteHead.stencil tweak for every note.
> >
> > Best
> >
> > --
> > Karim Haddad
> 
> Hi,
> 
> in
> http://lsr.di.unimi.it/LSR/Item?id=1033
> I tried to explain thoroughly how to customize drums-appearance.
> Probably some general help...
> 
> It should be clear then that the list-argument in question is a 
> note-head-style.
> Ofcourse only estabished styles will work.
> 
> Not sure if it might possible to define a custom style and let the
> stencil-procedure rely on it.
> (And not the time yet to try.)
> 
> 
> Cheers,
>   Harm

-- 
Karim Haddad



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


Re: Custom drum noteHead in define expression

2018-04-03 Thread Thomas Morley
2018-04-03 2:25 GMT+02:00 Karim Haddad :
> Hi,
>
>
> Just trying to figure out if this is possible :
>
> When defining  a drum instrument with this expression:
>
>
> #(define mydrums '(
>  (bassdrumdefault   #f   -1)
>  (snare   default   #f   0)
>  (hihat   cross #f   1)
>  (halfopenhihat   cross "halfopen"   1)
>  (pedalhihat  xcircle   "stopped"2)
>  (lowtom  diamond   #f   3)))
>
> Is there a way to define a very custom notehead in the 2nd argumrnt of the 
> list such as any other glyph not being a notehead, like per example a pedal 
> glyph (pedal.*)
> or any other glyph or even eps ?
>
> I have searched (maybe not too thouroughly) trying to figure this out. Any 
> help or idea will be just great. this will prevent me to use an override 
> NoteHead.stencil tweak for every note.
>
> Best
>
> --
> Karim Haddad

Hi,

in
http://lsr.di.unimi.it/LSR/Item?id=1033
I tried to explain thoroughly how to customize drums-appearance.
Probably some general help...

It should be clear then that the list-argument in question is a note-head-style.
Ofcourse only estabished styles will work.

Not sure if it might possible to define a custom style and let the
stencil-procedure rely on it.
(And not the time yet to try.)


Cheers,
  Harm

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