timidity_playmidi.h

Go to the documentation of this file.
00001 /*
00002 
00003     TiMidity -- Experimental MIDI to WAVE converter
00004     Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 
00020    playmidi.h
00021 
00022    */
00023 
00024 #ifdef USE_TIMIDITY_MIDI
00025 
00026 #ifndef TIMIDITY_PLAYMIDI_H_INCLUDED
00027 #define TIMIDITY_PLAYMIDI_H_INCLUDED
00028 
00029 #include "timidity.h"
00030 
00031 #ifdef NS_TIMIDITY
00032 namespace NS_TIMIDITY {
00033 #endif
00034 
00035 struct MidiEvent {
00036   sint32 time;
00037   uint8 channel, type, a, b;
00038 };
00039 
00040 /* Midi events */
00041 #define ME_NONE         0
00042 #define ME_NOTEON       1
00043 #define ME_NOTEOFF      2
00044 #define ME_KEYPRESSURE  3
00045 #define ME_MAINVOLUME   4
00046 #define ME_PAN          5
00047 #define ME_SUSTAIN      6
00048 #define ME_EXPRESSION   7
00049 #define ME_PITCHWHEEL   8
00050 #define ME_PROGRAM      9
00051 #define ME_TEMPO        10
00052 #define ME_PITCH_SENS   11
00053 
00054 #define ME_ALL_SOUNDS_OFF       12
00055 #define ME_RESET_CONTROLLERS    13
00056 #define ME_ALL_NOTES_OFF        14
00057 #define ME_TONE_BANK    15
00058 
00059 #define ME_LYRIC        16
00060 
00061 #define ME_EOT          99
00062 
00063 struct Channel {
00064   int
00065     bank, program, volume, sustain, panning, pitchbend, expression, 
00066     mono, /* one note only on this channel -- not implemented yet */
00067     pitchsens;
00068   /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
00069      processor near you */
00070   float
00071     pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
00072 };
00073 
00074 /* Causes the instrument's default panning to be used. */
00075 #define NO_PANNING -1
00076 
00077 struct Voice {
00078   uint8
00079     status, channel, note, velocity;
00080   Sample *sample;
00081   sint32
00082     orig_frequency, frequency,
00083     sample_offset, sample_increment,
00084     envelope_volume, envelope_target, envelope_increment,
00085     tremolo_sweep, tremolo_sweep_position,
00086     tremolo_phase, tremolo_phase_increment,
00087     vibrato_sweep, vibrato_sweep_position;
00088   
00089   final_volume_t left_mix, right_mix;
00090 
00091   float
00092     left_amp, right_amp, tremolo_volume;
00093   sint32
00094     vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
00095   int
00096     vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
00097     envelope_stage, control_counter, panning, panned;
00098 
00099 };
00100 
00101 /* Voice status options: */
00102 #define VOICE_FREE 0
00103 #define VOICE_ON 1
00104 #define VOICE_SUSTAINED 2
00105 #define VOICE_OFF 3
00106 #define VOICE_DIE 4
00107 
00108 /* Voice panned options: */
00109 #define PANNED_MYSTERY 0
00110 #define PANNED_LEFT 1
00111 #define PANNED_RIGHT 2
00112 #define PANNED_CENTER 3
00113 /* Anything but PANNED_MYSTERY only uses the left volume */
00114 
00115 extern Channel channel[16];
00116 extern Voice voice[MAX_VOICES];
00117 
00118 extern sint32 control_ratio, amp_with_poly, amplification;
00119 extern sint32 drumchannels;
00120 extern int adjust_panning_immediately;
00121 extern int voices;
00122 
00123 #define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c))))
00124 
00125 extern int play_midi(MidiEvent *el, sint32 events, sint32 samples);
00126 extern int play_midi_file(char *fn);
00127 extern void dumb_pass_playing_list(int number_of_files, char *list_of_files[]);
00128 
00129 #ifdef NS_TIMIDITY
00130 };
00131 #endif
00132 
00133 #endif
00134 
00135 #endif //USE_TIMIDITY_MIDI

Generated on Fri Jul 27 22:27:44 2007 for pentagram by  doxygen 1.4.7