summaryrefslogtreecommitdiff
path: root/src/miniaudio
diff options
context:
space:
mode:
Diffstat (limited to 'src/miniaudio')
-rw-r--r--src/miniaudio/CMakeLists.txt9
-rw-r--r--src/miniaudio/audio.h176
-rw-r--r--src/miniaudio/bind55
-rw-r--r--src/miniaudio/bind.bind513
-rw-r--r--src/miniaudio/engine.c303
-rw-r--r--src/miniaudio/impl.c8
-rw-r--r--src/miniaudio/setup.c31
-rw-r--r--src/miniaudio/sound.c640
-rw-r--r--src/miniaudio/sound_group.c522
9 files changed, 2257 insertions, 0 deletions
diff --git a/src/miniaudio/CMakeLists.txt b/src/miniaudio/CMakeLists.txt
new file mode 100644
index 0000000..c4b333c
--- /dev/null
+++ b/src/miniaudio/CMakeLists.txt
@@ -0,0 +1,9 @@
+project(honey_engine)
+
+target_sources(honey PUBLIC
+ ${CMAKE_CURRENT_LIST_DIR}/impl.c
+ ${CMAKE_CURRENT_LIST_DIR}/setup.c
+ ${CMAKE_CURRENT_LIST_DIR}/engine.c
+ ${CMAKE_CURRENT_LIST_DIR}/sound.c
+ ${CMAKE_CURRENT_LIST_DIR}/sound_group.c
+)
diff --git a/src/miniaudio/audio.h b/src/miniaudio/audio.h
new file mode 100644
index 0000000..0ea02d0
--- /dev/null
+++ b/src/miniaudio/audio.h
@@ -0,0 +1,176 @@
+#ifndef HONEY_AUDIO_H
+#define HONEY_AUDIO_H
+
+#include <lua.h>
+#include <miniaudio.h>
+
+
+ma_sound_group * to_sound_group(lua_State *L, int index);
+void ma_push_node(lua_State *L, ma_node *n);
+
+#define AUDIO_METATABLES \
+ X("ma.engine", ma_engine_tname) \
+ X("ma.node", ma_node_tname) \
+ X("ma.sound", ma_sound_tname) \
+ X("ma.sound_group", ma_sound_group_tname) \
+
+#define X(name, mt) extern const char *mt;
+AUDIO_METATABLES
+#undef X
+
+
+#define AUDIO_FUNCTIONS \
+ /* engine */ \
+ X("engine_init", ma_engine_init_bind) \
+ X("engine_uninit", ma_engine_uninit_bind) \
+ X("engine_get_time", ma_engine_get_time_bind) \
+ X("engine_set_time", ma_engine_set_time_bind) \
+ X("engine_get_channels", ma_engine_get_channels_bind) \
+ X("engine_get_sample_rate", ma_engine_get_sample_rate_bind) \
+ X("engine_start", ma_engine_start_bind) \
+ X("engine_stop", ma_engine_stop_bind) \
+ X("engine_set_volume", ma_engine_set_volume_bind) \
+ X("engine_set_gain_db", ma_engine_set_gain_db_bind) \
+ X("engine_get_listener_count", ma_engine_get_listener_count_bind) \
+ X("engine_find_closest_listener", ma_engine_find_closest_listener_bind) \
+ X("engine_listener_set_position", ma_engine_listener_set_position_bind) \
+ X("engine_listener_get_position", ma_engine_listener_get_position_bind) \
+ X("engine_listener_set_direction", ma_engine_listener_set_direction_bind) \
+ X("engine_listener_get_direction", ma_engine_listener_get_direction_bind) \
+ X("engine_listener_set_velocity", ma_engine_listener_set_velocity_bind) \
+ X("engine_listener_get_velocity", ma_engine_listener_get_velocity_bind) \
+ X("engine_listener_set_cone", ma_engine_listener_set_cone_bind) \
+ X("engine_listener_get_cone", ma_engine_listener_get_cone_bind) \
+ X("engine_listener_set_world_up", ma_engine_listener_set_world_up_bind) \
+ X("engine_listener_get_world_up", ma_engine_listener_get_world_up_bind) \
+ X("engine_listener_set_enabled", ma_engine_listener_set_enabled_bind) \
+ X("engine_listener_is_enabled", ma_engine_listener_is_enabled_bind) \
+ X("engine_play_sound_ex", ma_engine_play_sound_ex_bind) \
+ X("engine_play_sound", ma_engine_play_sound_bind) \
+\
+ /* sound */ \
+ X("sound_init_from_file", ma_sound_init_from_file_bind) \
+ X("sound_init_copy", ma_sound_init_copy_bind) \
+ X("sound_uninit", ma_sound_uninit_bind) \
+ X("sound_start", ma_sound_start_bind) \
+ X("sound_stop", ma_sound_stop_bind) \
+ X("sound_set_volume", ma_sound_set_volume_bind) \
+ X("sound_get_volume", ma_sound_get_volume_bind) \
+ X("sound_set_pan", ma_sound_set_pan_bind) \
+ X("sound_get_pan", ma_sound_get_pan_bind) \
+ X("sound_set_pan_mode", ma_sound_set_pan_mode_bind) \
+ X("sound_get_pan_mode", ma_sound_get_pan_mode_bind) \
+ X("sound_set_pitch", ma_sound_set_pitch_bind) \
+ X("sound_get_pitch", ma_sound_get_pitch_bind) \
+ X("sound_set_spatialization_enabled", ma_sound_set_spatialization_enabled_bind) \
+ X("sound_is_spatialization_enabled", ma_sound_is_spatialization_enabled_bind) \
+ X("sound_set_pinned_listener_index", ma_sound_set_pinned_listener_index_bind) \
+ X("sound_get_pinned_listener_index", ma_sound_get_pinned_listener_index_bind) \
+ X("sound_get_listener_index", ma_sound_get_listener_index_bind) \
+ X("sound_get_direction_to_listener", ma_sound_get_direction_to_listener_bind) \
+ X("sound_set_position", ma_sound_set_position_bind) \
+ X("sound_get_position", ma_sound_get_position_bind) \
+ X("sound_set_direction", ma_sound_set_direction_bind) \
+ X("sound_get_direction", ma_sound_get_direction_bind) \
+ X("sound_set_velocity", ma_sound_set_velocity_bind) \
+ X("sound_get_velocity", ma_sound_get_velocity_bind) \
+ X("sound_set_attenuation_model", ma_sound_set_attenuation_model_bind) \
+ X("sound_get_attenuation_model", ma_sound_get_attenuation_model_bind) \
+ X("sound_set_positioning", ma_sound_set_positioning_bind) \
+ X("sound_get_positioning", ma_sound_get_positioning_bind) \
+ X("sound_set_rolloff", ma_sound_set_rolloff_bind) \
+ X("sound_get_rolloff", ma_sound_get_rolloff_bind) \
+ X("sound_set_min_gain", ma_sound_set_min_gain_bind) \
+ X("sound_get_min_gain", ma_sound_get_min_gain_bind) \
+ X("sound_set_max_gain", ma_sound_set_max_gain_bind) \
+ X("sound_get_max_gain", ma_sound_get_max_gain_bind) \
+ X("sound_set_min_distance", ma_sound_set_min_distance_bind) \
+ X("sound_get_min_distance", ma_sound_get_min_distance_bind) \
+ X("sound_set_max_distance", ma_sound_set_max_distance_bind) \
+ X("sound_get_max_distance", ma_sound_get_max_distance_bind) \
+ X("sound_set_cone", ma_sound_set_cone_bind) \
+ X("sound_get_cone", ma_sound_get_cone_bind) \
+ X("sound_set_doppler_factor", ma_sound_set_doppler_factor_bind) \
+ X("sound_get_doppler_factor", ma_sound_get_doppler_factor_bind) \
+ X("sound_set_directional_attenuation_factor", ma_sound_set_directional_attenuation_factor_bind) \
+ X("sound_get_directional_attenuation_factor", ma_sound_get_directional_attenuation_factor_bind) \
+ X("sound_set_fade_in_pcm_frames", ma_sound_set_fade_in_pcm_frames_bind) \
+ X("sound_set_fade_in_milliseconds", ma_sound_set_fade_in_milliseconds_bind) \
+ X("sound_get_current_fade_volume", ma_sound_get_current_fade_volume_bind) \
+ X("sound_set_start_time_in_pcm_frames", ma_sound_set_start_time_in_pcm_frames_bind) \
+ X("sound_set_start_time_in_milliseconds", ma_sound_set_start_time_in_milliseconds_bind) \
+ X("sound_set_stop_time_in_pcm_frames", ma_sound_set_stop_time_in_pcm_frames_bind) \
+ X("sound_set_stop_time_in_milliseconds", ma_sound_set_stop_time_in_milliseconds_bind) \
+ X("sound_is_playing", ma_sound_is_playing_bind) \
+ X("sound_get_time_in_pcm_frames", ma_sound_get_time_in_pcm_frames_bind) \
+ X("sound_set_looping", ma_sound_set_looping_bind) \
+ X("sound_is_looping", ma_sound_is_looping_bind) \
+ X("sound_at_end", ma_sound_at_end_bind) \
+ X("sound_seek_to_pcm_frame", ma_sound_seek_to_pcm_frame_bind) \
+ X("sound_get_data_format", ma_sound_get_data_format_bind) \
+ X("sound_get_cursor_in_pcm_frames", ma_sound_get_cursor_in_pcm_frames_bind) \
+ X("sound_get_length_in_pcm_frames", ma_sound_get_length_in_pcm_frames_bind) \
+ X("sound_get_cursor_in_seconds", ma_sound_get_cursor_in_seconds_bind) \
+ X("sound_get_length_in_seconds", ma_sound_get_length_in_seconds_bind) \
+\
+ /* sound group */ \
+ X("sound_group_init", ma_sound_group_init_bind) \
+ X("sound_group_uninit", ma_sound_group_uninit_bind) \
+ X("sound_group_start", ma_sound_group_start_bind) \
+ X("sound_group_stop", ma_sound_group_stop_bind) \
+ X("sound_group_set_volume", ma_sound_group_set_volume_bind) \
+ X("sound_group_get_volume", ma_sound_group_get_volume_bind) \
+ X("sound_group_set_pan", ma_sound_group_set_pan_bind) \
+ X("sound_group_get_pan", ma_sound_group_get_pan_bind) \
+ X("sound_group_set_pan_mode", ma_sound_group_set_pan_mode_bind) \
+ X("sound_group_get_pan_mode", ma_sound_group_get_pan_mode_bind) \
+ X("sound_group_set_pitch", ma_sound_group_set_pitch_bind) \
+ X("sound_group_get_pitch", ma_sound_group_get_pitch_bind) \
+ X("sound_group_set_spatialization_enabled", ma_sound_group_set_spatialization_enabled_bind) \
+ X("sound_group_is_spatialization_enabled", ma_sound_group_is_spatialization_enabled_bind) \
+ X("sound_group_set_pinned_listener_index", ma_sound_group_set_pinned_listener_index_bind) \
+ X("sound_group_get_pinned_listener_index", ma_sound_group_get_pinned_listener_index_bind) \
+ X("sound_group_get_listener_index", ma_sound_group_get_listener_index_bind) \
+ X("sound_group_get_direction_to_listener", ma_sound_group_get_direction_to_listener_bind) \
+ X("sound_group_set_position", ma_sound_group_set_position_bind) \
+ X("sound_group_get_position", ma_sound_group_get_position_bind) \
+ X("sound_group_set_direction", ma_sound_group_set_direction_bind) \
+ X("sound_group_get_direction", ma_sound_group_get_direction_bind) \
+ X("sound_group_set_velocity", ma_sound_group_set_velocity_bind) \
+ X("sound_group_get_velocity", ma_sound_group_get_velocity_bind) \
+ X("sound_group_set_attenuation_model", ma_sound_group_set_attenuation_model_bind) \
+ X("sound_group_get_attenuation_model", ma_sound_group_get_attenuation_model_bind) \
+ X("sound_group_set_positioning", ma_sound_group_set_positioning_bind) \
+ X("sound_group_get_positioning", ma_sound_group_get_positioning_bind) \
+ X("sound_group_set_rolloff", ma_sound_group_set_rolloff_bind) \
+ X("sound_group_get_rolloff", ma_sound_group_get_rolloff_bind) \
+ X("sound_group_set_min_gain", ma_sound_group_set_min_gain_bind) \
+ X("sound_group_get_min_gain", ma_sound_group_get_min_gain_bind) \
+ X("sound_group_set_max_gain", ma_sound_group_set_max_gain_bind) \
+ X("sound_group_get_max_gain", ma_sound_group_get_max_gain_bind) \
+ X("sound_group_set_min_distance", ma_sound_group_set_min_distance_bind) \
+ X("sound_group_get_min_distance", ma_sound_group_get_min_distance_bind) \
+ X("sound_group_set_max_distance", ma_sound_group_set_max_distance_bind) \
+ X("sound_group_get_max_distance", ma_sound_group_get_max_distance_bind) \
+ X("sound_group_set_cone", ma_sound_group_set_cone_bind) \
+ X("sound_group_get_cone", ma_sound_group_get_cone_bind) \
+ X("sound_group_set_doppler_factor", ma_sound_group_set_doppler_factor_bind) \
+ X("sound_group_get_doppler_factor", ma_sound_group_get_doppler_factor_bind) \
+ X("sound_group_set_directional_attenuation_factor", ma_sound_group_set_directional_attenuation_factor_bind) \
+ X("sound_group_get_directional_attenuation_factor", ma_sound_group_get_directional_attenuation_factor_bind) \
+ X("sound_group_set_fade_in_pcm_frames", ma_sound_group_set_fade_in_pcm_frames_bind) \
+ X("sound_group_set_fade_in_milliseconds", ma_sound_group_set_fade_in_milliseconds_bind) \
+ X("sound_group_get_current_fade_volume", ma_sound_group_get_current_fade_volume_bind) \
+ X("sound_group_set_start_time_in_pcm_frames", ma_sound_group_set_start_time_in_pcm_frames_bind) \
+ X("sound_group_set_start_time_in_milliseconds", ma_sound_group_set_start_time_in_milliseconds_bind) \
+ X("sound_group_set_stop_time_in_pcm_frames", ma_sound_group_set_stop_time_in_pcm_frames_bind) \
+ X("sound_group_set_stop_time_in_milliseconds", ma_sound_group_set_stop_time_in_milliseconds_bind) \
+ X("sound_group_is_playing", ma_sound_group_is_playing_bind) \
+ X("sound_group_get_time_in_pcm_frames", ma_sound_group_get_time_in_pcm_frames_bind) \
+
+
+#define X(name, func) int func(lua_State *L);
+AUDIO_FUNCTIONS
+#undef X
+
+#endif
diff --git a/src/miniaudio/bind b/src/miniaudio/bind
new file mode 100644
index 0000000..3a9befe
--- /dev/null
+++ b/src/miniaudio/bind
@@ -0,0 +1,55 @@
+ma_result ma_sound_group_init(ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup);
+ma_result ma_sound_group_init_ex(ma_engine* pEngine, const ma_sound_group_config* pConfig, ma_sound_group* pGroup);
+void ma_sound_group_uninit(ma_sound_group* pGroup);
+ma_engine* ma_sound_group_get_engine(const ma_sound_group* pGroup);
+ma_result ma_sound_group_start(ma_sound_group* pGroup);
+ma_result ma_sound_group_stop(ma_sound_group* pGroup);
+void ma_sound_group_set_volume(ma_sound_group* pGroup, float volume);
+float ma_sound_group_get_volume(const ma_sound_group* pGroup);
+void ma_sound_group_set_pan(ma_sound_group* pGroup, float pan);
+float ma_sound_group_get_pan(const ma_sound_group* pGroup);
+void ma_sound_group_set_pan_mode(ma_sound_group* pGroup, ma_pan_mode panMode);
+ma_pan_mode ma_sound_group_get_pan_mode(const ma_sound_group* pGroup);
+void ma_sound_group_set_pitch(ma_sound_group* pGroup, float pitch);
+float ma_sound_group_get_pitch(const ma_sound_group* pGroup);
+void ma_sound_group_set_spatialization_enabled(ma_sound_group* pGroup, ma_bool32 enabled);
+ma_bool32 ma_sound_group_is_spatialization_enabled(const ma_sound_group* pGroup);
+void ma_sound_group_set_pinned_listener_index(ma_sound_group* pGroup, ma_uint32 listenerIndex);
+ma_uint32 ma_sound_group_get_pinned_listener_index(const ma_sound_group* pGroup);
+ma_uint32 ma_sound_group_get_listener_index(const ma_sound_group* pGroup);
+ma_vec3f ma_sound_group_get_direction_to_listener(const ma_sound_group* pGroup);
+void ma_sound_group_set_position(ma_sound_group* pGroup, float x, float y, float z);
+ma_vec3f ma_sound_group_get_position(const ma_sound_group* pGroup);
+void ma_sound_group_set_direction(ma_sound_group* pGroup, float x, float y, float z);
+ma_vec3f ma_sound_group_get_direction(const ma_sound_group* pGroup);
+void ma_sound_group_set_velocity(ma_sound_group* pGroup, float x, float y, float z);
+ma_vec3f ma_sound_group_get_velocity(const ma_sound_group* pGroup);
+void ma_sound_group_set_attenuation_model(ma_sound_group* pGroup, ma_attenuation_model attenuationModel);
+ma_attenuation_model ma_sound_group_get_attenuation_model(const ma_sound_group* pGroup);
+void ma_sound_group_set_positioning(ma_sound_group* pGroup, ma_positioning positioning);
+ma_positioning ma_sound_group_get_positioning(const ma_sound_group* pGroup);
+void ma_sound_group_set_rolloff(ma_sound_group* pGroup, float rolloff);
+float ma_sound_group_get_rolloff(const ma_sound_group* pGroup);
+void ma_sound_group_set_min_gain(ma_sound_group* pGroup, float minGain);
+float ma_sound_group_get_min_gain(const ma_sound_group* pGroup);
+void ma_sound_group_set_max_gain(ma_sound_group* pGroup, float maxGain);
+float ma_sound_group_get_max_gain(const ma_sound_group* pGroup);
+void ma_sound_group_set_min_distance(ma_sound_group* pGroup, float minDistance);
+float ma_sound_group_get_min_distance(const ma_sound_group* pGroup);
+void ma_sound_group_set_max_distance(ma_sound_group* pGroup, float maxDistance);
+float ma_sound_group_get_max_distance(const ma_sound_group* pGroup);
+void ma_sound_group_set_cone(ma_sound_group* pGroup, float innerAngleInRadians, float outerAngleInRadians, float outerGain);
+void ma_sound_group_get_cone(const ma_sound_group* pGroup, float* pInnerAngleInRadians, float* pOuterAngleInRadians, float* pOuterGain);
+void ma_sound_group_set_doppler_factor(ma_sound_group* pGroup, float dopplerFactor);
+float ma_sound_group_get_doppler_factor(const ma_sound_group* pGroup);
+void ma_sound_group_set_directional_attenuation_factor(ma_sound_group* pGroup, float directionalAttenuationFactor);
+float ma_sound_group_get_directional_attenuation_factor(const ma_sound_group* pGroup);
+void ma_sound_group_set_fade_in_pcm_frames(ma_sound_group* pGroup, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames);
+void ma_sound_group_set_fade_in_milliseconds(ma_sound_group* pGroup, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds);
+float ma_sound_group_get_current_fade_volume(ma_sound_group* pGroup);
+void ma_sound_group_set_start_time_in_pcm_frames(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInFrames);
+void ma_sound_group_set_start_time_in_milliseconds(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInMilliseconds);
+void ma_sound_group_set_stop_time_in_pcm_frames(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInFrames);
+void ma_sound_group_set_stop_time_in_milliseconds(ma_sound_group* pGroup, ma_uint64 absoluteGlobalTimeInMilliseconds);
+ma_bool32 ma_sound_group_is_playing(const ma_sound_group* pGroup);
+ma_uint64 ma_sound_group_get_time_in_pcm_frames(const ma_sound_group* pGroup);
diff --git a/src/miniaudio/bind.bind b/src/miniaudio/bind.bind
new file mode 100644
index 0000000..41fddd6
--- /dev/null
+++ b/src/miniaudio/bind.bind
@@ -0,0 +1,513 @@
+int ma_sound_group_init_bind(lua_State *L)
+{
+ ma_engine * pEngine = get: ma_engine *
+ ma_uint32 flags = luaL_checkinteger(L, 2);
+ ma_sound_group * pParentGroup = get: ma_sound_group *
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_result bind_result = ma_sound_group_init(pEngine, flags, pParentGroup, pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_init_ex_bind(lua_State *L)
+{
+ ma_engine * pEngine = get: ma_engine *
+ const ma_sound_group_config * pConfig = get: const ma_sound_group_config *
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_result bind_result = ma_sound_group_init_ex(pEngine, pConfig, pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_uninit_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_sound_group_uninit(pGroup);
+ return 0;
+}
+
+
+int ma_sound_group_get_engine_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_engine* bind_result = ma_sound_group_get_engine(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_start_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_result bind_result = ma_sound_group_start(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_stop_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_result bind_result = ma_sound_group_stop(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_volume_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float volume = luaL_checknumber(L, 2);
+ ma_sound_group_set_volume(pGroup, volume);
+ return 0;
+}
+
+
+int ma_sound_group_get_volume_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_volume(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_pan_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float pan = luaL_checknumber(L, 2);
+ ma_sound_group_set_pan(pGroup, pan);
+ return 0;
+}
+
+
+int ma_sound_group_get_pan_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_pan(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_pan_mode_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_pan_mode panMode = get: ma_pan_mode
+ ma_sound_group_set_pan_mode(pGroup, panMode);
+ return 0;
+}
+
+
+int ma_sound_group_get_pan_mode_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_pan_mode bind_result = ma_sound_group_get_pan_mode(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_pitch_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float pitch = luaL_checknumber(L, 2);
+ ma_sound_group_set_pitch(pGroup, pitch);
+ return 0;
+}
+
+
+int ma_sound_group_get_pitch_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_pitch(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_spatialization_enabled_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_bool32 enabled = get: ma_bool32
+ ma_sound_group_set_spatialization_enabled(pGroup, enabled);
+ return 0;
+}
+
+
+int ma_sound_group_is_spatialization_enabled_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_bool32 bind_result = ma_sound_group_is_spatialization_enabled(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_pinned_listener_index_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_sound_group_set_pinned_listener_index(pGroup, listenerIndex);
+ return 0;
+}
+
+
+int ma_sound_group_get_pinned_listener_index_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_uint32 bind_result = ma_sound_group_get_pinned_listener_index(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_get_listener_index_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_uint32 bind_result = ma_sound_group_get_listener_index(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_get_direction_to_listener_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_vec3f bind_result = ma_sound_group_get_direction_to_listener(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_position_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_group_set_position(pGroup, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_group_get_position_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_vec3f bind_result = ma_sound_group_get_position(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_direction_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_group_set_direction(pGroup, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_group_get_direction_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_vec3f bind_result = ma_sound_group_get_direction(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_velocity_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_group_set_velocity(pGroup, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_group_get_velocity_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_vec3f bind_result = ma_sound_group_get_velocity(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_attenuation_model_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_attenuation_model attenuationModel = get: ma_attenuation_model
+ ma_sound_group_set_attenuation_model(pGroup, attenuationModel);
+ return 0;
+}
+
+
+int ma_sound_group_get_attenuation_model_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_attenuation_model bind_result = ma_sound_group_get_attenuation_model(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_positioning_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_positioning positioning = get: ma_positioning
+ ma_sound_group_set_positioning(pGroup, positioning);
+ return 0;
+}
+
+
+int ma_sound_group_get_positioning_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_positioning bind_result = ma_sound_group_get_positioning(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_set_rolloff_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float rolloff = luaL_checknumber(L, 2);
+ ma_sound_group_set_rolloff(pGroup, rolloff);
+ return 0;
+}
+
+
+int ma_sound_group_get_rolloff_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_rolloff(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_min_gain_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float minGain = luaL_checknumber(L, 2);
+ ma_sound_group_set_min_gain(pGroup, minGain);
+ return 0;
+}
+
+
+int ma_sound_group_get_min_gain_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_min_gain(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_max_gain_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float maxGain = luaL_checknumber(L, 2);
+ ma_sound_group_set_max_gain(pGroup, maxGain);
+ return 0;
+}
+
+
+int ma_sound_group_get_max_gain_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_max_gain(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_min_distance_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float minDistance = luaL_checknumber(L, 2);
+ ma_sound_group_set_min_distance(pGroup, minDistance);
+ return 0;
+}
+
+
+int ma_sound_group_get_min_distance_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_min_distance(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_max_distance_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float maxDistance = luaL_checknumber(L, 2);
+ ma_sound_group_set_max_distance(pGroup, maxDistance);
+ return 0;
+}
+
+
+int ma_sound_group_get_max_distance_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_max_distance(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_cone_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float innerAngleInRadians = luaL_checknumber(L, 2);
+ float outerAngleInRadians = luaL_checknumber(L, 3);
+ float outerGain = luaL_checknumber(L, 4);
+ ma_sound_group_set_cone(pGroup, innerAngleInRadians, outerAngleInRadians, outerGain);
+ return 0;
+}
+
+
+int ma_sound_group_get_cone_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float * pInnerAngleInRadians = get: float *
+ float * pOuterAngleInRadians = get: float *
+ float * pOuterGain = get: float *
+ ma_sound_group_get_cone(pGroup, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain);
+ return 0;
+}
+
+
+int ma_sound_group_set_doppler_factor_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float dopplerFactor = luaL_checknumber(L, 2);
+ ma_sound_group_set_doppler_factor(pGroup, dopplerFactor);
+ return 0;
+}
+
+
+int ma_sound_group_get_doppler_factor_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_doppler_factor(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_directional_attenuation_factor_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float directionalAttenuationFactor = luaL_checknumber(L, 2);
+ ma_sound_group_set_directional_attenuation_factor(pGroup, directionalAttenuationFactor);
+ return 0;
+}
+
+
+int ma_sound_group_get_directional_attenuation_factor_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ float bind_result = ma_sound_group_get_directional_attenuation_factor(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_fade_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float volumeBeg = luaL_checknumber(L, 2);
+ float volumeEnd = luaL_checknumber(L, 3);
+ ma_uint64 fadeLengthInFrames = luaL_checkinteger(L, 4);
+ ma_sound_group_set_fade_in_pcm_frames(pGroup, volumeBeg, volumeEnd, fadeLengthInFrames);
+ return 0;
+}
+
+
+int ma_sound_group_set_fade_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float volumeBeg = luaL_checknumber(L, 2);
+ float volumeEnd = luaL_checknumber(L, 3);
+ ma_uint64 fadeLengthInMilliseconds = luaL_checkinteger(L, 4);
+ ma_sound_group_set_fade_in_milliseconds(pGroup, volumeBeg, volumeEnd, fadeLengthInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_group_get_current_fade_volume_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ float bind_result = ma_sound_group_get_current_fade_volume(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_start_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_uint64 absoluteGlobalTimeInFrames = luaL_checkinteger(L, 2);
+ ma_sound_group_set_start_time_in_pcm_frames(pGroup, absoluteGlobalTimeInFrames);
+ return 0;
+}
+
+
+int ma_sound_group_set_start_time_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_uint64 absoluteGlobalTimeInMilliseconds = luaL_checkinteger(L, 2);
+ ma_sound_group_set_start_time_in_milliseconds(pGroup, absoluteGlobalTimeInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_group_set_stop_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_uint64 absoluteGlobalTimeInFrames = luaL_checkinteger(L, 2);
+ ma_sound_group_set_stop_time_in_pcm_frames(pGroup, absoluteGlobalTimeInFrames);
+ return 0;
+}
+
+
+int ma_sound_group_set_stop_time_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = get: ma_sound_group *
+ ma_uint64 absoluteGlobalTimeInMilliseconds = luaL_checkinteger(L, 2);
+ ma_sound_group_set_stop_time_in_milliseconds(pGroup, absoluteGlobalTimeInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_group_is_playing_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_bool32 bind_result = ma_sound_group_is_playing(pGroup);
+ /* push result */
+ return /* count */;
+}
+
+
+int ma_sound_group_get_time_in_pcm_frames_bind(lua_State *L)
+{
+ const ma_sound_group * pGroup = get: const ma_sound_group *
+ ma_uint64 bind_result = ma_sound_group_get_time_in_pcm_frames(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
diff --git a/src/miniaudio/engine.c b/src/miniaudio/engine.c
new file mode 100644
index 0000000..ec43728
--- /dev/null
+++ b/src/miniaudio/engine.c
@@ -0,0 +1,303 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <miniaudio.h>
+#include "audio.h"
+
+
+#define GET_PARAM(param) \
+do { \
+ lua_getfield(L, conf_tbl, #param); \
+ if (!lua_isnil(L, -1)) { \
+ config.param = lua_tointeger(L, -1); \
+ } \
+ lua_pop(L, 1); \
+} while (0)
+
+int ma_engine_init_bind(lua_State *L)
+{
+ luaL_checktype(L, 1, LUA_TTABLE);
+ const int conf_tbl = 1;
+ ma_engine_config config = ma_engine_config_init();
+ GET_PARAM(listenerCount);
+ GET_PARAM(sampleRate);
+ GET_PARAM(gainSmoothTimeInFrames);
+ GET_PARAM(gainSmoothTimeInMilliseconds);
+
+ ma_engine *engine = lua_newuserdata(L, sizeof(ma_engine));
+ int engine_index = lua_gettop(L);
+ ma_result result = ma_engine_init(&config, engine);
+ lua_pushinteger(L, result);
+ lua_pushvalue(L, engine_index);
+ lua_remove(L, engine_index);
+ luaL_getmetatable(L, ma_engine_tname);
+ lua_setmetatable(L, -2);
+ return 2;
+}
+
+
+int ma_engine_uninit_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_engine_uninit(pEngine);
+ return 0;
+}
+
+
+int ma_engine_get_time_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint64 bind_result = ma_engine_get_time(pEngine);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_set_time_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint64 globalTime = luaL_checkinteger(L, 2);
+ ma_result bind_result = ma_engine_set_time(pEngine, globalTime);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_get_channels_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 bind_result = ma_engine_get_channels(pEngine);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_get_sample_rate_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 bind_result = ma_engine_get_sample_rate(pEngine);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_start_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_result bind_result = ma_engine_start(pEngine);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_stop_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_result bind_result = ma_engine_stop(pEngine);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_set_volume_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ float volume = luaL_checknumber(L, 2);
+ ma_result bind_result = ma_engine_set_volume(pEngine, volume);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_set_gain_db_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ float gainDB = luaL_checknumber(L, 2);
+ ma_result bind_result = ma_engine_set_gain_db(pEngine, gainDB);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_get_listener_count_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 bind_result = ma_engine_get_listener_count(pEngine);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_find_closest_listener_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ float absolutePosX = luaL_checknumber(L, 2);
+ float absolutePosY = luaL_checknumber(L, 3);
+ float absolutePosZ = luaL_checknumber(L, 4);
+ ma_uint32 bind_result = ma_engine_find_closest_listener(pEngine, absolutePosX, absolutePosY, absolutePosZ);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_listener_set_position_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ float x = luaL_checknumber(L, 3);
+ float y = luaL_checknumber(L, 4);
+ float z = luaL_checknumber(L, 5);
+ ma_engine_listener_set_position(pEngine, listenerIndex, x, y, z);
+ return 0;
+}
+
+
+int ma_engine_listener_get_position_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_vec3f bind_result = ma_engine_listener_get_position(pEngine, listenerIndex);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_engine_listener_set_direction_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ float x = luaL_checknumber(L, 3);
+ float y = luaL_checknumber(L, 4);
+ float z = luaL_checknumber(L, 5);
+ ma_engine_listener_set_direction(pEngine, listenerIndex, x, y, z);
+ return 0;
+}
+
+
+int ma_engine_listener_get_direction_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_vec3f bind_result = ma_engine_listener_get_direction(pEngine, listenerIndex);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_engine_listener_set_velocity_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ float x = luaL_checknumber(L, 3);
+ float y = luaL_checknumber(L, 4);
+ float z = luaL_checknumber(L, 5);
+ ma_engine_listener_set_velocity(pEngine, listenerIndex, x, y, z);
+ return 0;
+}
+
+
+int ma_engine_listener_get_velocity_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_vec3f bind_result = ma_engine_listener_get_velocity(pEngine, listenerIndex);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_engine_listener_set_cone_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ float innerAngleInRadians = luaL_checknumber(L, 3);
+ float outerAngleInRadians = luaL_checknumber(L, 4);
+ float outerGain = luaL_checknumber(L, 5);
+ ma_engine_listener_set_cone(pEngine, listenerIndex, innerAngleInRadians, outerAngleInRadians, outerGain);
+ return 0;
+}
+
+
+int ma_engine_listener_get_cone_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ float innerAngleInRadians, outerAngleInRadians, outerGain;
+ ma_engine_listener_get_cone(pEngine, listenerIndex, &innerAngleInRadians, &outerAngleInRadians, &outerGain);
+ lua_pushnumber(L, innerAngleInRadians);
+ lua_pushnumber(L, outerAngleInRadians);
+ lua_pushnumber(L, outerGain);
+ return 3;
+}
+
+
+int ma_engine_listener_set_world_up_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ float x = luaL_checknumber(L, 3);
+ float y = luaL_checknumber(L, 4);
+ float z = luaL_checknumber(L, 5);
+ ma_engine_listener_set_world_up(pEngine, listenerIndex, x, y, z);
+ return 0;
+}
+
+
+int ma_engine_listener_get_world_up_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_vec3f bind_result = ma_engine_listener_get_world_up(pEngine, listenerIndex);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_engine_listener_set_enabled_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_bool32 isEnabled = luaL_checkinteger(L, 3);
+ ma_engine_listener_set_enabled(pEngine, listenerIndex, isEnabled);
+ return 0;
+}
+
+
+int ma_engine_listener_is_enabled_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_bool32 bind_result = ma_engine_listener_is_enabled(pEngine, listenerIndex);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_play_sound_ex_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ const char * pFilePath = luaL_checkstring(L, 2);
+ ma_node * pNode = luaL_checkudata(L, 3, ma_node_tname);
+ ma_uint32 nodeInputBusIndex = luaL_checkinteger(L, 4);
+ ma_result bind_result = ma_engine_play_sound_ex(pEngine, pFilePath, pNode, nodeInputBusIndex);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_engine_play_sound_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ const char * pFilePath = luaL_checkstring(L, 2);
+ ma_sound_group * pGroup = to_sound_group(L, 3);
+ ma_result bind_result = ma_engine_play_sound(pEngine, pFilePath, pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
diff --git a/src/miniaudio/impl.c b/src/miniaudio/impl.c
new file mode 100644
index 0000000..5e8969a
--- /dev/null
+++ b/src/miniaudio/impl.c
@@ -0,0 +1,8 @@
+#define STB_VORBIS_HEADER_ONLY
+#include <stb_vorbis.c>
+#define MINIAUDIO_IMPLEMENTATION
+#include <miniaudio.h>
+#undef STB_VORBIS_HEADER_ONLY
+#include <stb_vorbis.c>
+
+
diff --git a/src/miniaudio/setup.c b/src/miniaudio/setup.c
new file mode 100644
index 0000000..774bf39
--- /dev/null
+++ b/src/miniaudio/setup.c
@@ -0,0 +1,31 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <miniaudio.h>
+#include "util/util.h"
+#include "audio.h"
+
+
+#define X(name, mt) const char *mt = name;
+AUDIO_METATABLES
+#undef X
+
+
+void setup_audio(lua_State *L, int honey_tbl)
+{
+ #define X(n, mt) luaL_newmetatable(L, mt); lua_pop(L, 1);
+ AUDIO_METATABLES
+ #undef X
+
+ struct honey_tbl_t audio[] = {
+ #define X(name, func) H_FUNC(name, func),
+ AUDIO_FUNCTIONS
+ #undef X
+
+ /* ma_result values */
+ H_ENUM(MA_SUCCESS),
+
+ H_END,
+ };
+ create_table(L, audio);
+ lua_setfield(L, honey_tbl, "ma");
+}
diff --git a/src/miniaudio/sound.c b/src/miniaudio/sound.c
new file mode 100644
index 0000000..334a08a
--- /dev/null
+++ b/src/miniaudio/sound.c
@@ -0,0 +1,640 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <miniaudio.h>
+#include "audio.h"
+
+
+void push_sound(lua_State *L, ma_sound s) {
+ ma_sound *su = lua_newuserdata(L, sizeof(ma_sound));
+ *su = s;
+ luaL_getmetatable(L, ma_sound_tname);
+ lua_setmetatable(L, -2);
+}
+
+
+int ma_sound_init_from_file_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ const char * pFilePath = luaL_checkstring(L, 2);
+ ma_uint32 flags = luaL_checkinteger(L, 3);
+ ma_sound_group * pGroup = to_sound_group(L, 4);
+
+ ma_sound *sound = lua_newuserdata(L, sizeof(ma_sound));
+ int sound_index = lua_gettop(L);
+ ma_result bind_result = ma_sound_init_from_file(pEngine, pFilePath, flags, pGroup, NULL, sound);
+ lua_pushinteger(L, bind_result);
+ lua_pushvalue(L, sound_index);
+ lua_remove(L, sound_index);
+ luaL_getmetatable(L, ma_sound_tname);
+ lua_setmetatable(L, -2);
+ return 2;
+}
+
+
+int ma_sound_init_copy_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_sound * pExistingSound = luaL_checkudata(L, 2, ma_sound_tname);
+ ma_uint32 flags = luaL_checkinteger(L, 3);
+ ma_sound_group * pGroup = to_sound_group(L, 4);
+ ma_sound *sound = lua_newuserdata(L, sizeof(ma_sound));
+ int sound_index = lua_gettop(L);
+ ma_result bind_result = ma_sound_init_copy(pEngine, pExistingSound, flags, pGroup, sound);
+ lua_pushinteger(L, bind_result);
+ lua_pushvalue(L, sound_index);
+ lua_remove(L, sound_index);
+ luaL_getmetatable(L, ma_sound_tname);
+ lua_setmetatable(L, -2);
+ return 2;
+}
+
+
+int ma_sound_uninit_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_sound_uninit(pSound);
+ return 0;
+}
+
+
+int ma_sound_start_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_result bind_result = ma_sound_start(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_stop_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_result bind_result = ma_sound_stop(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_volume_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float volume = luaL_checknumber(L, 2);
+ ma_sound_set_volume(pSound, volume);
+ return 0;
+}
+
+
+int ma_sound_get_volume_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_volume(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_pan_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float pan = luaL_checknumber(L, 2);
+ ma_sound_set_pan(pSound, pan);
+ return 0;
+}
+
+
+int ma_sound_get_pan_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_pan(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_pan_mode_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_pan_mode panMode = luaL_checkinteger(L, 2);
+ ma_sound_set_pan_mode(pSound, panMode);
+ return 0;
+}
+
+
+int ma_sound_get_pan_mode_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_pan_mode bind_result = ma_sound_get_pan_mode(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_pitch_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float pitch = luaL_checknumber(L, 2);
+ ma_sound_set_pitch(pSound, pitch);
+ return 0;
+}
+
+
+int ma_sound_get_pitch_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_pitch(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_spatialization_enabled_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_bool32 enabled = lua_toboolean(L, 2);
+ ma_sound_set_spatialization_enabled(pSound, enabled);
+ return 0;
+}
+
+
+int ma_sound_is_spatialization_enabled_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_bool32 bind_result = ma_sound_is_spatialization_enabled(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_pinned_listener_index_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_sound_set_pinned_listener_index(pSound, listenerIndex);
+ return 0;
+}
+
+
+int ma_sound_get_pinned_listener_index_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint32 bind_result = ma_sound_get_pinned_listener_index(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_get_listener_index_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint32 bind_result = ma_sound_get_listener_index(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_get_direction_to_listener_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_vec3f bind_result = ma_sound_get_direction_to_listener(pSound);
+ lua_pushinteger(L, bind_result.x);
+ lua_pushinteger(L, bind_result.y);
+ lua_pushinteger(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_set_position_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_set_position(pSound, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_get_position_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_vec3f bind_result = ma_sound_get_position(pSound);
+ lua_pushinteger(L, bind_result.x);
+ lua_pushinteger(L, bind_result.y);
+ lua_pushinteger(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_set_direction_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_set_direction(pSound, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_get_direction_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_vec3f bind_result = ma_sound_get_direction(pSound);
+ lua_pushinteger(L, bind_result.x);
+ lua_pushinteger(L, bind_result.y);
+ lua_pushinteger(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_set_velocity_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_set_velocity(pSound, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_get_velocity_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_vec3f bind_result = ma_sound_get_velocity(pSound);
+ lua_pushinteger(L, bind_result.x);
+ lua_pushinteger(L, bind_result.y);
+ lua_pushinteger(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_set_attenuation_model_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_attenuation_model attenuationModel = luaL_checkinteger(L, 2);
+ ma_sound_set_attenuation_model(pSound, attenuationModel);
+ return 0;
+}
+
+
+int ma_sound_get_attenuation_model_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_attenuation_model bind_result = ma_sound_get_attenuation_model(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_positioning_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_positioning positioning = luaL_checkinteger(L, 2);
+ ma_sound_set_positioning(pSound, positioning);
+ return 0;
+}
+
+
+int ma_sound_get_positioning_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_positioning bind_result = ma_sound_get_positioning(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_rolloff_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float rolloff = luaL_checknumber(L, 2);
+ ma_sound_set_rolloff(pSound, rolloff);
+ return 0;
+}
+
+
+int ma_sound_get_rolloff_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_rolloff(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_min_gain_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float minGain = luaL_checknumber(L, 2);
+ ma_sound_set_min_gain(pSound, minGain);
+ return 0;
+}
+
+
+int ma_sound_get_min_gain_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_min_gain(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_max_gain_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float maxGain = luaL_checknumber(L, 2);
+ ma_sound_set_max_gain(pSound, maxGain);
+ return 0;
+}
+
+
+int ma_sound_get_max_gain_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_max_gain(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_min_distance_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float minDistance = luaL_checknumber(L, 2);
+ ma_sound_set_min_distance(pSound, minDistance);
+ return 0;
+}
+
+
+int ma_sound_get_min_distance_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_min_distance(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_max_distance_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float maxDistance = luaL_checknumber(L, 2);
+ ma_sound_set_max_distance(pSound, maxDistance);
+ return 0;
+}
+
+
+int ma_sound_get_max_distance_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_max_distance(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_cone_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float innerAngleInRadians = luaL_checknumber(L, 2);
+ float outerAngleInRadians = luaL_checknumber(L, 3);
+ float outerGain = luaL_checknumber(L, 4);
+ ma_sound_set_cone(pSound, innerAngleInRadians, outerAngleInRadians, outerGain);
+ return 0;
+}
+
+
+int ma_sound_get_cone_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float innerAngleInRadians, outerAngleInRadians, outerGain;
+ ma_sound_get_cone(pSound, &innerAngleInRadians, &outerAngleInRadians, &outerGain);
+ lua_pushnumber(L, innerAngleInRadians);
+ lua_pushnumber(L, outerAngleInRadians);
+ lua_pushnumber(L, outerGain);
+ return 3;
+}
+
+
+int ma_sound_set_doppler_factor_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float dopplerFactor = luaL_checknumber(L, 2);
+ ma_sound_set_doppler_factor(pSound, dopplerFactor);
+ return 0;
+}
+
+
+int ma_sound_get_doppler_factor_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_doppler_factor(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_directional_attenuation_factor_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float directionalAttenuationFactor = luaL_checknumber(L, 2);
+ ma_sound_set_directional_attenuation_factor(pSound, directionalAttenuationFactor);
+ return 0;
+}
+
+
+int ma_sound_get_directional_attenuation_factor_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_directional_attenuation_factor(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_fade_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float volumeBeg = luaL_checknumber(L, 2);
+ float volumeEnd = luaL_checknumber(L, 3);
+ ma_uint64 fadeLengthInFrames = luaL_checkinteger(L, 4);
+ ma_sound_set_fade_in_pcm_frames(pSound, volumeBeg, volumeEnd, fadeLengthInFrames);
+ return 0;
+}
+
+
+int ma_sound_set_fade_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float volumeBeg = luaL_checknumber(L, 2);
+ float volumeEnd = luaL_checknumber(L, 3);
+ ma_uint64 fadeLengthInMilliseconds = luaL_checkinteger(L, 4);
+ ma_sound_set_fade_in_milliseconds(pSound, volumeBeg, volumeEnd, fadeLengthInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_get_current_fade_volume_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float bind_result = ma_sound_get_current_fade_volume(pSound);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_start_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 absoluteGlobalTimeInFrames = luaL_checkinteger(L, 2);
+ ma_sound_set_start_time_in_pcm_frames(pSound, absoluteGlobalTimeInFrames);
+ return 0;
+}
+
+
+int ma_sound_set_start_time_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 absoluteGlobalTimeInMilliseconds = luaL_checkinteger(L, 2);
+ ma_sound_set_start_time_in_milliseconds(pSound, absoluteGlobalTimeInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_set_stop_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 absoluteGlobalTimeInFrames = luaL_checkinteger(L, 2);
+ ma_sound_set_stop_time_in_pcm_frames(pSound, absoluteGlobalTimeInFrames);
+ return 0;
+}
+
+
+int ma_sound_set_stop_time_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 absoluteGlobalTimeInMilliseconds = luaL_checkinteger(L, 2);
+ ma_sound_set_stop_time_in_milliseconds(pSound, absoluteGlobalTimeInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_is_playing_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_bool32 bind_result = ma_sound_is_playing(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_get_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 bind_result = ma_sound_get_time_in_pcm_frames(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_set_looping_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_bool32 isLooping = luaL_checkinteger(L, 2);
+ ma_sound_set_looping(pSound, isLooping);
+ return 0;
+}
+
+
+int ma_sound_is_looping_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_bool32 bind_result = ma_sound_is_looping(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_at_end_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_bool32 bind_result = ma_sound_at_end(pSound);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_seek_to_pcm_frame_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 frameIndex = luaL_checkinteger(L, 2);
+ ma_result bind_result = ma_sound_seek_to_pcm_frame(pSound, frameIndex);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_get_data_format_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_format format;
+ ma_uint32 channels;
+ ma_uint32 sampleRate;
+ ma_channel channelMap;
+ size_t channelMapCap = 0;
+ ma_result bind_result = ma_sound_get_data_format(pSound, &format, &channels, &sampleRate, &channelMap, channelMapCap);
+ lua_pushinteger(L, bind_result);
+ lua_pushinteger(L, format);
+ lua_pushinteger(L, channels);
+ lua_pushinteger(L, sampleRate);
+ lua_pushinteger(L, channelMap);
+ return 5;
+}
+
+
+int ma_sound_get_cursor_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 cursor;
+ ma_result bind_result = ma_sound_get_cursor_in_pcm_frames(pSound, &cursor);
+ lua_pushinteger(L, bind_result);
+ lua_pushinteger(L, cursor);
+ return 2;
+}
+
+
+int ma_sound_get_length_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ ma_uint64 length;
+ ma_result bind_result = ma_sound_get_length_in_pcm_frames(pSound, &length);
+ lua_pushinteger(L, bind_result);
+ lua_pushinteger(L, length);
+ return 2;
+}
+
+
+int ma_sound_get_cursor_in_seconds_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float cursor;
+ ma_result bind_result = ma_sound_get_cursor_in_seconds(pSound, &cursor);
+ lua_pushinteger(L, bind_result);
+ lua_pushnumber(L, cursor);
+ return 2;
+}
+
+
+int ma_sound_get_length_in_seconds_bind(lua_State *L)
+{
+ ma_sound * pSound = luaL_checkudata(L, 1, ma_sound_tname);
+ float length;
+ ma_result bind_result = ma_sound_get_length_in_seconds(pSound, &length);
+ lua_pushinteger(L, bind_result);
+ lua_pushnumber(L, length);
+ return 2;
+}
+
+
diff --git a/src/miniaudio/sound_group.c b/src/miniaudio/sound_group.c
new file mode 100644
index 0000000..c52b3be
--- /dev/null
+++ b/src/miniaudio/sound_group.c
@@ -0,0 +1,522 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <miniaudio.h>
+#include "audio.h"
+
+
+ma_sound_group * to_sound_group(lua_State *L, int index)
+{
+ if (lua_isnil(L, index)) {
+ return NULL;
+ }
+ return luaL_checkudata(L, index, ma_sound_group_tname);
+}
+
+
+int ma_sound_group_init_bind(lua_State *L)
+{
+ ma_engine * pEngine = luaL_checkudata(L, 1, ma_engine_tname);
+ ma_uint32 flags = luaL_checkinteger(L, 2);
+ ma_sound_group * pParentGroup = to_sound_group(L, 3);
+ ma_sound_group * pGroup = lua_newuserdata(L, sizeof(ma_sound_group));
+ int gindex = lua_gettop(L);
+ ma_result bind_result = ma_sound_group_init(pEngine, flags, pParentGroup, pGroup);
+ lua_pushinteger(L, bind_result);
+ lua_pushvalue(L, gindex);
+ lua_remove(L, gindex);
+ luaL_getmetatable(L, ma_sound_group_tname);
+ lua_setmetatable(L, -2);
+ return 2;
+}
+
+
+int ma_sound_group_uninit_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_sound_group_uninit(pGroup);
+ return 0;
+}
+
+
+int ma_sound_group_start_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_result bind_result = ma_sound_group_start(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_stop_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_result bind_result = ma_sound_group_stop(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_volume_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float volume = luaL_checknumber(L, 2);
+ ma_sound_group_set_volume(pGroup, volume);
+ return 0;
+}
+
+
+int ma_sound_group_get_volume_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_volume(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_pan_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float pan = luaL_checknumber(L, 2);
+ ma_sound_group_set_pan(pGroup, pan);
+ return 0;
+}
+
+
+int ma_sound_group_get_pan_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_pan(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_pan_mode_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_pan_mode panMode = luaL_checkinteger(L, 2);
+ ma_sound_group_set_pan_mode(pGroup, panMode);
+ return 0;
+}
+
+
+int ma_sound_group_get_pan_mode_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_pan_mode bind_result = ma_sound_group_get_pan_mode(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_pitch_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float pitch = luaL_checknumber(L, 2);
+ ma_sound_group_set_pitch(pGroup, pitch);
+ return 0;
+}
+
+
+int ma_sound_group_get_pitch_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_pitch(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_spatialization_enabled_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_bool32 enabled = lua_toboolean(L, 2);
+ ma_sound_group_set_spatialization_enabled(pGroup, enabled);
+ return 0;
+}
+
+
+int ma_sound_group_is_spatialization_enabled_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_bool32 bind_result = ma_sound_group_is_spatialization_enabled(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_pinned_listener_index_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint32 listenerIndex = luaL_checkinteger(L, 2);
+ ma_sound_group_set_pinned_listener_index(pGroup, listenerIndex);
+ return 0;
+}
+
+
+int ma_sound_group_get_pinned_listener_index_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint32 bind_result = ma_sound_group_get_pinned_listener_index(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_get_listener_index_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint32 bind_result = ma_sound_group_get_listener_index(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_get_direction_to_listener_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_vec3f bind_result = ma_sound_group_get_direction_to_listener(pGroup);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_group_set_position_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_group_set_position(pGroup, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_group_get_position_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_vec3f bind_result = ma_sound_group_get_position(pGroup);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_group_set_direction_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_group_set_direction(pGroup, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_group_get_direction_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_vec3f bind_result = ma_sound_group_get_direction(pGroup);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_group_set_velocity_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float x = luaL_checknumber(L, 2);
+ float y = luaL_checknumber(L, 3);
+ float z = luaL_checknumber(L, 4);
+ ma_sound_group_set_velocity(pGroup, x, y, z);
+ return 0;
+}
+
+
+int ma_sound_group_get_velocity_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_vec3f bind_result = ma_sound_group_get_velocity(pGroup);
+ lua_pushnumber(L, bind_result.x);
+ lua_pushnumber(L, bind_result.y);
+ lua_pushnumber(L, bind_result.z);
+ return 3;
+}
+
+
+int ma_sound_group_set_attenuation_model_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_attenuation_model attenuationModel = luaL_checkinteger(L, 2);
+ ma_sound_group_set_attenuation_model(pGroup, attenuationModel);
+ return 0;
+}
+
+
+int ma_sound_group_get_attenuation_model_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_attenuation_model bind_result = ma_sound_group_get_attenuation_model(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_positioning_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_positioning positioning = luaL_checkinteger(L, 2);
+ ma_sound_group_set_positioning(pGroup, positioning);
+ return 0;
+}
+
+
+int ma_sound_group_get_positioning_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_positioning bind_result = ma_sound_group_get_positioning(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_rolloff_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float rolloff = luaL_checknumber(L, 2);
+ ma_sound_group_set_rolloff(pGroup, rolloff);
+ return 0;
+}
+
+
+int ma_sound_group_get_rolloff_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_rolloff(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_min_gain_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float minGain = luaL_checknumber(L, 2);
+ ma_sound_group_set_min_gain(pGroup, minGain);
+ return 0;
+}
+
+
+int ma_sound_group_get_min_gain_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_min_gain(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_max_gain_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float maxGain = luaL_checknumber(L, 2);
+ ma_sound_group_set_max_gain(pGroup, maxGain);
+ return 0;
+}
+
+
+int ma_sound_group_get_max_gain_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_max_gain(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_min_distance_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float minDistance = luaL_checknumber(L, 2);
+ ma_sound_group_set_min_distance(pGroup, minDistance);
+ return 0;
+}
+
+
+int ma_sound_group_get_min_distance_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_min_distance(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_max_distance_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float maxDistance = luaL_checknumber(L, 2);
+ ma_sound_group_set_max_distance(pGroup, maxDistance);
+ return 0;
+}
+
+
+int ma_sound_group_get_max_distance_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_max_distance(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_cone_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float innerAngleInRadians = luaL_checknumber(L, 2);
+ float outerAngleInRadians = luaL_checknumber(L, 3);
+ float outerGain = luaL_checknumber(L, 4);
+ ma_sound_group_set_cone(pGroup, innerAngleInRadians, outerAngleInRadians, outerGain);
+ return 0;
+}
+
+
+int ma_sound_group_get_cone_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float InnerAngleInRadians, OuterAngleInRadians, OuterGain;
+ ma_sound_group_get_cone(pGroup, &InnerAngleInRadians, &OuterAngleInRadians, &OuterGain);
+ lua_pushnumber(L, InnerAngleInRadians);
+ lua_pushnumber(L, OuterAngleInRadians);
+ lua_pushnumber(L, OuterGain);
+ return 3;
+}
+
+
+int ma_sound_group_set_doppler_factor_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float dopplerFactor = luaL_checknumber(L, 2);
+ ma_sound_group_set_doppler_factor(pGroup, dopplerFactor);
+ return 0;
+}
+
+
+int ma_sound_group_get_doppler_factor_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_doppler_factor(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_directional_attenuation_factor_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float directionalAttenuationFactor = luaL_checknumber(L, 2);
+ ma_sound_group_set_directional_attenuation_factor(pGroup, directionalAttenuationFactor);
+ return 0;
+}
+
+
+int ma_sound_group_get_directional_attenuation_factor_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_directional_attenuation_factor(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_fade_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float volumeBeg = luaL_checknumber(L, 2);
+ float volumeEnd = luaL_checknumber(L, 3);
+ ma_uint64 fadeLengthInFrames = luaL_checkinteger(L, 4);
+ ma_sound_group_set_fade_in_pcm_frames(pGroup, volumeBeg, volumeEnd, fadeLengthInFrames);
+ return 0;
+}
+
+
+int ma_sound_group_set_fade_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float volumeBeg = luaL_checknumber(L, 2);
+ float volumeEnd = luaL_checknumber(L, 3);
+ ma_uint64 fadeLengthInMilliseconds = luaL_checkinteger(L, 4);
+ ma_sound_group_set_fade_in_milliseconds(pGroup, volumeBeg, volumeEnd, fadeLengthInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_group_get_current_fade_volume_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ float bind_result = ma_sound_group_get_current_fade_volume(pGroup);
+ lua_pushnumber(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_set_start_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint64 absoluteGlobalTimeInFrames = luaL_checkinteger(L, 2);
+ ma_sound_group_set_start_time_in_pcm_frames(pGroup, absoluteGlobalTimeInFrames);
+ return 0;
+}
+
+
+int ma_sound_group_set_start_time_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint64 absoluteGlobalTimeInMilliseconds = luaL_checkinteger(L, 2);
+ ma_sound_group_set_start_time_in_milliseconds(pGroup, absoluteGlobalTimeInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_group_set_stop_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint64 absoluteGlobalTimeInFrames = luaL_checkinteger(L, 2);
+ ma_sound_group_set_stop_time_in_pcm_frames(pGroup, absoluteGlobalTimeInFrames);
+ return 0;
+}
+
+
+int ma_sound_group_set_stop_time_in_milliseconds_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint64 absoluteGlobalTimeInMilliseconds = luaL_checkinteger(L, 2);
+ ma_sound_group_set_stop_time_in_milliseconds(pGroup, absoluteGlobalTimeInMilliseconds);
+ return 0;
+}
+
+
+int ma_sound_group_is_playing_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_bool32 bind_result = ma_sound_group_is_playing(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+
+int ma_sound_group_get_time_in_pcm_frames_bind(lua_State *L)
+{
+ ma_sound_group * pGroup = luaL_checkudata(L, 1, ma_sound_group_tname);
+ ma_uint64 bind_result = ma_sound_group_get_time_in_pcm_frames(pGroup);
+ lua_pushinteger(L, bind_result);
+ return 1;
+}
+
+