Skip to content

Commit

Permalink
Okay, windows specific code is now out of the native midi header. You…
Browse files Browse the repository at this point in the history
… should probably initialize native midi music when a midi file is first loaded, and then deinitialize after the last midi song is unloaded. The "init" is really a detection routine.
  • Loading branch information
slouken committed Aug 19, 2001
1 parent 041a2a3 commit a3957be
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
6 changes: 3 additions & 3 deletions music.c
Expand Up @@ -333,7 +333,7 @@ int open_music(SDL_AudioSpec *mixer)
#ifdef USE_NATIVE_MIDI
native_midi_ok = !timidity_ok;
if ( native_midi_ok ) {
native_midi_ok = native_midi_init();
native_midi_ok = native_midi_detect();
}
#endif
#endif
Expand Down Expand Up @@ -925,8 +925,8 @@ void close_music(void)
#endif
#ifdef MOD_MUSIC
MikMod_Exit();
MikMod_UnregisterAllLoaders();
MikMod_UnregisterAllDrivers();
MikMod_UnregisterAllLoaders();
MikMod_UnregisterAllDrivers();
#endif
}

37 changes: 1 addition & 36 deletions native_midi/native_midi.h
Expand Up @@ -23,44 +23,9 @@
#ifndef _NATIVE_MIDI_H_
#define _NATIVE_MIDI_H_

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>

#define MIDI_TRACKS 32

typedef unsigned char byte;
typedef struct MIDI /* a midi file */
{
int divisions; /* number of ticks per quarter note */
struct {
unsigned char *data; /* MIDI message stream */
int len; /* length of the track data */
} track[MIDI_TRACKS];
int loaded;
} MIDI;

struct _NativeMidiSong {
MIDI mididata;
int MusicLoaded;
int MusicPlaying;
MIDIEVENT *MidiEvents[MIDI_TRACKS];
MIDIHDR MidiStreamHdr;
MIDIEVENT *NewEvents;
int NewSize;
int NewPos;
int BytesRecorded[MIDI_TRACKS];
int BufferSize[MIDI_TRACKS];
int CurrentTrack;
int CurrentPos;
};
#endif /* WINDOWS */

typedef struct _NativeMidiSong NativeMidiSong;

int native_midi_init();
int native_midi_detect();
NativeMidiSong *native_midi_loadsong(char *midifile);
void native_midi_freesong(NativeMidiSong *song);
void native_midi_start(NativeMidiSong *song);
Expand Down
37 changes: 35 additions & 2 deletions native_midi/native_midi_win32.c
Expand Up @@ -20,14 +20,47 @@
florian.proff.schulze@gmx.net
*/

#ifdef _WIN32
/* everything below is currently one very big bad hack ;) Proff */

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "native_midi.h"


#define MIDI_TRACKS 32

typedef unsigned char byte;
typedef struct MIDI /* a midi file */
{
int divisions; /* number of ticks per quarter note */
struct {
unsigned char *data; /* MIDI message stream */
int len; /* length of the track data */
} track[MIDI_TRACKS];
int loaded;
} MIDI;

struct _NativeMidiSong {
MIDI mididata;
int MusicLoaded;
int MusicPlaying;
MIDIEVENT *MidiEvents[MIDI_TRACKS];
MIDIHDR MidiStreamHdr;
MIDIEVENT *NewEvents;
int NewSize;
int NewPos;
int BytesRecorded[MIDI_TRACKS];
int BufferSize[MIDI_TRACKS];
int CurrentTrack;
int CurrentPos;
};

#define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
# define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
(((x)&0xFF00)<<8) | \
Expand Down Expand Up @@ -308,7 +341,7 @@ void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD dwInstance,
}
}

int native_midi_init()
int native_midi_detect()
{
MMRESULT merr;
HMIDISTRM MidiStream;
Expand Down

0 comments on commit a3957be

Please sign in to comment.