Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Sound-related lua binders #583

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libzhl/IsaacRepentance_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,9 @@ bool Music::ValidateMusicID(int id, int& max) {

return id >= 0 && id < max;
}

bool SoundEffects::ValidateSoundID(int id, int& max) {
max = _sounds.size();

return id >= 0 && id < max;
}
7 changes: 7 additions & 0 deletions libzhl/LuaCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ namespace lua {
const char* MinimapMT = "Minimap";
const char* ModsMenuMT = "ModsMenu";
const char* MultiShotParamsMT = "MultiShotParams";
const char* MusicEntryMT = "MusicEntry";
const char* MusicLayerMT = "MusicLayer";
const char* NightmareSceneMT = "NightmareScene";
const char* NullFrameMT = "NullFrame";
const char* OptionsMenuMT = "OptionsMenu";
Expand All @@ -804,7 +806,12 @@ namespace lua {
const char* RoomTransitionMT = "RoomTransition";
const char* SaveMenuMT = "SaveMenu";
const char* ScoreSheetMT = "ScoreSheet";
const char* SFXEntryMT = "SFXEntry";
const char* SFXEntrySampleMT = "SFXEntrySample";
const char* ShapeMT = "Shape";
const char* SoundActorMT = "SoundActor";
const char* SoundStreamMT = "SoundStream";
const char* SoundStreamSetMT = "SoundStreamSet";
const char* SpecialSeedsMenuMT = "SpecialSeedsMenu";
const char* StageTransitionMT = "StageTransition";
const char* StatsMenuMT = "StatsMenu";
Expand Down
7 changes: 7 additions & 0 deletions libzhl/LuaCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ namespace lua {
extern LIBZHL_API const char* MinimapMT;
extern LIBZHL_API const char* ModsMenuMT;
extern LIBZHL_API const char* MultiShotParamsMT;
extern LIBZHL_API const char* MusicEntryMT;
extern LIBZHL_API const char* MusicLayerMT;
extern LIBZHL_API const char* NightmareSceneMT;
extern LIBZHL_API const char* NullFrameMT;
extern LIBZHL_API const char* OptionsMenuMT;
Expand All @@ -239,7 +241,12 @@ namespace lua {
extern LIBZHL_API const char* RoomTransitionMT;
extern LIBZHL_API const char* SaveMenuMT;
extern LIBZHL_API const char* ScoreSheetMT;
extern LIBZHL_API const char* SFXEntryMT;
extern LIBZHL_API const char* SFXEntrySampleMT;
extern LIBZHL_API const char* ShapeMT;
extern LIBZHL_API const char* SoundActorMT;
extern LIBZHL_API const char* SoundStreamMT;
extern LIBZHL_API const char* SoundStreamSetMT;
extern LIBZHL_API const char* SpecialSeedsMenuMT;
extern LIBZHL_API const char* StageTransitionMT;
extern LIBZHL_API const char* StatsMenuMT;
Expand Down
17 changes: 6 additions & 11 deletions libzhl/functions/Music.zhl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __thiscall void Music::Play(int musicid,float volume);
__thiscall void Music::Crossfade(int musicid,float faderate);

"558bec51568bf1578b860c030000":
__thiscall void Music::PlayJingle(int musicid, int unusedInt, bool unusedBool);
__thiscall void Music::PlayJingle(int musicid, int unusedLength, bool unusedBool);

"558bec5651":
__thiscall void Music::Fadein(unsigned int Id, float Volume, float FadeRate);
Expand Down Expand Up @@ -40,24 +40,19 @@ __thiscall void Music::UpdateVolume();
"558beca1????????f30f1045":
__thiscall void Music::VolumeSlide(float TargetVolume, float FadeRate);

struct Music depends (MusicEntry) {
struct Music depends (MusicEntry, SoundStream, SoundStreamSet) {
{{
inline void StopJingle() {
*(int*)((char*)this + 0x348) = 0;
*(int*)((char*)this + 0x364) = -99;
};

bool LIBZHL_API ValidateMusicID(int id, int& max);
}}
unsigned int _currentStream : 0x0;
// i'll add StreamSet later
SoundStreamSet _streamSets[2] : 0x4;
unsigned int _currentId : 0x30c;
unsigned int _queuedId : 0x310;
float _pitch : 0x314;
float _targetPitch : 0x318;
vector_MusicEntry _entries : 0x31c;
bool _enabled : 0x328;
// and Stream
float _jingleVolumeMaybe : 0x360;
int _jingleCountdownMaybe : 0x364;
SoundStream _jingleStream : 0x32c;
float _jingleVolume : 0x360;
int _jingleCountdown : 0x364;
} : 0x368;
13 changes: 11 additions & 2 deletions libzhl/functions/MusicEntry.zhl
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
struct MusicEntry
struct MusicEntry depends (MusicLayer)
{
std_string _string1 : 0x4;
int _id : 0x0;
std_string _name : 0x4;
std_string _introFilename : 0x1c;
std_string _filename : 0x34;
bool _loop : 0x4c;
unsigned char _layerMode : 0x4d;
float _multiplier : 0x50;
float _layerFadeRate : 0x54;
MusicLayer* _layers : 0x58;
unsigned int _numLayers : 0x5c;
} : 0x60;
6 changes: 6 additions & 0 deletions libzhl/functions/MusicLayer.zhl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct MusicLayer
{
std_string _intro : 0x0;
std_string _path : 0x18;
float _mul : 0x30;
} : 0x34;
59 changes: 59 additions & 0 deletions libzhl/functions/SampleSourceBase.zhl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
struct SampleSourceBase : public SoundSourcePlatformBase {
__vtable {
override
"558bec6aff68????????64a1????????505657a1????????33c5508d45??64a3????????8bf1c706????????8d7e":
void * Free(bool param_1);

skip; // ApplyDataToHardware

override
"8b41??8b40??c3??????????????????8b41":
int GetHardwareBufferSize();

skip; // open_file_dunno
skip; // Queue
skip; // Deque
skip; // HasQueuedData

override
"8b41??8b11c641??01":
bool Open(char * path);

override
"558bec6aff68????????64a1????????5083ec08535657a1????????33c5508d45??64a3????????8bd98b75??85f60f84":
bool Clone(SoundSourceBase * param_1);

override
"558bec518bc18378??00":
void Close();

skip; // IsOpen

override
"558bec568bf18b06ff50??ff75":
void Play(bool unk);

skip; // Pause
skip; // Resume
skip; // IsPlaying
skip; // Stop
skip; // SetLooping
skip; // IsLooping
skip; // SetVolume
skip; // GetVolume
skip; // SetPan
skip; // GetPan
skip; // SetPitch
skip; // GetPitch
skip; // GetNumChannels
skip; // GetSourceFormat
skip; // GetSampleRate
skip; // SystemSuspend
skip; // SystemResume
skip; // ProcessData
skip; // ActivateNextQueuedData
skip; // Update
skip; // IsPlaybackFinished
skip; // IsProcessingFinished
};
} : 0x48;
58 changes: 58 additions & 0 deletions libzhl/functions/SampleSourceOgg.zhl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
struct SampleSourceOgg : public SampleSourceBase {
__vtable {
override
"558bec6aff68????????64a1????????505657a1????????33c5508d45??64a3????????8bf1c745??00000000837e??00c706????????74??e8????????84c074??ff76??ff15????????83c404ff15????????85c074??5068????????6a02e8????????83c40c8bcee8":
void * Free(bool param_1);

skip; // ApplyDataToHardware
skip; // GetHardwareBufferSize
skip; // open_file_dunno
skip; // Queue
skip; // Deque
skip; // HasQueuedData

override
"558bec83e4f883ec24535657ff75":
bool Open(char * path);

override
"558bec8b55??85d274??8b41??8942??8b41":
bool Clone(SoundSourceBase * param_1);

skip; // Close
skip; // IsOpen
skip; // Play
skip; // Pause
skip; // Resume
skip; // IsPlaying
skip; // Stop
skip; // SetLooping
skip; // IsLooping
skip; // SetVolume
skip; // GetVolume
skip; // SetPan
skip; // GetPan
skip; // SetPitch
skip; // GetPitch

override
"8b41??c3????????????????????????558bec6aff68????????64a1????????505156":
uint16_t GetNumChannels();

override
"8b41??c3????????????????????????8b41??c3????????????????????????558bec6aff68????????64a1????????505153":
int GetSourceFormat();

override
"8b41??c3????????????????????????558bec6aff68????????64a1????????505153":
unsigned int GetSampleRate();

skip; // SystemSuspend
skip; // SystemResume
skip; // ProcessData
skip; // ActivateNextQueuedData
skip; // Update
skip; // IsPlaybackFinished
skip; // IsProcessingFinished
};
} : 0x48;
61 changes: 61 additions & 0 deletions libzhl/functions/SampleSourceOrg.zhl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
struct SampleSourceOrg : public SampleSourceBase {
__vtable {
override
"558bec568bf1e8????????f645??0174??68b01b0000":
void * Free(bool param_1);

skip; // ApplyDataToHardware
skip; // GetHardwareBufferSize
skip; // open_file_dunno
skip; // Queue
skip; // Deque
skip; // HasQueuedData

override
"558bec6aff68????????64a1????????5083ec4c535657a1????????33c5508d45??64a3????????8bd9":
bool Open(char * param_1);

override
"558bec5668":
bool Clone(SoundSourceBase * param_1);

override
"558bec51538bd95657bf10000000":
void Close();

skip; // IsOpen
skip; // Play
skip; // Pause
skip; // Resume
skip; // IsPlaying
skip; // Stop
skip; // SetLooping
skip; // IsLooping
skip; // SetVolume
skip; // GetVolume
skip; // SetPan
skip; // GetPan
skip; // SetPitch
skip; // GetPitch

override
"b802000000c3????????????????????b822560000":
uint16_t GetNumChannels();

override
"b801000000c3????????????????????8b81":
int GetSourceFormat();

override
"b822560000":
unsigned int GetSampleRate();

skip; // SystemSuspend
skip; // SystemResume
skip; // ProcessData
skip; // ActivateNextQueuedData
skip; // Update
skip; // IsPlaybackFinished
skip; // IsProcessingFinished
};
} : 0x60;
61 changes: 61 additions & 0 deletions libzhl/functions/SampleSourceWav.zhl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
struct SampleSourceWav : public SampleSourceBase {
__vtable {
override
"558bec6aff68????????64a1????????505657a1????????33c5508d45??64a3????????8bf1c745??00000000837e??00c706????????74??e8????????84c074??ff76??ff15????????83c404ff15????????85c074??5068????????6a02e8????????83c40c8bcec746??00000000":
void * Free(bool param_1);

skip; // ApplyDataToHardware
skip; // GetHardwareBufferSize
skip; // open_file_dunno
skip; // Queue
skip; // Deque
skip; // HasQueuedData

override
"558bec83e4f883ec1ca1????????33c4894424??53":
bool Open(char * param_1);

override
"558bec568b75??85f674??8b41":
bool Clone(SoundSourceBase * param_1);

override
"c741??00000000c741??00000000e9??????????????????????????????????0fb741":
void Close();

skip; // IsOpen
skip; // Play
skip; // Pause
skip; // Resume
skip; // IsPlaying
skip; // Stop
skip; // SetLooping
skip; // IsLooping
skip; // SetVolume
skip; // GetVolume
skip; // SetPan
skip; // GetPan
skip; // SetPitch
skip; // GetPitch

override
"0fb741??c3??????????????????????33c0":
uint16_t GetNumChannels();

override
"33c0668379??10":
int GetSourceFormat();

override
"8b41??c3????????????????????????558bec83e4f8":
unsigned int GetSampleRate();

skip; // SystemSuspend
skip; // SystemResume
skip; // ProcessData
skip; // ActivateNextQueuedData
skip; // Update
skip; // IsPlaybackFinished
skip; // IsProcessingFinished
};
} : 0x60;
11 changes: 11 additions & 0 deletions libzhl/functions/SoundActor.zhl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
struct SoundActor depends (SoundSourceBase)
{
SoundSourceBase * _source : 0x0;
void * _sp2 : 0x4;
bool _loop : 0x8;
bool _playing : 0x9;
bool _paused : 0xa;
float _volume : 0xc;
float _pan : 0x10;
float _pitch : 0x14;
} : 0x18;
Loading
Loading