1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195
|
%{
/*
(c) 2000 Adam Tee <eenajt@electeng.leeds.ac.uk>
(c) 2000 University of Leeds
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "frogdefs.h"
#include "redefs.h"
#include "datastructures.h"
#include "contexts.h"
#include "file.h"
#include "frogio.h"
#include "draw.h"
#include "keyresponses.h"
#include "chordops.h"
#include "scoreops.h"
#include "staffops.h"
#include "dialogs.h"
#include "measureops.h"
#include "calculatepositions.h"
#include "objops.h"
#include "processstaffname.h"
#include "tupletops.h"
#define yyin frogin
#define yytext frogtext
#define YYDEBUG 0
#define YYMAXDEPTH 100000
#define YYINITDEPTH 500
objnode *currentobject;
extern int count;
static struct scoreinfo *frogsi;
extern int yylex (void);
int yyerror (char *);
static void
newnoteobj (struct p_note *thenote, gfloat length, struct scoreinfo *si);
static void newclef (char *clefname);
static void newkeysigobj (char *keyname);
static void newtimesig (int upper, int lower);
static void newdynamic (gchar * type);
static gint setnoteheadtype (gchar * type);
optionlist *createoption(struct p_modifier option);
void emptylist(optionlist *head) ;
void insertoption(optionlist **header, optionlist *newitem);
%}
%union
{
gfloat f;
char string[FROG_MAX_TOKEN_STRING];
int number;
char character;
struct p_pitch t_pitch;
struct p_noteoption *t_option;
struct p_note t_note;
struct p_modifier t_modifier;
struct p_position t_position;
struct p_grace t_grace;
struct p_beam t_beamd;
struct p_beam_type t_beamtype;
struct p_gracenoteoption t_graceoption;
struct p_staff t_staff;
struct p_rest t_rest;
struct p_tupops t_tupops;
struct p_slur t_slur;
struct p_hairpin t_hairpin;
}
%token < string > STAFFNAME
%token < string > TIE
%token < number > END
%token < f > FLOAT
%token < string > NOTENAME
%token < f > DURATION
%token < character > RESTTYPE
%token < string > DIRECTION
%token < string > SLURPOSITION
%token < string > NUMPOSITION
%token < string > KEYTYPE
%token < number > NUM
%token < string > BRACKET
%token < string > CLEFTYPE
%token < string > ORNAMENT
%token < string > FULL
%token < string > PARTIAL
%token < string > MODE
%token < string > BARTYPE
%token < string > TEMPOTERM
%token < string > TRANSTEMPO
%token < string > DYN
%token < string > ACCIDENTAL
%token < string > ACCENT
%token < string > ORNAMENT
%token < string > NOTEHEAD
%token < string > STYLE
%token < string > CURVESHAPE
%token < character > SYSTEM
%token < character > STAFFGROUP
%token < character > STAFF
%token < character > ENDSTAFFGROUP
%token < character > TUPLET
%token < string > TUP_END
%token < string > SLURTYPE
%token < string > HAIRPINTYPE
%type < number > additive
%type < number > octave
%type < string > directions
%type < number > no_of_lines
%type < number > position_in_half_lines
%type < number > transposition
%type < number > barnumber
%type < number > dot
%type < f > beatnumber
%type < t_pitch > pitch
%type < t_option > note_option
%type < t_note > note
%type < string > stem_dir
%type < string > flag
%type < number > number_of_half_lines
%type < t_modifier > modifier_note_type
%type < string > tie
%type < t_grace > grace_notes
%type < t_beamd > beam
%type < t_beamtype > beam_type
%type < string > primary
%type < string > secondary
%type < t_position > position
%type < t_graceoption > grace_note_option
%type < t_staff > staffparams
%type < t_rest > rest
%type < t_tupops > tuplet_option
%type < t_slur > slur
%type < t_hairpin > hairpin
/*
* Global variables for the new objects
*/
%{
staff *thestaffstruct = NULL;
measurenode *themeasures = NULL;
gint cleftype;
static int counter = 0;
static int n = 1;
static int currentbar=1;
static gfloat beatnum = 0;
static gfloat totaldurs = 0;
static gint staffnum = 0;
gboolean is_tup = FALSE;
static gfloat currentbeat = 0;
gint no_of_options = 0;
%}
%%
system:symbol staffgroup;
symbol:SYSTEM
{
fprintf (stderr, "Found %c \n", $1);
}
;
brace:BRACKET
{
}
|;
staffgroup:brace staffgroupsym staffgroup endstaffsym
| staffspec | staffspec staffgroup endstaffsym;
staffgroupsym:STAFFGROUP
{
}
;
endstaffsym:ENDSTAFFGROUP
{
}
;
staffspec:staffsym staffparams musicalobject
{
/*p_newstaff(frogsi, &$2); */
}
;
staffsym:STAFF
{
frogsi->currentstaffnum++;
newstaff (frogsi, ADDFROMLOAD, NULL);
frogsi->currentstaff = g_list_last (frogsi->thescore);
n = 1;
currentbar = 1;
staffnum++;
counter = 0;
frogsi->cursor_x = 0;
totaldurs = 0;
beatnum = 0;
currentbeat = 0;
}
;
staffparams:STAFFNAME no_of_lines position_in_half_lines transposition
{
g_string_assign (((staff *) frogsi->currentstaff->data)->lily_name, $1);
set_denemo_name (((staff *) frogsi->currentstaff->data)->lily_name,
((staff *) frogsi->currentstaff->data)->denemo_name);
((staff *) frogsi->currentstaff->data)->no_of_lines = $2;
((staff *) frogsi->currentstaff->data)->transposition = $4;
((staff *) frogsi->currentstaff->data)->pos_in_half_lines = $3;
}
;
musicalobject:characteristics musicalobjects musicalobject |;
characteristics:barnumber beatnumber position
{
if (n != $1)
{
currentbar = $1;
if (!frogsi->currentmeasure->next)
{
frogsi->currentmeasure = addmeasures
(frogsi, frogsi->currentmeasurenum, 1);
}
else
{
frogsi->currentmeasure = frogsi->currentmeasure->next;
}
frogsi->currentmeasurenum++;
frogsi->cursor_x = 0;
totaldurs = 0;
currentbeat = 0;
beatnum = 0;
}
counter++;
n = $1;
currentbeat = $2;
}
;
barnumber:NUM
{
$$ = $1;
}
;
beatnumber:FLOAT
{
$$ = $1;
}
;
musicalobjects:durationobject | slur
{
mudelaobject *obj =
frogsi->currentobject ? frogsi->currentobject->data : NULL;
printf ("Found Slur\n");
if (obj && (obj->type == CHORD))
{
if (strcmp ($1.string, "slur_begin") == 0)
{
obj->u.chordval.slur_begin_p = !obj->u.chordval.slur_begin_p;
/*obj->u.chordval.slur_end_p == FALSE; */
printf ("Current start slur val: %d\n",
obj->u.chordval.slur_begin_p);
}
else if (strcmp ($1.string, "slur_end") == 0)
{
obj->u.chordval.slur_end_p = !obj->u.chordval.slur_end_p;
/*obj->u.chordval.slur_begin_p == FALSE; */
printf ("Current end slur val: %d\n", obj->u.chordval.slur_end_p);
}
}
}
|CLEFTYPE
{
newclef ($1);
}
|timesignature
| BARTYPE { }
|DYN
{
GString *dynamic = g_string_new($1);
mudelaobject *obj = (mudelaobject *)
(frogsi->currentobject ? frogsi->currentobject->data : NULL);
if(obj && obj->type == CHORD) {
obj->u.chordval.dynamics =
g_list_append(obj->u.chordval.dynamics, dynamic);
}
/* newdynamic ($1);*/
}
|tempo
| keysignature
| hairpin
{
mudelaobject *obj =
frogsi->currentobject ? frogsi->currentobject->data : NULL;
printf ("Found Hairpin\n");
if (obj && (obj->type == CHORD))
{
if (strcmp ($1.string, "cresc_begin") == 0)
obj->u.chordval.crescendo_begin_p = !obj->u.chordval.crescendo_begin_p;
else if (strcmp ($1.string, "cresc_end") == 0)
obj->u.chordval.crescendo_end_p = !obj->u.chordval.crescendo_end_p;
if (strcmp ($1.string, "dim_begin") == 0)
obj->u.chordval.diminuendo_begin_p = !obj->u.chordval.diminuendo_begin_p;
else if (strcmp ($1.string, "dim_end") == 0)
obj->u.chordval.diminuendo_end_p = !obj->u.chordval.diminuendo_end_p;
}
};
position:FLOAT ',' FLOAT
{
$$.xoff = $1;
$$.yoff = $3;
}
;
durationobject:note FLOAT
{
if (currentbeat == beatnum && n == currentbar)
{
totaldurs = beatnum;
}
else
{
beatnum = currentbeat;
}
#ifdef DEBUG
printf("JTF Duration %f\n", $2);
printf("Current beat: %f \t Beat Number: %f\n",currentbeat, beatnum);
#endif
newnoteobj (&$1, $2, frogsi);
$1.t_option = NULL;
no_of_options = 0;
}
|rest FLOAT
{
gint duration = 0;
mudelaobject *newmudelaobj = NULL;
if (currentbeat == beatnum && n == currentbar)
{
totaldurs = beatnum;
}
else
{
beatnum = currentbeat;
}
duration = floattoduration ($2, is_tup);
#ifdef DEBUG
printf("JTF Duration %f\t Denemo Duration: %d\n", $2,duration);
printf("Current beat: %f \t Beat Number: %f\n",currentbeat, beatnum);
#endif
frogsi->rest_mode = TRUE;
newmudelaobj = newchord (duration, $1.dots);
frogsi->currentmeasure->data = g_list_append(frogsi->currentmeasure->data,
newmudelaobj);
frogsi->currentobject =
g_list_last(frogsi->currentmeasure->data);
no_of_options = 0;
}
|tuplet;
rest:RESTTYPE dot
{
$$.rest = $1;
$$.dots = $2;
}
|RESTTYPE
{
$$.rest = $1;
$$.dots = 0;
}
;
note:pitch stem_dir note_option beam
{
$$.t_option = NULL;
$$.t_pitch = $1;
strcpy ($$.stemdir, $2);
$$.t_option = $3;
$$.t_beamd = $4;
}
;
pitch:NOTENAME octave
{
strcpy ($$.notename, $1);
$$.octave = $2;
}
|number_of_half_lines
{
$$.number_of_lines = $1;
}
;
octave:NUM
{
$$ = $1;
}
;
stem_dir:directions
{
strcpy ($$, $1);
}
|END
{
}
;
directions:DIRECTION
{
strcpy ($$, $1);
}
;
note_option: {
$$ = (struct p_noteoption *)g_malloc(sizeof( struct p_noteoption));
$$->next = NULL;
}
| note_option modifier_note_type position
{
optionlist *nitem = createoption($2);
strcpy($$->type,$2.type);
insertoption(&$$,nitem);
nitem = NULL;
}
;
modifier_note_type:ACCIDENTAL
{
strcpy ($$.type, $1);
}
|ACCENT
{
strcpy ($$.type, $1);
}
|STYLE
{
strcpy ($$.type, $1);
}
|NUM
{
strcpy($$.type,"dots");
$$.dots = $1;
}
|ORNAMENT
{
strcpy ($$.type, $1);
}
|grace_notes
{
$$.gracenote = $1;
}
|TIE
{
strcpy ($$.type, $1);
}
|NOTEHEAD
{
strcpy ($$.type, $1);
}
;
tie:TIE
{
strcpy ($$, $1);
}
;
dot:NUM
{
$$ = $1;
}
;
grace_notes:pitch stem_dir grace_note_option beam FLOAT position
{
$$.t_pitch = $1;
strcpy ($$.stemdir, $2);
$$.option = $3;
$$.t_beamd = $4;
$$.duration = $5;
$$.t_position = $6;
}
;
grace_note_option:ACCIDENTAL position
{
strcpy ($$.type, $1);
$$.t_position = $2;
}
|ACCENT position
{
strcpy ($$.type, $1);
$$.t_position = $2;
}
|STYLE position
{
strcpy ($$.type, $1);
$$.t_position = $2;
}
|dot position
{
$$.dots = $1;
$$.t_position = $2;
}
|ORNAMENT position
{
strcpy ($$.type, $1);
$$.t_position = $2;
}
|tie position
{
strcpy ($$.type, $1);
$$.t_position = $2;
}
beam:beam_type
{
$$.type = $1;
}
|flag
{
strcpy ($$.direction, $1);
}
|END
{
}
;
beam_type:primary DIRECTION
{
strcpy ($$.btype, $1);
strcpy ($$.direction, $2);
}
|secondary DIRECTION
{
strcpy ($$.btype, $1);
strcpy ($$.direction, $2);
}
;
flag:DIRECTION
{
}
;
primary:FULL
{
}
;
secondary:PARTIAL
{
}
;
tuplet:TUPLET tuplet_option
{
objnode *theobj = firstobjnode (frogsi->currentmeasure);
mudelaobject *newmudelaobj = NULL;
newmudelaobj = newtupopen ($2.numerator, $2.denominator);
theobj = g_list_insert (theobj, newmudelaobj, counter);
frogsi->cursor_x++;
frogsi->currentmeasure->data = theobj;
if (frogsi->cursor_appending)
{
frogsi->currentobject = g_list_last (theobj);
}
else
{
frogsi->currentobject = g_list_nth (theobj, frogsi->cursor_x);
}
is_tup = TRUE;
}
|TUPLET TUP_END
{
objnode *theobj = firstobjnode (frogsi->currentmeasure);
mudelaobject *newmudelaobj = NULL;
newmudelaobj = newtupclose ();
theobj = g_list_insert (theobj, newmudelaobj, counter);
frogsi->cursor_x++;
frogsi->currentmeasure->data = theobj;
if (frogsi->cursor_appending)
{
frogsi->currentobject = g_list_last (theobj);
}
else
{
frogsi->currentobject = g_list_nth (theobj, frogsi->cursor_x);
}
is_tup = FALSE;
}
;
tuplet_option:NUM NUM
{
$$.numerator = $1;
$$.denominator = $2;
} /*slur_position number_position */
;
slur:SLURTYPE position CURVESHAPE
{
strcpy ($$.string, $1);
$$.t_position = $2;
strcpy ($$.curve, $3);
}
hairpin: HAIRPINTYPE
{
strcpy ($$.string, $1);
};
keysignature:no_of_sharps no_of_flats name_of_sharps name_of_flats | MODE
{
}
|KEYTYPE
{
newkeysigobj ($1);
}
;
no_of_sharps:NUM
{
}
;
no_of_flats:NUM
{
}
;
name_of_sharps:NOTENAME name_of_sharps
{
}
|END
{
}
;
name_of_flats:NOTENAME name_of_flats
{
}
|END
{
}
;
tempo:stationary | transitional;
stationary:tempo_term | FLOAT '=' NUM
{
}
;
tempo_term:TEMPOTERM
{
}
;
transitional:TRANSTEMPO
{
}
;
no_of_lines:NUM
{
$$ = $1;
}
;
transposition:NUM
{
$$ = $1;
}
;
additive:NUM '+' additive
{
$$ = $1;
}
|NUM
{
$$ = $1;
}
;
timesignature:additive '/' NUM
{
newtimesig ($1, $3);
}
|additive '/' NUM '+' timesignature
{
}
;
number_of_half_lines:NUM
{
}
;
position_in_half_lines:NUM
{
$$ = $1;
}
;
%%int
froginput (char *filename, struct scoreinfo *si)
{
extern FILE *yyin;
#ifdef YYDEBUG
// yydebug =1;
#endif
if ((yyin = fopen (filename, "r")) == NULL)
{
fprintf (stderr, "Cannot open the file: %s\n", filename);
return -1;
}
else
{
fprintf (stderr, "In FROGINPUT");
yy_setscore (si);
while (!feof (yyin))
{
yyparse ();
}
}
fclose (yyin);
return 0;
}
int
yyerror (char *errmsg)
{
extern char *yytext;
fprintf (stderr, "%d : %s at default %s\n", count, errmsg, yytext);
return 0;
}
/*
* Add a new note to the bar takes p_note structure with all the data
* for the note to be inserted
*
*/
void
newnoteobj (struct p_note *thenote, gfloat length, struct scoreinfo *si)
{
gint no_dots=0;
gchar notehead[20];
objnode *theobj = firstobjnode (si->currentmeasure);
mudelaobject *newmudelaobj = NULL;
/*struct p_modifier *mod = NULL;*/
struct p_noteoption *list = NULL;
note *newnote = NULL;
gint duration = 0, notename = 0, enharmonic = 0;/*, i = 0;*/
gboolean is_tie = FALSE;
mudelaobject *curmudelaobj =
si->currentobject ? si->currentobject->data : NULL;
notename =
fetchnotename (thenote->t_pitch.notename, thenote->t_pitch.octave);
enharmonic = fetchenharmonic (thenote->t_pitch.notename);
for(list = thenote->t_option; list; list = list->next)
{
/*printf("Modifier = %s : %d \n",list->t_modifier.type,
list->t_modifier.dots);*/
if (!strcmp (list->t_modifier.type, "tie"))
is_tie = TRUE;
if (list->t_modifier.dots)
no_dots = list->t_modifier.dots;
if (!strcmp (list->t_modifier.type, "cross")
|| !strcmp (list->t_modifier.type, "diamond")
|| !strcmp (list->t_modifier.type, "harmonic"))
{
strcpy (notehead,list->t_modifier.type);
}
else
strcpy (notehead,"normal");
}
if (beatnum != totaldurs)
{
duration = floattoduration (length, is_tup);
newmudelaobj = newchord (duration, no_dots);
newmudelaobj->u.chordval.is_tied = is_tie;
for(list = thenote->t_option; list; list = list->next)
{
if (strcmp (list->t_modifier.type, "accent") == 0)
newmudelaobj->u.chordval.is_accented_p = TRUE;
if (strcmp (list->t_modifier.type, "staccato") == 0)
newmudelaobj->u.chordval.has_stacatto_p = TRUE;
if (strcmp (list->t_modifier.type, "fermata") == 0)
newmudelaobj->u.chordval.has_fermata_p = TRUE;
if (strcmp (list->t_modifier.type, "tenuto") == 0)
newmudelaobj->u.chordval.has_tenuto_p = TRUE;
if (strcmp (list->t_modifier.type, "trill") == 0)
newmudelaobj->u.chordval.has_trill_p = TRUE;
if (strcmp (list->t_modifier.type, "turn") == 0)
newmudelaobj->u.chordval.has_turn_p = TRUE;
if (strcmp (list->t_modifier.type, "mordent") == 0)
newmudelaobj->u.chordval.has_mordent_p = TRUE;
if (strcmp (list->t_modifier.type, "staccatissimo") == 0)
newmudelaobj->u.chordval.has_staccatissimo_p = TRUE;
if (strcmp (list->t_modifier.type, "ubow") == 0)
newmudelaobj->u.chordval.has_ubow_p = TRUE;
if (strcmp (list->t_modifier.type, "dbow") == 0)
newmudelaobj->u.chordval.has_dbow_p = TRUE;
}
addtone (newmudelaobj, notename, enharmonic, cleftype);
if(notehead)
{
newnote = newmudelaobj->u.chordval.tones->data;
newnote->noteheadtype = setnoteheadtype (notehead);
}
theobj = g_list_insert (theobj, newmudelaobj, counter);
si->cursor_x++;
si->currentmeasure->data = theobj;
if (si->cursor_appending)
si->currentobject = g_list_last (theobj);
else
si->currentobject = g_list_nth (theobj, si->cursor_x);
}
else
{
addtone (curmudelaobj, notename, enharmonic, cleftype);
}
/* Should really do these two things once per measure, but anyway: */
}
static gint
setnoteheadtype (gchar * type)
{
if (strcmp (type, "cross") == 0)
return CROSS;
else if (strcmp (type, "diamond") == 0)
return DIAMOND;
else if (strcmp (type, "harmonic") == 0)
return HARMONIC;
else
return NORMAL;
}
/*
* Add new Clef at the beginning of the staff
*
*/
static void
newclef (char *clefname)
{
gint clefstring;
mudelaobject *clefobj;
clefstring = cleftoenum (clefname);
cleftype = clefstring;
if (counter == 1)
{
((staff *) frogsi->currentstaff->data)->sclef = clefstring;
find_leftmost_staffcontext (frogsi->currentstaff->data, frogsi);
}
else
{
clefobj = newclefobj (clefstring);
frogsi->currentmeasure->data = g_list_append
(frogsi->currentmeasure->data, clefobj);
}
}
/*
* Add new Key Signature at the beginning of the staff
*
*/
static void
newkeysigobj (char *keyname)
{
mudelaobject *newobj = NULL;
gboolean isminor = FALSE;
gint keynum = 0;
gint len = strlen (keyname);
keynum = Keytoint (keyname);
fprintf (stderr, "%d len \t %d keynum \n ", len, keynum);
if (len == 4)
{
if (keyname[1] == 'm' && keyname[2] == 'i' && keyname[3] == 'n')
{
if (counter == 2)
((staff *) frogsi->currentstaff->data)->skey_isminor = TRUE;
else
isminor = TRUE;
}
}
else if (len == 5)
{
if (keyname[2] == 'm' && keyname[3] == 'i' && keyname[4] == 'n')
{
if (counter == 2)
((staff *) frogsi->currentstaff->data)->skey_isminor = TRUE;
else
isminor = TRUE;
}
}
if (counter == 2)
{
((staff *) frogsi->currentstaff->data)->skey = keynum;
find_leftmost_allcontexts (frogsi);
}
else
{
newobj = newkeyobj (keynum, isminor);
frogsi->currentmeasure->data = g_list_append
(frogsi->currentmeasure->data, newobj);
}
initkeyaccs (((staff *) frogsi->currentstaff->data)->skeyaccs, keynum);
}
/*
* Add new Time Signature at the beginning of the staff
*
*/
static void
newtimesig (gint upper, gint lower)
{
mudelaobject *ret;
if (counter == 3)
{
((staff *) frogsi->currentstaff->data)->stime1 = upper;
((staff *) frogsi->currentstaff->data)->stime2 = lower;
find_leftmost_staffcontext (frogsi->currentstaff->data, frogsi);
}
else
{
ret = newtimesigobj (upper, lower);
frogsi->currentmeasure->data = g_list_append
(frogsi->currentmeasure->data, ret);
}
}
static void
newdynamic (gchar * type)
{
mudelaobject *ret;
ret = dynamic_new (type);
frogsi->currentmeasure->data = g_list_append
(frogsi->currentmeasure->data, ret);
}
/* Set global Parser structure equal to the main scoreinfo structure */
void
yy_setscore (struct scoreinfo *si)
{
frogsi = si;
free_score (frogsi);
frogsi->currentstaffnum = 0;
}
optionlist *createoption(struct p_modifier option)
{
optionlist *newitem = (optionlist *)malloc(sizeof(optionlist));
if(!newitem)
return NULL;
else {
newitem->t_modifier = option;
newitem->next = NULL;
}
return newitem;
}
void insertoption(optionlist **header, optionlist *newitem)
{
newitem->next = *header;
*header = newitem;
return;
}
void emptylist(optionlist *head)
{
optionlist *itemdel = NULL;
while(head != NULL) {
itemdel = head;
itemdel->next = NULL;
free(itemdel);
head = head->next;
}
}
|