diff --git a/include/zmusic.h b/include/zmusic.h index 0dd186c..ec6c10e 100644 --- a/include/zmusic.h +++ b/include/zmusic.h @@ -12,7 +12,7 @@ typedef unsigned char zmusic_bool; // These constants must match the corresponding values of the Windows headers // to avoid readjustment in the native Windows device's playback functions // and should not be changed. -typedef enum EMidiDeviceClass_ +typedef enum EZMusicMidiDeviceClass_ { MIDIDEV_MIDIPORT = 1, MIDIDEV_SYNTH, @@ -21,18 +21,18 @@ typedef enum EMidiDeviceClass_ MIDIDEV_MAPPER, MIDIDEV_WAVETABLE, MIDIDEV_SWSYNTH -} EMidiDeviceClass; +} EZMusicMidiDeviceClass; -typedef enum EMIDIType_ +typedef enum EZMusicMIDIType_ { MIDI_NOTMIDI, MIDI_MIDI, MIDI_HMI, MIDI_XMI, MIDI_MUS -} EMIDIType; +} EZMusicMIDIType; -typedef enum EMidiDevice_ +typedef enum EZMusicMidiDevice_ { MDEV_DEFAULT = -1, MDEV_STANDARD = 0, @@ -46,36 +46,36 @@ typedef enum EMidiDevice_ MDEV_OPN = 8, MDEV_COUNT -} EMidiDevice; +} EZMusicMidiDevice; -typedef enum ESoundFontTypes_ +typedef enum EZMusicSoundFontTypes_ { SF_SF2 = 1, SF_GUS = 2, SF_WOPL = 4, SF_WOPN = 8 -} ESoundFontTypes; +} EZMusicSoundFontTypes; -typedef struct SoundStreamInfo_ +typedef struct ZMusicSoundStreamInfo_ { int mBufferSize; // If mBufferSize is 0, the song doesn't use streaming but plays through a different interface. int mSampleRate; int mNumChannels; // If mNumChannels is negative, 16 bit integer format is used instead of floating point. -} SoundStreamInfo; +} ZMusicSoundStreamInfo; -typedef enum SampleType_ +typedef enum EZMusicSampleType_ { SampleType_UInt8, SampleType_Int16 -} SampleType; +} EZMusicSampleType; -typedef enum ChannelConfig_ +typedef enum EZMusicChannelConfig_ { ChannelConfig_Mono, ChannelConfig_Stereo -} ChannelConfig; +} EZMusicChannelConfig; -typedef enum EIntConfigKey_ +typedef enum EZMusicIntConfigKey_ { zmusic_adl_chips_count, zmusic_adl_emulator_id, @@ -142,9 +142,9 @@ typedef enum EIntConfigKey_ zmusic_snd_outputrate, NUM_ZMUSIC_INT_CONFIGS -} EIntConfigKey; +} EZMusicIntConfigKey; -typedef enum EFloatConfigKey_ +typedef enum EZMusicFloatConfigKey_ { zmusic_fluid_gain = 1000, zmusic_fluid_reverb_roomsize, @@ -167,9 +167,9 @@ typedef enum EFloatConfigKey_ zmusic_snd_mastervolume, NUM_FLOAT_CONFIGS -} EFloatConfigKey; +} EZMusicFloatConfigKey; -typedef enum EStringConfigKey_ +typedef enum EZMusicStringConfigKey_ { zmusic_adl_custom_bank = 2000, zmusic_fluid_lib, @@ -181,7 +181,7 @@ typedef enum EStringConfigKey_ zmusic_wildmidi_config, NUM_STRING_CONFIGS -} EStringConfigKey; +} EZMusicStringConfigKey; typedef struct ZMusicCustomReader_ @@ -264,9 +264,9 @@ typedef struct ZMusicConfigurationSetting_ #ifndef ZMUSIC_INTERNAL #ifdef _MSC_VER -#define DLL_IMPORT _declspec(dllimport) +#define ZMUSIC_DLL_IMPORT _declspec(dllimport) #else // !_MSC_VER -#define DLL_IMPORT +#define ZMUSIC_DLL_IMPORT #endif // _MSC_VER // Note that the internal 'class' definitions are not C compatible! typedef struct { int zm1; } *ZMusic_MidiSource; @@ -279,96 +279,96 @@ struct SoundDecoder; extern "C" { #endif - DLL_IMPORT const char* ZMusic_GetLastError(); + ZMUSIC_DLL_IMPORT const char* ZMusic_GetLastError(); // Sets callbacks for functionality that the client needs to provide. - DLL_IMPORT void ZMusic_SetCallbacks(const ZMusicCallbacks* callbacks); + ZMUSIC_DLL_IMPORT void ZMusic_SetCallbacks(const ZMusicCallbacks* callbacks); // Sets GenMidi data for OPL playback. If this isn't provided the OPL synth will not work. - DLL_IMPORT void ZMusic_SetGenMidi(const uint8_t* data); + ZMUSIC_DLL_IMPORT void ZMusic_SetGenMidi(const uint8_t* data); // Set default bank for OPN. Without this OPN only works with custom banks. - DLL_IMPORT void ZMusic_SetWgOpn(const void* data, unsigned len); + ZMUSIC_DLL_IMPORT void ZMusic_SetWgOpn(const void* data, unsigned len); // Set DMXGUS data for running the GUS synth in actual GUS mode. - DLL_IMPORT void ZMusic_SetDmxGus(const void* data, unsigned len); + ZMUSIC_DLL_IMPORT void ZMusic_SetDmxGus(const void* data, unsigned len); // Returns an array with all available configuration options - terminated with an empty entry where all elements are 0. - DLL_IMPORT const ZMusicConfigurationSetting* ZMusic_GetConfiguration(); + ZMUSIC_DLL_IMPORT const ZMusicConfigurationSetting* ZMusic_GetConfiguration(); // These exports are needed by the MIDI dumpers which need to remain on the client side because the need access to the client's file system. - DLL_IMPORT EMIDIType ZMusic_IdentifyMIDIType(uint32_t* id, int size); - DLL_IMPORT ZMusic_MidiSource ZMusic_CreateMIDISource(const uint8_t* data, size_t length, EMIDIType miditype); - DLL_IMPORT zmusic_bool ZMusic_MIDIDumpWave(ZMusic_MidiSource source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate); + ZMUSIC_DLL_IMPORT EZMusicMIDIType ZMusic_IdentifyMIDIType(uint32_t* id, int size); + ZMUSIC_DLL_IMPORT ZMusic_MidiSource ZMusic_CreateMIDISource(const uint8_t* data, size_t length, EZMusicMIDIType miditype); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_MIDIDumpWave(ZMusic_MidiSource source, EZMusicMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate); - DLL_IMPORT ZMusic_MusicStream ZMusic_OpenSong(ZMusicCustomReader* reader, EMidiDevice device, const char* Args); - DLL_IMPORT ZMusic_MusicStream ZMusic_OpenSongFile(const char *filename, EMidiDevice device, const char* Args); - DLL_IMPORT ZMusic_MusicStream ZMusic_OpenSongMem(const void *mem, size_t size, EMidiDevice device, const char* Args); - DLL_IMPORT ZMusic_MusicStream ZMusic_OpenCDSong(int track, int cdid); + ZMUSIC_DLL_IMPORT ZMusic_MusicStream ZMusic_OpenSong(ZMusicCustomReader* reader, EZMusicMidiDevice device, const char* Args); + ZMUSIC_DLL_IMPORT ZMusic_MusicStream ZMusic_OpenSongFile(const char *filename, EZMusicMidiDevice device, const char* Args); + ZMUSIC_DLL_IMPORT ZMusic_MusicStream ZMusic_OpenSongMem(const void *mem, size_t size, EZMusicMidiDevice device, const char* Args); + ZMUSIC_DLL_IMPORT ZMusic_MusicStream ZMusic_OpenCDSong(int track, int cdid); - DLL_IMPORT zmusic_bool ZMusic_FillStream(ZMusic_MusicStream stream, void* buff, int len); - DLL_IMPORT zmusic_bool ZMusic_Start(ZMusic_MusicStream song, int subsong, zmusic_bool loop); - DLL_IMPORT void ZMusic_Pause(ZMusic_MusicStream song); - DLL_IMPORT void ZMusic_Resume(ZMusic_MusicStream song); - DLL_IMPORT void ZMusic_Update(ZMusic_MusicStream song); - DLL_IMPORT zmusic_bool ZMusic_IsPlaying(ZMusic_MusicStream song); - DLL_IMPORT void ZMusic_Stop(ZMusic_MusicStream song); - DLL_IMPORT void ZMusic_Close(ZMusic_MusicStream song); - DLL_IMPORT zmusic_bool ZMusic_SetSubsong(ZMusic_MusicStream song, int subsong); - DLL_IMPORT zmusic_bool ZMusic_IsLooping(ZMusic_MusicStream song); - DLL_IMPORT zmusic_bool ZMusic_IsMIDI(ZMusic_MusicStream song); - DLL_IMPORT void ZMusic_VolumeChanged(ZMusic_MusicStream song); - DLL_IMPORT zmusic_bool ZMusic_WriteSMF(ZMusic_MidiSource source, const char* fn, int looplimit); - DLL_IMPORT void ZMusic_GetStreamInfo(ZMusic_MusicStream song, SoundStreamInfo *info); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_FillStream(ZMusic_MusicStream stream, void* buff, int len); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_Start(ZMusic_MusicStream song, int subsong, zmusic_bool loop); + ZMUSIC_DLL_IMPORT void ZMusic_Pause(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT void ZMusic_Resume(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT void ZMusic_Update(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_IsPlaying(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT void ZMusic_Stop(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT void ZMusic_Close(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_SetSubsong(ZMusic_MusicStream song, int subsong); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_IsLooping(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_IsMIDI(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT void ZMusic_VolumeChanged(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT zmusic_bool ZMusic_WriteSMF(ZMusic_MidiSource source, const char* fn, int looplimit); + ZMUSIC_DLL_IMPORT void ZMusic_GetStreamInfo(ZMusic_MusicStream song, ZMusicSoundStreamInfo *info); // Configuration interface. The return value specifies if a music restart is needed. // RealValue should be written back to the CVAR or whatever other method the client uses to store configuration state. - DLL_IMPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); - DLL_IMPORT zmusic_bool ChangeMusicSettingFloat(EFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); - DLL_IMPORT zmusic_bool ChangeMusicSettingString(EStringConfigKey key, ZMusic_MusicStream song, const char* value); - DLL_IMPORT const char *ZMusic_GetStats(ZMusic_MusicStream song); + ZMUSIC_DLL_IMPORT zmusic_bool ChangeMusicSettingInt(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); + ZMUSIC_DLL_IMPORT zmusic_bool ChangeMusicSettingFloat(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); + ZMUSIC_DLL_IMPORT zmusic_bool ChangeMusicSettingString(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value); + ZMUSIC_DLL_IMPORT const char *ZMusic_GetStats(ZMusic_MusicStream song); - DLL_IMPORT struct SoundDecoder* CreateDecoder(const uint8_t* data, size_t size, zmusic_bool isstatic); - DLL_IMPORT void SoundDecoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, ChannelConfig* chans, SampleType* type); - DLL_IMPORT size_t SoundDecoder_Read(struct SoundDecoder* decoder, void* buffer, size_t length); - DLL_IMPORT void SoundDecoder_Close(struct SoundDecoder* decoder); - DLL_IMPORT void FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass); + ZMUSIC_DLL_IMPORT struct SoundDecoder* CreateDecoder(const uint8_t* data, size_t size, zmusic_bool isstatic); + ZMUSIC_DLL_IMPORT void SoundDecoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type); + ZMUSIC_DLL_IMPORT size_t SoundDecoder_Read(struct SoundDecoder* decoder, void* buffer, size_t length); + ZMUSIC_DLL_IMPORT void SoundDecoder_Close(struct SoundDecoder* decoder); + ZMUSIC_DLL_IMPORT void FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass); // The rest of the decoder interface is only useful for streaming music. - DLL_IMPORT const ZMusicMidiOutDevice *ZMusic_GetMidiDevices(int *pAmount); - DLL_IMPORT int ZMusic_GetADLBanks(const char* const** pNames); + ZMUSIC_DLL_IMPORT const ZMusicMidiOutDevice *ZMusic_GetMidiDevices(int *pAmount); + ZMUSIC_DLL_IMPORT int ZMusic_GetADLBanks(const char* const** pNames); // Direct access to the CD drive. // Stops playing the CD - DLL_IMPORT void CD_Stop(); + ZMUSIC_DLL_IMPORT void CD_Stop(); // Pauses CD playing - DLL_IMPORT void CD_Pause(); + ZMUSIC_DLL_IMPORT void CD_Pause(); // Resumes CD playback after pausing - DLL_IMPORT zmusic_bool CD_Resume(); + ZMUSIC_DLL_IMPORT zmusic_bool CD_Resume(); // Eject the CD tray - DLL_IMPORT void CD_Eject(); + ZMUSIC_DLL_IMPORT void CD_Eject(); // Close the CD tray - DLL_IMPORT zmusic_bool CD_UnEject(); + ZMUSIC_DLL_IMPORT zmusic_bool CD_UnEject(); // Closes a CD device previously opened with CD_Init - DLL_IMPORT void CD_Close(); + ZMUSIC_DLL_IMPORT void CD_Close(); - DLL_IMPORT zmusic_bool CD_Enable(const char* drive); + ZMUSIC_DLL_IMPORT zmusic_bool CD_Enable(const char* drive); #ifdef __cplusplus } -inline bool ChangeMusicSetting(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue = NULL) +inline bool ChangeMusicSetting(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue = NULL) { return ChangeMusicSettingInt(key, song, value, pRealValue); } -inline bool ChangeMusicSetting(EFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue = NULL) +inline bool ChangeMusicSetting(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue = NULL) { return ChangeMusicSettingFloat(key, song, value, pRealValue); } -inline bool ChangeMusicSetting(EStringConfigKey key, ZMusic_MusicStream song, const char* value) +inline bool ChangeMusicSetting(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value) { return ChangeMusicSettingString(key, song, value); } @@ -383,12 +383,12 @@ typedef void (*pfn_ZMusic_SetGenMidi)(const uint8_t* data); typedef void (*pfn_ZMusic_SetWgOpn)(const void* data, unsigned len); typedef void (*pfn_ZMusic_SetDmxGus)(const void* data, unsigned len); typedef const ZMusicConfigurationSetting* (*pfn_ZMusic_GetConfiguration)(); -typedef EMIDIType (*pfn_ZMusic_IdentifyMIDIType)(uint32_t* id, int size); -typedef ZMusic_MidiSource (*pfn_ZMusic_CreateMIDISource)(const uint8_t* data, size_t length, EMIDIType miditype); -typedef zmusic_bool (*pfn_ZMusic_MIDIDumpWave)(ZMusic_MidiSource source, EMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate); -typedef ZMusic_MusicStream (*pfn_ZMusic_OpenSong)(ZMusicCustomReader* reader, EMidiDevice device, const char* Args); -typedef ZMusic_MusicStream (*pfn_ZMusic_OpenSongFile)(const char *filename, EMidiDevice device, const char* Args); -typedef ZMusic_MusicStream (*pfn_ZMusic_OpenSongMem)(const void *mem, size_t size, EMidiDevice device, const char* Args); +typedef EZMusicMIDIType (*pfn_ZMusic_IdentifyMIDIType)(uint32_t* id, int size); +typedef ZMusic_MidiSource (*pfn_ZMusic_CreateMIDISource)(const uint8_t* data, size_t length, EZMusicMIDIType miditype); +typedef zmusic_bool (*pfn_ZMusic_MIDIDumpWave)(ZMusic_MidiSource source, EZMusicMidiDevice devtype, const char* devarg, const char* outname, int subsong, int samplerate); +typedef ZMusic_MusicStream (*pfn_ZMusic_OpenSong)(ZMusicCustomReader* reader, EZMusicMidiDevice device, const char* Args); +typedef ZMusic_MusicStream (*pfn_ZMusic_OpenSongFile)(const char *filename, EZMusicMidiDevice device, const char* Args); +typedef ZMusic_MusicStream (*pfn_ZMusic_OpenSongMem)(const void *mem, size_t size, EZMusicMidiDevice device, const char* Args); typedef ZMusic_MusicStream (*pfn_ZMusic_OpenCDSong)(int track, int cdid); typedef zmusic_bool (*pfn_ZMusic_FillStream)(ZMusic_MusicStream stream, void* buff, int len); typedef zmusic_bool (*pfn_ZMusic_Start)(ZMusic_MusicStream song, int subsong, zmusic_bool loop); @@ -403,13 +403,13 @@ typedef zmusic_bool (*pfn_ZMusic_IsLooping)(ZMusic_MusicStream song); typedef zmusic_bool (*pfn_ZMusic_IsMIDI)(ZMusic_MusicStream song); typedef void (*pfn_ZMusic_VolumeChanged)(ZMusic_MusicStream song); typedef zmusic_bool (*pfn_ZMusic_WriteSMF)(ZMusic_MidiSource source, const char* fn, int looplimit); -typedef void (*pfn_ZMusic_GetStreamInfo)(ZMusic_MusicStream song, SoundStreamInfo *info); -typedef zmusic_bool (*pfn_ChangeMusicSettingInt)(EIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); -typedef zmusic_bool (*pfn_ChangeMusicSettingFloat)(EFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); -typedef zmusic_bool (*pfn_ChangeMusicSettingString)(EStringConfigKey key, ZMusic_MusicStream song, const char* value); +typedef void (*pfn_ZMusic_GetStreamInfo)(ZMusic_MusicStream song, ZMusicSoundStreamInfo *info); +typedef zmusic_bool (*pfn_ChangeMusicSettingInt)(EZMusicIntConfigKey key, ZMusic_MusicStream song, int value, int* pRealValue); +typedef zmusic_bool (*pfn_ChangeMusicSettingFloat)(EZMusicFloatConfigKey key, ZMusic_MusicStream song, float value, float* pRealValue); +typedef zmusic_bool (*pfn_ChangeMusicSettingString)(EZMusicStringConfigKey key, ZMusic_MusicStream song, const char* value); typedef const char *(*pfn_ZMusic_GetStats)(ZMusic_MusicStream song); typedef struct SoundDecoder* (*pfn_CreateDecoder)(const uint8_t* data, size_t size, zmusic_bool isstatic); -typedef void (*pfn_SoundDecoder_GetInfo)(struct SoundDecoder* decoder, int* samplerate, ChannelConfig* chans, SampleType* type); +typedef void (*pfn_SoundDecoder_GetInfo)(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type); typedef size_t (*pfn_SoundDecoder_Read)(struct SoundDecoder* decoder, void* buffer, size_t length); typedef void (*pfn_SoundDecoder_Close)(struct SoundDecoder* decoder); typedef void (*pfn_FindLoopTags)(const uint8_t* data, size_t size, uint32_t* start, zmusic_bool* startass, uint32_t* end, zmusic_bool* endass); diff --git a/source/decoder/mpg123_decoder.cpp b/source/decoder/mpg123_decoder.cpp index 78cc973..a7286e5 100644 --- a/source/decoder/mpg123_decoder.cpp +++ b/source/decoder/mpg123_decoder.cpp @@ -152,7 +152,7 @@ bool MPG123Decoder::open(MusicIO::FileInterface *reader) return false; } -void MPG123Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) +void MPG123Decoder::getInfo(int *samplerate, EZMusicChannelConfig *chans, EZMusicSampleType *type) { int enc = 0, channels = 0; long srate = 0; diff --git a/source/decoder/mpg123_decoder.h b/source/decoder/mpg123_decoder.h index 7e91588..d8a3d49 100644 --- a/source/decoder/mpg123_decoder.h +++ b/source/decoder/mpg123_decoder.h @@ -18,7 +18,7 @@ typedef ptrdiff_t ssize_t; struct MPG123Decoder : public SoundDecoder { - virtual void getInfo(int* samplerate, ChannelConfig* chans, SampleType* type) override; + virtual void getInfo(int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type) override; virtual size_t read(char* buffer, size_t bytes) override; virtual bool seek(size_t ms_offset, bool ms, bool mayrestart) override; diff --git a/source/decoder/sndfile_decoder.cpp b/source/decoder/sndfile_decoder.cpp index 5ffe7dc..db0407b 100644 --- a/source/decoder/sndfile_decoder.cpp +++ b/source/decoder/sndfile_decoder.cpp @@ -133,7 +133,7 @@ bool SndFileDecoder::open(MusicIO::FileInterface *reader) return false; } -void SndFileDecoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) +void SndFileDecoder::getInfo(int *samplerate, EZMusicChannelConfig *chans, EZMusicSampleType *type) { *samplerate = SndInfo.samplerate; diff --git a/source/decoder/sndfile_decoder.h b/source/decoder/sndfile_decoder.h index 2645ebd..b8f2429 100644 --- a/source/decoder/sndfile_decoder.h +++ b/source/decoder/sndfile_decoder.h @@ -13,7 +13,7 @@ struct SndFileDecoder : public SoundDecoder { - virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) override; + virtual void getInfo(int *samplerate, EZMusicChannelConfig *chans, EZMusicSampleType *type) override; virtual size_t read(char *buffer, size_t bytes) override; virtual std::vector readAll() override; diff --git a/source/decoder/sounddecoder.cpp b/source/decoder/sounddecoder.cpp index 4c6e02d..ebc71e2 100644 --- a/source/decoder/sounddecoder.cpp +++ b/source/decoder/sounddecoder.cpp @@ -90,8 +90,8 @@ extern "C" short* dumb_decode_vorbis(int outlen, const void* oggstream, int sizebytes) { short* samples = (short*)calloc(1, outlen); - ChannelConfig chans; - SampleType type; + EZMusicChannelConfig chans; + EZMusicSampleType type; int srate; // The decoder will take ownership of the reader if it succeeds so this may not be a local variable. @@ -126,7 +126,7 @@ DLL_EXPORT struct SoundDecoder* CreateDecoder(const uint8_t* data, size_t size, return res; } -DLL_EXPORT void SoundDecoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, ChannelConfig* chans, SampleType* type) +DLL_EXPORT void SoundDecoder_GetInfo(struct SoundDecoder* decoder, int* samplerate, EZMusicChannelConfig* chans, EZMusicSampleType* type) { if (decoder) decoder->getInfo(samplerate, chans, type); else if (samplerate) *samplerate = 0; diff --git a/source/mididevices/mididevice.h b/source/mididevices/mididevice.h index 2cdd167..3987f1f 100644 --- a/source/mididevices/mididevice.h +++ b/source/mididevices/mididevice.h @@ -51,7 +51,7 @@ public: virtual std::string GetStats(); virtual int GetDeviceType() const { return MDEV_DEFAULT; } virtual bool CanHandleSysex() const { return true; } - virtual SoundStreamInfo GetStreamInfo() const; + virtual ZMusicSoundStreamInfo GetStreamInfo() const; protected: MidiCallback Callback; @@ -81,7 +81,7 @@ public: virtual int Open() override; virtual bool ServiceStream(void* buff, int numbytes); int GetSampleRate() const { return SampleRate; } - SoundStreamInfo GetStreamInfo() const override; + ZMusicSoundStreamInfo GetStreamInfo() const override; protected: double Tempo; diff --git a/source/mididevices/music_base_mididevice.cpp b/source/mididevices/music_base_mididevice.cpp index fa6f9df..fa81081 100644 --- a/source/mididevices/music_base_mididevice.cpp +++ b/source/mididevices/music_base_mididevice.cpp @@ -176,7 +176,7 @@ std::string MIDIDevice::GetStats() // //========================================================================== -SoundStreamInfo MIDIDevice::GetStreamInfo() const +ZMusicSoundStreamInfo MIDIDevice::GetStreamInfo() const { return { 0, 0, 0 }; // i.e. do not use streaming. } diff --git a/source/mididevices/music_softsynth_mididevice.cpp b/source/mididevices/music_softsynth_mididevice.cpp index 8b7ea1f..9ab9df3 100644 --- a/source/mididevices/music_softsynth_mididevice.cpp +++ b/source/mididevices/music_softsynth_mididevice.cpp @@ -92,7 +92,7 @@ SoftSynthMIDIDevice::~SoftSynthMIDIDevice() // //========================================================================== -SoundStreamInfo SoftSynthMIDIDevice::GetStreamInfo() const +ZMusicSoundStreamInfo SoftSynthMIDIDevice::GetStreamInfo() const { int chunksize = (SampleRate / StreamBlockSize) * 4; if (!isMono) diff --git a/source/midisources/midisource.cpp b/source/midisources/midisource.cpp index 4cf6392..ee65262 100644 --- a/source/midisources/midisource.cpp +++ b/source/midisources/midisource.cpp @@ -418,7 +418,7 @@ extern int MUSHeaderSearch(const uint8_t *head, int len); // //========================================================================== -DLL_EXPORT EMIDIType ZMusic_IdentifyMIDIType(uint32_t *id, int size) +DLL_EXPORT EZMusicMIDIType ZMusic_IdentifyMIDIType(uint32_t *id, int size) { // Check for MUS format // Tolerate sloppy wads by searching up to 32 bytes for the header @@ -467,7 +467,7 @@ DLL_EXPORT EMIDIType ZMusic_IdentifyMIDIType(uint32_t *id, int size) // //========================================================================== -DLL_EXPORT ZMusic_MidiSource ZMusic_CreateMIDISource(const uint8_t *data, size_t length, EMIDIType miditype) +DLL_EXPORT ZMusic_MidiSource ZMusic_CreateMIDISource(const uint8_t *data, size_t length, EZMusicMIDIType miditype) { try { diff --git a/source/musicformats/music_midi.cpp b/source/musicformats/music_midi.cpp index f999fc0..881923c 100644 --- a/source/musicformats/music_midi.cpp +++ b/source/musicformats/music_midi.cpp @@ -67,7 +67,7 @@ enum class MIDIStreamer : public MusInfo { public: - MIDIStreamer(EMidiDevice type, const char* args); + MIDIStreamer(EZMusicMidiDevice type, const char* args); ~MIDIStreamer(); void MusicVolumeChanged() override; @@ -87,7 +87,7 @@ public: int ServiceEvent(); void SetMIDISource(MIDISource* _source); bool ServiceStream(void* buff, int len) override; - SoundStreamInfo GetStreamInfo() const override; + ZMusicSoundStreamInfo GetStreamInfo() const override; int GetDeviceType() const override; @@ -95,7 +95,7 @@ public: protected: - MIDIStreamer(const char* dumpname, EMidiDevice type); + MIDIStreamer(const char* dumpname, EZMusicMidiDevice type); void OutputVolume(uint32_t volume); int FillBuffer(int buffer_num, int max_events, uint32_t max_time); @@ -110,8 +110,8 @@ protected: //void SetMidiSynth(MIDIDevice *synth); - static EMidiDevice SelectMIDIDevice(EMidiDevice devtype); - MIDIDevice* CreateMIDIDevice(EMidiDevice devtype, int samplerate); + static EZMusicMidiDevice SelectMIDIDevice(EZMusicMidiDevice devtype); + MIDIDevice* CreateMIDIDevice(EZMusicMidiDevice devtype, int samplerate); static void Callback(void* userdata); @@ -132,7 +132,7 @@ protected: bool InitialPlayback; uint32_t NewVolume; uint32_t Volume; - EMidiDevice DeviceType; + EZMusicMidiDevice DeviceType; bool CallbackIsThreaded; int LoopLimit; std::string Args; @@ -150,7 +150,7 @@ protected: // //========================================================================== -MIDIStreamer::MIDIStreamer(EMidiDevice type, const char *args) +MIDIStreamer::MIDIStreamer(EZMusicMidiDevice type, const char *args) : DeviceType(type), Args(args) { @@ -201,7 +201,7 @@ bool MIDIStreamer::IsValid() const // //========================================================================== -EMidiDevice MIDIStreamer::SelectMIDIDevice(EMidiDevice device) +EZMusicMidiDevice MIDIStreamer::SelectMIDIDevice(EZMusicMidiDevice device) { /* MIDI are played as: - OPL: @@ -248,15 +248,15 @@ EMidiDevice MIDIStreamer::SelectMIDIDevice(EMidiDevice device) // //========================================================================== -static EMidiDevice lastRequestedDevice, lastSelectedDevice; +static EZMusicMidiDevice lastRequestedDevice, lastSelectedDevice; -MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate) +MIDIDevice *MIDIStreamer::CreateMIDIDevice(EZMusicMidiDevice devtype, int samplerate) { bool checked[MDEV_COUNT] = { false }; MIDIDevice *dev = nullptr; if (devtype == MDEV_SNDSYS) devtype = MDEV_FLUIDSYNTH; - EMidiDevice requestedDevice = devtype, selectedDevice; + EZMusicMidiDevice requestedDevice = devtype, selectedDevice; while (dev == nullptr) { selectedDevice = devtype; @@ -361,7 +361,7 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate) void MIDIStreamer::Play(bool looping, int subsong) { - EMidiDevice devtype; + EZMusicMidiDevice devtype; if (source == nullptr) return; // We have nothing to play so abort. @@ -446,7 +446,7 @@ bool MIDIStreamer::InitPlayback() } } -SoundStreamInfo MIDIStreamer::GetStreamInfo() const +ZMusicSoundStreamInfo MIDIStreamer::GetStreamInfo() const { if (MIDI) return MIDI->GetStreamInfo(); else return { 0, 0, 0 }; @@ -1010,14 +1010,14 @@ bool MIDIStreamer::ServiceStream(void* buff, int len) // //========================================================================== -MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args) +MusInfo* CreateMIDIStreamer(MIDISource *source, EZMusicMidiDevice devtype, const char* args) { auto me = new MIDIStreamer(devtype, args); me->SetMIDISource(source); return me; } -DLL_EXPORT zmusic_bool ZMusic_MIDIDumpWave(ZMusic_MidiSource source, EMidiDevice devtype, const char *devarg, const char *outname, int subsong, int samplerate) +DLL_EXPORT zmusic_bool ZMusic_MIDIDumpWave(ZMusic_MidiSource source, EZMusicMidiDevice devtype, const char *devarg, const char *outname, int subsong, int samplerate) { try { diff --git a/source/musicformats/music_stream.cpp b/source/musicformats/music_stream.cpp index 7bb5c12..4f15436 100644 --- a/source/musicformats/music_stream.cpp +++ b/source/musicformats/music_stream.cpp @@ -54,7 +54,7 @@ public: void ChangeSettingNum(const char *name, double value) override { if (m_Source) m_Source->ChangeSettingNum(name, value); } void ChangeSettingString(const char *name, const char *value) override { if(m_Source) m_Source->ChangeSettingString(name, value); } bool ServiceStream(void* buff, int len) override; - SoundStreamInfo GetStreamInfo() const override { return m_Source->GetFormat(); } + ZMusicSoundStreamInfo GetStreamInfo() const override { return m_Source->GetFormat(); } protected: diff --git a/source/streamsources/music_dumb.cpp b/source/streamsources/music_dumb.cpp index ffb4270..1b3b83e 100644 --- a/source/streamsources/music_dumb.cpp +++ b/source/streamsources/music_dumb.cpp @@ -64,7 +64,7 @@ public: //bool SetPosition(int ms); bool SetSubsong(int subsong) override; bool Start() override; - SoundStreamInfo GetFormat() override; + ZMusicSoundStreamInfo GetFormat() override; void ChangeSettingNum(const char* setting, double val) override; std::string GetStats() override; @@ -1034,7 +1034,7 @@ DumbSong::~DumbSong() // //========================================================================== -SoundStreamInfo DumbSong::GetFormat() +ZMusicSoundStreamInfo DumbSong::GetFormat() { return { 32*1024, srate, 2 }; } diff --git a/source/streamsources/music_gme.cpp b/source/streamsources/music_gme.cpp index 5a522e4..1026cbd 100644 --- a/source/streamsources/music_gme.cpp +++ b/source/streamsources/music_gme.cpp @@ -57,7 +57,7 @@ public: void ChangeSettingNum(const char *name, double val) override; std::string GetStats() override; bool GetData(void *buffer, size_t len) override; - SoundStreamInfo GetFormat() override; + ZMusicSoundStreamInfo GetFormat() override; protected: Music_Emu *Emu; @@ -167,7 +167,7 @@ GMESong::GMESong(Music_Emu *emu, int sample_rate) } -SoundStreamInfo GMESong::GetFormat() +ZMusicSoundStreamInfo GMESong::GetFormat() { return { 32*1024, SampleRate, -2 }; } diff --git a/source/streamsources/music_libsndfile.cpp b/source/streamsources/music_libsndfile.cpp index 9c9a6b2..76288b0 100644 --- a/source/streamsources/music_libsndfile.cpp +++ b/source/streamsources/music_libsndfile.cpp @@ -50,7 +50,7 @@ public: SndFileSong(SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass); ~SndFileSong(); std::string GetStats() override; - SoundStreamInfo GetFormat() override; + ZMusicSoundStreamInfo GetFormat() override; bool GetData(void *buffer, size_t len) override; protected: @@ -415,8 +415,8 @@ static int32_t Scale(int32_t a, int32_t b, int32_t c) SndFileSong::SndFileSong(SoundDecoder *decoder, uint32_t loop_start, uint32_t loop_end, bool startass, bool endass) { - ChannelConfig iChannels; - SampleType Type; + EZMusicChannelConfig iChannels; + EZMusicSampleType Type; decoder->getInfo(&SampleRate, &iChannels, &Type); @@ -430,7 +430,7 @@ SndFileSong::SndFileSong(SoundDecoder *decoder, uint32_t loop_start, uint32_t lo Channels = iChannels == ChannelConfig_Stereo? 2:1; } -SoundStreamInfo SndFileSong::GetFormat() +ZMusicSoundStreamInfo SndFileSong::GetFormat() { // deal with this once the configuration is handled better. return { 64/*snd_streambuffersize*/ * 1024, SampleRate, -Channels }; diff --git a/source/streamsources/music_opl.cpp b/source/streamsources/music_opl.cpp index a011c60..de53936 100644 --- a/source/streamsources/music_opl.cpp +++ b/source/streamsources/music_opl.cpp @@ -51,7 +51,7 @@ public: ~OPLMUSSong (); bool Start() override; void ChangeSettingInt(const char *name, int value) override; - SoundStreamInfo GetFormat() override; + ZMusicSoundStreamInfo GetFormat() override; protected: bool GetData(void *buffer, size_t len) override; @@ -90,7 +90,7 @@ OPLMUSSong::OPLMUSSong(MusicIO::FileInterface* reader, OPLConfig* config) // //========================================================================== -SoundStreamInfo OPLMUSSong::GetFormat() +ZMusicSoundStreamInfo OPLMUSSong::GetFormat() { int samples = int(OPL_SAMPLE_RATE / 14); return { samples * 4, int(OPL_SAMPLE_RATE), current_opl_core == 0? 1:2 }; diff --git a/source/streamsources/music_xa.cpp b/source/streamsources/music_xa.cpp index befa91e..419b2bf 100644 --- a/source/streamsources/music_xa.cpp +++ b/source/streamsources/music_xa.cpp @@ -235,7 +235,7 @@ class XASong : public StreamSource { public: XASong(MusicIO::FileInterface *readr); - SoundStreamInfo GetFormat() override; + ZMusicSoundStreamInfo GetFormat() override; bool Start() override; bool GetData(void *buffer, size_t len) override; @@ -260,7 +260,7 @@ XASong::XASong(MusicIO::FileInterface * reader) getNextXABlock(&xad, false); } -SoundStreamInfo XASong::GetFormat() +ZMusicSoundStreamInfo XASong::GetFormat() { auto SampleRate = xad.blockIs18K? 18900 : 37800; return { 64*1024, SampleRate, 2}; diff --git a/source/streamsources/streamsource.h b/source/streamsources/streamsource.h index 48b1810..2f06c52 100644 --- a/source/streamsources/streamsource.h +++ b/source/streamsources/streamsource.h @@ -21,7 +21,7 @@ public: virtual bool SetPosition(unsigned position) { return false; } virtual bool SetSubsong(int subsong) { return false; } virtual bool GetData(void *buffer, size_t len) = 0; - virtual SoundStreamInfo GetFormat() { return {65536, m_OutputRate, 2 }; } // Default format is: System's output sample rate, 32 bit float, stereo + virtual ZMusicSoundStreamInfo GetFormat() { return {65536, m_OutputRate, 2 }; } // Default format is: System's output sample rate, 32 bit float, stereo virtual std::string GetStats() { return ""; } virtual void ChangeSettingInt(const char *name, int value) { } virtual void ChangeSettingNum(const char *name, double value) { } diff --git a/source/zmusic/configuration.cpp b/source/zmusic/configuration.cpp index 652eaab..94a7a1e 100644 --- a/source/zmusic/configuration.cpp +++ b/source/zmusic/configuration.cpp @@ -320,7 +320,7 @@ static void TimidityPlus_SetReverb() // //========================================================================== -DLL_EXPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSong, int value, int *pRealValue) +DLL_EXPORT zmusic_bool ChangeMusicSettingInt(EZMusicIntConfigKey key, MusInfo *currSong, int value, int *pRealValue) { switch (key) { @@ -651,7 +651,7 @@ DLL_EXPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSon return false; } -DLL_EXPORT zmusic_bool ChangeMusicSettingFloat(EFloatConfigKey key, MusInfo* currSong, float value, float *pRealValue) +DLL_EXPORT zmusic_bool ChangeMusicSettingFloat(EZMusicFloatConfigKey key, MusInfo* currSong, float value, float *pRealValue) { switch (key) { @@ -805,7 +805,7 @@ DLL_EXPORT zmusic_bool ChangeMusicSettingFloat(EFloatConfigKey key, MusInfo* cur return false; } -DLL_EXPORT zmusic_bool ChangeMusicSettingString(EStringConfigKey key, MusInfo* currSong, const char *value) +DLL_EXPORT zmusic_bool ChangeMusicSettingString(EZMusicStringConfigKey key, MusInfo* currSong, const char *value) { switch (key) { diff --git a/source/zmusic/musinfo.h b/source/zmusic/musinfo.h index 99d8f38..5556912 100644 --- a/source/zmusic/musinfo.h +++ b/source/zmusic/musinfo.h @@ -31,7 +31,7 @@ public: virtual void ChangeSettingNum(const char* setting, double value) {} // " virtual void ChangeSettingString(const char* setting, const char* value) {} // " virtual bool ServiceStream(void *buff, int len) { return false; } - virtual SoundStreamInfo GetStreamInfo() const { return { 0,0,0 }; } + virtual ZMusicSoundStreamInfo GetStreamInfo() const { return { 0,0,0 }; } enum EState { diff --git a/source/zmusic/sounddecoder.h b/source/zmusic/sounddecoder.h index e0e7d57..3b1d3af 100644 --- a/source/zmusic/sounddecoder.h +++ b/source/zmusic/sounddecoder.h @@ -7,7 +7,7 @@ struct SoundDecoder { static SoundDecoder* CreateDecoder(MusicIO::FileInterface* reader); - virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0; + virtual void getInfo(int *samplerate, EZMusicChannelConfig *chans, EZMusicSampleType *type) = 0; virtual size_t read(char *buffer, size_t bytes) = 0; virtual std::vector readAll(); diff --git a/source/zmusic/zmusic.cpp b/source/zmusic/zmusic.cpp index 1b8916e..10f3fd1 100644 --- a/source/zmusic/zmusic.cpp +++ b/source/zmusic/zmusic.cpp @@ -65,7 +65,7 @@ MusInfo *OpenStreamSong(StreamSource *source); const char *GME_CheckFormat(uint32_t header); MusInfo* CDDA_OpenSong(MusicIO::FileInterface* reader); MusInfo* CD_OpenSong(int track, int id); -MusInfo* CreateMIDIStreamer(MIDISource *source, EMidiDevice devtype, const char* args); +MusInfo* CreateMIDIStreamer(MIDISource *source, EZMusicMidiDevice devtype, const char* args); //========================================================================== // @@ -150,7 +150,7 @@ static bool ungzip(uint8_t *data, int complen, std::vector &newdata) // //========================================================================== -static MusInfo *ZMusic_OpenSongInternal (MusicIO::FileInterface *reader, EMidiDevice device, const char *Args) +static MusInfo *ZMusic_OpenSongInternal (MusicIO::FileInterface *reader, EZMusicMidiDevice device, const char *Args) { MusInfo *info = nullptr; StreamSource *streamsource = nullptr; @@ -193,7 +193,7 @@ static MusInfo *ZMusic_OpenSongInternal (MusicIO::FileInterface *reader, EMidiD } } - EMIDIType miditype = ZMusic_IdentifyMIDIType(id, sizeof(id)); + EZMusicMIDIType miditype = ZMusic_IdentifyMIDIType(id, sizeof(id)); if (miditype != MIDI_NOTMIDI) { std::vector data(reader->filelength()); @@ -299,7 +299,7 @@ static MusInfo *ZMusic_OpenSongInternal (MusicIO::FileInterface *reader, EMidiD } } -DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSongFile(const char* filename, EMidiDevice device, const char* Args) +DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSongFile(const char* filename, EZMusicMidiDevice device, const char* Args) { auto f = MusicIO::utf8_fopen(filename, "rb"); if (!f) @@ -312,7 +312,7 @@ DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSongFile(const char* filename, EMidiDev return ZMusic_OpenSongInternal(fr, device, Args); } -DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSongMem(const void* mem, size_t size, EMidiDevice device, const char* Args) +DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSongMem(const void* mem, size_t size, EZMusicMidiDevice device, const char* Args) { if (!mem || !size) { @@ -324,7 +324,7 @@ DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSongMem(const void* mem, size_t size, E return ZMusic_OpenSongInternal(mr, device, Args); } -DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSong(ZMusicCustomReader* reader, EMidiDevice device, const char* Args) +DLL_EXPORT ZMusic_MusicStream ZMusic_OpenSong(ZMusicCustomReader* reader, EZMusicMidiDevice device, const char* Args) { if (!reader) { @@ -446,7 +446,7 @@ DLL_EXPORT zmusic_bool ZMusic_IsMIDI(MusInfo *song) return song->IsMIDI(); } -DLL_EXPORT void ZMusic_GetStreamInfo(MusInfo *song, SoundStreamInfo *fmt) +DLL_EXPORT void ZMusic_GetStreamInfo(MusInfo *song, ZMusicSoundStreamInfo *fmt) { if (!fmt) return; if (!song) *fmt = {}; diff --git a/source/zmusic/zmusic_internal.h b/source/zmusic/zmusic_internal.h index 629b49f..c27832a 100644 --- a/source/zmusic/zmusic_internal.h +++ b/source/zmusic/zmusic_internal.h @@ -3,10 +3,10 @@ #ifdef _MSC_VER #define DLL_EXPORT __declspec(dllexport) -#define DLL_IMPORT __declspec(dllexport) // without this the compiler complains. +#define ZMUSIC_DLL_IMPORT __declspec(dllexport) // without this the compiler complains. #else // !_MSC_VER #define DLL_EXPORT -#define DLL_IMPORT +#define ZMUSIC_DLL_IMPORT #endif // _MSC_VER typedef class MIDISource *ZMusic_MidiSource;