home *** CD-ROM | disk | FTP | other *** search
/ PC Musician 2000 / PC_Musician_2000.iso / PCMUSIC / NOTATION / SCOREIO / SCTOOL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-26  |  4.3 KB  |  112 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6. #include "sctypes.h"
  7. #include "sclib.h"
  8.  
  9. #define MAX_NAMES       99
  10.  
  11. #define INFO_1   "\n\nFile %s loaded with %d parameters in %d items"
  12. #define INFO_2   "\nFile %s saved with %d parameters in %d items"
  13.  
  14. void resize(list_ptr sl);                           /* Function prototype */
  15.  
  16.  
  17.  
  18. Int main()
  19. {
  20.         Char            fname[MAX_NAMES+1][FNAME_LEN];
  21.         Int             i, count, erg;
  22.         list_head       sl;
  23.  
  24. /*------------------- Query filenames ------------------------------------*/
  25.  
  26.         printf("\nEnter filename and number of files--");
  27.         scanf("%20s %d", fname[0], &count);
  28.         if (strlen(fname[0]) >= FNAME_LEN) {
  29.           printf("\nError filename too long");
  30.           return(-1);
  31.         }
  32.         strupr(fname[0]);                           /* All upper case */
  33.  
  34.         count = get_fnames(fname, count, MAX_NAMES);
  35.         if (count < 1) {
  36.            printf("\nError while reading %s", fname[0]);
  37.         }
  38.  
  39. /*------------------- Load SCORE file ------------------------------------*/
  40.  
  41.         for (i = 0; i < count; i++) {              /* Process every file */
  42.           erg  = get_parms(fname[i], &sl);         /* Load SCORE-file    */
  43.           if(erg < 0) printf("\nError while loading %s", fname[i]);
  44.           else {
  45.             printf(INFO_1, fname[i], sl.parameters+1, sl.items);
  46.  
  47. /*------------------- Process SCORE-file----------------------------------*/
  48.  
  49.         sort_items_xy(&sl);                     /* sort all items     */
  50.  
  51.             resize(&sl);                   /* resize half and whole notes */
  52.  
  53. /*------------------- Save SCORE file ------------------------------------*/
  54.  
  55.             erg = put_parms(fname[i], &sl);       /* save SCORE-file     */
  56.             if (erg == OK)
  57.               printf(INFO_2, fname[i], sl.parameters+1, sl.items);
  58.             else {
  59.               printf("\nError while saving %s", fname[i]);
  60.               return(-1);
  61.             }
  62.           } /* else */
  63.           set_free(&sl);                                /* release Memory */
  64.         }   /* for  */
  65.         return(0);
  66. } /* end of main programm */
  67.  
  68. /*----------------------------------------------------------------------------*/
  69. /* This procedure resizes half and whole notes (P15 = 1.1) which was a        */
  70. /* requirement of my publisher for a string-quartett score.                   */
  71. /*                                                                            */
  72. /* The problem was that if you change P15 you also have to adjust the         */
  73. /* steam-length (P8)                                                          */
  74. /*                                                                            */
  75. /*----------------------------------------------------------------------------*/
  76. void resize(list_ptr sl)
  77. {
  78.         item_ptr cur_pos;            /* cur_pos is our pointer to the       */
  79.         Float   *cdp, os;            /* current item                        */
  80.         Int     j, cnt;
  81.  
  82.         cur_pos = sl -> first;       /* cur_pos points to first item        */
  83.  
  84.         while (cur_pos != NULL) {    /* process all items                   */
  85.           cdp = cur_pos -> cd;       /* the float array cdp contains the    */
  86.                                      /* parameters                          */
  87.  
  88.           cnt = (int) cdp[0];        /* cdp[0] contains the valid number of */
  89.                                      /* parameters for the current item     */
  90.  
  91.           for (j = cnt+1; j <= 18; j++)  cdp[j] = 0.0;
  92.  
  93.           if (cdp[1] == 1.0F) {        /* process only notes                  */
  94.  
  95.             os = 1.0F;
  96.             if (cdp[0] >= 15) os = cdp[15];
  97.  
  98.             if ((cdp[7] >= 2.0F) && (cdp[4] < 100.0F)) {
  99.               cdp[15] = 1.1F;                                /* resize note */
  100.               cdp[8]  = (os / cdp[15]) * (cdp[8] + 7.0F) - 7.0F; /* adjust steam */
  101.               if (cdp[0] < 15) cdp[0]  = 15.0F;  /* now there are 15 valid pars */
  102.             }
  103.             if ((cdp[7] >= 4.0F) && (cdp[4] < 100.0F))
  104.               cdp[8] = 0.0F;               /* no steam with whole notes     */
  105.           }
  106.           cur_pos = cur_pos -> next;       /* take next item                */
  107.         }
  108. }
  109.  
  110.  
  111.  
  112.