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