diff options
Diffstat (limited to 'src/devices/sound/vgm_visualizer.h')
-rw-r--r-- | src/devices/sound/vgm_visualizer.h | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/devices/sound/vgm_visualizer.h b/src/devices/sound/vgm_visualizer.h index 7e782a59bcc..af713384e82 100644 --- a/src/devices/sound/vgm_visualizer.h +++ b/src/devices/sound/vgm_visualizer.h @@ -46,8 +46,29 @@ public: vgmviz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); virtual ~vgmviz_device(); + void cycle_viz_mode(); + void toggle_normalize(); + protected: - static constexpr int FFT_LENGTH = 1024; + enum viz_mode : int + { + VIZ_WAVEFORM, + VIZ_WATERFALL, + VIZ_SPEC_START, + VIZ_RAWSPEC = VIZ_SPEC_START, + VIZ_BARSPEC4, + VIZ_BARSPEC8, + VIZ_BARSPEC16, + VIZ_SPEC_END = VIZ_BARSPEC16, + + VIZ_COUNT + }; + + static constexpr int FFT_LENGTH = 512; + static constexpr int BUF_LENGTH = FFT_LENGTH; + static constexpr int SCREEN_WIDTH = FFT_LENGTH / 2; + static constexpr int SCREEN_HEIGHT = 768; + static constexpr size_t NORMALIZE_BUF_SIZE = 131072; // device-level overrides virtual void device_add_mconfig(machine_config &config) override; @@ -57,9 +78,15 @@ protected: // device_sound_interface-level overrides void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; + void update_waveform(stream_sample_t **outputs); + void update_fft(stream_sample_t **outputs); + void init_palette(palette_device &palette) const; uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void draw_waveform(bitmap_rgb32 &bitmap); + void draw_waterfall(bitmap_rgb32 &bitmap); + void draw_spectrogram(bitmap_rgb32 &bitmap); void fill_window(); void apply_window(uint32_t buf_index); @@ -70,6 +97,7 @@ protected: required_device<screen_device> m_screen; required_device<palette_device> m_palette; + uint32_t m_history_length; float m_audio_buf[2][2][FFT_LENGTH]; float m_fft_buf[2][FFT_LENGTH]; int m_current_rate; @@ -79,11 +107,16 @@ protected: bool m_audio_available; int m_waterfall_length; - int m_waterfall_buf[1024][256]; + int m_waterfall_buf[SCREEN_WIDTH * 2][FFT_LENGTH / 2]; + float m_curr_levels[2]; float m_curr_peaks[2]; + float m_window[FFT_LENGTH]; - float m_power; + + viz_mode m_viz_mode; + + static const bool NEEDS_FFT[VIZ_COUNT]; }; #endif // MAME_SOUND_VGMVIZ_H |