From 8546166f788c74a993ebab78302141a9efe87ef5 Mon Sep 17 00:00:00 2001 From: "K.Ohta" Date: Mon, 23 Jan 2017 01:10:37 +0900 Subject: [PATCH] [VM][SOUND][PCM1BIT] Add "Strict Rendering" to "Sound" menu. --- source/src/config.cpp | 4 ++++ source/src/config.h | 1 + source/src/qt/CMakeLists.txt | 4 ++-- source/src/qt/avio/CMakeLists.txt | 4 ++-- source/src/qt/common/menu_flags.h | 1 - source/src/qt/emuutils/CMakeLists.txt | 4 ++-- source/src/qt/gui/CMakeLists.txt | 4 ++-- source/src/qt/gui/mainwidget_base.h | 4 +++- source/src/qt/gui/menu_sound.cpp | 18 +++++++++++++++++- source/src/vm/event.cpp | 12 ++++++++---- source/src/vm/msx/msx.cpp | 3 --- 11 files changed, 41 insertions(+), 18 deletions(-) diff --git a/source/src/config.cpp b/source/src/config.cpp index 091b10852..7e685de94 100644 --- a/source/src/config.cpp +++ b/source/src/config.cpp @@ -106,6 +106,7 @@ void initialize_config() #elif defined(USE_SOUND_DEVICE_TYPE) config.sound_device_type = 0; #endif + config.sound_strict_rendering = true; // input #ifdef _WIN32 @@ -345,6 +346,8 @@ void load_config(const _TCHAR *config_path) #endif MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path); config.general_sound_level = MyGetPrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"), config.general_sound_level, config_path); + config.sound_strict_rendering = MyGetPrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path); + // input #ifdef _WIN32 config.use_direct_input = MyGetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path); @@ -648,6 +651,7 @@ void save_config(const _TCHAR *config_path) MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path); MyWritePrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"), config.general_sound_level, config_path); + MyWritePrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);; // input #ifdef _WIN32 MyWritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path); diff --git a/source/src/config.h b/source/src/config.h index a29e7ea2b..a801cf962 100644 --- a/source/src/config.h +++ b/source/src/config.h @@ -135,6 +135,7 @@ typedef struct { int sound_volume_l[32]; int sound_volume_r[32]; _TCHAR fmgen_dll_path[_MAX_PATH]; + bool sound_strict_rendering; // input #ifdef _WIN32 diff --git a/source/src/qt/CMakeLists.txt b/source/src/qt/CMakeLists.txt index d3cde619d..c254cddaf 100644 --- a/source/src/qt/CMakeLists.txt +++ b/source/src/qt/CMakeLists.txt @@ -61,8 +61,8 @@ target_link_libraries(CSPosd PUBLIC ) set_target_properties(CSPosd PROPERTIES - SOVERSION 2.5.1 - VERSION 2.5.1 + SOVERSION 2.5.2 + VERSION 2.5.2 ) INSTALL(TARGETS CSPosd DESTINATION ${LIBCSP_INSTALL_DIR}) endif() diff --git a/source/src/qt/avio/CMakeLists.txt b/source/src/qt/avio/CMakeLists.txt index aeb899125..63f57c2c0 100644 --- a/source/src/qt/avio/CMakeLists.txt +++ b/source/src/qt/avio/CMakeLists.txt @@ -63,8 +63,8 @@ target_link_libraries(CSPavio PUBLIC ) set_target_properties(CSPavio PROPERTIES - SOVERSION 2.5.1 - VERSION 2.5.1 + SOVERSION 2.5.2 + VERSION 2.5.2 ) INSTALL(TARGETS CSPavio DESTINATION ${LIBCSP_INSTALL_DIR}) endif() diff --git a/source/src/qt/common/menu_flags.h b/source/src/qt/common/menu_flags.h index 42718a77d..d5ba9fbf1 100644 --- a/source/src/qt/common/menu_flags.h +++ b/source/src/qt/common/menu_flags.h @@ -247,7 +247,6 @@ public: bool is_use_sound_files_fdd() { return use_sound_files_fdd; } bool is_use_sound_files_relay() { return use_sound_files_relay; } bool is_use_sound_files_buttons() { return use_sound_files_buttons; } - bool is_use_special_reset() { return use_special_reset; } bool is_use_state() { return use_state; } diff --git a/source/src/qt/emuutils/CMakeLists.txt b/source/src/qt/emuutils/CMakeLists.txt index 74178add3..5d0ddca10 100644 --- a/source/src/qt/emuutils/CMakeLists.txt +++ b/source/src/qt/emuutils/CMakeLists.txt @@ -36,8 +36,8 @@ add_library(CSPemu_utils SHARED ) set_target_properties(CSPemu_utils PROPERTIES - SOVERSION 2.2.0 - VERSION 2.2.0 + SOVERSION 2.2.1 + VERSION 2.2.1 ) INSTALL(TARGETS CSPemu_utils DESTINATION ${LIBCSP_INSTALL_DIR}) endif() diff --git a/source/src/qt/gui/CMakeLists.txt b/source/src/qt/gui/CMakeLists.txt index 353b6b775..42ce47c1f 100644 --- a/source/src/qt/gui/CMakeLists.txt +++ b/source/src/qt/gui/CMakeLists.txt @@ -157,8 +157,8 @@ target_link_libraries(CSPgui PUBLIC ) set_target_properties(CSPgui PROPERTIES - SOVERSION 2.4.1 - VERSION 2.4.1 + SOVERSION 2.4.2 + VERSION 2.4.2 ) INSTALL(TARGETS CSPgui DESTINATION ${LIBCSP_INSTALL_DIR}) endif() diff --git a/source/src/qt/gui/mainwidget_base.h b/source/src/qt/gui/mainwidget_base.h index 3768ce02c..13143ebe0 100644 --- a/source/src/qt/gui/mainwidget_base.h +++ b/source/src/qt/gui/mainwidget_base.h @@ -280,7 +280,7 @@ class DLL_PREFIX Ui_MainWindowBase : public QMainWindow class Action_Control *actionStart_Record_Movie; class Action_Control *actionStop_Record_Movie; class Action_Control *action_VolumeDialog; - + class Action_Control *actionSoundStrictRendering; class Action_Control *actionMouseEnable; class Action_Control *actionHelp_AboutQt; @@ -580,6 +580,8 @@ public slots: void set_freq(int); void set_latency(int); void set_sound_device(int); + void do_set_sound_strict_rendering(bool f); + void set_monitor_type(int); void message_status_bar(QString); void resize_statusbar(int w, int h); diff --git a/source/src/qt/gui/menu_sound.cpp b/source/src/qt/gui/menu_sound.cpp index 541c71c54..b03327f2f 100644 --- a/source/src/qt/gui/menu_sound.cpp +++ b/source/src/qt/gui/menu_sound.cpp @@ -27,6 +27,12 @@ void Object_Menu_Control::on_set_latency(void) { } +void Ui_MainWindowBase::do_set_sound_strict_rendering(bool f) +{ + if(using_flags != NULL) { + using_flags->get_config_ptr()->sound_strict_rendering = f; + } +} void Ui_MainWindowBase::rise_volume_dialog(void) { @@ -60,11 +66,19 @@ void Ui_MainWindowBase::CreateSoundMenu(void) menuSound->addAction(actionStart_Record); menuSound->addSeparator(); + actionSoundStrictRendering = new Action_Control(this, using_flags); + actionSoundStrictRendering->setObjectName(QString::fromUtf8("actionSoundStrictRendering")); + actionSoundStrictRendering->setCheckable(true); + if(using_flags->get_config_ptr()->sound_strict_rendering) actionSoundStrictRendering->setChecked(true); + connect(actionSoundStrictRendering, SIGNAL(toggled(bool)), + this, SLOT(do_set_sound_strict_rendering(bool))); + menuSound->addAction(actionSoundStrictRendering); + menuOutput_Frequency = new QMenu(menuSound); menuOutput_Frequency->setObjectName(QString::fromUtf8("menuOutput_Frequency")); menuSound->addAction(menuOutput_Frequency->menuAction()); menuSound->addSeparator(); - + if(using_flags->is_datarec_sound()) { actionSoundCMT = new Action_Control(this, using_flags); actionSoundCMT->setObjectName(QString::fromUtf8("actionSoundCMT")); @@ -189,6 +203,8 @@ void Ui_MainWindowBase::retranslateSoundMenu(void) if(using_flags->is_datarec_sound()) { actionSoundCMT->setText(QApplication::translate("MainWindow", "Sound CMT", 0)); } + actionSoundStrictRendering->setText(QApplication::translate("MainWindow", "Strict Rendering", 0)); + menuSound->setTitle(QApplication::translate("MainWindow", "Sound", 0)); menuOutput_Frequency->setTitle(QApplication::translate("MainWindow", "Output Frequency", 0)); menuSound_Latency->setTitle(QApplication::translate("MainWindow", "Sound Latency", 0)); diff --git a/source/src/vm/event.cpp b/source/src/vm/event.cpp index 54061b1fe..503d6ef98 100644 --- a/source/src/vm/event.cpp +++ b/source/src/vm/event.cpp @@ -417,7 +417,6 @@ double EVENT::get_event_remaining_usec(int register_id) void EVENT::event_callback(int event_id, int err) { - //if(event_id == EVENT_MIX) { // mix sound if(prev_skip && dont_skip_frames == 0 && !sound_changed) { buffer_ptr = 0; @@ -425,6 +424,14 @@ void EVENT::event_callback(int event_id, int err) if(sound_tmp_samples - buffer_ptr > 0) { int t_s = mix_counter; if(t_s >= (sound_tmp_samples - buffer_ptr)) t_s = sound_tmp_samples - buffer_ptr - 1; + if(config.sound_strict_rendering) { + if(t_s <= 1) { + mix_sound(1); + mix_counter = 1; + sound_touched = false; + return; + } + } if((need_mix > 0) || (mix_counter >= mix_limit) || sound_touched) { if(t_s > 0) { mix_sound(t_s); @@ -435,10 +442,7 @@ void EVENT::event_callback(int event_id, int err) } else { mix_counter++; } - //sound_touched = false; - //mix_sound(1); } - //} } void EVENT::mix_sound(int samples) diff --git a/source/src/vm/msx/msx.cpp b/source/src/vm/msx/msx.cpp index ab27cd457..6c866ec52 100644 --- a/source/src/vm/msx/msx.cpp +++ b/source/src/vm/msx/msx.cpp @@ -148,15 +148,12 @@ VM::VM(EMU* parent_emu) : emu(parent_emu) psg->set_context_port_b(joystick, SIG_JOYSTICK_SEL, 0x40, 0); vdp->set_context_irq(cpu, SIG_CPU_IRQ, 1); - // Sound:: Force realtime rendering. This is temporally fix. 20161024 K.O - pcm->set_realtime_render(true); #if defined(_PX7) pio->set_context_port_c(slot2, SIG_SLOT2_MUTE, 0x10, 0); ldp->set_context_exv(slot2, SIG_SLOT2_EXV, 1); ldp->set_context_ack(slot2, SIG_SLOT2_ACK, 1); ldp->set_context_sound(psg, SIG_YM2203_PORT_A, 0x80); #endif - joystick->set_context_psg(psg); // keyboard->set_context_cpu(cpu); keyboard->set_context_pio(pio); -- 2.11.0