timidity/playmidi.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 typedef struct {
    10   int32 time;
    11   uint8 channel, type, a, b;
    12 } MidiEvent;
    13 
    14 /* Midi events */
    15 #define ME_NONE 	0
    16 #define ME_NOTEON	1
    17 #define ME_NOTEOFF	2
    18 #define ME_KEYPRESSURE	3
    19 #define ME_MAINVOLUME	4
    20 #define ME_PAN		5
    21 #define ME_SUSTAIN	6
    22 #define ME_EXPRESSION	7
    23 #define ME_PITCHWHEEL	8
    24 #define ME_PROGRAM	9
    25 #define ME_TEMPO	10
    26 #define ME_PITCH_SENS	11
    27 
    28 #define ME_ALL_SOUNDS_OFF	12
    29 #define ME_RESET_CONTROLLERS	13
    30 #define ME_ALL_NOTES_OFF	14
    31 #define ME_TONE_BANK	15
    32 
    33 #define ME_LYRIC	16
    34 #define ME_TONE_KIT	17
    35 #define ME_MASTERVOLUME	18
    36 #define ME_CHANNEL_PRESSURE 19
    37 
    38 #define ME_HARMONICCONTENT	71
    39 #define ME_RELEASETIME		72
    40 #define ME_ATTACKTIME		73
    41 #define ME_BRIGHTNESS		74
    42 
    43 #define ME_REVERBERATION	91
    44 #define ME_CHORUSDEPTH		93
    45 
    46 #define ME_EOT		99
    47 
    48 
    49 #define SFX_BANKTYPE	64
    50 
    51 typedef struct {
    52   int
    53     bank, program, volume, sustain, panning, pitchbend, expression, 
    54     mono, /* one note only on this channel -- not implemented yet */
    55     /* new stuff */
    56     variationbank, reverberation, chorusdepth, harmoniccontent,
    57     releasetime, attacktime, brightness, kit, sfx,
    58     /* end new */
    59     pitchsens;
    60   FLOAT_T
    61     pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
    62   char transpose;
    63   char *name;
    64 } Channel;
    65 
    66 /* Causes the instrument's default panning to be used. */
    67 #define NO_PANNING -1
    68 /* envelope points */
    69 #define MAXPOINT 7
    70 
    71 typedef struct {
    72   uint8
    73     status, channel, note, velocity, clone_type;
    74   Sample *sample;
    75   Sample *left_sample;
    76   Sample *right_sample;
    77   int32 clone_voice;
    78   int32
    79     orig_frequency, frequency,
    80     sample_offset, loop_start, loop_end;
    81   int32
    82     envelope_volume, modulation_volume;
    83   int32
    84     envelope_target, modulation_target;
    85   int32
    86     tremolo_sweep, tremolo_sweep_position, tremolo_phase,
    87     lfo_sweep, lfo_sweep_position, lfo_phase,
    88     vibrato_sweep, vibrato_sweep_position, vibrato_depth, vibrato_delay,
    89     starttime, echo_delay_count;
    90   int32
    91     echo_delay,
    92     sample_increment,
    93     envelope_increment,
    94     modulation_increment,
    95     tremolo_phase_increment,
    96     lfo_phase_increment;
    97   
    98   final_volume_t left_mix, right_mix, lr_mix, rr_mix, ce_mix, lfe_mix;
    99 
   100   FLOAT_T
   101     left_amp, right_amp, lr_amp, rr_amp, ce_amp, lfe_amp,
   102     volume, tremolo_volume, lfo_volume;
   103   int32
   104     vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
   105   int32
   106     envelope_rate[MAXPOINT], envelope_offset[MAXPOINT];
   107   int32
   108     vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
   109     envelope_stage, modulation_stage, control_counter,
   110     modulation_delay, modulation_counter, panning, panned;
   111 } Voice;
   112 
   113 /* Voice status options: */
   114 #define VOICE_FREE 0
   115 #define VOICE_ON 1
   116 #define VOICE_SUSTAINED 2
   117 #define VOICE_OFF 3
   118 #define VOICE_DIE 4
   119 
   120 /* Voice panned options: */
   121 #define PANNED_MYSTERY 0
   122 #define PANNED_LEFT 1
   123 #define PANNED_RIGHT 2
   124 #define PANNED_CENTER 3
   125 /* Anything but PANNED_MYSTERY only uses the left volume */
   126 
   127 /* Envelope stages: */
   128 #define ATTACK 0
   129 #define HOLD 1
   130 #define DECAY 2
   131 #define RELEASE 3
   132 #define RELEASEB 4
   133 #define RELEASEC 5
   134 #define DELAY 6
   135 
   136 extern Channel channel[16];
   137 extern Voice voice[MAX_VOICES];
   138 extern signed char drumvolume[MAXCHAN][MAXNOTE];
   139 extern signed char drumpanpot[MAXCHAN][MAXNOTE];
   140 extern signed char drumreverberation[MAXCHAN][MAXNOTE];
   141 extern signed char drumchorusdepth[MAXCHAN][MAXNOTE];
   142 
   143 extern int32 control_ratio, amp_with_poly, amplification;
   144 extern int32 drumchannels;
   145 extern int adjust_panning_immediately;
   146 extern int voices;
   147 
   148 #define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c))))
   149 
   150 extern int GM_System_On;
   151 extern int XG_System_On;
   152 extern int GS_System_On;
   153 
   154 extern int XG_System_reverb_type;
   155 extern int XG_System_chorus_type;
   156 extern int XG_System_variation_type;
   157 
   158 extern int play_midi(MidiEvent *el, int32 events, int32 samples);
   159 extern int play_midi_file(const char *fn);
   160 extern void dumb_pass_playing_list(int number_of_files, char *list_of_files[]);