home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / sonido / mod-0.000 / mod-0 / mod / mod.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-15  |  8.4 KB  |  322 lines

  1. /*
  2.  *  mod.h - Main header file
  3.  *
  4.  *  (C) 1994 Mikael Nordqvist (d91mn@efd.lth.se, mech@df.lth.se)
  5.  */
  6.  
  7. #ifndef _MOD_H
  8. #define _MOD_H
  9.  
  10. #include <limits.h>
  11.  
  12. /*
  13.  *  Name of the mixer device-file.
  14.  */
  15.  
  16. #define MIXER_NAME "/dev/mixer"
  17.  
  18. /*
  19.  *  Decompressing commands
  20.  */
  21.  
  22. #define GZIP_COMMAND     "gzip -cd "
  23. #define LHA_COMMAND      "lharc xqf "
  24. #define LHA_COMMAND_LIST "lharc l "
  25. #define ZIP_COMMAND      "unzip -xq "
  26. #define ZIP_COMMAND_LIST "unzip -lq "
  27. #define ARJ_COMMAND      "unarj e "
  28. #define ARJ_COMMAND_LIST "unarj l "
  29.  
  30. #define TMP_DIR          "/tmp/.modtmp"
  31.  
  32. /*
  33.  *  Global environment variable
  34.  */
  35.  
  36. #define ENV_VAR_NAME "MOD_OPTIONS"
  37.  
  38. /*
  39.  *  Format of modules
  40.  */
  41.  
  42. #define MODFORMAT_MOD 1
  43. #define MODFORMAT_ULT 2
  44. #define MODFORMAT_MTM 3
  45. #define MODFORMAT_S3M 4
  46.  
  47. /*
  48.  *  Constants for effects
  49.  */
  50.  
  51. /* PT-effects */
  52.  
  53. #define EFX_ARPEGGIO           0x00
  54. #define EFX_PORTAUP            0x01
  55. #define EFX_PORTADOWN          0x02
  56. #define EFX_PORTANOTE          0x03
  57. #define EFX_VIBRATO            0x04
  58. #define EFX_PORTANOTEVOLSLIDE  0x05
  59. #define EFX_VIBRATOVOLSLIDE    0x06
  60. #define EFX_TREMOLO            0x07
  61. #define EFX_UNUSED1            0x08 /* Unused EFX # */
  62. #define EFX_SAMPLEOFFSET       0x09
  63. #define EFX_VOLSLIDE           0x0a
  64. #define EFX_JUMP               0x0b
  65. #define EFX_VOLUME             0x0c
  66. #define EFX_BREAK              0x0d
  67. #define EFX_EXTENDED           0x0e /* should never appear in code */
  68. #define EFX_PTSPEED            0x0f
  69.  
  70. #define EFX_FILTER             0x10 /* NOT SUPPORTED */
  71. #define EFX_FINEPORTAUP        0x11
  72. #define EFX_FINEPORTADOWN      0x12
  73. #define EFX_GLISSANDO          0x13
  74. #define EFX_VIBWAVEFORM        0x14
  75. #define EFX_FINETUNE           0x15
  76. #define EFX_LOOP               0x16
  77. #define EFX_TREMWAVEFORM       0x17
  78. #define EFX_UNUSED2            0x18 /* KarplusStrong in PT3.0; NOT SUPPORTED */
  79. #define EFX_RETRIGGER          0x19
  80. #define EFX_FINEVOLSLIDEUP     0x1a
  81. #define EFX_FINEVOLSLIDEDOWN   0x1b
  82. #define EFX_NOTECUT            0x1c
  83. #define EFX_NOTEDELAY          0x1d
  84. #define EFX_PATTERNDELAY       0x1e
  85. #define EFX_INVERTEDLOOP       0x1f /* NOT SUPPORTED */
  86.  
  87. /* New effects for ULT (EFX_BALANCE is used with MTM's too) */
  88.  
  89. #define EFX_BALANCE            0x20
  90. #define EFX_VIBDEPTH           0x21
  91. #define EFX_SAMPLEOFFSET_ULT   0x22
  92.  
  93. /* New effects for S3M */
  94.  
  95. #define EFX_EXTRAFINEPORTAUP   0x23
  96. #define EFX_EXTRAFINEPORTADOWN 0x24
  97. #define EFX_TREMOR             0x25
  98. #define EFX_SAMPLEOFFSET_S3M   0x26
  99. #define EFX_RETRIGGERVOLSLIDE  0x27
  100. #define EFX_SPEED              0x28
  101. #define EFX_TEMPO              0x29
  102. #define EFX_GLOBALVOLUME       0x2a
  103. #define EFX_PORTAUPCONTINUE    0x2b
  104. #define EFX_PORTADOWNCONTINUE  0x2c
  105. #define EFX_VOLSLIDECONTINUE   0x2d
  106.  
  107. #define NR_EFX                 0x2e
  108. #define NR_OCTAVES               10
  109.  
  110. #define WAVEFORM_SINE    0
  111. #define WAVEFORM_RAMP    1
  112. #define WAVEFORM_SQUARE  2
  113. #define WAVEFORM_RANDOM  3
  114.  
  115. #define LOOP_FORWARD     1
  116. #define LOOP_BIDIR       2
  117.  
  118. #define S3M_ORDER_SKIP     254
  119. #define S3M_ORDER_SONGEND  255
  120.  
  121. /*
  122.  *  Structures used to store the module in memory.
  123.  *  Notes are accessed with the GET_EVENT() macro below.
  124.  *
  125.  *  Track = pattern for one voice (64 events).
  126.  */
  127.  
  128. #define GET_EVENT_PTR(voice, pattern, line) \
  129.         (&M.tracks[M.track_idx[voice][pattern]][line])
  130.  
  131. struct event {
  132.     unsigned char note;
  133.     unsigned char sample;
  134.     unsigned char effect;
  135.     unsigned char arg;
  136.     unsigned char effect2;  /* The second effect is for ULT */
  137.     unsigned char arg2;
  138. };
  139.  
  140.  
  141. struct sample_info {
  142.     char           name[33];    /* PT=22, ULT=32 */
  143.     char           dosname[13]; /* ULT */
  144.     char           finetune;
  145.     char           bits_16;     /* True if 16 bit sample (ULT) */
  146.     char           unsigned_data; /* True if unsigned data */
  147.     char           looped;
  148.     int            length;
  149.     unsigned char  volume;
  150.     char           valid;
  151.     int            repeat_start;
  152.     int            repeat_end;
  153.     char           *data;
  154.     int            c2freq;
  155. };
  156.  
  157. #define MAX_VOICES 32
  158.  
  159. struct mod_info {
  160.     char           format;                  /* What type of module it is  */
  161.     char           name[32];                /* Mod 20+1, ult 32+0         */
  162.     char           filename[NAME_MAX];      /* uncompressed name w/o path */ 
  163.     char           real_filename[PATH_MAX]; /* name of the file w/ path   */
  164.     unsigned short  nr_voices;
  165.     unsigned char  restartpos;
  166.     unsigned short songlength;
  167.     unsigned short nr_patterns;
  168.     unsigned short nr_tracks;   /* nr_patterns*nr_voices if uncompressed */
  169.     unsigned short nr_samples;
  170.  
  171.     unsigned char  panning[MAX_VOICES];  /* Panning of the voices  */
  172.     struct sample_info *sample;          /* sample[0] not used     */
  173.     unsigned char  patterntable[256];    /* order to play patterns
  174.                       * PT=128, ULT=256
  175.                       */
  176.  
  177.     int            *track_idx[MAX_VOICES];
  178.     struct event   **tracks;    
  179.     char           *songtext;   /* Only used for Ultratracker modules */
  180.     unsigned char  volrange;    /* MOD 64, ULT 255 */
  181. };
  182.  
  183. /*
  184.  *  Structures used to play module
  185.  */
  186.  
  187. struct voice {
  188.     int sample;                /* Current sample    */
  189.     char finetune;             /* Current finetune  */
  190.     unsigned char volume;      /* Current volume    */
  191.     unsigned char real_volume; /* Current volume used to play note */
  192.  
  193.     unsigned char note;        /* Current note(midi)*/
  194.  
  195.     int pitchbend;        /* Current pitchbend */
  196.     int real_period;      /* Period used to calculate pitchbend */
  197.     int period;           /* Period used to calculate effects   */
  198.  
  199.     int period_goal;      /* Period goal during toneportamento  */
  200.     int toneporta_speed;  /* Speed of toneportamento            */
  201.     char glissando;       /* True if glissando is on   */
  202.  
  203.     char vibrato;         /* True if we have vibrato   */
  204.     char vibrato_retrig;  /* True if waveform is retriggered */
  205.     int vibrato_amplitude;/* Amplitude of vibrato      */
  206.     int vibrato_speed;    /* Speed of vibrato          */
  207.     int vibrato_pos;      /* Position in vibratotable  */
  208.     int vibrato_waveform; /* Waveform used for vibrato */
  209.  
  210.     char tremolo;         /* True if we have tremolo */
  211.     char tremolo_retrig;  /* True if waveform is retriggered */
  212.     int tremolo_amplitude;/* Amplitude of tremolo      */
  213.     int tremolo_speed;    /* Speed of tremolo          */
  214.     int tremolo_pos;      /* Position in vibratotable  */
  215.     int tremolo_waveform; /* Waveform used for tremolo */
  216.  
  217.     unsigned int sampleoffset;      /* Current sample offset        */
  218.     unsigned int last_sampleoffset; /* Last specified sample offset */
  219.     int last_volumeslide;               /* Used for S3M's */
  220.     unsigned char last_volumeslidetype; /* Used for S3M's */
  221.     int last_portamento;                /* Used for S3M's */
  222.     unsigned char last_portamentotype;  /* Used for S3M's */
  223.  
  224.     unsigned int loopcount;         /* Remaining iterations  */
  225.     unsigned char loopstartpos;     /* Loop restart position */
  226. };
  227.  
  228. struct effects {
  229.     /* The following 3 variables have the same names as in pt-replay.s to make
  230.      * it easier for me to mimic it's behaviour. 
  231.      */
  232.  
  233.     char PosJumpFlag; /* True when a new pattern should be activated at
  234.                * position PBreakPos (EFX_JMP|BREAK).
  235.                */
  236.     char PBreakFlag;  /* True when we should jump back in pattern (EFX_LOOP) */
  237.     
  238.     char PBreakPos;   /* Line to start with in next pattern (EFX_JMP|BREAK) OR
  239.                * Line to jump to in current pattern (EFX_LOOP)
  240.                */
  241.  
  242.     char pattern_delay;
  243.  
  244.     char set_volume, set_finepitch, set_balance;
  245.     char note_delay, dont_trigger_note, kill_voice;
  246.     unsigned char retrig_note;
  247. };
  248.  
  249. /*
  250.  *  Structure handling options for the current module
  251.  */
  252.  
  253. struct options {
  254.     char
  255.     noscroll,
  256.     nobpm,
  257.     speed0stop,
  258.         mono,
  259.     ntsc_samples,
  260.     break_loops,
  261.     tolerant,
  262.  
  263.     verbose,
  264.     interactive,
  265.     quiet,
  266.  
  267.     auto_next,
  268.     random_mode,
  269.     loop_module,
  270.     replay_forever,
  271.     play_list;
  272.  
  273.     int 
  274.     speed,
  275.     tempo,
  276.     start_pos,
  277.     active_voices,
  278.     maxtime,
  279.     click_removal,
  280.     max_lines,
  281.     voice_detail,
  282.  
  283.     format,
  284.     low_note,
  285.     high_note;
  286. };
  287.  
  288. /*
  289.  *  Structure used to store current files
  290.  */
  291.  
  292. struct mod_file {
  293.     char *name;
  294.     int size;
  295.     char dir;     /* True if this is a directory */
  296.     char options; /* True if there are options (play_list) */
  297. };
  298.  
  299. /*
  300.  *  Various constants
  301.  */
  302.  
  303. #define BASE_NOTE (1*12)
  304. #define NOTE_OFF  (NR_OCTAVES*12+BASE_NOTE)
  305.  
  306. #define QUIT_QUIT   1
  307. #define QUIT_SIGNAL 2
  308.  
  309. #define PIPE_READ  0
  310. #define PIPE_WRITE 1
  311.  
  312. /*
  313.  *  MIN - MAX macros
  314.  */
  315.  
  316. #define MIN(x,y) (x < y ? x : y)
  317. #define MAX(x,y) (x > y ? x : y)
  318.  
  319. #include "protos.h"
  320.  
  321. #endif /* _MOD_H */
  322.