Skip to content

Commit

Permalink
Added native MIDI music support on MacOS and MacOS X
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 5, 2001
1 parent 477cef3 commit 7b72465
Show file tree
Hide file tree
Showing 6 changed files with 1,126 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,5 +1,7 @@

1.2.1:
Max Horn - Tue Sep 4 20:38:11 PDT 2001
* Added native MIDI music support on MacOS and MacOS X
Florian Schulze - Sun Aug 19 14:55:37 PDT 2001
* Added native MIDI music support on Windows
Sam Lantinga - Sun Aug 19 02:20:55 PDT 2001
Expand Down
12 changes: 9 additions & 3 deletions configure.in
Expand Up @@ -118,8 +118,14 @@ AC_ARG_ENABLE(music-midi,
[ --enable-music-midi enable MIDI music via timidity [default=yes]],
, enable_music_midi=yes)
if test x$enable_music_midi = xyes; then
CFLAGS="$CFLAGS -DMID_MUSIC -I\$(top_srcdir)/timidity"
MUSIC_SUBDIRS="$MUSIC_SUBDIRS timidity"
CFLAGS="$CFLAGS -DMID_MUSIC"
AC_ARG_ENABLE(music-timidity-midi,
[ --enable-music-timidity-midi enable timidity MIDI output [default=yes]],
, enable_music_timidity_midi=yes)
if test x$enable_music_timidity_midi = xyes; then
CFLAGS="$CFLAGS -I\$(top_srcdir)/timidity"
MUSIC_SUBDIRS="$MUSIC_SUBDIRS timidity"
fi
AC_ARG_ENABLE(music-native-midi,
[ --enable-music-native-midi enable native MIDI music output [default=yes]],
, enable_music_native_midi=yes)
Expand Down Expand Up @@ -170,7 +176,7 @@ fi
dnl Add Makefile conditionals
AC_SUBST(MUSIC_SUBDIRS)
AM_CONDITIONAL(USE_MIKMOD, test x$enable_music_mod = xyes)
AM_CONDITIONAL(USE_TIMIDITY, test x$enable_music_midi = xyes)
AM_CONDITIONAL(USE_TIMIDITY, test x$enable_music_timidity_midi = xyes)
AM_CONDITIONAL(USE_NATIVE_MIDI, test x$use_music_native_midi = xyes)

# Finally create all the generated files
Expand Down
52 changes: 40 additions & 12 deletions music.c
Expand Up @@ -55,10 +55,17 @@
# endif
#endif
#ifdef MID_MUSIC
#include "timidity.h"
#ifdef USE_NATIVE_MIDI
#include "native_midi.h"
#endif
# ifdef USE_TIMIDITY_MIDI
# include "timidity.h"
# endif
# ifdef USE_NATIVE_MIDI
# include "native_midi.h"
# endif
# if defined(USE_TIMIDITY_MIDI) && defined(USE_NATIVE_MIDI)
# define MIDI_ELSE else
# else
# define MIDI_ELSE
# endif
#endif
#ifdef OGG_MUSIC
#include "music_ogg.h"
Expand Down Expand Up @@ -99,7 +106,9 @@ struct _Mix_Music {
UNIMOD *module;
#endif
#ifdef MID_MUSIC
#ifdef USE_TIMIDITY_MIDI
MidiSong *midi;
#endif
#ifdef USE_NATIVE_MIDI
NativeMidiSong *nativemidi;
#endif
Expand All @@ -118,7 +127,9 @@ struct _Mix_Music {
int error;
};
#ifdef MID_MUSIC
#ifdef USE_TIMIDITY_MIDI
static int timidity_ok;
#endif
#ifdef USE_NATIVE_MIDI
static int native_midi_ok;
#endif
Expand Down Expand Up @@ -232,13 +243,15 @@ void music_mixer(void *udata, Uint8 *stream, int len)
break;
#endif
#ifdef MID_MUSIC
#ifdef USE_TIMIDITY_MIDI
case MUS_MID:
if ( timidity_ok ) {
int samples = len / samplesize;
Timidity_PlaySome(stream, samples);
}
break;
#endif
#endif
#ifdef OGG_MUSIC
case MUS_OGG:
OGG_playAudio(music_playing->data.ogg, stream, len);
Expand Down Expand Up @@ -323,18 +336,21 @@ int open_music(SDL_AudioSpec *mixer)
}
#endif
#ifdef MID_MUSIC
#ifdef USE_TIMIDITY_MIDI
samplesize = mixer->size/mixer->samples;
if ( Timidity_Init(mixer->freq, mixer->format,
mixer->channels, mixer->samples) == 0 ) {
timidity_ok = 1;
} else {
timidity_ok = 0;
}
#endif
#ifdef USE_NATIVE_MIDI
#ifdef USE_TIMIDITY_MIDI
native_midi_ok = !timidity_ok;
if ( native_midi_ok ) {
if ( native_midi_ok )
#endif
native_midi_ok = native_midi_detect();
}
#endif
#endif
#ifdef OGG_MUSIC
Expand Down Expand Up @@ -419,8 +435,9 @@ Mix_Music *Mix_LoadMUS(const char *file)
Mix_SetError("%s", native_midi_error());
music->error = 1;
}
} else
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
music->data.midi = Timidity_LoadSong((char *)file);
if ( music->data.midi == NULL ) {
Expand All @@ -431,6 +448,7 @@ Mix_Music *Mix_LoadMUS(const char *file)
Mix_SetError("%s", Timidity_Error());
music->error = 1;
}
#endif
} else
#endif
#ifdef OGG_MUSIC
Expand Down Expand Up @@ -512,11 +530,13 @@ void Mix_FreeMusic(Mix_Music *music)
#ifdef USE_NATIVE_MIDI
if ( native_midi_ok ) {
native_midi_freesong(music->data.nativemidi);
} else
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
Timidity_FreeSong(music->data.midi);
}
#endif
break;
#endif
#ifdef OGG_MUSIC
Expand Down Expand Up @@ -568,12 +588,14 @@ static int lowlevel_play(Mix_Music *music)
if ( native_midi_ok ) {
native_midi_setvolume(music_volume);
native_midi_start(music->data.nativemidi);
} else
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
Timidity_SetVolume(music_volume);
Timidity_Start(music->data.midi);
}
#endif
break;
#endif
#ifdef OGG_MUSIC
Expand Down Expand Up @@ -672,11 +694,13 @@ int Mix_VolumeMusic(int volume)
#ifdef USE_NATIVE_MIDI
if ( native_midi_ok ) {
native_midi_setvolume(music_volume);
} else
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
Timidity_SetVolume(music_volume);
}
#endif
break;
#endif
#ifdef OGG_MUSIC
Expand Down Expand Up @@ -720,11 +744,13 @@ static void lowlevel_halt(void)
#ifdef USE_NATIVE_MIDI
if ( native_midi_ok ) {
native_midi_stop();
} else
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
Timidity_Stop();
}
#endif
break;
#endif
#ifdef OGG_MUSIC
Expand Down Expand Up @@ -869,12 +895,14 @@ int Mix_PlayingMusic(void)
if ( native_midi_ok ) {
if ( ! native_midi_active() )
return(0);
} else
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
if ( ! Timidity_Active() )
return(0);
}
#endif
break;
#endif
#ifdef OGG_MUSIC
Expand Down

0 comments on commit 7b72465

Please sign in to comment.