denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] Scheme book


From: Richard Shann
Subject: Re: [Denemo-devel] Scheme book
Date: Tue, 26 Aug 2008 13:28:13 +0100

On Mon, 2008-08-25 at 19:06 -0500, Jeremiah Benham wrote:
> On Mon, 2008-08-25 at 19:17 +0100, Richard Shann wrote:
> > On Mon, 2008-08-25 at 12:41 -0500, Jeremiah Benham wrote:

> 
> Actually part of it is in exportlilypond.c where it can't be reused and
> some of it is in utils.c. I wrapped this up and put it utils.c do you
> think it would be better to have it in exportlilypond.c? 
I would go for utils.c, since it is could be used by the scheme
interface and by the Lilypond interface (that is we are going to use the
lilypond format in two different places). This is not too important.

> The interface
> looks like this:
> 
> gchar *mid_c_offsettolily (int mid_c_offset, int enshift)
> 
> It returns a pointer and will need to be freed. Is the above 2 input
> arguments okay. If not then we could pass a struct note, that is
> contained in a denemo chord object, and have the mid_c_offset and
> enshift extrapolated from it. The struct note has a many things in it
> like stem directive and all that. We could keep it two arguments or make
> a smaller struct that only contains mid_c_offset and enshift.
I think we should break it down further

void note2lilynotename(struct note*, GString *ret)
void *note2lilyaccidental(struct note*, GString *ret)
void *chord2lilyduration(struct chord *, GString *ret)

The scheme interface would be to functions declared thus
gchar *lilyNoteName(void)        yields   "a"   for example
gchar *lilyNoteAccidental(void)      yields   "eses" for example
gchar *lilyNoteOctave(void)    yields ",," for example
gchar *lilyNoteDuration(void)  yields "8." for example, or perhaps
lilyNoteBaseDuration() and lilyNoteDots()

These functions would all apply to the note at the cursor, returning the
empty string (not NULL) if the cursor is not on an object, or not on a
chord or not on a chord with notes or cursor_y is not on a note in the
chord.

To support this we will need additional up/down cursor navigation
functions: GoToHighestNote, NextNote, GoToLowestNote, which move the
cursor if the current object satisfies all the conditions, that is:
the gui->si->currentobject is not NULL, and is a chord and is a chord
with notes.
(As with many of our callbacks, we will want to return a status, to
indicate whether the cursor moved).

Here is the (rough) definition of the first of the interface functions
(off the top of my head, there's all the casts etc to do):

gchar *lilyNoteName(void){
GString *ret = g_string_new("");
DenemoGUI *gui = Denemo.gui;
if(gui->si && gui->si->currentobject && typeofcurrentobject==CHORD &&
gui->si->currentobject->object->notes) {
        find note at gui->si->cursor_y
        if(found) note2lilynotename(struct note*, ret)
        }
return g_string_free(ret, FALSE);//I haven't looked this up, but I take
it you did!!! I mean return ret->str freeing ret
}


There should be predicates in Scheme:

SchemeChord?   #t if current object is Chord* and there are notes
SchemeRest?     #t if current object is chord* and notes==NULL
SchemeNote?   #t if  SchemeChord? and the cursor is on a note

which will need the obvious C-functions behind them, testing
gui->si->currentobject.


In Scheme we will write convenience functions, e.g. NextNote would do
NextObject until SchemeChord? is #t then GoToHighestNote
returning a status to indicate success.

Richard













reply via email to

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