2009-07-27 05:47:50 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1994-1995 Apogee Software, Ltd.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
/**********************************************************************
|
|
|
|
file: _MULTIVC.H
|
|
|
|
|
|
|
|
author: James R. Dose
|
|
|
|
date: December 20, 1993
|
|
|
|
|
|
|
|
Private header for MULTIVOC.C
|
|
|
|
|
|
|
|
(c) Copyright 1993 James R. Dose. All Rights Reserved.
|
|
|
|
**********************************************************************/
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef MULTIVC_H_
|
|
|
|
#define MULTIVC_H_
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2012-12-29 11:27:07 +00:00
|
|
|
#include "limits.h"
|
|
|
|
#include "inttypes.h"
|
|
|
|
#include "multivoc.h"
|
|
|
|
|
2009-07-27 05:47:50 +00:00
|
|
|
#define VOC_8BIT 0x0
|
|
|
|
#define VOC_16BIT 0x4
|
|
|
|
|
|
|
|
#define T_SIXTEENBIT_STEREO 0
|
|
|
|
#define T_MONO 2
|
|
|
|
#define T_16BITSOURCE 4
|
|
|
|
#define T_STEREOSOURCE 8
|
|
|
|
#define T_LEFTQUIET 16
|
|
|
|
#define T_RIGHTQUIET 32
|
|
|
|
#define T_DEFAULT T_SIXTEENBIT_STEREO
|
|
|
|
|
2011-11-01 22:02:14 +00:00
|
|
|
#define MV_MAXPANPOSITION 127 /* formerly 31 */
|
|
|
|
#define MV_NUMPANPOSITIONS ( MV_MAXPANPOSITION + 1 )
|
|
|
|
#define MV_MAXTOTALVOLUME 255
|
2018-02-27 16:54:42 +00:00
|
|
|
#define MV_MAXVOLUME 255 /* formerly 63 */
|
2011-11-01 22:02:14 +00:00
|
|
|
#define MV_NUMVOICES 8
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
// mirrors FX_MUSIC_PRIORITY from fx_man.h
|
|
|
|
#define MV_MUSIC_PRIORITY INT_MAX
|
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
#define MIX_VOLUME(volume) ((max(0, min((volume), 255)) * (MV_MAXVOLUME + 1)) >> 8)
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2011-11-01 22:02:14 +00:00
|
|
|
#define MV_MIXBUFFERSIZE 256
|
|
|
|
#define MV_NUMBEROFBUFFERS 16
|
|
|
|
#define MV_TOTALBUFFERSIZE ( MV_MIXBUFFERSIZE * MV_NUMBEROFBUFFERS )
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2011-11-01 22:02:14 +00:00
|
|
|
//#define PI 3.1415926536
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
typedef enum
|
2015-07-08 03:33:56 +00:00
|
|
|
{
|
|
|
|
NoMoreData,
|
|
|
|
KeepPlaying
|
|
|
|
} playbackstatus;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct VoiceNode
|
2015-07-08 03:33:56 +00:00
|
|
|
{
|
|
|
|
struct VoiceNode *next;
|
|
|
|
struct VoiceNode *prev;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
playbackstatus (*GetSound)(struct VoiceNode *voice);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
void (*mix)(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
const char *sound;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
const int16_t *LeftVolume;
|
|
|
|
const int16_t *RightVolume;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2016-01-11 05:05:38 +00:00
|
|
|
void *rawdataptr;
|
2012-02-16 19:24:28 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
const char *NextBlock;
|
|
|
|
const char *LoopStart;
|
|
|
|
const char *LoopEnd;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
wavefmt_t wavetype;
|
|
|
|
char bits;
|
|
|
|
char channels;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
unsigned LoopCount;
|
|
|
|
uint32_t LoopSize;
|
|
|
|
uint32_t BlockLength;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
int32_t ptrlength; // ptrlength-1 is the max permissible index for rawdataptr
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
uint32_t PitchScale;
|
|
|
|
uint32_t FixedPointBufferSize;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
uint32_t length;
|
|
|
|
uint32_t SamplingRate;
|
|
|
|
uint32_t RateScale;
|
|
|
|
uint32_t position;
|
|
|
|
int32_t Playing;
|
|
|
|
int32_t Paused;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
int32_t handle;
|
|
|
|
int32_t priority;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
uint32_t callbackval;
|
|
|
|
} VoiceNode;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
typedef struct
|
2015-07-08 03:33:56 +00:00
|
|
|
{
|
|
|
|
uint8_t left;
|
|
|
|
uint8_t right;
|
|
|
|
} Pan;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
typedef struct
|
2015-07-08 03:33:56 +00:00
|
|
|
{
|
|
|
|
char RIFF[4];
|
|
|
|
uint32_t file_size;
|
|
|
|
char WAVE[4];
|
|
|
|
char fmt[4];
|
|
|
|
uint32_t format_size;
|
|
|
|
} riff_header;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
typedef struct
|
2015-07-08 03:33:56 +00:00
|
|
|
{
|
|
|
|
uint16_t wFormatTag;
|
|
|
|
uint16_t nChannels;
|
|
|
|
uint32_t nSamplesPerSec;
|
|
|
|
uint32_t nAvgBytesPerSec;
|
|
|
|
uint16_t nBlockAlign;
|
|
|
|
uint16_t nBitsPerSample;
|
|
|
|
} format_header;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
typedef struct
|
2015-07-08 03:33:56 +00:00
|
|
|
{
|
|
|
|
uint8_t DATA[4];
|
|
|
|
uint32_t size;
|
|
|
|
} data_header;
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2011-11-01 22:02:14 +00:00
|
|
|
extern Pan MV_PanTable[ MV_NUMPANPOSITIONS ][ MV_MAXVOLUME + 1 ];
|
2009-07-27 05:47:50 +00:00
|
|
|
extern int32_t MV_ErrorCode;
|
|
|
|
extern int32_t MV_Installed;
|
|
|
|
extern int32_t MV_MixRate;
|
2011-11-01 22:02:14 +00:00
|
|
|
typedef char HARSH_CLIP_TABLE_8[ MV_NUMVOICES * 256 ];
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
#define MV_SetErrorCode(status) MV_ErrorCode = (status);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
void MV_PlayVoice(VoiceNode *voice);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
VoiceNode *MV_AllocVoice(int32_t priority);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
void MV_SetVoiceMixMode(VoiceNode *voice);
|
|
|
|
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right);
|
|
|
|
void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int32_t pitchoffset);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
2015-01-17 00:28:49 +00:00
|
|
|
int32_t MV_GetVorbisPosition(VoiceNode *voice);
|
|
|
|
void MV_SetVorbisPosition(VoiceNode *voice, int32_t position);
|
|
|
|
int32_t MV_GetFLACPosition(VoiceNode *voice);
|
|
|
|
void MV_SetFLACPosition(VoiceNode *voice, int32_t position);
|
|
|
|
int32_t MV_GetXAPosition(VoiceNode *voice);
|
|
|
|
void MV_SetXAPosition(VoiceNode *voice, int32_t position);
|
2016-11-08 02:59:05 +00:00
|
|
|
int32_t MV_GetXMPPosition(VoiceNode *voice);
|
|
|
|
void MV_SetXMPPosition(VoiceNode *voice, int32_t position);
|
2015-01-17 00:28:49 +00:00
|
|
|
|
2015-07-08 03:33:56 +00:00
|
|
|
void MV_ReleaseVorbisVoice(VoiceNode *voice);
|
|
|
|
void MV_ReleaseFLACVoice(VoiceNode *voice);
|
|
|
|
void MV_ReleaseXAVoice(VoiceNode *voice);
|
2016-11-08 02:59:05 +00:00
|
|
|
void MV_ReleaseXMPVoice(VoiceNode *voice);
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
// implemented in mix.c
|
2015-07-08 03:33:56 +00:00
|
|
|
void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_16BitReverb( char const *src, char *dest, int16_t *volume, int32_t count );
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
// implemented in mixst.c
|
2015-07-08 03:33:56 +00:00
|
|
|
void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_Mix16BitStereo8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_Mix16BitMono16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
void MV_Mix16BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
|
|
|
|
|
|
|
|
extern char *MV_MixDestination; // pointer to the next output sample
|
|
|
|
extern uint32_t MV_MixPosition; // return value of where the source pointer got to
|
2011-11-01 22:02:37 +00:00
|
|
|
extern const int16_t *MV_LeftVolume;
|
|
|
|
extern const int16_t *MV_RightVolume;
|
2015-07-08 03:33:56 +00:00
|
|
|
extern int32_t MV_SampleSize;
|
|
|
|
extern int32_t MV_RightChannelOffset;
|
2011-11-01 22:02:37 +00:00
|
|
|
|
2016-10-14 07:40:59 +00:00
|
|
|
#define loopStartTagCount 3
|
2012-12-29 10:57:24 +00:00
|
|
|
extern const char *loopStartTags[loopStartTagCount];
|
|
|
|
#define loopEndTagCount 2
|
|
|
|
extern const char *loopEndTags[loopEndTagCount];
|
|
|
|
#define loopLengthTagCount 2
|
|
|
|
extern const char *loopLengthTags[loopLengthTagCount];
|
|
|
|
|
2012-05-01 12:40:53 +00:00
|
|
|
#if defined __POWERPC__ || defined GEKKO
|
2011-11-01 22:02:37 +00:00
|
|
|
# define BIGENDIAN
|
|
|
|
#endif
|
2009-07-27 05:47:50 +00:00
|
|
|
|
|
|
|
#endif
|