music.c
changeset 106 ba6a6039e158
parent 102 8845cc8b6aec
child 125 60af9d35aba2
     1.1 --- a/music.c	Mon Aug 20 03:57:29 2001 +0000
     1.2 +++ b/music.c	Wed Sep 05 03:38:51 2001 +0000
     1.3 @@ -55,10 +55,17 @@
     1.4  #  endif
     1.5  #endif
     1.6  #ifdef MID_MUSIC
     1.7 -#include "timidity.h"
     1.8 -#ifdef USE_NATIVE_MIDI
     1.9 -#include "native_midi.h"
    1.10 -#endif
    1.11 +#  ifdef USE_TIMIDITY_MIDI
    1.12 +#    include "timidity.h"
    1.13 +#  endif
    1.14 +#  ifdef USE_NATIVE_MIDI
    1.15 +#    include "native_midi.h"
    1.16 +#  endif
    1.17 +#  if defined(USE_TIMIDITY_MIDI) && defined(USE_NATIVE_MIDI)
    1.18 +#    define MIDI_ELSE	else
    1.19 +#  else
    1.20 +#    define MIDI_ELSE
    1.21 +#  endif
    1.22  #endif
    1.23  #ifdef OGG_MUSIC
    1.24  #include "music_ogg.h"
    1.25 @@ -99,7 +106,9 @@
    1.26  		UNIMOD *module;
    1.27  #endif
    1.28  #ifdef MID_MUSIC
    1.29 +#ifdef USE_TIMIDITY_MIDI
    1.30  		MidiSong *midi;
    1.31 +#endif
    1.32  #ifdef USE_NATIVE_MIDI
    1.33  		NativeMidiSong *nativemidi;
    1.34  #endif
    1.35 @@ -118,7 +127,9 @@
    1.36  	int error;
    1.37  };
    1.38  #ifdef MID_MUSIC
    1.39 +#ifdef USE_TIMIDITY_MIDI
    1.40  static int timidity_ok;
    1.41 +#endif
    1.42  #ifdef USE_NATIVE_MIDI
    1.43  static int native_midi_ok;
    1.44  #endif
    1.45 @@ -232,6 +243,7 @@
    1.46  				break;
    1.47  #endif
    1.48  #ifdef MID_MUSIC
    1.49 +#ifdef USE_TIMIDITY_MIDI
    1.50  			case MUS_MID:
    1.51  				if ( timidity_ok ) {
    1.52  					int samples = len / samplesize;
    1.53 @@ -239,6 +251,7 @@
    1.54  				}
    1.55  				break;
    1.56  #endif
    1.57 +#endif
    1.58  #ifdef OGG_MUSIC
    1.59  			case MUS_OGG:
    1.60  				OGG_playAudio(music_playing->data.ogg, stream, len);
    1.61 @@ -323,6 +336,7 @@
    1.62  	}
    1.63  #endif
    1.64  #ifdef MID_MUSIC
    1.65 +#ifdef USE_TIMIDITY_MIDI
    1.66  	samplesize = mixer->size/mixer->samples;
    1.67  	if ( Timidity_Init(mixer->freq, mixer->format,
    1.68  	                    mixer->channels, mixer->samples) == 0 ) {
    1.69 @@ -330,11 +344,13 @@
    1.70  	} else {
    1.71  		timidity_ok = 0;
    1.72  	}
    1.73 +#endif
    1.74  #ifdef USE_NATIVE_MIDI
    1.75 +#ifdef USE_TIMIDITY_MIDI
    1.76  	native_midi_ok = !timidity_ok;
    1.77 -	if ( native_midi_ok ) {
    1.78 +	if ( native_midi_ok )
    1.79 +#endif
    1.80  		native_midi_ok = native_midi_detect();
    1.81 -	}
    1.82  #endif
    1.83  #endif
    1.84  #ifdef OGG_MUSIC
    1.85 @@ -419,8 +435,9 @@
    1.86  		  		Mix_SetError("%s", native_midi_error());
    1.87  			  	music->error = 1;
    1.88  			}
    1.89 -      		} else
    1.90 +	  	} MIDI_ELSE
    1.91  #endif
    1.92 +#ifdef USE_TIMIDITY_MIDI
    1.93  		if ( timidity_ok ) {
    1.94  			music->data.midi = Timidity_LoadSong((char *)file);
    1.95  			if ( music->data.midi == NULL ) {
    1.96 @@ -431,6 +448,7 @@
    1.97  			Mix_SetError("%s", Timidity_Error());
    1.98  			music->error = 1;
    1.99  		}
   1.100 +#endif
   1.101  	} else
   1.102  #endif
   1.103  #ifdef OGG_MUSIC
   1.104 @@ -512,11 +530,13 @@
   1.105  #ifdef USE_NATIVE_MIDI
   1.106    				if ( native_midi_ok ) {
   1.107  					native_midi_freesong(music->data.nativemidi);
   1.108 -				} else
   1.109 +				} MIDI_ELSE
   1.110  #endif
   1.111 +#ifdef USE_TIMIDITY_MIDI
   1.112  				if ( timidity_ok ) {
   1.113  					Timidity_FreeSong(music->data.midi);
   1.114  				}
   1.115 +#endif
   1.116  				break;
   1.117  #endif
   1.118  #ifdef OGG_MUSIC
   1.119 @@ -568,12 +588,14 @@
   1.120    			if ( native_midi_ok ) {
   1.121  				native_midi_setvolume(music_volume);
   1.122  				native_midi_start(music->data.nativemidi);
   1.123 -			} else
   1.124 +			} MIDI_ELSE
   1.125  #endif
   1.126 +#ifdef USE_TIMIDITY_MIDI
   1.127  			if ( timidity_ok ) {
   1.128  				Timidity_SetVolume(music_volume);
   1.129  				Timidity_Start(music->data.midi);
   1.130  			}
   1.131 +#endif
   1.132  			break;
   1.133  #endif
   1.134  #ifdef OGG_MUSIC
   1.135 @@ -672,11 +694,13 @@
   1.136  #ifdef USE_NATIVE_MIDI
   1.137  			if ( native_midi_ok ) {
   1.138  				native_midi_setvolume(music_volume);
   1.139 -			} else
   1.140 +			} MIDI_ELSE
   1.141  #endif
   1.142 +#ifdef USE_TIMIDITY_MIDI
   1.143  			if ( timidity_ok ) {
   1.144  				Timidity_SetVolume(music_volume);
   1.145  			}
   1.146 +#endif
   1.147  			break;
   1.148  #endif
   1.149  #ifdef OGG_MUSIC
   1.150 @@ -720,11 +744,13 @@
   1.151  #ifdef USE_NATIVE_MIDI
   1.152  		if ( native_midi_ok ) {
   1.153  			native_midi_stop();
   1.154 -		} else
   1.155 +		} MIDI_ELSE
   1.156  #endif
   1.157 +#ifdef USE_TIMIDITY_MIDI
   1.158  		if ( timidity_ok ) {
   1.159  			Timidity_Stop();
   1.160  		}
   1.161 +#endif
   1.162  		break;
   1.163  #endif
   1.164  #ifdef OGG_MUSIC
   1.165 @@ -869,12 +895,14 @@
   1.166  				if ( native_midi_ok ) {
   1.167  					if ( ! native_midi_active() )
   1.168  						return(0);
   1.169 -				} else
   1.170 +				} MIDI_ELSE
   1.171  #endif
   1.172 +#ifdef USE_TIMIDITY_MIDI
   1.173  				if ( timidity_ok ) {
   1.174  					if ( ! Timidity_Active() )
   1.175  						return(0);
   1.176  				}
   1.177 +#endif
   1.178  				break;
   1.179  #endif
   1.180  #ifdef OGG_MUSIC