Fixed discrete (probably)

This commit is contained in:
Olivier Galibert 2025-04-30 16:37:52 +02:00
parent 649d5af11a
commit 4af2e3e24e
2 changed files with 6 additions and 35 deletions

View File

@ -236,14 +236,10 @@ public:
uint32_t m_stream_in_number = 0;
uint32_t m_inview_sample = 0;
private:
void stream_generate(sound_stream &stream);
double m_gain = 0.0; /* node gain */
double m_offset = 0.0; /* node offset */
uint8_t m_data = 0; /* data written */
uint8_t m_is_buffered = 0;
/* the buffer stream */
sound_stream *m_buffer_stream = nullptr;
};
class DISCRETE_CLASS_NAME(dss_input_buffer): public DISCRETE_CLASS_NAME(dss_input_stream)

View File

@ -242,16 +242,12 @@ void DISCRETE_CLASS_FUNC(dss_input_pulse, input_write)(int sub_node, uint8_t dat
#define DSS_INPUT_STREAM__GAIN DISCRETE_INPUT(1)
#define DSS_INPUT_STREAM__OFFSET DISCRETE_INPUT(2)
void discrete_dss_input_stream_node::stream_generate(sound_stream &stream)
{
stream.fill(0, m_data * (1.0 / 32768.0));
}
DISCRETE_STEP(dss_input_stream)
{
/* the context pointer is set to point to the current input stream data in discrete_stream_update */
if (EXPECTED(m_buffer_stream))
if (m_is_buffered)
{
set_output(0, m_buffer_stream->get(m_stream_in_number, m_inview_sample) * 32768.0 * m_gain + m_offset);
set_output(0, m_data * m_gain + m_offset);
m_inview_sample++;
}
else
@ -271,23 +267,14 @@ void DISCRETE_CLASS_FUNC(dss_input_stream, input_write)(int sub_node, uint8_t da
if (m_data != new_data)
{
if (m_is_buffered)
{
/* Bring the system up to now */
m_buffer_stream->update();
/* Bring the system up to now */
m_device->update_to_current_time();
m_data = new_data;
}
else
{
/* Bring the system up to now */
m_device->update_to_current_time();
m_data = new_data;
m_data = new_data;
if (!m_is_buffered)
/* Update the node output here so we don't have to do it each step */
set_output(0, new_data * m_gain + m_offset);
}
}
}
@ -301,20 +288,8 @@ DISCRETE_START(dss_input_stream)
m_offset = DSS_INPUT_STREAM__OFFSET;
m_is_buffered = is_buffered();
m_buffer_stream = nullptr;
}
void DISCRETE_CLASS_NAME(dss_input_stream)::stream_start(void)
{
if (m_is_buffered)
{
/* stream_buffered input only supported for sound devices */
discrete_sound_device *snd_device = downcast<discrete_sound_device *>(m_device);
//assert(DSS_INPUT_STREAM__STREAM < snd_device->m_input_stream_list.count());
m_buffer_stream = m_device->machine().sound().stream_alloc(*snd_device, 1, 1, this->sample_rate(), stream_update_delegate(&discrete_dss_input_stream_node::stream_generate,this), STREAM_DEFAULT_FLAGS);
// WTF?
// snd_device->get_stream()->set_input(m_stream_in_number, m_buffer_stream);
}
}