diff options
author | feos <vadosnaprimer@users.noreply.github.com> | 2019-08-17 18:50:48 +0300 |
---|---|---|
committer | R. Belmont <rb6502@users.noreply.github.com> | 2019-08-17 11:50:48 -0400 |
commit | b8986566ef2028bebbbe21cbb3692a682e030178 (patch) | |
tree | af04e8ca912cff0ea9991278649726e929204f42 /src/frontend/mame | |
parent | 3d3f35ad6451e50d36023a765d4dfb5ccd1ef2a2 (diff) |
Expose sound buffer and samplerate to luaengine (#5497)
* luaengine: manager:machine():sound():samples()
* luaengine: fix natural_keyboard docs
* tiny cleanup as requested in #5348
* fix clang build
Diffstat (limited to 'src/frontend/mame')
-rw-r--r-- | src/frontend/mame/luaengine.cpp | 26 | ||||
-rw-r--r-- | src/frontend/mame/ui/ui.cpp | 2 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 0182a5cbeeb..8cda9cc6c98 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1253,6 +1253,7 @@ void lua_engine::initialize() * * machine:system() - get game_driver for running driver * machine:video() - get video_manager + * machine:sound() - get sound_manager * machine:render() - get render_manager * machine:ioport() - get ioport_manager * machine:parameters() - get parameter_manager @@ -1264,6 +1265,7 @@ void lua_engine::initialize() * machine:debugger() - get debugger_manager * * machine.paused - get paused state + * machine.samplerate - get audio sample rate * * machine.devices[] - get device table (k=tag, v=device_t) * machine.screens[] - get screens table (k=tag, v=screen_device) @@ -1293,6 +1295,7 @@ void lua_engine::initialize() return sol::make_object(sol(), &m.debugger()); }, "paused", sol::property(&running_machine::paused), + "samplerate", sol::property(&running_machine::sample_rate), "devices", sol::property([this](running_machine &m) { std::function<void(device_t &, sol::table)> tree; sol::table table = sol().create_table(); @@ -1739,15 +1742,16 @@ void lua_engine::initialize() return port_table; })); -/* natkeyboard library +/* natural_keyboard library * * manager:machine():ioport():natkeyboard() * - * natkeyboard.empty - is the natural keyboard buffer empty? - * natkeyboard.in_use - is the natural keyboard in use? * natkeyboard:paste() - paste clipboard data * natkeyboard:post() - post data to natural keyboard * natkeyboard:post_coded() - post data to natural keyboard + * + * natkeyboard.empty - is the natural keyboard buffer empty? + * natkeyboard.in_use - is the natural keyboard in use? */ sol().registry().new_usertype<natural_keyboard>("natkeyboard", "new", sol::no_constructor, @@ -1757,6 +1761,7 @@ void lua_engine::initialize() "post", [](natural_keyboard &nat, const std::string &text) { nat.post_utf8(text); }, "post_coded", [](natural_keyboard &nat, const std::string &text) { nat.post_coded(text); }); + /* ioport_port library * * manager:machine():ioport().ports[port_tag] @@ -1995,16 +2000,29 @@ void lua_engine::initialize() * sound:stop_recording() - end audio recording * sound:ui_mute(turn_off) - turns on/off UI sound * sound:system_mute() - turns on/off system sound - * sound:attenuation - sound attenuation + * sound:samples() - get current frame's audio buffer contents in binary form as string + * + * sound.attenuation - sound attenuation */ + sol().registry().new_usertype<sound_manager>("sound", "new", sol::no_constructor, "start_recording", &sound_manager::start_recording, "stop_recording", &sound_manager::stop_recording, "ui_mute", &sound_manager::ui_mute, "debugger_mute", &sound_manager::debugger_mute, "system_mute", &sound_manager::system_mute, + "samples", [](sound_manager &sm, sol::this_state s) { + lua_State *L = s; + luaL_Buffer buff; + s32 count = sm.sample_count() * 2 * 2; // 2 channels, 2 bytes per sample + s16 *ptr = (s16 *)luaL_buffinitsize(L, &buff, count); + sm.samples(ptr); + luaL_pushresultsize(&buff, count); + return sol::make_reference(L, sol::stack_reference(L, -1)); + }, "attenuation", sol::property(&sound_manager::attenuation, &sound_manager::set_attenuation)); + /* input_manager library * * manager:machine():input() diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index ec176328835..446c848939f 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -304,7 +304,7 @@ void mame_ui_manager::display_startup_screens(bool first_time) int str = machine().options().seconds_to_run(); bool show_gameinfo = !machine().options().skip_gameinfo(); bool show_warnings = true, show_mandatory_fileman = true; - bool video_none = strcmp(downcast<osd_options &>(machine().options()).video(), "none") == 0; + bool video_none = strcmp(downcast<osd_options &>(machine().options()).video(), OSDOPTVAL_NONE) == 0; // disable everything if we are using -str for 300 or fewer seconds, or if we're the empty driver, // or if we are debugging, or if there's no mame window to send inputs to |