timidity/timidity.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 12 Nov 2018 16:54:24 -0800
changeset 925 5945988b4a41
parent 799 82dcc7ce6d20
permissions -rw-r--r--
Fixed bug 4371 - tvOS Simulator devices not listed

Caleb Cornett

In the Xcode-iOS project, when selecting the libSDL_mixer-tvOS target, no tvOS simulators appear in the available device dropdown.

This is easily fixed with the attached patch.
     1 /*
     2 
     3     TiMidity -- Experimental MIDI to WAVE converter
     4     Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
     5 
     6     This program is free software; you can redistribute it and/or modify
     7     it under the terms of the Perl Artistic License, available in COPYING.
     8 */
     9 
    10 #ifndef TIMIDITY_H
    11 #define TIMIDITY_H
    12 #ifdef __cplusplus
    13 extern "C" {
    14 #endif
    15 
    16 typedef Sint16 sample_t;
    17 typedef Sint32 final_volume_t;
    18 
    19 #define VIBRATO_SAMPLE_INCREMENTS 32
    20 
    21 /* Maximum polyphony. */
    22 /* #define MAX_VOICES	48 */
    23 #define MAX_VOICES	256
    24 #define MAXCHAN	16
    25 /* #define MAXCHAN	64 */
    26 #define MAXBANK	128
    27 
    28 typedef struct {
    29   Sint32
    30     loop_start, loop_end, data_length,
    31     sample_rate, low_freq, high_freq, root_freq;
    32   Sint32
    33     envelope_rate[6], envelope_offset[6];
    34   float
    35     volume;
    36   sample_t *data;
    37   Sint32 
    38     tremolo_sweep_increment, tremolo_phase_increment, 
    39     vibrato_sweep_increment, vibrato_control_ratio;
    40   Uint8
    41     tremolo_depth, vibrato_depth,
    42     modes;
    43   Sint8
    44     panning, note_to_use;
    45 } Sample;
    46 
    47 typedef struct {
    48   int
    49     bank, program, volume, sustain, panning, pitchbend, expression, 
    50     mono, /* one note only on this channel -- not implemented yet */
    51     pitchsens;
    52   /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
    53      processor near you */
    54   float
    55     pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
    56 } Channel;
    57 
    58 typedef struct {
    59   Uint8
    60     status, channel, note, velocity;
    61   Sample *sample;
    62   Sint32
    63     orig_frequency, frequency,
    64     sample_offset, sample_increment,
    65     envelope_volume, envelope_target, envelope_increment,
    66     tremolo_sweep, tremolo_sweep_position,
    67     tremolo_phase, tremolo_phase_increment,
    68     vibrato_sweep, vibrato_sweep_position;
    69   
    70   final_volume_t left_mix, right_mix;
    71 
    72   float
    73     left_amp, right_amp, tremolo_volume;
    74   Sint32
    75     vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
    76   int
    77     vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
    78     envelope_stage, control_counter, panning, panned;
    79 
    80 } Voice;
    81 
    82 typedef struct {
    83   int samples;
    84   Sample *sample;
    85 } Instrument;
    86 
    87 /* Shared data */
    88 typedef struct {
    89   char *name;
    90   int note, amp, pan, strip_loop, strip_envelope, strip_tail;
    91 } ToneBankElement;
    92 
    93 typedef struct {
    94   ToneBankElement *tone;
    95   Instrument *instrument[128];
    96 } ToneBank;
    97 
    98 typedef struct {
    99     Sint32 time;
   100     Uint8 channel, type, a, b;
   101 } MidiEvent;
   102 
   103 typedef struct {
   104     MidiEvent event;
   105     void *next;
   106 } MidiEventList;
   107 
   108 typedef struct {
   109     int playing;
   110     SDL_RWops *rw;
   111     Sint32 rate;
   112     Sint32 encoding;
   113     float master_volume;
   114     Sint32 amplification;
   115     ToneBank *tonebank[MAXBANK];
   116     ToneBank *drumset[MAXBANK];
   117     Instrument *default_instrument;
   118     int default_program;
   119     void (*write)(void *dp, Sint32 *lp, Sint32 c);
   120     int buffer_size;
   121     sample_t *resample_buffer;
   122     Sint32 *common_buffer;
   123     Sint32 *buffer_pointer;
   124     /* These would both fit into 32 bits, but they are often added in
   125        large multiples, so it's simpler to have two roomy ints */
   126     /* samples per MIDI delta-t */
   127     Sint32 sample_increment;
   128     Sint32 sample_correction;
   129     Channel channel[MAXCHAN];
   130     Voice voice[MAX_VOICES];
   131     int voices;
   132     Sint32 drumchannels;
   133     Sint32 buffered_count;
   134     Sint32 control_ratio;
   135     Sint32 lost_notes;
   136     Sint32 cut_notes;
   137     Sint32 samples;
   138     MidiEvent *events;
   139     MidiEvent *current_event;
   140     MidiEventList *evlist;
   141     Sint32 current_sample;
   142     Sint32 event_count;
   143     Sint32 at;
   144     Sint32 groomed_event_count;
   145 } MidiSong;
   146 
   147 /* Some of these are not defined in timidity.c but are here for convenience */
   148 
   149 extern int Timidity_Init(void);
   150 extern int Timidity_Init_NoConfig(void);
   151 extern void Timidity_SetVolume(MidiSong *song, int volume);
   152 extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len);
   153 extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio);
   154 extern void Timidity_Start(MidiSong *song);
   155 extern void Timidity_Seek(MidiSong *song, Uint32 ms);
   156 extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */
   157 extern void Timidity_FreeSong(MidiSong *song);
   158 extern void Timidity_Exit(void);
   159 
   160 #ifdef __cplusplus
   161 }
   162 #endif
   163 #endif /* TIMIDITY_H */