home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / SOUNDUTILS / mm1_tracker.lzh / TRACKER4.6 / analyzer.c next >
C/C++ Source or Header  |  1994-11-24  |  3KB  |  154 lines

  1. /* analyzer.c 
  2.     vi:ts=3 sw=3:
  3. */
  4.  
  5.  
  6. /* read module files and output statistics on them */
  7.  
  8. /* $Id: analyzer.c,v 4.4 1994/11/15 16:11:01 espie Exp espie $
  9.  * $Log: analyzer.c,v $
  10.  * Revision 4.4  1994/11/15  16:11:01  espie
  11.  * *** empty log message ***
  12.  *
  13.  *
  14.  * Revision 4.1  1994/01/12  16:10:20  espie
  15.  * Fixed up last minute problems.
  16.  * Lots of changes.
  17.  * removed create_note_tables(), run_in_fg().
  18.  * Use new pref scheme.
  19.  * New open_file semantics.
  20.  * Added speed check.
  21.  * Added patch for non termio.
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27.  
  28. #include "defs.h"
  29. #include "extern.h"
  30. #include "song.h"
  31. #include "tags.h"
  32. #include "prefs.h"
  33.  
  34. ID("$Id: analyzer.c,v 4.4 1994/11/15 16:11:01 espie Exp espie $")
  35.  
  36. int error;
  37.  
  38. struct song *do_read_song(name, type)
  39. char *name;
  40. int type;
  41.    {
  42.    struct song *song;
  43.    struct exfile *file;
  44.  
  45.    file = open_file(name, "r", getenv("MODPATH"));
  46.    if (!file)
  47.       return NULL;
  48.    song = read_song(file, type); 
  49.    close_file(file);
  50.    if (song)
  51.       puts(name);
  52.    return song;
  53.    }
  54.  
  55.  
  56. int use_command[16];
  57. int use_extended[16];
  58.  
  59. void analyze_block(b)
  60. struct block *b;
  61.    {
  62.    int i, j;
  63.    struct event *e;
  64.  
  65.    for (i = 0; i < BLOCK_LENGTH; i++)
  66.       {
  67.       int special;
  68.  
  69.       special = 0;
  70.       for (j = 0; j < NUMBER_TRACKS; j++)
  71.          {
  72.          e = &b->e[j][i];
  73.          switch(e->effect)
  74.             {
  75. #if 0
  76.          case 13: /* skip */
  77.             return;
  78.          case 11: /* fastskip */
  79.             return;
  80. #endif
  81.          case 14:
  82.             use_extended[HI(e->parameters)] = TRUE;
  83.             break;
  84.          case 15:
  85.             if (special != 0 && e->parameters != special)
  86.                putchar('!');
  87.             else
  88.                special = e->parameters;
  89.          default:
  90.             use_command[e->effect] = TRUE;
  91.             }
  92.          }
  93.       }
  94.    }
  95.  
  96.  
  97. void analyze_song(song)
  98. struct song *song;
  99.    {
  100.    int i;
  101.  
  102.    for (i = 0; i < NUMBER_SAMPLES; i++)
  103.       {
  104.       if (song->samples[i].start)
  105.          {
  106.          if (song->samples[i].finetune)
  107.             printf("Sample %d: finetune is %d\n", 
  108.                i, song->samples[i].finetune);
  109.          }
  110.       }
  111.    for (i = 0; i < 16; i++)
  112.       {
  113.       use_command[i] = FALSE;
  114.       use_extended[i] = FALSE;
  115.       }
  116.    for (i = 0; i < song->info.maxpat; i++)
  117.       analyze_block(song->info.pblocks+i);
  118.    for (i = 0; i < 16; i++)
  119.       if (use_command[i])
  120.          printf("%3d", i);
  121.    for (i = 0; i < 16; i++)
  122.       if (use_extended[i])
  123.          printf("%3dE", i);
  124.    printf("\n");
  125.    }
  126.  
  127. int main(argc, argv)
  128. int argc;
  129. char **argv;
  130.    {
  131.    int i;
  132.  
  133.    struct song *song;
  134.    int default_type;
  135.  
  136.    default_type = BOTH;
  137.    set_pref_scalar(PREF_TOLERATE, 2);
  138.  
  139.    for (i = 1; i < argc; i++)
  140.       {
  141.       song = do_read_song(argv[i], NEW);
  142.       if (!song && error != NEXT_SONG)
  143.          song = do_read_song(argv[i], OLD);
  144.       if (song)
  145.          {
  146.          analyze_song(song);
  147.          release_song(song);
  148.          }
  149.       }
  150.    }
  151.  
  152.  
  153.  
  154.