SBSPSS/source/sound/xmplay.h

177 lines
4.4 KiB
C
Raw Normal View History

2000-10-05 16:16:09 +02:00
/*=========================================================================
xmplay.h
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __SOUND_XMPLAY_H__
#define __SOUND_XMPLAY_H__
/*----------------------------------------------------------------------
Includes
-------- */
#ifndef _FILEIO_HEADER_
#include "fileio\fileio.h"
#endif
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
// This is a bit messy, but makes sure that you can't easily pass the wrong IDs to the xm functions
// ( ..something scares me about this way of doing it tho :)
typedef enum {NO_SAMPLE=-1} xmSampleId;
2000-10-10 00:06:20 +02:00
typedef enum {NO_SONG=-1} xmModId;
typedef enum {NOT_PLAYING=-1} xmPlayingId;
2000-10-12 17:18:47 +02:00
// Note that a playing id is a 16 bit value. Top 8 bits are an ( effectively ) random number and the bottom
// 8 bits are the base channel of the playing sound.
2000-10-05 16:16:09 +02:00
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class CXMPlaySound
{
public:
2000-10-11 18:47:03 +02:00
enum
{
MIN_VOLUME=0,
MAX_VOLUME=255,
PAN_LEFT=0,
PAN_CENTRE=127,
PAN_RIGHT=255,
};
2000-10-05 16:16:09 +02:00
void initialise();
void shutdown();
2000-10-10 00:06:20 +02:00
void think();
2000-10-05 16:16:09 +02:00
2000-10-11 18:47:03 +02:00
void setMasterSongVolume(unsigned char _vol);
void setMasterSfxVolume(unsigned char _vol);
2000-10-10 00:06:20 +02:00
xmSampleId loadSampleData(FileEquate _vhFe,FileEquate _vbFe);
2000-10-10 01:30:58 +02:00
xmModId loadModData(FileEquate _modFe);
2000-10-10 00:06:20 +02:00
void dumpSampleData(xmSampleId _sampleId);
2000-10-10 01:30:58 +02:00
void dumpModData(xmModId _modId);
2000-10-05 16:16:09 +02:00
void setStereo(int _stereo);
2000-10-10 01:30:58 +02:00
void setVolume(xmPlayingId _playingId,unsigned char _volume);
void setPanning(xmPlayingId _playingId,char _pan);
2000-10-05 16:16:09 +02:00
2001-03-29 03:29:11 +02:00
void stopAndUnlockAllSfx();
2000-10-11 18:47:03 +02:00
void stopAndUnlockAllSound();
2001-01-19 17:25:05 +01:00
xmPlayingId playSong(xmSampleId _sampleId,xmModId _modId,int _startPattern=0);
2000-10-11 18:47:03 +02:00
xmPlayingId playSfx(xmSampleId _sampleId,xmModId _modId,int _sfxPattern,int _playMask,u8 _priority);
xmPlayingId playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int _soundId,u8 _priority,int _pitch=0x400);
2000-10-05 16:16:09 +02:00
2001-06-18 17:59:09 +02:00
int isStillPlaying(xmPlayingId _playingId);
2001-07-18 22:11:46 +02:00
int isSfxPatternPlaying(int _startPattern);
2001-06-18 17:59:09 +02:00
2000-10-10 00:06:20 +02:00
void unlockPlayingId(xmPlayingId _playingId);
void stopPlayingId(xmPlayingId _playingId);
2000-10-05 16:16:09 +02:00
private:
enum
{
2001-07-13 23:31:02 +02:00
MAX_XM_SONGS=2, // How many mods our internal loader copes with
MAX_XM_VABS=2, // How many vabs our internal loader copes with
2000-10-10 01:30:58 +02:00
MAX_SONG_HEADERS=24, // Number of mods that xmplay can play at once
MAX_XM_HEADERS=MAX_XM_SONGS, // Number of mods that xmplay can load at once
2000-10-10 00:06:20 +02:00
NUM_SPU_CHANNELS=24,
2000-10-05 16:16:09 +02:00
};
2000-10-10 00:06:20 +02:00
typedef enum
{
SONG,
SFX,
LOOPINGSFX,
2000-10-12 16:35:13 +02:00
2001-07-18 22:11:46 +02:00
SILENTSONG, // Channel is silent
SILENTSFX, // " " " "
2000-10-12 16:35:13 +02:00
FREE, // Channel is free for re-allocation
CONTINUE, // Channel is a continuation of the previous channel
2000-10-10 00:06:20 +02:00
} CHANNELUSETYPE;
2000-10-11 18:47:03 +02:00
// Internal representation of loaded mods
2000-10-10 01:30:58 +02:00
typedef struct XMMod
{
unsigned char *m_xmData;
FileEquate m_file;
int m_refCount;
};
// Internal representation of loaded vabs
typedef struct XMVab
{
int m_vabId;
FileEquate m_vhFile,m_vbFile;
int m_refCount;
};
// Structure that records what is going on for each SPU channel
2000-10-10 00:06:20 +02:00
typedef struct
{
CHANNELUSETYPE m_useType;
2000-10-10 01:30:58 +02:00
xmPlayingId m_playingId;
2000-10-10 00:06:20 +02:00
u8 m_internalId;
u8 m_priority;
u8 m_locked;
2000-10-11 18:47:03 +02:00
u8 m_vol,m_pan;
2001-07-18 22:11:46 +02:00
u8 m_startPattern;
2000-10-10 00:06:20 +02:00
} spuChannelUse;
2000-10-12 17:18:47 +02:00
xmPlayingId getNextSparePlayingId(int _baseChannel);
2000-10-10 00:06:20 +02:00
int findSpareChannels(int _channelCount,int _priority);
void markChannelsAsActive(int _baseChannel,int _channelCount,CHANNELUSETYPE _useType,xmPlayingId _playingId,int _internalId,u8 _priority);
2000-10-05 16:16:09 +02:00
void defragSpuMemory();
2000-10-11 18:47:03 +02:00
void updateLoopingSfx(spuChannelUse *ch);
2000-10-10 00:06:20 +02:00
unsigned char *m_fhPtr[MAX_XM_HEADERS];
unsigned char *m_songPtr[MAX_SONG_HEADERS];
2000-10-11 18:47:03 +02:00
XMMod m_xmMods[MAX_XM_SONGS];
XMVab m_xmVabs[MAX_XM_VABS];
2000-10-10 00:06:20 +02:00
spuChannelUse m_spuChannelUse[NUM_SPU_CHANNELS];
2000-10-11 18:47:03 +02:00
unsigned char m_masterSongVolume;
unsigned char m_masterSfxVolume;
2000-10-05 16:16:09 +02:00
};
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __SOUND_XMPLAY_H__ */
/*===========================================================================
end */