denemo-devel
[Top][All Lists]
Advanced

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

Re: Scheme Interface (was Re: [Denemo-devel] Staff menu transpose)


From: Richard Shann
Subject: Re: Scheme Interface (was Re: [Denemo-devel] Staff menu transpose)
Date: Tue, 23 Sep 2008 22:06:48 +0100

On Tue, 2008-09-23 at 12:11 -0500, Jeremiah Benham wrote:
> I wrote a little diatonic transposition script but I don't know how to
> deal with split strings so it does not deal with chords yet.
In fact the diatonic_shift() function in C calls modify_note() which is
no use for changing chords. For our first implementation we can delete
the chord and replace it with a new one. But to preserve things like
guitar fingerings attached to notes we will probably need to write
something that replaces all the notes of a chord in single C function
call that takes a list of notes.
>  I am
> attaching it here. It is based off the diatonic transposition item
> called "Third".  
This one does the note-alteration in C (via a purpose written function
diatonic_shift()). The challenge is to do transformations on notes in
Scheme - probably to build up a library of routines that can be called
on a note to transform it.
I've done a little messing around, but it needs someone to get to grips
with Scheme. One of the scraps of code I have in my file of scraps (as a
result of messing around) is this

(define newnote 
  (+ (modulo (+ 3 (- (char->integer (car (string->list
(d-GetNoteName))))) (char->integer #\a))  7) (char->integer #\a))
)
(display (integer->char newnote))

I have a note about this scrap saying 
;; this script outputs in the terminal the name of the note 3 steps
higher than the note at the cursor.
;; not working!

I don't remember quite what it was all about, but it looks like an
attempt to do the diatonic shift in Scheme. I am not sure how far from
working it is. The subtraction of #\a would be exploiting the ordering
of the character set to convert note names to the 0-7 integers, etc.
(Oh! Yes, and the number 3 that appears there is just the arbitrary
shift of a Third that I was taking as my example, the thing you have
generalized).
Of course we are not obliged to do any particular things in Scheme
rather than C, e.g. if we need enshift as a number we can call a
C-function to return it if it is easier. But it would be a pity to be
calling out to C just because we haven't got our heads round the
functions that Scheme provides.
The final goal is to enable people to add functionality to Denemo
without the need to re-compile. The most important factor will be the
uniformity of the model against which they are coding: e.g. all denemo
commands start d-, the note names are a,b,c,d,e,f,g and so on.

Richard





reply via email to

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