2019-11-10 22:58:51 +00:00
|
|
|
|
|
|
|
#ifndef __S_MUSIC__
|
|
|
|
#define __S_MUSIC__
|
|
|
|
|
|
|
|
#include "zstring.h"
|
|
|
|
#include "tarray.h"
|
2019-11-11 00:01:18 +00:00
|
|
|
#include "name.h"
|
2020-02-09 12:26:51 +00:00
|
|
|
#include <zmusic.h>
|
2019-11-10 22:58:51 +00:00
|
|
|
|
2020-04-12 06:07:48 +00:00
|
|
|
class FileReader;
|
2020-07-23 20:26:07 +00:00
|
|
|
class SoundStream;
|
|
|
|
|
|
|
|
|
|
|
|
typedef bool(*StreamCallback)(SoundStream* stream, void* buff, int len, void* userdata);
|
|
|
|
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata);
|
|
|
|
void S_StopCustomStream(SoundStream* stream);
|
2020-04-12 06:07:48 +00:00
|
|
|
|
|
|
|
struct MusicCallbacks
|
|
|
|
{
|
|
|
|
FString(*LookupFileName)(const char* fn, int &order);
|
|
|
|
FileReader(*OpenMusic)(const char* fn);
|
|
|
|
};
|
|
|
|
void S_SetMusicCallbacks(MusicCallbacks* cb);
|
|
|
|
|
2019-11-11 18:10:46 +00:00
|
|
|
void S_CreateStream();
|
|
|
|
void S_PauseStream(bool pause);
|
|
|
|
void S_StopStream();
|
|
|
|
void S_SetStreamVolume(float vol);
|
|
|
|
|
2019-11-10 22:58:51 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
void S_InitMusic ();
|
2020-04-12 06:07:48 +00:00
|
|
|
void S_ResetMusic ();
|
2019-11-10 22:58:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Start music using <music_name>
|
|
|
|
bool S_StartMusic (const char *music_name);
|
|
|
|
|
|
|
|
// Start music using <music_name>, and set whether looping
|
|
|
|
bool S_ChangeMusic (const char *music_name, int order=0, bool looping=true, bool force=false);
|
|
|
|
|
|
|
|
void S_RestartMusic ();
|
|
|
|
void S_MIDIDeviceChanged(int newdev);
|
|
|
|
|
|
|
|
int S_GetMusic (const char **name);
|
|
|
|
|
|
|
|
// Stops the music for sure.
|
|
|
|
void S_StopMusic (bool force);
|
|
|
|
|
|
|
|
// Stop and resume music, during game PAUSE.
|
|
|
|
void S_PauseMusic ();
|
|
|
|
void S_ResumeMusic ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Updates music & sounds
|
|
|
|
//
|
|
|
|
void S_UpdateMusic ();
|
|
|
|
|
|
|
|
struct MidiDeviceSetting
|
|
|
|
{
|
|
|
|
int device;
|
|
|
|
FString args;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef TMap<FName, MidiDeviceSetting> MidiDeviceMap;
|
2019-11-11 00:01:18 +00:00
|
|
|
typedef TMap<FName, float> MusicVolumeMap;
|
2019-11-10 22:58:51 +00:00
|
|
|
|
|
|
|
extern MidiDeviceMap MidiDevices;
|
2019-11-11 00:01:18 +00:00
|
|
|
extern MusicVolumeMap MusicVolumes;
|
2019-11-10 22:58:51 +00:00
|
|
|
|
|
|
|
struct MusPlayingInfo
|
|
|
|
{
|
|
|
|
FString name;
|
2020-02-09 12:26:51 +00:00
|
|
|
ZMusic_MusicStream handle;
|
2019-11-10 22:58:51 +00:00
|
|
|
int baseorder;
|
|
|
|
bool loop;
|
|
|
|
FString LastSong; // last music that was played
|
|
|
|
};
|
|
|
|
|
|
|
|
extern MusPlayingInfo mus_playing;
|
|
|
|
|
|
|
|
extern float relative_volume, saved_relative_volume;
|
|
|
|
|
2019-11-28 02:18:58 +00:00
|
|
|
|
2019-11-10 22:58:51 +00:00
|
|
|
#endif
|