Skip to content

Commit

Permalink
funtech/umc6619_sound.cpp: add live audio view debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
angelosa committed Sep 10, 2024
1 parent e7b5dac commit 55de7f0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/mame/funtech/umc6619_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define VERBOSE (0)
#include "logmacro.h"

#define LIVE_AUDIO_VIEW 0

// device type definition
DEFINE_DEVICE_TYPE(UMC6619_SOUND, umc6619_sound_device, "umc6619_sound", "UMC UM6619 Sound Engine")

Expand Down Expand Up @@ -53,6 +55,7 @@ void umc6619_sound_device::device_start()
save_item(STRUCT_MEMBER(m_channels, volume_l));
save_item(STRUCT_MEMBER(m_channels, volume_r));
save_item(STRUCT_MEMBER(m_channels, one_shot));
save_item(STRUCT_MEMBER(m_channels, unk_upper_05));
save_item(NAME(m_regs));
}

Expand All @@ -64,7 +67,20 @@ void umc6619_sound_device::device_reset()

for (auto &channel : m_channels)
{
channel.pitch = 0;
channel.length = 0;
channel.start_addr = 0;
channel.curr_addr = 0;
channel.end_addr = 0;
channel.addr_increment = 0;
channel.frac = 0;
channel.register9 = 0;
std::fill(std::begin(channel.envelope), std::end(channel.envelope), 0);
channel.volume = 0;
channel.volume_l = 0;
channel.volume_r = 0;
channel.one_shot = false;
channel.unk_upper_05 = 0;
}

m_timer->reset();
Expand All @@ -84,10 +100,45 @@ TIMER_CALLBACK_MEMBER(umc6619_sound_device::channel_irq)
}
}

std::string umc6619_sound_device::print_audio_state()
{
std::ostringstream outbuffer;

util::stream_format(outbuffer, "channel | address | length | pitch | one? | vol | DMA? | (unk09) |\n");

for (int i = 0; i < 16; i++)
{
acan_channel &channel = m_channels[i];

util::stream_format(outbuffer, "%02d: %01d | %04x (%04x-%04x) | %04x | %04x | %d (%02x)| %02x | %02x | %02x %02x %02x %02x|\n"
, i
, BIT(m_active_channels, i)
, channel.curr_addr
, (channel.start_addr << 6) & 0xffff
, channel.end_addr
, channel.length
, channel.pitch
, channel.one_shot
, channel.unk_upper_05
, channel.volume
, channel.register9
, channel.envelope[0]
, channel.envelope[1]
, channel.envelope[2]
, channel.envelope[3]
);
}

return outbuffer.str();
}

void umc6619_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
std::fill_n(&m_mix[0], outputs[0].samples() * 2, 0);

if (LIVE_AUDIO_VIEW)
popmessage(print_audio_state());

for (int i = 0; i < 16 && m_active_channels != 0; i++)
{
if (BIT(m_active_channels, i))
Expand Down Expand Up @@ -244,6 +295,7 @@ void umc6619_sound_device::write(offs_t offset, uint8_t data)
acan_channel &channel = m_channels[lower];
channel.length = 0x40 << ((data & 0x0e) >> 1);
channel.one_shot = BIT(data, 0);
channel.unk_upper_05 = data & 0xf0;
LOG("%s: Waveform length and attributes (voice %02x): %02x\n", machine().describe_context(), lower, data);
break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/mame/funtech/umc6619_sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class umc6619_sound_device : public device_t, public device_sound_interface
uint8_t volume_l;
uint8_t volume_r;
bool one_shot;
uint8_t unk_upper_05;
};

void keyon_voice(uint8_t voice);
Expand All @@ -63,6 +64,8 @@ class umc6619_sound_device : public device_t, public device_sound_interface
acan_channel m_channels[16];
uint8_t m_regs[256];
std::unique_ptr<int32_t[]> m_mix;

std::string print_audio_state();
};

DECLARE_DEVICE_TYPE(UMC6619_SOUND, umc6619_sound_device)
Expand Down

0 comments on commit 55de7f0

Please sign in to comment.