diff options
Diffstat (limited to 'src/emu/sound.cpp')
-rw-r--r-- | src/emu/sound.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index 1d0d3d753b8..a393fcefb46 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -844,7 +844,8 @@ void sound_manager::after_devices_init() m_record_buffer.resize(m_outputs_count * machine().sample_rate(), 0); m_record_samples = 0; - // Resamplers will be created at config load time + // Create resamplers and setup history + rebuild_all_resamplers(); m_effects_done = false; @@ -858,7 +859,7 @@ void sound_manager::after_devices_init() void sound_manager::input_get(int id, sound_stream &stream) { u32 samples = stream.samples(); - u64 end_pos = stream.sample_index(); + u64 end_pos = stream.end_index(); u32 skip = stream.output_count(); for(const auto &step : m_microphones[id].m_input_mixing_steps) { @@ -1114,7 +1115,6 @@ void sound_manager::config_load(config_type cfg_type, config_level cfg_level, ut break; case config_type::DEFAULT: { - fprintf(stderr, "loading resampler config\n"); // In the global config, get the default effect chain configuration util::xml::data_node const *efl_node = parentnode->get_child("default_audio_effects"); @@ -1130,11 +1130,12 @@ void sound_manager::config_load(config_type cfg_type, config_level cfg_level, ut // and the resampler configuration util::xml::data_node const *rs_node = parentnode->get_child("resampler"); if(rs_node) { - m_resampler_type = rs_node->get_attribute_int("type", RESAMPLER_LOFI); m_resampler_hq_latency = rs_node->get_attribute_float("hq_latency", 0.0050); m_resampler_hq_length = rs_node->get_attribute_int("hq_length", 400); - m_resampler_hq_phases = rs_node->get_attribute_int("hq_phases", 200); - rebuild_all_resamplers(); + m_resampler_hq_phases = rs_node->get_attribute_int("hq_phases", 200); + + // this also applies the hq settings if resampler is hq + set_resampler_type(rs_node->get_attribute_int("type", RESAMPLER_LOFI)); } break; } @@ -1216,8 +1217,6 @@ void sound_manager::config_save(config_type cfg_type, util::xml::data_node *pare break; case config_type::DEFAULT: { - fprintf(stderr, "saving resampler config\n"); - // In the global config, save the default effect chain configuration util::xml::data_node *const efl_node = parentnode->add_child("default_audio_effects", nullptr); for(u32 ei = 0; ei != m_default_effects.size(); ei++) { @@ -2490,7 +2489,7 @@ const audio_resampler *sound_manager::get_resampler(u32 fs, u32 ft) auto i = m_resamplers.find(key); if(i != m_resamplers.end()) return i->second.get(); - fprintf(stderr, "creating %d %d (%d)\n", fs, ft, m_resampler_type); + audio_resampler *res; if(m_resampler_type == RESAMPLER_HQ) res = new audio_resampler_hq(fs, ft, m_resampler_hq_latency, m_resampler_hq_length, m_resampler_hq_phases); @@ -2508,31 +2507,39 @@ void sound_manager::rebuild_all_resamplers() stream->create_resamplers(); for(auto &stream : m_stream_list) - stream->lookup_history_sizes(); + stream->lookup_history_sizes(); } void sound_manager::set_resampler_type(u32 type) { - m_resampler_type = type; - rebuild_all_resamplers(); + if(type != m_resampler_type) { + m_resampler_type = type; + rebuild_all_resamplers(); + } } void sound_manager::set_resampler_hq_latency(double latency) { - m_resampler_hq_latency = latency; - rebuild_all_resamplers(); + if(latency != m_resampler_hq_latency) { + m_resampler_hq_latency = latency; + rebuild_all_resamplers(); + } } void sound_manager::set_resampler_hq_length(u32 length) { - m_resampler_hq_length = length; - rebuild_all_resamplers(); + if(length != m_resampler_hq_length) { + m_resampler_hq_length = length; + rebuild_all_resamplers(); + } } void sound_manager::set_resampler_hq_phases(u32 phases) { - m_resampler_hq_phases = phases; - rebuild_all_resamplers(); + if(phases != m_resampler_hq_phases) { + m_resampler_hq_phases = phases; + rebuild_all_resamplers(); + } } const char *sound_manager::resampler_type_names(u32 type) const |