[gsharp-devel] selections, copy, paste, etc.

David Lewis d.lewis at gold.ac.uk
Mon Nov 17 13:06:55 UTC 2008


Hi,

I'm working on a project that may allow me the opportunity to work on  
gsharp as a (small) part of my job. I'm not really sure how much and  
when to commit or submit diffs to the list---I'm maintaining my own  
repository locally---but some of what I'm doing may be useful to  
others (and Christophe is nagging me to be more visible on this list...)

In particular:

1) I've just started looking at selections, with the aim of adding  
copy, paste and search facilities. I'm beginning with simple region  
selects and a kill-ring-like approach, without an immediate  
implementation of anything to actually do with the results. Paste/yank  
will come later.

   Although much of the code is likely to change substantially as I  
go, some of it may be useful elsewhere, and if anyone else is working  
on anything related, they may be interested in its progress. How  
cautious should I be about submitting patches to this list or  
committing them to cvs?

   One side-effect of working on this has been a version of select- 
layer that moves the cursor to the right time (rather than the end of  
the bar), and I've attached a diff for that to the bottom of this e- 
mail.

2) I've also got the beginnings of code for adding time signatures to  
pieces. One thing that held me back from doing anything further with  
this when I was working on this was the lack of any way of rendering  
them. I notice from recent updates that the necessary glyphs are being  
added. Does that mean that someone is also working on time signatures?  
Should I be picking up my work on this again now that the glyphs are  
appearing, or is a working version going to materialise soon anyway? ;-)

I also have a few questions about naming conventions for staves and  
layers - currently gsharp accepts empty strings as names (although  
these don't appear on M-/ lists on my machine). Is this a useful  
feature or is it worth avoiding? also, uniqueness is enforced on data  
entry, but not on file loading, and the sample files seem to have all  
their staves and layers named with the class default: should there be  
an extra step to test for this on load? Should the sample scores be  
updated to avoid this?

Thanks,

David Lewis
---------------------------------

diff -rN old-gsharp/cursor.lisp new-gsharp/cursor.lisp
337,342c344,350
< 	 (oldbarno (number oldbar))
< 	 (oldslice (slice oldbar))
< 	 (oldsliceno (number oldslice))
< 	 (newslice (sliceno new-layer oldsliceno))
< 	 (newbarno (min (1- (nb-bars newslice)) oldbarno))
< 	 (newbar (barno newslice newbarno)))
---
 >          (oldbarno (number oldbar))
 >          (oldslice (slice oldbar))
 >          (oldsliceno (number oldslice))
 >          (oldtime (cursor-time cursor))
 >          (newslice (sliceno new-layer oldsliceno))
 >          (newbarno (min (1- (nb-bars newslice)) oldbarno))
 >          (newbar (barno newslice newbarno)))
344c352
<     (set-cursor cursor newbar (nb-elements newbar))))
---
 >     (set-cursor cursor newbar (get-position oldtime newbar))))
499a513,524
 >
 > (defun cursor-time (cursor)
 >   (loop for n from 0 to (1- (pos cursor))
 >      sum (duration (elt (elements (cursor-bar cursor)) n))))
 >
 > (defun get-position (time bar)
 >   (let ((sum 0) (pos 0))
 >     (dolist (element (elements bar) pos)
 >       (when (>= sum time)
 >         (return-from get-position pos))
 >       (incf sum (duration element))
 >       (incf pos))))







More information about the gsharp-devel mailing list