Moved Windows midi functions to digi_audio_* functions

This commit is contained in:
zicodxx 2007-09-30 13:38:25 +00:00
parent 631fe7149c
commit 2a889d2d9c
4 changed files with 64 additions and 108 deletions

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20070930
--------
SConstruct, arch/sdl/digi_audio.c: Moved Windows midi functions to digi_audio_* functions
20070929
--------
INSTALL.txt, README.txt, SConstruct, arch/sdl/digi_audio.c, arch/sdl/event.c, arch/sdl/gr.c, arch/sdl/joy.c, arch/sdl/key.c, include/physfsx.h, main/gamecntl.c, main/kconfig.c, main/menu.c, main/newmenu.c, main/scores.c: Updated docs; Removed GP2X support since I won't support this device anymore

View file

@ -264,10 +264,8 @@ if (sdlmixer == 1):
arch_win32_sources = [
'arch/win32/hmpfile.c',
'arch/win32/ipx_win.c',
'arch/win32/midi.c',
'arch/win32/mono.c',
'arch/win32/winnet.c',
'arch/sdl/digi.c',
'arch/win32/arch_ip.cpp'
]

View file

@ -17,6 +17,10 @@
#include <SDL/SDL.h>
#include <digi_audio.h>
#ifdef _WIN32
#include "hmpfile.h"
#endif
#include "pstypes.h"
#include "error.h"
#include "mono.h"
@ -429,11 +433,56 @@ void digi_audio_end_sound(int channel)
SoundSlots[channel].persistent = 0;
}
#ifdef _WIN32
hmp_file *hmp = NULL;
static int digi_midi_song_playing = 0;
#endif
#ifndef _WIN32
// MIDI stuff follows.
void digi_audio_set_midi_volume( int mvolume ) { }
void digi_audio_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop ) {}
void digi_audio_set_midi_volume( int mvolume )
{
#ifdef _WIN32
int mm_volume;
if (mvolume < 0)
midi_volume = 0;
else if (mvolume > 127)
midi_volume = 127;
else
midi_volume = mvolume;
// scale up from 0-127 to 0-0xffff
mm_volume = (midi_volume << 1) | (midi_volume & 1);
mm_volume |= (mm_volume << 8);
if (hmp)
midiOutSetVolume((HMIDIOUT)hmp->hmidi, mm_volume | mm_volume << 16);
#endif
}
void digi_audio_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop )
{
#ifdef _WIN32
if (GameArg.SndNoMusic)
return;
digi_stop_current_song();
if (filename == NULL)
return;
if (midi_volume < 1)
return;
if ((hmp = hmp_open(filename)))
{
hmp_play(hmp,loop);
digi_midi_song_playing = 1;
digi_set_midi_volume(midi_volume);
}
else
printf("hmp_open failed\n");
#endif
}
void digi_audio_stop_current_song()
{
@ -443,10 +492,17 @@ void digi_audio_stop_current_song()
sprintf(buf,"s");
send_ipc(buf);
#endif
#ifdef _WIN32
if (digi_midi_song_playing)
{
hmp_close(hmp);
hmp = NULL;
digi_midi_song_playing = 0;
}
#endif
}
void digi_audio_pause_midi() {}
void digi_audio_resume_midi() {}
#endif
#ifndef NDEBUG
void digi_audio_debug()

View file

@ -1,102 +0,0 @@
/* $Id: midi.c,v 1.1.1.1 2006/03/17 19:54:11 zicodxx Exp $ */
// MIDI stuff follows.
#include <stdio.h>
#include "error.h"
#include "hmpfile.h"
#include "args.h"
hmp_file *hmp = NULL;
int midi_volume = 255;
int digi_midi_song_playing = 0;
void digi_stop_current_song()
{
if (digi_midi_song_playing)
{
hmp_close(hmp);
hmp = NULL;
digi_midi_song_playing = 0;
}
}
void digi_set_midi_volume(int n)
{
int mm_volume;
if (n < 0)
midi_volume = 0;
else if (n > 127)
midi_volume = 127;
else
midi_volume = n;
// scale up from 0-127 to 0-0xffff
mm_volume = (midi_volume << 1) | (midi_volume & 1);
mm_volume |= (mm_volume << 8);
if (hmp)
midiOutSetVolume((HMIDIOUT)hmp->hmidi, mm_volume | mm_volume << 16);
}
void digi_play_midi_song(char *filename, char *melodic_bank, char *drum_bank, int loop)
{
#if 0
if (!digi_initialised)
return;
#endif
if (GameArg.SndNoMusic)
return;
digi_stop_current_song();
if (filename == NULL)
return;
if (midi_volume < 1)
return;
if ((hmp = hmp_open(filename)))
{
hmp_play(hmp,loop);
digi_midi_song_playing = 1;
digi_set_midi_volume(midi_volume);
}
else
printf("hmp_open failed\n");
}
int sound_paused = 0;
void digi_pause_midi()
{
#if 0
if (!digi_initialised)
return;
#endif
if (sound_paused == 0)
{
// pause here
}
sound_paused++;
}
void digi_resume_midi()
{
#if 0
if (!digi_initialised)
return;
#endif
Assert(sound_paused > 0);
if (sound_paused == 1)
{
// resume sound here
}
sound_paused--;
}