diff options
Diffstat (limited to 'src/devices/sound/spu.h')
-rw-r--r-- | src/devices/sound/spu.h | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/src/devices/sound/spu.h b/src/devices/sound/spu.h index 1f9af3d5ca6..ff51c9c378d 100644 --- a/src/devices/sound/spu.h +++ b/src/devices/sound/spu.h @@ -7,7 +7,7 @@ // ======================> spu_device -class stream_buffer; +class spu_stream_buffer; class psxcpu_device; class spu_device : public device_t, public device_sound_interface @@ -25,37 +25,37 @@ class spu_device : public device_t, public device_sound_interface dirtyflag_irq=0x04000000 }; + sound_stream_flags m_stream_flags; + protected: - static constexpr unsigned int spu_base_frequency_hz=44100; class reverb; // device-level overrides - virtual void device_start() override; - virtual void device_reset() override; + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; virtual void device_post_load() override; - virtual void device_stop() override; + virtual void device_stop() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; + virtual void sound_stream_update(sound_stream &stream) override; - static constexpr float ms_to_rate(float ms) { return 1.0f / (ms * (float(spu_base_frequency_hz) / 1000.0f)); } - static constexpr float s_to_rate(float s) { return ms_to_rate(s * 1000.0f); } - static const float linear_rate[]; - static const float pos_exp_rate[]; - static const float neg_exp_rate[]; - static const float decay_rate[]; - static const float linear_release_rate[]; - static const float exp_release_rate[]; + float spu_base_frequency_hz; + float linear_rate[108]; + float pos_exp_rate[100]; + float neg_exp_rate[108]; + float decay_rate[16]; + float linear_release_rate[27]; + float exp_release_rate[27]; // internal state devcb_write_line m_irq_handler; - unsigned char *spu_ram; + std::unique_ptr<unsigned char []> spu_ram; reverb *rev; unsigned int taddr; unsigned int sample_t; - stream_buffer *xa_buffer; - stream_buffer *cdda_buffer; + spu_stream_buffer *xa_buffer; + spu_stream_buffer *cdda_buffer; unsigned int xa_cnt; unsigned int cdda_cnt; unsigned int xa_freq; @@ -73,13 +73,13 @@ protected: bool status_enabled, xa_playing, cdda_playing; int xa_voll, xa_volr, changed_xa_vol; voiceinfo *voice; - sample_cache **cache; + std::unique_ptr<sample_cache * []> cache; float samples_per_frame; float samples_per_cycle; static float freq_multiplier; - unsigned char *output_buf[4]; + std::unique_ptr<unsigned char []> output_buf[4]; unsigned int output_head; unsigned int output_tail; unsigned int output_size; @@ -145,6 +145,9 @@ protected: static reverb_preset reverb_presets[]; static reverb_params *spu_reverb_cfg; + float ms_to_rate(float ms) const { return 1.0f / (ms * (spu_base_frequency_hz / 1000.0f)); } + float s_to_rate(float s) const { return ms_to_rate(s * 1000.0f); } + void key_on(const int v); void key_off(const int v); bool update_envelope(const int v); @@ -187,17 +190,25 @@ protected: void write_cache_pointer(outfile *fout, cache_pointer *cp, sample_loop_cache *lc=nullptr); void read_cache_pointer(infile *fin, cache_pointer *cp, sample_loop_cache **lc=nullptr); #endif - static float get_linear_rate(const int n); - static float get_linear_rate_neg_phase(const int n); - static float get_pos_exp_rate(const int n); - static float get_pos_exp_rate_neg_phase(const int n); - static float get_neg_exp_rate(const int n); - static float get_neg_exp_rate_neg_phase(const int n); - static float get_decay_rate(const int n); - static float get_sustain_level(const int n); - static float get_linear_release_rate(const int n); - static float get_exp_release_rate(const int n); - static reverb_preset *find_reverb_preset(const unsigned short *param); + + void generate_linear_rate_table(); + void generate_pos_exp_rate_table(); + void generate_neg_exp_rate_table(); + void generate_decay_rate_table(); + void generate_linear_release_rate_table(); + void generate_exp_release_rate_table(); + + float get_linear_rate(const int n); + float get_linear_rate_neg_phase(const int n); + float get_pos_exp_rate(const int n); + float get_pos_exp_rate_neg_phase(const int n); + float get_neg_exp_rate(const int n); + float get_neg_exp_rate_neg_phase(const int n); + float get_decay_rate(const int n); + float get_sustain_level(const int n); + float get_linear_release_rate(const int n); + float get_exp_release_rate(const int n); + reverb_preset *find_reverb_preset(const unsigned short *param); public: spu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, psxcpu_device *cpu); @@ -205,6 +216,7 @@ public: // configuration helpers auto irq_handler() { return m_irq_handler.bind(); } + void set_stream_flags(sound_stream_flags flags) { m_stream_flags = flags; } void dma_read( uint32_t *ram, uint32_t n_address, int32_t n_size ); void dma_write( uint32_t *ram, uint32_t n_address, int32_t n_size ); @@ -218,8 +230,8 @@ public: void flush_xa(const unsigned int sector=0); void flush_cdda(const unsigned int sector=0); - DECLARE_READ16_MEMBER( read ); - DECLARE_WRITE16_MEMBER( write ); + uint16_t read(offs_t offset); + void write(offs_t offset, uint16_t data); }; // device type definition |