denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] Operations on the selection


From: Richard Shann
Subject: Re: [Denemo-devel] Operations on the selection
Date: Fri, 14 Nov 2008 11:28:59 +0000

Here is a scheme script that defines a procedure ApplyToSelection which
takes one parameter, a procedure, and applies that procedure to each
note in the selection (after the first). For example
(d-GoToMark)
(ApplyToSelection d-ToggleStaccato)
would put a staccato mark on every note in the selection (assuming they
didn't have them already).
The next step would be to create a menuitem that would apply the next
command to the selection...

Below is the code for ApplyToSelection
Richard
;;; Scheme script to define the procedure ApplyToSelection
(define isChord (lambda ()
  (string=? (d-GetType) "CHORD")))

(define NextChordInSelection (lambda () (if (d-NextSelectedObject) 
    (if (isChord)
                #t
                (NextChordInSelection))
    #f
    )))
(define ApplyToSelection (lambda (command)
(if (NextChordInSelection)
    (begin (command)
        (ApplyToSelection command))
)))

;;;; end of script






On Wed, 2008-11-12 at 11:22 +0000, Richard Shann wrote:
> I've refined the working of d-NextSelectedObject to step over the
> appending position (and changed the semantics of d-GetType when in that
> position). This means you can now iterate over objects in the selection.
> As an example, here is a script that peppers a score with EighthRests,
> putting one after every note/rest in the selection.
> A fairly useless activity, but it outlines what can be done. Note that
> it starts on the second note of the selection - an initialization would
> be needed to avoid this.
> Script follows
> Richard
> ;;;;;;; script to pepper a score with rests...
> (define isChord (lambda ()
>                 (string=? (d-GetType) "CHORD")))
> 
> (define NextChordInSelection (lambda () (if (d-NextSelectedObject) 
>                                           (if (isChord)
>                                                #t
>                                                (NextChordInSelection))
>                                           #f
>                                           )))
> (define pepper (lambda ()
> 
> (if (NextChordInSelection)
>     (begin (d-InsertEighthRest)
>         (pepper))
> )))
> (d-GoToMark)
> (pepper)
> 
> 
> 
> 
> _______________________________________________
> Denemo-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/denemo-devel





reply via email to

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