summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/vgm_visualizer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/vgm_visualizer.h')
-rw-r--r--src/devices/sound/vgm_visualizer.h41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/devices/sound/vgm_visualizer.h b/src/devices/sound/vgm_visualizer.h
index 60b54d0cde9..af713384e82 100644
--- a/src/devices/sound/vgm_visualizer.h
+++ b/src/devices/sound/vgm_visualizer.h
@@ -46,20 +46,29 @@ public:
vgmviz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
virtual ~vgmviz_device();
- void cycle_spectrogram();
+ void cycle_viz_mode();
+ void toggle_normalize();
protected:
- enum spec_mode : int
+ enum viz_mode : int
{
- SPEC_RAW,
- SPEC_BAR4,
- SPEC_BAR8,
- SPEC_BAR16,
-
- SPEC_COUNT
+ 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;
@@ -69,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);
@@ -82,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;
@@ -91,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];
- spec_mode m_spec_mode;
+
+ viz_mode m_viz_mode;
+
+ static const bool NEEDS_FFT[VIZ_COUNT];
};
#endif // MAME_SOUND_VGMVIZ_H