playmidi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. TiMidity -- Experimental MIDI to WAVE converter
  3. Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. playmidi.h
  16. */
  17. #include "structs.h"
  18. /* Midi events */
  19. #define ME_NONE 0
  20. #define ME_NOTEON 1
  21. #define ME_NOTEOFF 2
  22. #define ME_KEYPRESSURE 3
  23. #define ME_MAINVOLUME 4
  24. #define ME_PAN 5
  25. #define ME_SUSTAIN 6
  26. #define ME_EXPRESSION 7
  27. #define ME_PITCHWHEEL 8
  28. #define ME_PROGRAM 9
  29. #define ME_TEMPO 10
  30. #define ME_PITCH_SENS 11
  31. #define ME_ALL_SOUNDS_OFF 12
  32. #define ME_RESET_CONTROLLERS 13
  33. #define ME_ALL_NOTES_OFF 14
  34. #define ME_TONE_BANK 15
  35. #define ME_LYRIC 16
  36. #define ME_EOT 99
  37. typedef struct {
  38. int
  39. bank, program, volume, sustain, panning, pitchbend, expression,
  40. mono, /* one note only on this channel -- not implemented yet */
  41. pitchsens;
  42. /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
  43. processor near you */
  44. float
  45. pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
  46. } Channel;
  47. /* Causes the instrument's default panning to be used. */
  48. #define NO_PANNING -1
  49. typedef struct {
  50. uint8_t
  51. status, channel, note, velocity;
  52. Sample *sample;
  53. int32_t
  54. orig_frequency, frequency,
  55. sample_offset, sample_increment,
  56. envelope_volume, envelope_target, envelope_increment,
  57. tremolo_sweep, tremolo_sweep_position,
  58. tremolo_phase, tremolo_phase_increment,
  59. vibrato_sweep, vibrato_sweep_position;
  60. final_volume_t left_mix, right_mix;
  61. float
  62. left_amp, right_amp, tremolo_volume;
  63. int32_t
  64. vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
  65. int
  66. vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
  67. envelope_stage, control_counter, panning, panned;
  68. } Voice;
  69. /* Voice status options: */
  70. #define VOICE_FREE 0
  71. #define VOICE_ON 1
  72. #define VOICE_SUSTAINED 2
  73. #define VOICE_OFF 3
  74. #define VOICE_DIE 4
  75. /* Voice panned options: */
  76. #define PANNED_MYSTERY 0
  77. #define PANNED_LEFT 1
  78. #define PANNED_RIGHT 2
  79. #define PANNED_CENTER 3
  80. /* Anything but PANNED_MYSTERY only uses the left volume */
  81. extern Channel channel[16];
  82. extern Voice voice[MAX_VOICES];
  83. extern int32_t control_ratio, amp_with_poly, amplification;
  84. extern int32_t drumchannels;
  85. extern int adjust_panning_immediately;
  86. extern int voices;
  87. #define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c))))
  88. extern int play_midi(MidiEvent *el, int32_t events, int32_t samples);
  89. extern int play_midi_file(char *fn);
  90. extern void dumb_pass_playing_list(int number_of_files, char *list_of_files[]);