Accessing timecode of notes or bars

2014-04-20 Thread Boris Lau

Hi all,

I'm trying to provide id-values to noteheads or barlines for use with 
the SVG output so I can access them using JavaScript. In the archive I 
found the snipped below.


1. Is there a property that gives me a timecode-like value for a 
notehead with a bar and beat number of a note?


2. I also tried to assign a string id to a BarLine, but that doesn't 
appear in the svg. Is there a workaround for that?


Best, Boris

#(define (note-number grob)
(string-concatenate
 (list
  NoteHead/
  (number-string
(ly:beam-score-count)
  (ly:event-property (ly:grob-property grob 'cause)'pitch))
  (number-string


\override NoteHead #'id = #note-number


\relative c' {
  c8 d e f
}

--
Boris Lau
- Web:   http://www.borislau.de
- Phone: +49 761 1529078 | SMS: +49 174 9436758
- Mail:  Kartäuserstr. 124, D-79104 Freiburg, Germany


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


Re: Accessing timecode of notes or bars

2014-04-20 Thread Thomas Morley
2014-04-20 15:45 GMT+02:00 Boris Lau m...@borislau.de:
 Hi all,

 I'm trying to provide id-values to noteheads or barlines for use with the
 SVG output so I can access them using JavaScript. In the archive I found the
 snipped below.
[...]

Hi,

please give us the link or provide a compilable snippet.
Otherwise I doubt you will get much help.

Cheers,
  Harm

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


Re: Accessing timecode of notes or bars

2014-04-20 Thread Boris Lau

Sorry, there was an error in my posted snipped. Here is the correct version:

\version 2.16.2
#(define (note-number grob)
 (string-concatenate
  (list
   NoteHead/
   (number-string
(ly:pitch-semitones
 (ly:event-property (ly:grob-property grob 'cause) 'pitch))

\relative c' {
  \time 4/4
\override NoteHead #'id = #note-number
c d e
}

Please compile with lilypond -dbackend=svg test_id.ly

As expected, each notehead in the output is assigned with an id value, 
e.g., NoteHead/0, where the number indicates the pitch.
Now I want to replace the pitch with its position in time expressed in 
bars and beats. Is this possible?


Best, Boris


On 20.04.14 16:24, Thomas Morley wrote:

please give us the link or provide a compilable snippet.
Otherwise I doubt you will get much help.


--
Boris Lau
- Web:   http://www.borislau.de
- Phone: +49 761 1529078 | SMS: +49 174 9436758
- Mail:  Kartäuserstr. 124, D-79104 Freiburg, Germany

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


Re: Accessing timecode of notes or bars

2014-04-20 Thread Thomas Morley
2014-04-20 16:50 GMT+02:00 Boris Lau m...@borislau.de:
 Sorry, there was an error in my posted snipped. Here is the correct version:

 \version 2.16.2

 #(define (note-number grob)
  (string-concatenate
   (list
NoteHead/
(number-string
 (ly:pitch-semitones

  (ly:event-property (ly:grob-property grob 'cause) 'pitch))

 \relative c' {
   \time 4/4

 \override NoteHead #'id = #note-number
 c d e
 }

 Please compile with lilypond -dbackend=svg test_id.ly

 As expected, each notehead in the output is assigned with an id value, e.g.,
 NoteHead/0, where the number indicates the pitch.
 Now I want to replace the pitch with its position in time expressed in bars
 and beats. Is this possible?

 Best, Boris



 On 20.04.14 16:24, Thomas Morley wrote:

 please give us the link or provide a compilable snippet.
 Otherwise I doubt you will get much help.


 --
 Boris Lau
 - Web:   http://www.borislau.de
 - Phone: +49 761 1529078 | SMS: +49 174 9436758
 - Mail:  Kartäuserstr. 124, D-79104 Freiburg, Germany

Hi again,

maybe an idea:

\version 2.16.2

#(use-modules (ice-9 pretty-print))

#(define grob-name
  (lambda (x)
(if (ly:grob? x)
(assq-ref (ly:grob-property x 'meta) 'name)
(ly:error ~a is not a grob x


#(define (look-up-for-parent name-symbol axis grob)

 Return the parent of @var{grob}, specified by it's @var{name-symbol} in
 axis @var{axis}.
 If not found, look up for the next parent.

 (let* ((parent (ly:grob-parent grob axis)))
 (cond
   ((not (ly:grob? parent))
(ly:error
   (_Perhaps typing error for \~a\ or \~a\ is not in the parent-tree.)
   name-symbol name-symbol))
   ((not (equal? name-symbol (grob-name parent)))
(look-up-for-parent name-symbol axis parent))
   (else parent

#(define (note-info grob)
  (pretty-print
(ly:grob-property
  (look-up-for-parent 'PaperColumn X grob)
  'rhythmic-location)))

%5

\relative c' {
  \time 4/4

\override NoteHead #'id = #note-info
c d e
}

Tested only with pdf-output!

Cheers,
  Harm

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