1 // license:BSD-3-Clause 2 // copyright-holders:Richard Davies 3 #ifndef MAME_AUDIO_PHOENIX_H 4 #define MAME_AUDIO_PHOENIX_H 5 6 #pragma once 7 8 #include "sound/discrete.h" 9 #include "sound/tms36xx.h" 10 11 12 class phoenix_sound_device : public device_t, public device_sound_interface 13 { 14 public: 15 phoenix_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); 16 17 void control_a_w(uint8_t data); 18 void control_b_w(uint8_t data); 19 20 protected: 21 // device-level overrides 22 virtual void device_start() override; 23 24 // sound stream update overrides 25 virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; 26 27 private: 28 struct c_state 29 { 30 int32_t counter; 31 int32_t level; 32 }; 33 34 struct n_state 35 { 36 int32_t counter; 37 int32_t polyoffs; 38 int32_t polybit; 39 int32_t lowpass_counter; 40 int32_t lowpass_polybit; 41 }; 42 43 // internal state 44 struct c_state m_c24_state; 45 struct c_state m_c25_state; 46 struct n_state m_noise_state; 47 uint8_t m_sound_latch_a; 48 sound_stream * m_channel; 49 std::unique_ptr<uint32_t[]> m_poly18; 50 required_device<discrete_device> m_discrete; 51 required_device<tms36xx_device> m_tms; 52 53 int update_c24(int samplerate); 54 int update_c25(int samplerate); 55 int noise(int samplerate); 56 }; 57 58 DECLARE_DEVICE_TYPE(PHOENIX_SOUND, phoenix_sound_device) 59 60 DISCRETE_SOUND_EXTERN(phoenix_discrete); 61 62 #endif // MAME_AUDIO_PHOENIX_H 63