timidity/instrum.h
author Ozkan Sezer <sezeroz@gmail.com>
Sat, 13 Oct 2018 23:02:04 +0300
branchSDL-1.2
changeset 908 6b860486ce24
parent 518 8bc9b5fd2aae
child 782 e7d3a8f73e88
permissions -rw-r--r--
Mix_InitMP3: unload dll if mpg123_init() fails.
     1 /*
     2     TiMidity -- Experimental MIDI to WAVE converter
     3     Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
     4 
     5     This program is free software; you can redistribute it and/or modify
     6     it under the terms of the Perl Artistic License, available in COPYING.
     7  */
     8 
     9 
    10 typedef struct {
    11   int32
    12     loop_start, loop_end, data_length,
    13     sample_rate, low_freq, high_freq, root_freq;
    14   uint8
    15     root_tune, fine_tune;
    16   int32
    17     envelope_rate[7], envelope_offset[7],
    18     modulation_rate[7], modulation_offset[7];
    19   FLOAT_T
    20     volume, resonance,
    21     modEnvToFilterFc, modEnvToPitch, modLfoToFilterFc;
    22   sample_t *data;
    23   int32 
    24     tremolo_sweep_increment, tremolo_phase_increment, 
    25     lfo_sweep_increment, lfo_phase_increment,
    26     vibrato_sweep_increment, vibrato_control_ratio,
    27     cutoff_freq;
    28   uint8
    29     reverberation, chorusdepth,
    30     tremolo_depth, vibrato_depth,
    31     modes;
    32   uint8
    33     attenuation, freq_center;
    34   int8
    35     panning, note_to_use, exclusiveClass;
    36   int16
    37     scale_tuning, keyToModEnvHold, keyToModEnvDecay,
    38     keyToVolEnvHold, keyToVolEnvDecay;
    39   int32
    40     freq_scale, vibrato_delay;
    41 } Sample;
    42 
    43 /* Bits in modes: */
    44 #define MODES_16BIT	(1<<0)
    45 #define MODES_UNSIGNED	(1<<1)
    46 #define MODES_LOOPING	(1<<2)
    47 #define MODES_PINGPONG	(1<<3)
    48 #define MODES_REVERSE	(1<<4)
    49 #define MODES_SUSTAIN	(1<<5)
    50 #define MODES_ENVELOPE	(1<<6)
    51 #define MODES_FAST_RELEASE	(1<<7)
    52 
    53 #if 0
    54 typedef struct {
    55   int samples;
    56   Sample *sample;
    57 } Instrument;
    58 #endif
    59 
    60 #define INST_GUS	0
    61 #define INST_SF2	1
    62 
    63 typedef struct {
    64   int type;
    65   int samples;
    66   Sample *sample;
    67   int left_samples;
    68   Sample *left_sample;
    69   int right_samples;
    70   Sample *right_sample;
    71   unsigned char *contents;
    72 } Instrument;
    73 
    74 
    75 typedef struct _InstrumentLayer {
    76   uint8 lo, hi;
    77   int size;
    78   Instrument *instrument;
    79   struct _InstrumentLayer *next;
    80 } InstrumentLayer;
    81 
    82 struct cfg_type {
    83 	int font_code;
    84 	int num;
    85 	const char *name;
    86 };
    87 
    88 #define FONT_NORMAL 0
    89 #define FONT_FFF    1
    90 #define FONT_SBK    2
    91 #define FONT_TONESET 3
    92 #define FONT_DRUMSET 4
    93 #define FONT_PRESET 5
    94 
    95 
    96 typedef struct {
    97   char *name;
    98   InstrumentLayer *layer;
    99   int font_type, sf_ix, last_used, tuning;
   100   int note, amp, pan, strip_loop, strip_envelope, strip_tail;
   101 } ToneBankElement;
   102 
   103 #if 0
   104 typedef struct {
   105   char *name;
   106   Instrument *instrument;
   107   int note, amp, pan, strip_loop, strip_envelope, strip_tail;
   108 } ToneBankElement;
   109 #endif
   110 /* A hack to delay instrument loading until after reading the
   111    entire MIDI file. */
   112 #define MAGIC_LOAD_INSTRUMENT ((InstrumentLayer *)(-1))
   113 
   114 #define MAXPROG 128
   115 #define MAXBANK 130
   116 #define SFXBANK (MAXBANK-1)
   117 #define SFXDRUM1 (MAXBANK-2)
   118 #define SFXDRUM2 (MAXBANK-1)
   119 #define XGDRUM 1
   120 
   121 #if 0
   122 typedef struct {
   123   ToneBankElement tone[128];
   124 } ToneBank;
   125 #endif
   126 
   127 typedef struct {
   128   char *name;
   129   ToneBankElement tone[MAXPROG];
   130 } ToneBank;
   131 
   132 
   133 extern char *sf_file;
   134 
   135 extern ToneBank *tonebank[], *drumset[];
   136 
   137 #if 0
   138 extern Instrument *default_instrument;
   139 #endif
   140 extern InstrumentLayer *default_instrument;
   141 extern int default_program;
   142 extern int antialiasing_allowed;
   143 extern int fast_decay;
   144 extern int free_instruments_afterwards;
   145 
   146 #define SPECIAL_PROGRAM -1
   147 
   148 extern int load_missing_instruments(void);
   149 extern void free_instruments(void);
   150 extern void end_soundfont(void);
   151 extern int set_default_instrument(const char *name);
   152 
   153 
   154 extern int32 convert_tremolo_sweep(uint8 sweep);
   155 extern int32 convert_vibrato_sweep(uint8 sweep, int32 vib_control_ratio);
   156 extern int32 convert_tremolo_rate(uint8 rate);
   157 extern int32 convert_vibrato_rate(uint8 rate);
   158 
   159 extern int init_soundfont(char *fname, int oldbank, int newbank, int level);
   160 extern InstrumentLayer *load_sbk_patch(const char *name, int gm_num, int bank, int percussion,
   161  int panning, int amp, int note_to_use, int sf_ix);
   162 extern int current_tune_number;
   163 extern int max_patch_memory;
   164 extern int current_patch_memory;
   165 #define XMAPMAX 800
   166 extern int xmap[XMAPMAX][5];
   167 extern void pcmap(int *b, int *v, int *p, int *drums);
   168