mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
CON: Add new commands "getmusicposition" and "setmusicposition" that operate on the playback position of the current music track.
// Example: Switch between tracks like radio stations. getmusicposition temp starttrackvar next_music_track setmusicposition temp Only implemented for Ogg Vorbis, FLAC, and XA. Consult the devs before using these commands. git-svn-id: https://svn.eduke32.com/eduke32@4928 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
86e7a97ef7
commit
011fd40dda
18 changed files with 212 additions and 0 deletions
|
@ -95,6 +95,7 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] =
|
|||
{ CON_SCREENTEXT, 20130529 },
|
||||
{ CON_DYNAMICSOUNDREMAP, 20130530 },
|
||||
{ CON_SCREENSOUND, 20130628 },
|
||||
{ CON_SETMUSICPOSITION, 20150115 },
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -549,6 +550,8 @@ const char *keyw[] =
|
|||
"screentext", // 370
|
||||
"dynamicsoundremap", // 371
|
||||
"screensound", // 372
|
||||
"getmusicposition", // 373
|
||||
"setmusicposition", // 374
|
||||
"<null>"
|
||||
};
|
||||
#endif
|
||||
|
@ -4095,6 +4098,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
case CON_SECTCLEARINTERPOLATION:
|
||||
case CON_SETACTORANGLE:
|
||||
case CON_SETPLAYERANGLE:
|
||||
case CON_SETMUSICPOSITION:
|
||||
C_GetNextVar();
|
||||
continue;
|
||||
|
||||
|
@ -4109,6 +4113,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
case CON_GETPLAYERANGLE:
|
||||
case CON_GETTICKS:
|
||||
case CON_GETCURRADDRESS:
|
||||
case CON_GETMUSICPOSITION:
|
||||
C_GetNextVarType(GAMEVAR_READONLY);
|
||||
continue;
|
||||
|
||||
|
|
|
@ -966,6 +966,8 @@ enum ScriptKeywords_t
|
|||
CON_SCREENTEXT, // 370
|
||||
CON_DYNAMICSOUNDREMAP, // 371
|
||||
CON_SCREENSOUND, // 372
|
||||
CON_GETMUSICPOSITION, // 373
|
||||
CON_SETMUSICPOSITION, // 374
|
||||
CON_END
|
||||
};
|
||||
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua
|
||||
|
|
|
@ -4841,6 +4841,16 @@ finish_qsprintf:
|
|||
}
|
||||
continue;
|
||||
|
||||
case CON_SETMUSICPOSITION:
|
||||
insptr++;
|
||||
S_SetMusicPosition(Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
|
||||
case CON_GETMUSICPOSITION:
|
||||
insptr++;
|
||||
Gv_SetVarX(*insptr++, S_GetMusicPosition());
|
||||
continue;
|
||||
|
||||
case CON_ACTIVATECHEAT:
|
||||
insptr++;
|
||||
{
|
||||
|
|
|
@ -122,6 +122,8 @@ int32_t FX_StartDemandFeedPlayback( void ( *function )( char **ptr, uint32_t *le
|
|||
int32_t FX_SetVoiceCallback(int32_t handle, uint32_t callbackval);
|
||||
int32_t FX_SetPrintf(void (*function)(const char *, ...));
|
||||
|
||||
int32_t FX_GetPosition(int32_t handle, int32_t *position);
|
||||
int32_t FX_SetPosition(int32_t handle, int32_t position);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -227,6 +227,13 @@ 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 );
|
||||
|
||||
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);
|
||||
|
||||
void MV_ReleaseVorbisVoice( VoiceNode * voice );
|
||||
void MV_ReleaseFLACVoice( VoiceNode * voice );
|
||||
void MV_ReleaseXAVoice( VoiceNode * voice );
|
||||
|
|
|
@ -275,6 +275,23 @@ void error_flac_stream(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderEr
|
|||
// FLAC__stream_decoder_flush(fd->stream);
|
||||
}
|
||||
|
||||
int32_t MV_GetFLACPosition(VoiceNode *voice)
|
||||
{
|
||||
FLAC__uint64 position = 0;
|
||||
flac_data * fd = (flac_data *) voice->extra;
|
||||
|
||||
FLAC__stream_decoder_get_decode_position(fd->stream, &position);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void MV_SetFLACPosition(VoiceNode *voice, int32_t position)
|
||||
{
|
||||
flac_data * fd = (flac_data *) voice->extra;
|
||||
|
||||
FLAC__stream_decoder_seek_absolute(fd->stream, position);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_GetNextFLACBlock
|
||||
|
||||
|
|
|
@ -400,6 +400,33 @@ int32_t FX_PauseVoice
|
|||
return status;
|
||||
}
|
||||
|
||||
int32_t FX_GetPosition(int32_t handle, int32_t *position)
|
||||
{
|
||||
int32_t status;
|
||||
|
||||
status = MV_GetPosition(handle, position);
|
||||
if (status == MV_Error)
|
||||
{
|
||||
FX_SetErrorCode(FX_MultiVocError);
|
||||
status = FX_Warning;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t FX_SetPosition(int32_t handle, int32_t position)
|
||||
{
|
||||
int32_t status;
|
||||
|
||||
status = MV_SetPosition(handle, position);
|
||||
if (status == MV_Error)
|
||||
{
|
||||
FX_SetErrorCode(FX_MultiVocError);
|
||||
status = FX_Warning;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: FX_EndLooping
|
||||
|
|
|
@ -987,6 +987,7 @@ void MV_SetVoiceMixMode(VoiceNode *voice)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_SetVoiceVolume
|
||||
|
||||
|
@ -1063,6 +1064,77 @@ int32_t MV_PauseVoice
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_GetPosition(int32_t handle, int32_t *position)
|
||||
{
|
||||
VoiceNode *voice;
|
||||
|
||||
if (!MV_Installed)
|
||||
{
|
||||
MV_SetErrorCode(MV_NotInstalled);
|
||||
return MV_Error;
|
||||
}
|
||||
|
||||
DisableInterrupts();
|
||||
|
||||
voice = MV_GetVoice(handle);
|
||||
if (voice == NULL)
|
||||
{
|
||||
RestoreInterrupts();
|
||||
MV_SetErrorCode(MV_VoiceNotFound);
|
||||
return MV_Warning;
|
||||
}
|
||||
|
||||
#ifdef HAVE_VORBIS
|
||||
if (voice->wavetype == Vorbis)
|
||||
*position = MV_GetVorbisPosition(voice);
|
||||
#endif
|
||||
#ifdef HAVE_FLAC
|
||||
if (voice->wavetype == FLAC)
|
||||
*position = MV_GetFLACPosition(voice);
|
||||
#endif
|
||||
if (voice->wavetype == XA)
|
||||
*position = MV_GetXAPosition(voice);
|
||||
|
||||
RestoreInterrupts();
|
||||
|
||||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_SetPosition(int32_t handle, int32_t position)
|
||||
{
|
||||
VoiceNode *voice;
|
||||
|
||||
if (!MV_Installed)
|
||||
{
|
||||
MV_SetErrorCode(MV_NotInstalled);
|
||||
return MV_Error;
|
||||
}
|
||||
|
||||
DisableInterrupts();
|
||||
|
||||
voice = MV_GetVoice(handle);
|
||||
if (voice == NULL)
|
||||
{
|
||||
RestoreInterrupts();
|
||||
MV_SetErrorCode(MV_VoiceNotFound);
|
||||
return MV_Warning;
|
||||
}
|
||||
|
||||
#ifdef HAVE_VORBIS
|
||||
if (voice->wavetype == Vorbis)
|
||||
MV_SetVorbisPosition(voice, position);
|
||||
#endif
|
||||
#ifdef HAVE_FLAC
|
||||
if (voice->wavetype == FLAC)
|
||||
MV_SetFLACPosition(voice, position);
|
||||
#endif
|
||||
if (voice->wavetype == XA)
|
||||
MV_SetXAPosition(voice, position);
|
||||
|
||||
RestoreInterrupts();
|
||||
|
||||
return MV_Ok;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_EndLooping
|
||||
|
|
|
@ -155,6 +155,10 @@ int32_t MV_PlayXA3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchof
|
|||
int32_t priority, uint32_t callbackval);
|
||||
int32_t MV_PlayXA(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol,
|
||||
int32_t left, int32_t right, int32_t priority, uint32_t callbackval);
|
||||
|
||||
int32_t MV_GetPosition(int32_t handle, int32_t *position);
|
||||
int32_t MV_SetPosition(int32_t handle, int32_t position);
|
||||
|
||||
// void MV_CreateVolumeTable( int32_t index, int32_t volume, int32_t MaxVolume );
|
||||
void MV_SetVolume(int32_t volume);
|
||||
int32_t MV_GetVolume(void);
|
||||
|
|
|
@ -201,6 +201,20 @@ static ov_callbacks vorbis_callbacks = {
|
|||
};
|
||||
|
||||
|
||||
int32_t MV_GetVorbisPosition(VoiceNode *voice)
|
||||
{
|
||||
vorbis_data * vd = (vorbis_data *) voice->extra;
|
||||
|
||||
return ov_pcm_tell(&vd->vf);
|
||||
}
|
||||
|
||||
void MV_SetVorbisPosition(VoiceNode *voice, int32_t position)
|
||||
{
|
||||
vorbis_data * vd = (vorbis_data *) voice->extra;
|
||||
|
||||
ov_pcm_seek(&vd->vf, position);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_GetNextVorbisBlock
|
||||
|
||||
|
|
|
@ -286,6 +286,21 @@ static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
|||
xad->blocksize = count;
|
||||
}
|
||||
|
||||
int32_t MV_GetXAPosition(VoiceNode *voice)
|
||||
{
|
||||
xa_data * xad = (xa_data *) voice->extra;
|
||||
return xad->pos;
|
||||
}
|
||||
|
||||
void MV_SetXAPosition(VoiceNode *voice, int32_t position)
|
||||
{
|
||||
xa_data * xad = (xa_data *) voice->extra;
|
||||
|
||||
if (position < XA_DATA_START || position >= xad->length)
|
||||
position = XA_DATA_START;
|
||||
|
||||
xad->pos = position;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
Function: MV_GetNextXABlock
|
||||
|
|
|
@ -979,6 +979,7 @@ lpeg.P(false) +
|
|||
"setplayervar" +
|
||||
"setplayerangle" +
|
||||
"setplayer" +
|
||||
"setmusicposition" +
|
||||
"setinput" +
|
||||
"setgamepalette" +
|
||||
"setgamename" +
|
||||
|
@ -1162,6 +1163,7 @@ lpeg.P(false) +
|
|||
"getplayervar" +
|
||||
"getplayerangle" +
|
||||
"getplayer" +
|
||||
"getmusicposition" +
|
||||
"getlastpal" +
|
||||
"getkeyname" +
|
||||
"getinput" +
|
||||
|
|
|
@ -1889,6 +1889,14 @@ function _starttrack(level)
|
|||
end
|
||||
end
|
||||
|
||||
function _getmusicposition()
|
||||
return ffic.S_GetMusicPosition()
|
||||
end
|
||||
|
||||
function _setmusicposition(position)
|
||||
ffic.S_SetMusicPosition(position)
|
||||
end
|
||||
|
||||
function _startlevel(volume, level)
|
||||
bcheck.volume_idx(volume)
|
||||
bcheck.level_idx(level)
|
||||
|
|
|
@ -697,6 +697,8 @@ int32_t S_CheckSoundPlaying(int32_t i, int32_t num);
|
|||
void S_StopEnvSound(int32_t num, int32_t i);
|
||||
int32_t FX_StopAllSounds(void);
|
||||
void S_ChangeSoundPitch(int32_t num, int32_t i, int32_t pitchoffset);
|
||||
int32_t S_GetMusicPosition(void);
|
||||
void S_SetMusicPosition(int32_t position);
|
||||
|
||||
int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb);
|
||||
void G_DrawTXDigiNumZ(int32_t starttile, int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,
|
||||
|
|
|
@ -230,6 +230,8 @@ S_CheckSoundPlaying;
|
|||
S_StopEnvSound;
|
||||
FX_StopAllSounds;
|
||||
S_ChangeSoundPitch;
|
||||
S_GetMusicPosition;
|
||||
S_SetMusicPosition;
|
||||
|
||||
minitext_;
|
||||
G_DrawTXDigiNumZ;
|
||||
|
|
|
@ -2907,6 +2907,11 @@ local Cinner = {
|
|||
starttrackvar = cmd(R)
|
||||
/ "_con._starttrack(%1)",
|
||||
|
||||
getmusicposition = cmd(W)
|
||||
/ "%1=_con._getmusicposition()",
|
||||
setmusicposition = cmd(R)
|
||||
/ "_con._setmusicposition(%1)",
|
||||
|
||||
setaspect = cmd(R,R)
|
||||
/ "_con._setaspect(%1,%2)",
|
||||
showview = cmd(R,R,R,R,R,R,R,R,R,R) -- 10R
|
||||
|
|
|
@ -311,6 +311,22 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
|
|||
return (alt != 0);
|
||||
}
|
||||
|
||||
int32_t S_GetMusicPosition(void)
|
||||
{
|
||||
int32_t position = 0;
|
||||
|
||||
if (MusicIsWaveform)
|
||||
FX_GetPosition(MusicVoice, &position);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void S_SetMusicPosition(int32_t position)
|
||||
{
|
||||
if (MusicIsWaveform)
|
||||
FX_SetPosition(MusicVoice, position);
|
||||
}
|
||||
|
||||
void S_StopMusic(void)
|
||||
{
|
||||
MusicPaused = 0;
|
||||
|
|
|
@ -104,6 +104,8 @@ void S_StopEnvSound(int32_t num,int32_t i);
|
|||
void S_StopMusic(void);
|
||||
void S_Update(void);
|
||||
void S_ChangeSoundPitch(int32_t num, int32_t i, int32_t pitchoffset);
|
||||
int32_t S_GetMusicPosition(void);
|
||||
void S_SetMusicPosition(int32_t position);
|
||||
|
||||
static inline int32_t S_IsAmbientSFX(int32_t i)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue