Re: Get context in Scheme function (determining current moment)

2013-12-04 Thread David Kastrup
Urs Liska u...@openlilylib.org writes:

 Hi,

 when I'm trying to determine the the position in a piece when inside a
 music function I think I have to use either
 ly:context-current-moment
 or
 ly:context-now

That's stupid: they do the same thing.  Why do we have the same function
twice?

 Both functions take a 'context' as argument, but I don't see where
 this should be taken from.

 so
 a)
 how do I get a current context from when inside a Scheme function?

That one's easy: there first _has_ to be a current context.  Contexts
are only created when a music expression is getting iterated.  So you
need to have your Scheme function called during iteration.  The easiest
way to do this is to use \applyMusic.

It will be called for every iteration of a score, so if you are doing
midi, you'll get it called there as well.

 and
 b)
 how would I proceed to determine the position in a score when the
 Scheme function is called?

Seems like it would do that.

Again: what are you trying to do?

-- 
David Kastrup

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


Re: Get context in Scheme function (determining current moment)

2013-12-04 Thread Urs Liska

Am 04.12.2013 16:39, schrieb David Kastrup:

Again: what are you trying to do?
Probably my reply to your previous answer will have told you in the 
meantime.


My \annotate function should also store the position in the score (to 
print that out and to sort by it).
So when I use the function in the input file it should store location 
elements and current measure and measure position in several variables.


The main goal of that is to make it possible to annotate a score with 
different types of comments (general annotation, todo, technical 
question, musical question, critical note etc.).
When compiling the score it will (among other things) output one or 
several files (don't know yet) with sorted list(s) of (clickable) 
annotations. That way I'll have a list of things that still have to be 
done. Reading the list I can simply click on an item and go to the input 
file.


Once that's reasonably stable I intend to write a LaTeX package that can 
use the output of \annotate (at least the critical notes) and insert 
them as a critical report in a LaTeX file. (Of course it won't be 
trivial to make that generally useful, but I think it's possible).


This way one will be able to edit a critical report directly in the 
musical score.
I found proof-reading of our Fried songs edition _very_ tedious. I had 
repeatedly (and with repeatedly I mean 7 pages of three-column 
scriptsize revision entries) to

- compare original edition with new engraving
- if there was a difference: check if there is an entry for that
- if not: decide if it's an error in our score or if I have to add an entry.
always switching between paper print, LilyPond edition and files and the 
LaTeX file with the report.


With that \annotate framework I could immediately see if there's an 
entry - in the .ly file - and add or edit it.


Also, while preparing the edition I could add an annotation at any time 
when I notice a questionable item. And when I'm decided about the issue 
I can change the annotation type from question to critical-note to 
make it available for the official report.


Surely a long way to go (particulary if I'm still having to poke around 
so much with Scheme basics), but hopefully very rewarding.
If it works out it will be a big selling point towards professional 
academics.


Best
Urs

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


Re: Get context in Scheme function (determining current moment)

2013-12-04 Thread Jan-Peter Voigt
Am 04.12.2013 17:01, schrieb Urs Liska:
 My \annotate function should also store the position in the score (to
 print that out and to sort by it).
 So when I use the function in the input file it should store location
 elements and current measure and measure position in several variables.
so yout need some kind of music function, that inserts an info to the
music objects, which will be caught by an engraver, or you use applyContext.
Then you need some kind of singleton, which holds the annotations. Then
you can add them anywhere and get the list afterwards.
Later more on that ...



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


Re: Get context in Scheme function (determining current moment)

2013-12-04 Thread Urs Liska

Am 04.12.2013 17:15, schrieb Jan-Peter Voigt:

Am 04.12.2013 17:01, schrieb Urs Liska:

My \annotate function should also store the position in the score (to
print that out and to sort by it).
So when I use the function in the input file it should store location
elements and current measure and measure position in several variables.

so yout need some kind of music function, that inserts an info to the
music objects, which will be caught by an engraver, or you use applyContext.
Then you need some kind of singleton, which holds the annotations. Then
you can add them anywhere and get the list afterwards.
Later more on that ...



Yes, that's for later. Now I first need to collect information on the 
current moment.


And I _do_ have read the whole section of lalily's edition.scm. But it's 
_way_ too complex, in particular because it references so much other 
code from outside the file.
IISC it isn't exactly what I need so I'm afraid I have to build up my 
stuff from ground up. Also in order to have understood what it does.


Best
Urs

PS: I'll surely come back on this current issue because I doubt I have 
fully grasped it yet.



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


Re: Get context in Scheme function (determining current moment)

2013-12-04 Thread Mike Solomon

On Dec 4, 2013, at 9:45 PM, Urs Liska u...@openlilylib.org wrote:

 Am 04.12.2013 17:15, schrieb Jan-Peter Voigt:
 Am 04.12.2013 17:01, schrieb Urs Liska:
 My \annotate function should also store the position in the score (to
 print that out and to sort by it).
 So when I use the function in the input file it should store location
 elements and current measure and measure position in several variables.
 so yout need some kind of music function, that inserts an info to the
 music objects, which will be caught by an engraver, or you use applyContext.
 Then you need some kind of singleton, which holds the annotations. Then
 you can add them anywhere and get the list afterwards.
 Later more on that ...
 
 
 Yes, that's for later. Now I first need to collect information on the current 
 moment.
 
 And I _do_ have read the whole section of lalily's edition.scm. But it's 
 _way_ too complex, in particular because it references so much other code 
 from outside the file.
 IISC it isn't exactly what I need so I'm afraid I have to build up my stuff 
 from ground up. Also in order to have understood what it does.
 
 Best
 Urs

From practice, my advice is to create a music function that does all this 
bookkeeping for you by iterating through your stream, minding time signatures, 
counting durations and adding events when appropriate.  All this before it 
hits the engravers.  I wrote a function that that did this back when I removed 
all the Es from the Overture to Fidelio (http://bit.ly/1gEXXJ7), but I lost 
the function when my hard drive crashed.  It was a day of work, though, so 
it’s re-doable and probably very useful for lots of people.

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