timidity/instrum.h
author Sam Lantinga <slouken@lokigames.com>
Thu, 21 Oct 1999 18:02:08 +0000
changeset 0 4ce2db4db959
child 245 63b3650714de
permissions -rw-r--r--
Initial revision
slouken@0
     1
/*
slouken@0
     2
slouken@0
     3
    TiMidity -- Experimental MIDI to WAVE converter
slouken@0
     4
    Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
slouken@0
     5
slouken@0
     6
    This program is free software; you can redistribute it and/or modify
slouken@0
     7
    it under the terms of the GNU General Public License as published by
slouken@0
     8
    the Free Software Foundation; either version 2 of the License, or
slouken@0
     9
    (at your option) any later version.
slouken@0
    10
slouken@0
    11
    This program is distributed in the hope that it will be useful,
slouken@0
    12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
slouken@0
    14
    GNU General Public License for more details.
slouken@0
    15
slouken@0
    16
    You should have received a copy of the GNU General Public License
slouken@0
    17
    along with this program; if not, write to the Free Software
slouken@0
    18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
slouken@0
    19
slouken@0
    20
   instrum.h
slouken@0
    21
slouken@0
    22
   */
slouken@0
    23
slouken@0
    24
typedef struct {
slouken@0
    25
  int32
slouken@0
    26
    loop_start, loop_end, data_length,
slouken@0
    27
    sample_rate, low_freq, high_freq, root_freq;
slouken@0
    28
  int32
slouken@0
    29
    envelope_rate[6], envelope_offset[6];
slouken@0
    30
  float
slouken@0
    31
    volume;
slouken@0
    32
  sample_t *data;
slouken@0
    33
  int32 
slouken@0
    34
    tremolo_sweep_increment, tremolo_phase_increment, 
slouken@0
    35
    vibrato_sweep_increment, vibrato_control_ratio;
slouken@0
    36
  uint8
slouken@0
    37
    tremolo_depth, vibrato_depth,
slouken@0
    38
    modes;
slouken@0
    39
  int8
slouken@0
    40
    panning, note_to_use;
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@0
    51
slouken@0
    52
typedef struct {
slouken@0
    53
  int samples;
slouken@0
    54
  Sample *sample;
slouken@0
    55
} Instrument;
slouken@0
    56
slouken@0
    57
typedef struct {
slouken@0
    58
  char *name;
slouken@0
    59
  Instrument *instrument;
slouken@0
    60
  int note, amp, pan, strip_loop, strip_envelope, strip_tail;
slouken@0
    61
} ToneBankElement;
slouken@0
    62
slouken@0
    63
/* A hack to delay instrument loading until after reading the
slouken@0
    64
   entire MIDI file. */
slouken@0
    65
#define MAGIC_LOAD_INSTRUMENT ((Instrument *)(-1))
slouken@0
    66
slouken@0
    67
typedef struct {
slouken@0
    68
  ToneBankElement tone[128];
slouken@0
    69
} ToneBank;
slouken@0
    70
slouken@0
    71
extern ToneBank *tonebank[], *drumset[];
slouken@0
    72
slouken@0
    73
extern Instrument *default_instrument;
slouken@0
    74
extern int default_program;
slouken@0
    75
extern int antialiasing_allowed;
slouken@0
    76
extern int fast_decay;
slouken@0
    77
extern int free_instruments_afterwards;
slouken@0
    78
slouken@0
    79
#define SPECIAL_PROGRAM -1
slouken@0
    80
slouken@0
    81
extern int load_missing_instruments(void);
slouken@0
    82
extern void free_instruments(void);
slouken@0
    83
extern int set_default_instrument(char *name);
slouken@0
    84