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