From 424ed17b1398ae447d28720183e97c511a031d19 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 20 Nov 2011 23:35:03 +0100 Subject: Aha, rhythm is reading correctly! --- maestropond.c | 65 ++++++++++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 45 deletions(-) diff --git a/maestropond.c b/maestropond.c index 6cf1ca0..7385ac8 100644 --- a/maestropond.c +++ b/maestropond.c @@ -311,50 +311,25 @@ static int is_rest(unsigned char n1) } -static int find_max_length(unsigned char g, unsigned char **notes, int *nptrs) -{ - int ch; - int lmax = 100; - - for ( ch=0; ch<8; ch++ ) { - - int len; - - if ( !(g & 1<> 5; - if ( len < lmax ) lmax = len; - - } - - if ( lmax == 100 ) { - fprintf(stderr, "No note length in gate!\n"); - } - - return lmax; -} - - -static int check_note(unsigned char *notes, int *nptr, struct chord *c, int ls, +static int check_note(unsigned char *notes, int *nptr, struct chord *c, struct stave *st) { int len, pos, acc; unsigned char n1, n2; - /* Is it the right length? If not, save it for the next chord */ - len = (notes[*nptr] & 0xe0) >> 5; - if ( len != ls ) return 0; - /* Is it a rest? */ - n1 = notes[*nptr]; + n1 = notes[(*nptr)++]; + n2 = notes[(*nptr)++]; + if ( is_rest(n1) ) return 0; - (*nptr)++; - n2 = notes[*nptr++]; + len = (n2 & 0xe0) >> 5; + printf("%i ", maestro_to_beat(len)); pos = (n1 & 0xf8) >> 3; acc = n2 & 0x07; + c->length = maestro_to_beat(len); c->notes[c->n_notes++] = pitch_to_note(pos, acc, st->last_clef); return 1; @@ -373,13 +348,15 @@ static int channel_in_stave(int ch, int stave, int n_staves) static void process_gate(struct music *mus, int i, int *nptrs) { - unsigned int l, j; + unsigned int j; - printf("("); - while ( mus->gates[i] != 0 ) { + if ( mus->gates[i] == 0 ) { + fprintf(stderr, "Empty gate encountered!\n"); + return; + } - l = find_max_length(mus->gates[i], mus->notes, nptrs); - printf("%i ", l); + printf("("); + do { for ( j=0; jn_staves; j++ ) { @@ -387,28 +364,26 @@ static void process_gate(struct music *mus, int i, int *nptrs) int k; n = add_chord(mus, j); - n->length = maestro_to_beat(l); n->type = CHORD_MUSIC; + printf("st%i: ", j); /* Find the notes of this length on this stave */ - for ( k=0; k<8; k++ ) { + for ( k=0; k<8; k+=4 ) { /* FIXME! */ if ( !channel_in_stave(k, j, mus->n_staves) ) { continue; } if ( !(mus->gates[i] & (1<notes[k], &nptrs[k], n, l, - &mus->staves[j]) ) - { - mus->gates[i] = mus->gates[i] ^ (1<notes[k], &nptrs[k], n, + &mus->staves[j]); + mus->gates[i] = mus->gates[i] & ~(1<gates[i] != 0) ); /* FIXME! */ printf(")"); } -- cgit v1.2.3