home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
-
- #include "sctypes.h"
- #include "sclib.h"
-
- #define MAX_NAMES 99
-
- #define INFO_1 "\n\nFile %s loaded with %d parameters in %d items"
- #define INFO_2 "\nFile %s saved with %d parameters in %d items"
-
- void resize(list_ptr sl); /* Function prototype */
-
-
-
- Int main()
- {
- Char fname[MAX_NAMES+1][FNAME_LEN];
- Int i, count, erg;
- list_head sl;
-
- /*------------------- Query filenames ------------------------------------*/
-
- printf("\nEnter filename and number of files--");
- scanf("%20s %d", fname[0], &count);
- if (strlen(fname[0]) >= FNAME_LEN) {
- printf("\nError filename too long");
- return(-1);
- }
- strupr(fname[0]); /* All upper case */
-
- count = get_fnames(fname, count, MAX_NAMES);
- if (count < 1) {
- printf("\nError while reading %s", fname[0]);
- }
-
- /*------------------- Load SCORE file ------------------------------------*/
-
- for (i = 0; i < count; i++) { /* Process every file */
- erg = get_parms(fname[i], &sl); /* Load SCORE-file */
- if(erg < 0) printf("\nError while loading %s", fname[i]);
- else {
- printf(INFO_1, fname[i], sl.parameters+1, sl.items);
-
- /*------------------- Process SCORE-file----------------------------------*/
-
- sort_items_xy(&sl); /* sort all items */
-
- resize(&sl); /* resize half and whole notes */
-
- /*------------------- Save SCORE file ------------------------------------*/
-
- erg = put_parms(fname[i], &sl); /* save SCORE-file */
- if (erg == OK)
- printf(INFO_2, fname[i], sl.parameters+1, sl.items);
- else {
- printf("\nError while saving %s", fname[i]);
- return(-1);
- }
- } /* else */
- set_free(&sl); /* release Memory */
- } /* for */
- return(0);
- } /* end of main programm */
-
- /*----------------------------------------------------------------------------*/
- /* This procedure resizes half and whole notes (P15 = 1.1) which was a */
- /* requirement of my publisher for a string-quartett score. */
- /* */
- /* The problem was that if you change P15 you also have to adjust the */
- /* steam-length (P8) */
- /* */
- /*----------------------------------------------------------------------------*/
- void resize(list_ptr sl)
- {
- item_ptr cur_pos; /* cur_pos is our pointer to the */
- Float *cdp, os; /* current item */
- Int j, cnt;
-
- cur_pos = sl -> first; /* cur_pos points to first item */
-
- while (cur_pos != NULL) { /* process all items */
- cdp = cur_pos -> cd; /* the float array cdp contains the */
- /* parameters */
-
- cnt = (int) cdp[0]; /* cdp[0] contains the valid number of */
- /* parameters for the current item */
-
- for (j = cnt+1; j <= 18; j++) cdp[j] = 0.0;
-
- if (cdp[1] == 1.0F) { /* process only notes */
-
- os = 1.0F;
- if (cdp[0] >= 15) os = cdp[15];
-
- if ((cdp[7] >= 2.0F) && (cdp[4] < 100.0F)) {
- cdp[15] = 1.1F; /* resize note */
- cdp[8] = (os / cdp[15]) * (cdp[8] + 7.0F) - 7.0F; /* adjust steam */
- if (cdp[0] < 15) cdp[0] = 15.0F; /* now there are 15 valid pars */
- }
- if ((cdp[7] >= 4.0F) && (cdp[4] < 100.0F))
- cdp[8] = 0.0F; /* no steam with whole notes */
- }
- cur_pos = cur_pos -> next; /* take next item */
- }
- }
-
-
-