diff --git a/src/devices/sound/262intf.cpp b/src/devices/sound/262intf.cpp index c4da329ecff..905d9afd8b6 100644 --- a/src/devices/sound/262intf.cpp +++ b/src/devices/sound/262intf.cpp @@ -109,6 +109,17 @@ void ymf262_device::device_reset() ymf262_reset_chip(m_chip); } +//------------------------------------------------- +// device_clock_changed - called if the clock +// changes +//------------------------------------------------- + +void ymf262_device::device_clock_changed() +{ + int rate = clock()/288; + ymf262_clock_changed(m_chip,clock(),rate); + m_stream->set_sample_rate(rate); +} READ8_MEMBER( ymf262_device::read ) { diff --git a/src/devices/sound/262intf.h b/src/devices/sound/262intf.h index 9f1575ccb01..cefaebd814c 100644 --- a/src/devices/sound/262intf.h +++ b/src/devices/sound/262intf.h @@ -26,6 +26,7 @@ protected: virtual void device_start() override; virtual void device_stop() override; virtual void device_reset() override; + virtual void device_clock_changed() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; diff --git a/src/devices/sound/ymf262.cpp b/src/devices/sound/ymf262.cpp index f69c15da9d4..666e377d5a8 100644 --- a/src/devices/sound/ymf262.cpp +++ b/src/devices/sound/ymf262.cpp @@ -1401,6 +1401,15 @@ static void OPL3_initalize(OPL3 *chip) } +static void OPL3_clock_changed(OPL3 *chip, int clock, int rate) +{ + chip->clock = clock; + chip->rate = rate; + + /* init global tables */ + OPL3_initalize(chip); +} + static inline void FM_KEYON(OPL3_SLOT *SLOT, uint32_t key_set) { if( !SLOT->key ) @@ -2360,11 +2369,7 @@ static OPL3 *OPL3Create(device_t *device, int clock, int rate, int type) chip->device = device; chip->type = type; - chip->clock = clock; - chip->rate = rate; - - /* init global tables */ - OPL3_initalize(chip); + OPL3_clock_changed(chip, clock, rate); /* reset chip */ OPL3ResetChip(chip); @@ -2531,6 +2536,11 @@ void * ymf262_init(device_t *device, int clock, int rate) return chip; } +void ymf262_clock_changed(void *chip, int clock, int rate) +{ + OPL3_clock_changed((OPL3 *)chip, clock, rate); +} + void ymf262_post_load(void *chip) { OPL3 *opl3 = (OPL3 *)chip; for (int ch=0; ch<18; ch++) { diff --git a/src/devices/sound/ymf262.h b/src/devices/sound/ymf262.h index b82a89b9724..bd1eed7cbe7 100644 --- a/src/devices/sound/ymf262.h +++ b/src/devices/sound/ymf262.h @@ -24,6 +24,7 @@ typedef void (*OPL3_UPDATEHANDLER)(device_t *device,int min_interval_us); void *ymf262_init(device_t *device, int clock, int rate); +void ymf262_clock_changed(void *chip, int clock, int rate); void ymf262_post_load(void *chip); void ymf262_shutdown(void *chip); void ymf262_reset_chip(void *chip); diff --git a/src/devices/sound/ymf278b.cpp b/src/devices/sound/ymf278b.cpp index d44f8cdaf00..e0e0dae40d2 100644 --- a/src/devices/sound/ymf278b.cpp +++ b/src/devices/sound/ymf278b.cpp @@ -777,6 +777,14 @@ READ8_MEMBER( ymf278b_device::read ) /**************************************************************************/ +//------------------------------------------------- +// device_post_load - device-specific post load +//------------------------------------------------- +void ymf278b_device::device_post_load() +{ + ymf262_post_load(m_ymf262); +} + //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- @@ -841,6 +849,17 @@ void ymf278b_device::device_stop() m_ymf262 = nullptr; } +void ymf278b_device::device_clock_changed() +{ + m_stream->set_sample_rate(clock()/768); + + // YMF262 related + + int ymf262_clock = clock() / (19/8.0); + ymf262_clock_changed(m_ymf262, ymf262_clock, ymf262_clock / 288); + m_stream_ymf262->set_sample_rate(ymf262_clock / 288); +} + void ymf278b_device::rom_bank_updated() { m_stream->update(); diff --git a/src/devices/sound/ymf278b.h b/src/devices/sound/ymf278b.h index 39456acfbe1..7b12ae322f9 100644 --- a/src/devices/sound/ymf278b.h +++ b/src/devices/sound/ymf278b.h @@ -24,9 +24,11 @@ public: protected: // device-level overrides + virtual void device_post_load() override; virtual void device_start() override; virtual void device_reset() override; virtual void device_stop() override; + virtual void device_clock_changed() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;