mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
Further small midi cleanup changes--nothing functional
git-svn-id: https://svn.eduke32.com/eduke32@8221 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/audiolib/include/al_midi.h # source/audiolib/src/_al_midi.h
This commit is contained in:
parent
6fa287c767
commit
a2ab5492cc
5 changed files with 36 additions and 38 deletions
|
@ -116,21 +116,21 @@ void AdLibDrv_MIDI_SetTempo(int tempo, int division)
|
||||||
static opl3_chip chip;
|
static opl3_chip chip;
|
||||||
opl3_chip *AL_GetChip() { return &chip; }
|
opl3_chip *AL_GetChip() { return &chip; }
|
||||||
|
|
||||||
static unsigned int OctavePitch[MAX_OCTAVE + 1] = {
|
static constexpr unsigned int OctavePitch[MAX_OCTAVE+1] = {
|
||||||
OCTAVE_0, OCTAVE_1, OCTAVE_2, OCTAVE_3, OCTAVE_4, OCTAVE_5, OCTAVE_6, OCTAVE_7,
|
OCTAVE_0, OCTAVE_1, OCTAVE_2, OCTAVE_3, OCTAVE_4, OCTAVE_5, OCTAVE_6, OCTAVE_7,
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int NoteMod12[MAX_NOTE + 1];
|
static unsigned int NoteMod12[MAX_NOTE+1];
|
||||||
static unsigned int NoteDiv12[MAX_NOTE + 1];
|
static unsigned int NoteDiv12[MAX_NOTE+1];
|
||||||
|
|
||||||
// Pitch table
|
// Pitch table
|
||||||
|
|
||||||
//static unsigned NotePitch[ FINETUNE_MAX + 1 ][ 12 ] =
|
//static unsigned NotePitch[ FINETUNE_MAX+1 ][ 12 ] =
|
||||||
// {
|
// {
|
||||||
// { C, C_SHARP, D, D_SHARP, E, F, F_SHARP, G, G_SHARP, A, A_SHARP, B },
|
// { C, C_SHARP, D, D_SHARP, E, F, F_SHARP, G, G_SHARP, A, A_SHARP, B },
|
||||||
// };
|
// };
|
||||||
|
|
||||||
static unsigned int NotePitch[FINETUNE_MAX + 1][12] = {
|
static constexpr unsigned int NotePitch[FINETUNE_MAX+1][12] = {
|
||||||
{ 0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca, 0x1e5, 0x202, 0x220, 0x241, 0x263, 0x287 },
|
{ 0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca, 0x1e5, 0x202, 0x220, 0x241, 0x263, 0x287 },
|
||||||
{ 0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca, 0x1e5, 0x202, 0x220, 0x242, 0x264, 0x288 },
|
{ 0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca, 0x1e5, 0x202, 0x220, 0x242, 0x264, 0x288 },
|
||||||
{ 0x158, 0x16c, 0x182, 0x199, 0x1b1, 0x1cb, 0x1e6, 0x203, 0x221, 0x243, 0x265, 0x289 },
|
{ 0x158, 0x16c, 0x182, 0x199, 0x1b1, 0x1cb, 0x1e6, 0x203, 0x221, 0x243, 0x265, 0x289 },
|
||||||
|
@ -168,7 +168,7 @@ static unsigned int NotePitch[FINETUNE_MAX + 1][12] = {
|
||||||
// Slot numbers as a function of the voice and the operator.
|
// Slot numbers as a function of the voice and the operator.
|
||||||
// ( melodic only)
|
// ( melodic only)
|
||||||
|
|
||||||
static int slotVoice[NUMADLIBVOICES][2] = {
|
static constexpr int slotVoice[NUMADLIBVOICES][2] = {
|
||||||
{ 0, 3 }, // voice 0
|
{ 0, 3 }, // voice 0
|
||||||
{ 1, 4 }, // 1
|
{ 1, 4 }, // 1
|
||||||
{ 2, 5 }, // 2
|
{ 2, 5 }, // 2
|
||||||
|
@ -186,7 +186,7 @@ static int VoiceKsl[AL_NumChipSlots][2];
|
||||||
// This table gives the offset of each slot within the chip.
|
// This table gives the offset of each slot within the chip.
|
||||||
// offset = fn( slot)
|
// offset = fn( slot)
|
||||||
|
|
||||||
static int8_t offsetSlot[AL_NumChipSlots] = { 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21 };
|
static constexpr int8_t offsetSlot[AL_NumChipSlots] = { 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21 };
|
||||||
|
|
||||||
static int VoiceReserved[NUMADLIBVOICES * 2];
|
static int VoiceReserved[NUMADLIBVOICES * 2];
|
||||||
|
|
||||||
|
@ -854,7 +854,6 @@ static void AL_SetPitchBend(int channel, int lsb, int msb)
|
||||||
static void AL_Shutdown(void)
|
static void AL_Shutdown(void)
|
||||||
{
|
{
|
||||||
AL_StereoOff();
|
AL_StereoOff();
|
||||||
|
|
||||||
AL_ResetVoices();
|
AL_ResetVoices();
|
||||||
AL_Reset();
|
AL_Reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,9 @@ int ASS_PCMSoundDriver = ASS_AutoDetect;
|
||||||
int ASS_MIDISoundDriver = ASS_AutoDetect;
|
int ASS_MIDISoundDriver = ASS_AutoDetect;
|
||||||
int ASS_EMIDICard = -1;
|
int ASS_EMIDICard = -1;
|
||||||
|
|
||||||
#define UNSUPPORTED_PCM 0,0,0,0,0,0
|
#define UNSUPPORTED_PCM nullptr,nullptr,nullptr,nullptr,nullptr,nullptr
|
||||||
#define UNSUPPORTED_MIDI 0,0,0,0,0,0,0
|
#define UNSUPPORTED_MIDI nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr
|
||||||
#define UNSUPPORTED_COMPLETELY { 0,0, UNSUPPORTED_PCM, UNSUPPORTED_MIDI },
|
#define UNSUPPORTED_COMPLETELY { nullptr, nullptr, nullptr, UNSUPPORTED_PCM, UNSUPPORTED_MIDI },
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
const char * DriverName;
|
const char * DriverName;
|
||||||
|
@ -169,39 +169,39 @@ const char *SoundDriver_GetName(int driver) { return SoundDrivers[driver].Drive
|
||||||
|
|
||||||
int SoundDriver_PCM_GetError(void)
|
int SoundDriver_PCM_GetError(void)
|
||||||
{
|
{
|
||||||
if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
|
if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return SoundDrivers[ASS_PCMSoundDriver].GetError();
|
return SoundDrivers[ASS_PCMSoundDriver].GetError();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * SoundDriver_PCM_ErrorString( int ErrorNumber )
|
const char * SoundDriver_PCM_ErrorString( int ErrorNumber )
|
||||||
{
|
{
|
||||||
if (ASS_PCMSoundDriver < 0 || ASS_PCMSoundDriver >= ASS_NumSoundCards) {
|
if (ASS_PCMSoundDriver < 0 || ASS_PCMSoundDriver >= ASS_NumSoundCards)
|
||||||
return "No sound driver selected.";
|
return "No sound driver selected.";
|
||||||
}
|
|
||||||
if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
|
if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver))
|
||||||
return "Unsupported sound driver selected.";
|
return "Unsupported sound driver selected.";
|
||||||
}
|
|
||||||
return SoundDrivers[ASS_PCMSoundDriver].ErrorString(ErrorNumber);
|
return SoundDrivers[ASS_PCMSoundDriver].ErrorString(ErrorNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SoundDriver_MIDI_GetError(void)
|
int SoundDriver_MIDI_GetError(void)
|
||||||
{
|
{
|
||||||
if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
|
if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return SoundDrivers[ASS_MIDISoundDriver].GetError();
|
return SoundDrivers[ASS_MIDISoundDriver].GetError();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * SoundDriver_MIDI_ErrorString( int ErrorNumber )
|
const char * SoundDriver_MIDI_ErrorString( int ErrorNumber )
|
||||||
{
|
{
|
||||||
if (ASS_MIDISoundDriver < 0 || ASS_MIDISoundDriver >= ASS_NumSoundCards) {
|
if (ASS_MIDISoundDriver < 0 || ASS_MIDISoundDriver >= ASS_NumSoundCards)
|
||||||
return "No sound driver selected.";
|
return "No sound driver selected.";
|
||||||
}
|
|
||||||
if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
|
if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver))
|
||||||
return "Unsupported sound driver selected.";
|
return "Unsupported sound driver selected.";
|
||||||
}
|
|
||||||
return SoundDrivers[ASS_MIDISoundDriver].ErrorString(ErrorNumber);
|
return SoundDrivers[ASS_MIDISoundDriver].ErrorString(ErrorNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "fx_man.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
|
#include "driver_adlib.h"
|
||||||
|
#include "midi.h"
|
||||||
#include "multivoc.h"
|
#include "multivoc.h"
|
||||||
#include "fx_man.h"
|
#include "osd.h"
|
||||||
|
|
||||||
int FX_ErrorCode = FX_Ok;
|
int FX_ErrorCode = FX_Ok;
|
||||||
int FX_Installed;
|
int FX_Installed;
|
||||||
|
|
|
@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "_al_midi.h"
|
#include "al_midi.h"
|
||||||
|
|
||||||
AdLibTimbre ADLIB_TimbreBank[256] =
|
AdLibTimbre ADLIB_TimbreBank[256] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -696,13 +696,6 @@ void MIDI_StopSong(void)
|
||||||
|
|
||||||
int MIDI_PlaySong(char *song, int loopflag)
|
int MIDI_PlaySong(char *song, int loopflag)
|
||||||
{
|
{
|
||||||
int numtracks;
|
|
||||||
int format;
|
|
||||||
int headersize;
|
|
||||||
int tracklength;
|
|
||||||
track *CurrentTrack;
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
if (_MIDI_Funcs == nullptr)
|
if (_MIDI_Funcs == nullptr)
|
||||||
return MIDI_NullMidiModule;
|
return MIDI_NullMidiModule;
|
||||||
|
|
||||||
|
@ -710,11 +703,13 @@ int MIDI_PlaySong(char *song, int loopflag)
|
||||||
return MIDI_InvalidMidiFile;
|
return MIDI_InvalidMidiFile;
|
||||||
|
|
||||||
song += 4;
|
song += 4;
|
||||||
headersize = _MIDI_ReadNumber(song, 4);
|
int const headersize = _MIDI_ReadNumber(song, 4);
|
||||||
song += 4;
|
song += 4;
|
||||||
format = _MIDI_ReadNumber(song, 2);
|
int const format = _MIDI_ReadNumber(song, 2);
|
||||||
|
|
||||||
int My_MIDI_NumTracks = _MIDI_ReadNumber(song + 2, 2);
|
int My_MIDI_NumTracks = _MIDI_ReadNumber(song + 2, 2);
|
||||||
int My_MIDI_Division = _MIDI_ReadNumber(song + 4, 2);
|
int My_MIDI_Division = _MIDI_ReadNumber(song + 4, 2);
|
||||||
|
|
||||||
if (My_MIDI_Division < 0)
|
if (My_MIDI_Division < 0)
|
||||||
{
|
{
|
||||||
// If a SMPTE time division is given, just set to 96 so no errors occur
|
// If a SMPTE time division is given, just set to 96 so no errors occur
|
||||||
|
@ -724,7 +719,7 @@ int MIDI_PlaySong(char *song, int loopflag)
|
||||||
if (format > MAX_FORMAT)
|
if (format > MAX_FORMAT)
|
||||||
return MIDI_UnknownMidiFormat;
|
return MIDI_UnknownMidiFormat;
|
||||||
|
|
||||||
ptr = song + headersize;
|
char *ptr = song + headersize;
|
||||||
|
|
||||||
if (My_MIDI_NumTracks == 0)
|
if (My_MIDI_NumTracks == 0)
|
||||||
return MIDI_NoTracks;
|
return MIDI_NoTracks;
|
||||||
|
@ -732,8 +727,8 @@ int MIDI_PlaySong(char *song, int loopflag)
|
||||||
int My_MIDI_TrackMemSize = My_MIDI_NumTracks * sizeof(track);
|
int My_MIDI_TrackMemSize = My_MIDI_NumTracks * sizeof(track);
|
||||||
track * My_MIDI_TrackPtr = (track *)Xmalloc(My_MIDI_TrackMemSize);
|
track * My_MIDI_TrackPtr = (track *)Xmalloc(My_MIDI_TrackMemSize);
|
||||||
|
|
||||||
CurrentTrack = My_MIDI_TrackPtr;
|
auto CurrentTrack = My_MIDI_TrackPtr;
|
||||||
numtracks = My_MIDI_NumTracks;
|
int numtracks = My_MIDI_NumTracks;
|
||||||
|
|
||||||
while (numtracks--)
|
while (numtracks--)
|
||||||
{
|
{
|
||||||
|
@ -746,7 +741,7 @@ int MIDI_PlaySong(char *song, int loopflag)
|
||||||
return MIDI_InvalidTrack;
|
return MIDI_InvalidTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracklength = _MIDI_ReadNumber(ptr + 4, 4);
|
int tracklength = _MIDI_ReadNumber(ptr + 4, 4);
|
||||||
ptr += 8;
|
ptr += 8;
|
||||||
CurrentTrack->start = ptr;
|
CurrentTrack->start = ptr;
|
||||||
ptr += tracklength;
|
ptr += tracklength;
|
||||||
|
|
Loading…
Reference in a new issue