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: Jeremiah Benham
Subject: Re: Scheme Interface (was Re: [Denemo-devel] Staff menu transpose)
Date: Wed, 24 Sep 2008 09:44:15 -0500

On Tue, 2008-09-23 at 22:06 +0100, Richard Shann wrote:
> 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.

Couldn't we just add this somewhere in either modify_note or before:

for (curobj = (objnode *) curmeasure->data; curobj;
          curobj = curobj->next)
{
  mudelaitem = (DenemoObject *) curobj->data;
  note *newnote = NULL;
  if (mudelaitem->type == CHORD)
  {
     node = ((chord *) mudelaitem->object)->notes;
     g_list_foreach(node, (GFunc )change_note, (int *) amount);

  }
}

The function change_note can be replaced with modify_note() or
something.

> >  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 will get working on this.

> 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!

ok. I see what you are trying to do with that. That gives me some ideas.
Can we make an array for sharps and flats. The sharps array looks like
{a, ais, b, c, cis, d, dis, e, f, fis, g, gis}. Then a function finds
the current note location in the array. The transposition value would be
added to the number of the position in the array. Then the newnote is
looked up by position and returns the char that is to be the transposed
note. The question would be determining when to use the sharp array
table or the flat table. 

Jeremiah

> 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
> 
> 
> 
> _______________________________________________
> 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]