home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / SOUNDUTILS / tracker.4.6.lzh / TRACKER4.6 / dump_song.c < prev    next >
Text File  |  1994-11-24  |  4KB  |  167 lines

  1. /* dump_song.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4.  
  5. /* $Id: dump_song.c,v 4.4 1994/11/15 16:11:01 espie Exp espie $
  6.  * $Log: dump_song.c,v $
  7.  * Revision 4.4  1994/11/15  16:11:01  espie
  8.  * *** empty log message ***
  9.  *
  10.  *
  11.  * Revision 4.0  1994/01/11  17:46:01  espie
  12.  * Use virtual windows.
  13.  * No more call to run_in_fg(), use begin_info result instead.
  14.  * Added instrument name as shown per display.c.
  15.  * Use info facility.
  16.  * Amiga support.
  17.  * Very small bug with volume (Lawrence).
  18.  * Added finetune display.
  19.  * Added bg/fg test.
  20.  */
  21.  
  22. #include "defs.h"
  23.  
  24. #ifdef MALLOC_NOT_IN_STDLIB
  25. #include <malloc.h>
  26. #else
  27. #include <stdlib.h>
  28. #endif
  29. #include <stdio.h>
  30. #include <string.h>
  31. #include <ctype.h>
  32.  
  33. #include "song.h"
  34. #include "extern.h"
  35. #include "channel.h"
  36.  
  37. ID("$Id: dump_song.c,v 4.4 1994/11/15 16:11:01 espie Exp espie $")
  38.  
  39. LOCAL void *handle = 0;
  40. LOCAL char buffer[80];
  41. extern char instname[];
  42.  
  43. /***
  44.  *
  45.  *  dump_block/dump_song:
  46.  *  shows most of the readable info
  47.  *  concerning a module on the screen.
  48.  *
  49.  ***/
  50.  
  51. LOCAL void dump_block(b)
  52. struct block *b;
  53.    {
  54.    int i, j;
  55.  
  56.    for (i = 0; i < BLOCK_LENGTH; i++)
  57.       {
  58.       for (j = 0; j < NUMBER_TRACKS; j++)
  59.          {
  60.          sprintf(buffer,"%8d%5d%2d%4d", b->e[j][i].sample_number,
  61.             b->e[j][i].pitch, b->e[j][i].effect,
  62.             b->e[j][i].parameters);
  63.          infos(handle, buffer);
  64.          }
  65.       info(handle, "");
  66.       }
  67.    }
  68.  
  69. /* make_readable(s):
  70.  * transform s into a really readable string */
  71.  
  72. LOCAL void make_readable(s)
  73. char *s;
  74.    {
  75.    char *t, *orig;
  76.  
  77.    if (!s)
  78.       return;
  79.  
  80.    orig = s;
  81.    t = s;
  82.  
  83.       /* get rid of the st-xx: junk */
  84.    if (strncmp(s, "st-", 3) == 0 || strncmp(s, "ST-", 3) == 0)
  85.       {
  86.       if (isdigit(s[3]) && isdigit(s[4]) && s[5] == ':')
  87.          s += 6;
  88.       }
  89.    while (*s)
  90.       {
  91.       if (isprint(*s))
  92.          *t++ = *s;
  93.       s++;
  94.       }
  95.    *t = '\0';
  96.    while (t != orig && isspace(t[-1]))
  97.       *--t = '\0';
  98.    }
  99.  
  100. void dump_song(song)
  101. struct song *song;
  102.    {
  103.    int i, j;
  104.    int maxlen;
  105.    static char dummy[1];
  106.  
  107.    
  108.    handle = begin_info(song->title);
  109.    if (!handle)
  110.       return;
  111.  
  112.    dummy[0] = '\0';
  113.    maxlen = 0;
  114.    for (i = 1; i < NUMBER_SAMPLES; i++)
  115.       {
  116.       if (!song->samples[i].name)
  117.          song->samples[i].name = dummy;
  118.       make_readable(song->samples[i].name);
  119.       if (maxlen < strlen(song->samples[i].name))
  120.          maxlen = strlen(song->samples[i].name);
  121.       }
  122.    for (i = 1; i < NUMBER_SAMPLES; i++)
  123.       {
  124.       if (song->samples[i].start || strlen(song->samples[i].name) > 2)
  125.          {
  126.          char s[3];
  127.          
  128.          s[0] = instname[i];
  129.          s[1] = ' ';
  130.          s[2] = 0;
  131.          infos(handle, s);
  132.          infos(handle, song->samples[i].name);
  133.          for (j = strlen(song->samples[i].name); j < maxlen + 2; j++)
  134.             infos(handle, " ");
  135.          if (song->samples[i].start)
  136.             {
  137.             sprintf(buffer, "%5d", song->samples[i].length);
  138.             infos(handle, buffer);
  139.             if (song->samples[i].rp_length > 2)
  140.                {
  141.                sprintf(buffer, "(%5d %5d)", 
  142.                   song->samples[i].rp_offset, 
  143.                   song->samples[i].rp_length);
  144.                infos(handle, buffer);
  145.                }
  146.             else
  147.                infos(handle, "             ");
  148.             if (song->samples[i].volume != MAX_VOLUME)
  149.                {
  150.                sprintf(buffer, "%3d", song->samples[i].volume);
  151.                infos(handle, buffer);
  152.                }
  153.             else 
  154.                infos(handle, "   ");
  155.             if (song->samples[i].finetune)
  156.                {
  157.                sprintf(buffer, "%3d", song->samples[i].finetune);
  158.                infos(handle, buffer);
  159.                }
  160.             }
  161.          info(handle, "");
  162.          }
  163.       }
  164.    end_info(handle);
  165.    handle = 0;
  166.    }
  167.