Commit d1f84f67 authored by porres's avatar porres
Browse files

note & pitch bend working

parent 15b8e729
......@@ -4,28 +4,30 @@
#X obj 267 468 else/bend.out -raw;
#X floatatom 267 440 0 0 0 0 - - -;
#X obj 270 413 hsl 128 15 0 16383 0 0 empty empty empty -2 -8 0 10
-228856 -1 -1 0 1;
#X obj 108 202 else/note.out;
-228856 -1 -1 4600 1;
#X obj 203 339 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
127;
#X obj 164 518 ./fluidsynth~ sf2/Famicom.sf2, f 16;
#X msg 200 366 60 \$1 1;
#X obj 489 342 else/hex2dec 0x80;
#X obj 488 315 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X floatatom 505 378 5 0 0 0 - - -;
#X obj 175 255 print;
#X msg 175 304 128 \, 60 \, 0;
#X connect 1 0 5 0;
#X connect 2 0 7 0;
#X msg 175 304 144 \, 60 \, \$1;
#X obj 180 276 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
127;
#X text 215 202 <= should not send note off (group 128);
#X obj 489 342 else/hex2dec 0xE0;
#X obj 108 202 else/note.out 1;
#X connect 1 0 14 0;
#X connect 2 0 6 0;
#X connect 3 0 2 0;
#X connect 4 0 3 0;
#X connect 5 0 7 0;
#X connect 5 0 12 0;
#X connect 6 0 8 0;
#X connect 7 0 0 0;
#X connect 7 1 0 1;
#X connect 8 0 7 0;
#X connect 9 0 11 0;
#X connect 10 0 9 0;
#X connect 13 0 7 0;
#X connect 6 0 0 0;
#X connect 6 1 0 1;
#X connect 7 0 6 0;
#X connect 8 0 13 0;
#X connect 10 0 6 0;
#X connect 11 0 10 0;
#X connect 13 0 9 0;
#X connect 14 0 6 0;
......@@ -73,12 +73,10 @@ static void fluid_note(t_fluid_tilde *x, t_symbol *s, int ac, t_atom *av){
s = NULL;
if(x->x_synth == NULL)
return;
post("ac = %d (%d %d %d)", ac, atom_getintarg(0, ac, av), atom_getintarg(1, ac, av), atom_getintarg(2, ac, av));
if(ac == 2 || ac == 3){
int key = atom_getintarg(0, ac, av);
int vel = atom_getintarg(1, ac, av);
int chan = ac > 2 ? atom_getintarg(2, ac, av) : 1;
post("key (%d) vel (%d) chan (%d)", key, vel, chan);
fluid_synth_noteon(x->x_synth, chan-1, key, vel);
}
}
......@@ -188,24 +186,23 @@ static void fluid_float(t_fluid_tilde *x, t_float f){
unsigned char val = (unsigned char)f;
if(val > 127){ // not a data type
x->x_type = val & 0xF0; // get type
// post("x->x_type = %d", (int)x->x_type);
x->x_channel = (val & 0x0F) + 1; // get channel
x->x_ready = (x->x_type == 0xC0 || x->x_type == 0xD0); // ready if program or touch
}
else if(x->x_ready){
switch(x->x_type){
case 0x80: // NOTE OFF
case 0x80: // group 128 (NOTE OFF)
SETFLOAT(&x->x_at[0], (t_float)x->x_data);
SETFLOAT(&x->x_at[1], 0); // make it note on with velocity 0
SETFLOAT(&x->x_at[3], (t_float)x->x_channel);
post("OFF x->x_data (%d) val (%d) x->x_channel (%d)", (int)x->x_data, (int)val, (int)x->x_channel);
fluid_note(x, &s_list, 2, x->x_at);
SETFLOAT(&x->x_at[2], (t_float)x->x_channel);
fluid_note(x, &s_list, 3, x->x_at);
break;
case 0x90: // group 144 (NOTE ON)
SETFLOAT(&x->x_at[0], (t_float)x->x_data);
SETFLOAT(&x->x_at[1], val);
SETFLOAT(&x->x_at[3], (t_float)x->x_channel);
post("ON x->x_data (%d) val (%d) x->x_channel (%d)", (int)x->x_data, (int)val, (int)x->x_channel);
fluid_note(x, &s_list, 2, x->x_at);
SETFLOAT(&x->x_at[2], (t_float)x->x_channel);
fluid_note(x, &s_list, 3, x->x_at);
break;
case 0xE0: // pitch bend
SETFLOAT(&x->x_at[0], (val << 7) + x->x_data);
......@@ -218,6 +215,7 @@ static void fluid_float(t_fluid_tilde *x, t_float f){
x->x_type = x->x_ready = 0; // clear
}
else{ // not ready, get data and make it ready
// post("x->x_data = %d", (int)x->x_data);
x->x_data = val;
x->x_ready = 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment