On Wed, 2024-09-11 at 09:13 -0400, Bric wrote:
> 
> > On 09/11/2024 8:57 AM EDT Bric <b...@flight.us> wrote:
> > 
> >  
> > > >  
> > > 
> > > >  You'd need to change the note's start position.  Given X%
> > > > swing,
> > > > you'd need to shift the start of the second eighth note in a
> > > > pair of
> > > > swung eighth notes, forward, in time, by (X-50)/50 of its own
> > > > duration.  (E.g., for a swing of 63, the second note shrinks by
> > > > (63-
> > > > 50)/50 = 13/50, and shifts forward by that difference.
> > > > 
> > > > But again. First, denemo needs to identify each pair of eights
> > > > properly,
> > 
> > > As you have an insight into the choosing of which pairs of eighth
> > > notes
> > > you would wish to swing I wonder if you would care to implement
> > > inside
> > > Denemo? You would need to familiarise yourself with Scheme, but
> > > that is
> > > not so difficult a very simple syntax, and with the procedures
> > > available for Denemo such as d-MoveCursorLeft and d-
> > > GetNoteDuration. I
> > > could help with the latter, it would be a question of modifying
> > > the
> > > script for the command SwingStaff which you can inspect from
> > > within
> > > Denemo.
> > > 
> > 
> > Would love to give it a go!  (and, no -- not suggesting we use "Go"
> > :-))
> > 
> > I'm not too solid on Scheme but have always been fascinated with
> > it. (Was able to do a few quick hacks in Scheme here and there)
> > 
> > Yeah... I've had some success writing a swing rhythm
> > transformation. (The code did not run in real time, however -- but
> > it probably could).  
> > 
> > Essentially, it first identified the swing pairs, by
> > tracking/evaluating the start position of every note, within the
> > measure. Not hard. Actually works for cases where there is no
> > explicit pair(!) -- where the first note of the pair is
> > theoretical/imaginary -- it applied the transform to the second
> > (explicit) note of the pair, because that note's position can be
> > computed for eligibility (without the existence of the first
> > note).  Once the eligible note is identified, the rest should be
> > trivial
> > 
> > To do the above in Denemo, it would also be easy -- if the function
> > had the start position parameter.  Would it do the transform
> > **ahead** of the playback? Like - prepping the data first and THEN
> > playing back?  Or would it apply the transform in realtime, as it
> > executes the playback?
> 
> Just realized that I already had the answer to that last one, i
> guess.  The color highlighting (in blue) in the editor is evidence
> that the function is being applied before any playback happens.

yes, SwingStaff is stepping the cursor through every object from the
start of the staff and where it finds consecutive eighth notes
shortening the duration of the first and lengthening the duration of
the second to match. It's that simple.
To make it more concrete for you here is the function that steps
through looking for an eighth note and if it finds one going on to see
if there is another and if there is lengthening and shortening the two
- I've added comments:

    (define (swing)

        ;this is the code I added this morning that looks for dotted notes
           (if (positive? (d-GetDots))          ;if dotted  
                        (begin
                                (NextNoteInMeasure) ; moves over the next two 
notes before starting to look againg
                                (NextNoteInMeasure)))

        ;this is the code that you have in SwingStaff


       (if (and (equal? (d-GetNoteDuration) "8") (not (d-IsGrace))     ;if it's 
an eighth note and not a grace note
                (NextNoteInMeasure)                                    ; and we 
can move cursor to next note
                (equal? (d-GetNoteDuration) "8")  (not (d-IsGrace)))   ; and 
this is also an eighth note
        (begin                                                         ; then
            (d-MoveCursorLeft)                                         ; go 
back to the first eighth note
            (d-SetDurationInTicks big)                                 ; make 
it big

;ignore these two lines
            (d-DirectivePut-chord-override tag (logior DENEMO_OVERRIDE_GRAPHIC 
DENEMO_ALT_OVERRIDE))
            (d-DirectivePut-chord-prefix tag "8") 
                                                                       ;go on 
to the second eighth note
            (d-MoveCursorRight)
            (d-SetDurationInTicks small)                               ; make 
it small
;ignore
            (d-DirectivePut-chord-override tag (logior DENEMO_OVERRIDE_GRAPHIC 
DENEMO_ALT_OVERRIDE))
            (d-DirectivePut-chord-prefix tag "8"))))

This procedure is called repeatedly until the end of the staff is reached. 
That's all there is to it.
You might want to do something simpler - write a command that adds an
amount to the duration of the current note and takes the same amount
off the duration of the previous note. Then as you enter notes you hit
a key that executes that command whenever you want to swing it from the
last note.

Richard


Reply via email to