denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] New Paste script


From: Richard Shann
Subject: Re: [Denemo-devel] New Paste script
Date: Sun, 22 Nov 2009 09:05:42 +0000

Here are some comments to explain the paste script as it is at present
- I'll put this on denemo.org

The clipboard comprises a list of Denemo objects interspersed with
MEASUREBREAK objects and STAFFBREAK objects; each measure break
corresponds to a place where a new "measure" (in the Denemo sense)
starts. The STAFFBREAK objects mark where the staff below the previous
staff is starting - the next measure being directly below the first
measure of the previous staff.

There is also a stack of cursor positions being used here:
d-PushPosition pushes the cursor position (movement number, staff/voice
number, object number) onto a stack. d-PopPosition pops it, moving the
cursor there. The other command is d-PopPushPosition which replaces the
top of the stack with the current cursor position.

> ;;;;;;;;;;;;;;;;;;;; Paste
> (d-PushPosition)
record the cursor position at the start of the paste (this is for the
benefit of the case where there is more than one staff, in which case we
will return here and go down for the next staff)
> (let loop ((type #f) (staff 0) (count 0))
>   (set! type (d-GetClipObjType staff count))
>   (format #t "type is ~a staff ~a count ~a~%" type staff count)
a debug print to see what we have and where we are - at present type 8
is measurebreak and 9 staffbreak, 0 is a CHORD. Type -1 means no object.
The count of objects starts at count=0, and the first staff on the
clipboard is accessed as staff=0
>    (cond 
>     ((= type MEASUREBREAK)      
>         (if (= staff 0)
>             (d-AddMeasure))
d-AddMeasure adds a measure in all the staffs, so we are doing this only
if staff is 0, the first staff. We could use d-InsertMeasureAfter (?) -
the command to insert a measure just in the current staff and do it for
each staff.
>         (loop type staff (1+ count)))
continue from the next object, count+1
>    ((= type STAFFBREAK)
>            (d-PopPosition)
We go back to the start of the pasting in the current staff
>            (if (d-StaffDown)
>                (begin 
>                  (d-PushPosition)
Once more we record where we start in case we have another staff to
paste
>                  (loop type (1+ staff) 0))))
continue with the next staff at the first object count=0
>     ((>= type 0)
That is all other types except the no object value which terminates loop
>      (d-PutClipObj staff count)
we insert the object in the score at the cursor position, which moves
the cursor on
>      (loop type staff (1+ count)))))
continue with object count+1

Here the loop is finished. There is a position still on the stack which
we didn't need. We get rid of it and keep the cursor at the end of the
last paste by the next two instructions (essentially we are swapping the
top of the stack for the current cursor position and popping that).
> (d-PopPushPosition)
> (d-PopPosition)
> (d-RefreshDisplay)

We have a lot of flexibility here. You could write a command to take the
nth staff from the clipboard a paste it at the cursor for example.

Richard








reply via email to

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