mirror of
https://github.com/holub/mame
synced 2025-07-02 08:39:21 +03:00
la7a1045/lmc1992/mas3507d/mea8000/mos6560/mos6581/mos7360/msm5232/multipcm: update to new stream callbacks
This commit is contained in:
parent
fdf35fe86b
commit
c9399d2377
@ -22,9 +22,6 @@ esq_5505_5510_pump_device::esq_5505_5510_pump_device(const machine_config &mconf
|
||||
, ticks_spent_processing(0)
|
||||
, samples_processed(0)
|
||||
{
|
||||
#if !PUMP_FAKE_ESP_PROCESSING && PUMP_REPLACE_ESP_PROGRAM
|
||||
e = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void esq_5505_5510_pump_device::device_start()
|
||||
|
@ -117,7 +117,7 @@ l7a1045_sound_device::l7a1045_sound_device(const machine_config &mconfig, const
|
||||
void l7a1045_sound_device::device_start()
|
||||
{
|
||||
/* Allocate the stream */
|
||||
m_stream = stream_alloc_legacy(0, 2, 66150); //clock() / 384);
|
||||
m_stream = stream_alloc(0, 2, 66150); //clock() / 384);
|
||||
|
||||
for (int voice = 0; voice < 32; voice++)
|
||||
{
|
||||
@ -143,15 +143,16 @@ void l7a1045_sound_device::device_start()
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// sound_stream_update_legacy - handle a stream update
|
||||
// sound_stream_update - handle a stream update
|
||||
//-------------------------------------------------
|
||||
|
||||
void l7a1045_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
/* Clear the buffers */
|
||||
memset(outputs[0], 0, samples*sizeof(*outputs[0]));
|
||||
memset(outputs[1], 0, samples*sizeof(*outputs[1]));
|
||||
outputs[0].fill(0);
|
||||
outputs[1].fill(0);
|
||||
|
||||
constexpr stream_buffer::sample_t sample_scale = 1.0 / (32768.0 * 512.0);
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if (m_key & (1 << i))
|
||||
@ -165,7 +166,7 @@ void l7a1045_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
|
||||
uint32_t pos = vptr->pos;
|
||||
uint32_t frac = vptr->frac;
|
||||
|
||||
for (int j = 0; j < samples; j++)
|
||||
for (int j = 0; j < outputs[0].samples(); j++)
|
||||
{
|
||||
int32_t sample;
|
||||
uint8_t data;
|
||||
@ -192,8 +193,8 @@ void l7a1045_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
|
||||
sample = ((int8_t)(data & 0xfc)) << (3 - (data & 3));
|
||||
frac += step;
|
||||
|
||||
outputs[0][j] += ((sample * vptr->l_volume) >> 9);
|
||||
outputs[1][j] += ((sample * vptr->r_volume) >> 9);
|
||||
outputs[0].add(j, stream_buffer::sample_t(sample * vptr->l_volume) * sample_scale);
|
||||
outputs[1].add(j, stream_buffer::sample_t(sample * vptr->r_volume) * sample_scale);
|
||||
}
|
||||
|
||||
vptr->pos = pos;
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
virtual void device_start() override;
|
||||
|
||||
// sound stream update overrides
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
private:
|
||||
struct l7a1045_voice
|
||||
|
@ -175,7 +175,7 @@ void lmc1992_device::device_start()
|
||||
// our sound stream
|
||||
//-------------------------------------------------
|
||||
|
||||
void lmc1992_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void lmc1992_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ protected:
|
||||
virtual void device_start() override;
|
||||
|
||||
// internal callbacks
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
private:
|
||||
inline void execute_command(int addr, int data);
|
||||
|
@ -29,7 +29,7 @@ mas3507d_device::mas3507d_device(const machine_config &mconfig, const char *tag,
|
||||
void mas3507d_device::device_start()
|
||||
{
|
||||
current_rate = 44100;
|
||||
stream = stream_alloc_legacy(0, 2, current_rate);
|
||||
stream = stream_alloc(0, 2, current_rate);
|
||||
cb_sample.resolve();
|
||||
}
|
||||
|
||||
@ -359,27 +359,25 @@ void mas3507d_device::fill_buffer()
|
||||
}
|
||||
}
|
||||
|
||||
void mas3507d_device::append_buffer(stream_sample_t * const *outputs, int &pos, int scount)
|
||||
void mas3507d_device::append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount)
|
||||
{
|
||||
if(!sample_count)
|
||||
return;
|
||||
|
||||
buffered_frame_count = scount;
|
||||
|
||||
int s1 = scount - pos;
|
||||
if(s1 > sample_count)
|
||||
s1 = sample_count;
|
||||
|
||||
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
|
||||
if(mp3_info.channels == 1) {
|
||||
for(int i=0; i<s1; i++) {
|
||||
stream_sample_t v = samples[i];
|
||||
outputs[0][i+pos] = v;
|
||||
outputs[1][i+pos] = v;
|
||||
stream_buffer::sample_t v = stream_buffer::sample_t(samples[i]) * sample_scale;
|
||||
outputs[0].put(i+pos, v);
|
||||
outputs[1].put(i+pos, v);
|
||||
}
|
||||
} else {
|
||||
for(int i=0; i<s1; i++) {
|
||||
outputs[0][i+pos] = samples[i*2];
|
||||
outputs[1][i+pos] = samples[i*2+1];
|
||||
outputs[0].put(i+pos, stream_buffer::sample_t(samples[i*2]) * sample_scale);
|
||||
outputs[1].put(i+pos, stream_buffer::sample_t(samples[i*2+1]) * sample_scale);
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,8 +398,9 @@ void mas3507d_device::append_buffer(stream_sample_t * const *outputs, int &pos,
|
||||
total_frame_count += s1;
|
||||
}
|
||||
|
||||
void mas3507d_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int csamples)
|
||||
void mas3507d_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
int csamples = outputs[0].samples();
|
||||
int pos = 0;
|
||||
|
||||
append_buffer(outputs, pos, csamples);
|
||||
@ -419,10 +418,8 @@ void mas3507d_device::sound_stream_update_legacy(sound_stream &stream, stream_sa
|
||||
total_frame_count = 0;
|
||||
buffered_frame_count = 0;
|
||||
|
||||
for(int i=pos; i != csamples; i++) {
|
||||
outputs[0][i] = 0;
|
||||
outputs[1][i] = 0;
|
||||
}
|
||||
outputs[0].fill(0, pos);
|
||||
outputs[1].fill(0, pos);
|
||||
return;
|
||||
}
|
||||
append_buffer(outputs, pos, csamples);
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
private:
|
||||
devcb_read16 cb_sample;
|
||||
@ -63,7 +63,7 @@ private:
|
||||
void reg_write(uint32_t adr, uint32_t val);
|
||||
|
||||
void fill_buffer();
|
||||
void append_buffer(stream_sample_t * const *outputs, int &pos, int samples);
|
||||
void append_buffer(std::vector<write_stream_view> &outputs, int &pos, int samples);
|
||||
};
|
||||
|
||||
|
||||
|
@ -134,7 +134,7 @@ void mea8000_device::device_start()
|
||||
|
||||
init_tables();
|
||||
|
||||
m_stream = stream_alloc_legacy(0, 1, clock() / 60);
|
||||
m_stream = stream_alloc(0, 1, clock() / 60);
|
||||
save_item(NAME(m_output));
|
||||
|
||||
m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mea8000_device::timer_expire),this));
|
||||
@ -422,12 +422,9 @@ void mea8000_device::stop_frame()
|
||||
|
||||
|
||||
|
||||
void mea8000_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void mea8000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
for (int samp = 0; samp < samples; samp++)
|
||||
{
|
||||
outputs[0][samp] = m_output;
|
||||
}
|
||||
outputs[0].fill(stream_buffer::sample_t(m_output) * (1.0 / 32768.0));
|
||||
}
|
||||
|
||||
/* next sample in frame, sampling at 64 kHz */
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
private:
|
||||
/* filter coefficients from frequencies */
|
||||
@ -111,7 +111,7 @@ private:
|
||||
|
||||
emu_timer *m_timer = nullptr;
|
||||
sound_stream * m_stream = nullptr;
|
||||
stream_sample_t m_output = 0;
|
||||
int32_t m_output = 0;
|
||||
|
||||
int m_cos_table[TABLE_LEN]; /* fm => cos coefficient */
|
||||
int m_exp_table[TABLE_LEN]; /* bw => exp coefficient */
|
||||
|
@ -622,11 +622,11 @@ void mos6560_device::sound_start()
|
||||
{
|
||||
int i;
|
||||
|
||||
m_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
|
||||
m_channel = stream_alloc(0, 1, machine().sample_rate());
|
||||
|
||||
/* buffer for fastest played sample for 5 second so we have enough data for min 5 second */
|
||||
m_noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC;
|
||||
m_noise = std::make_unique<int8_t[]>(m_noisesize);
|
||||
m_noise.resize(m_noisesize);
|
||||
{
|
||||
int noiseshift = 0x7ffff8;
|
||||
char data;
|
||||
@ -661,17 +661,13 @@ void mos6560_device::sound_start()
|
||||
|
||||
if (m_tonesize > 0)
|
||||
{
|
||||
m_tone = std::make_unique<int16_t[]>(m_tonesize);
|
||||
m_tone.resize(m_tonesize);
|
||||
|
||||
for (i = 0; i < m_tonesize; i++)
|
||||
{
|
||||
m_tone[i] = (int16_t)(sin (2 * M_PI * i / m_tonesize) * 127 + 0.5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tone = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -891,12 +887,13 @@ void mos6560_device::device_timer(emu_timer &timer, device_timer_id id, int para
|
||||
// sound_stream_update_legacy - handle a stream update
|
||||
//-------------------------------------------------
|
||||
|
||||
void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
int i, v;
|
||||
stream_sample_t *buffer = outputs[0];
|
||||
auto &buffer = outputs[0];
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
constexpr stream_buffer::sample_t sample_scale = 1.0 / 8192.0;
|
||||
for (i = 0; i < buffer.samples(); i++)
|
||||
{
|
||||
v = 0;
|
||||
if (TONE1_ON /*||(m_tone1pos != 0) */ )
|
||||
@ -909,7 +906,7 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
if (m_tone1pos >= m_tone1samples)
|
||||
{
|
||||
m_tone1pos = 0;
|
||||
m_tone1samples = machine().sample_rate() / TONE1_FREQUENCY;
|
||||
m_tone1samples = buffer.sample_rate() / TONE1_FREQUENCY;
|
||||
if (m_tone1samples == 0)
|
||||
m_tone1samples = 1;
|
||||
}
|
||||
@ -925,7 +922,7 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
if (m_tone2pos >= m_tone2samples)
|
||||
{
|
||||
m_tone2pos = 0;
|
||||
m_tone2samples = machine().sample_rate() / TONE2_FREQUENCY;
|
||||
m_tone2samples = buffer.sample_rate() / TONE2_FREQUENCY;
|
||||
if (m_tone2samples == 0)
|
||||
m_tone2samples = 1;
|
||||
}
|
||||
@ -941,7 +938,7 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
if (m_tone3pos >= m_tone3samples)
|
||||
{
|
||||
m_tone3pos = 0;
|
||||
m_tone3samples = machine().sample_rate() / TONE3_FREQUENCY;
|
||||
m_tone3samples = buffer.sample_rate() / TONE3_FREQUENCY;
|
||||
if (m_tone3samples == 0)
|
||||
m_tone3samples = 1;
|
||||
}
|
||||
@ -956,12 +953,11 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
m_noisepos = 0;
|
||||
}
|
||||
}
|
||||
v = (v * VOLUME) << 2;
|
||||
if (v > 32767)
|
||||
buffer[i] = 32767;
|
||||
else if (v < -32767)
|
||||
buffer[i] = -32767;
|
||||
else
|
||||
buffer[i] = v;
|
||||
v *= VOLUME;
|
||||
if (v > 8191)
|
||||
v = 8191;
|
||||
else if (v < -8191)
|
||||
v = -8191;
|
||||
buffer.put(i, stream_buffer::sample_t(v) * sample_scale);
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ protected:
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||
|
||||
// sound stream update overrides
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
inline uint8_t read_videoram(offs_t offset);
|
||||
inline uint8_t read_colorram(offs_t offset);
|
||||
@ -176,8 +176,8 @@ protected:
|
||||
m_noisesamples; /* count of samples to give out per tone */
|
||||
|
||||
sound_stream *m_channel;
|
||||
std::unique_ptr<int16_t[]> m_tone;
|
||||
std::unique_ptr<int8_t[]> m_noise;
|
||||
std::vector<int16_t> m_tone;
|
||||
std::vector<int8_t> m_noise;
|
||||
|
||||
emu_timer *m_line_timer;
|
||||
};
|
||||
|
@ -199,7 +199,7 @@ void mos6581_device::device_start()
|
||||
m_read_poty.resolve_safe(0xff);
|
||||
|
||||
// create sound stream
|
||||
m_stream = stream_alloc_legacy(0, 1, machine().sample_rate());
|
||||
m_stream = stream_alloc(0, 1, machine().sample_rate());
|
||||
|
||||
// initialize SID engine
|
||||
m_token->device = this;
|
||||
@ -239,9 +239,9 @@ void mos6581_device::device_post_load()
|
||||
// our sound stream
|
||||
//-------------------------------------------------
|
||||
|
||||
void mos6581_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void mos6581_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
m_token->fill_buffer(outputs[0], samples);
|
||||
m_token->fill_buffer(outputs[0]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ protected:
|
||||
virtual void device_post_load() override;
|
||||
|
||||
// device_sound_interface overrides
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
void save_state(SID6581_t *token);
|
||||
private:
|
||||
|
@ -297,7 +297,7 @@ void mos7360_device::device_start()
|
||||
screen().register_screen_bitmap(m_bitmap);
|
||||
|
||||
// create sound stream
|
||||
m_stream = stream_alloc_legacy(0, 1, machine().sample_rate());
|
||||
m_stream = stream_alloc(0, 1, machine().sample_rate());
|
||||
|
||||
// buffer for fastest played sample for 5 second so we have enough data for min 5 second
|
||||
m_noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC;
|
||||
@ -454,16 +454,17 @@ void mos7360_device::device_timer(emu_timer &timer, device_timer_id id, int para
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// sound_stream_update_legacy - handle update requests for
|
||||
// sound_stream_update - handle update requests for
|
||||
// our sound stream
|
||||
//-------------------------------------------------
|
||||
|
||||
void mos7360_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void mos7360_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
int i, v, a;
|
||||
stream_sample_t *buffer = outputs[0];
|
||||
auto &buffer = outputs[0];
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
|
||||
for (i = 0; i < buffer.samples(); i++)
|
||||
{
|
||||
v = 0;
|
||||
|
||||
@ -506,7 +507,7 @@ void mos7360_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
|
||||
v = v * a;
|
||||
|
||||
buffer[i] = v;
|
||||
buffer.put(i, stream_buffer::sample_t(v) * sample_scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ protected:
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||
|
||||
// device_sound_interface callbacks
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
inline void set_interrupt(int mask);
|
||||
inline void clear_interrupt(int mask);
|
||||
|
@ -34,7 +34,7 @@ void msm5232_device::device_start()
|
||||
|
||||
init(clock(), rate);
|
||||
|
||||
m_stream = stream_alloc_legacy(0, 11, rate);
|
||||
m_stream = stream_alloc(0, 11, rate);
|
||||
|
||||
/* register with the save state system */
|
||||
save_item(NAME(m_EN_out16));
|
||||
@ -725,34 +725,35 @@ void msm5232_device::set_clock(int clock)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// sound_stream_update_legacy - handle a stream update
|
||||
// sound_stream_update - handle a stream update
|
||||
//-------------------------------------------------
|
||||
|
||||
void msm5232_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
|
||||
void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
stream_sample_t *buf1 = outputs[0];
|
||||
stream_sample_t *buf2 = outputs[1];
|
||||
stream_sample_t *buf3 = outputs[2];
|
||||
stream_sample_t *buf4 = outputs[3];
|
||||
stream_sample_t *buf5 = outputs[4];
|
||||
stream_sample_t *buf6 = outputs[5];
|
||||
stream_sample_t *buf7 = outputs[6];
|
||||
stream_sample_t *buf8 = outputs[7];
|
||||
stream_sample_t *bufsolo1 = outputs[8];
|
||||
stream_sample_t *bufsolo2 = outputs[9];
|
||||
stream_sample_t *bufnoise = outputs[10];
|
||||
auto &buf1 = outputs[0];
|
||||
auto &buf2 = outputs[1];
|
||||
auto &buf3 = outputs[2];
|
||||
auto &buf4 = outputs[3];
|
||||
auto &buf5 = outputs[4];
|
||||
auto &buf6 = outputs[5];
|
||||
auto &buf7 = outputs[6];
|
||||
auto &buf8 = outputs[7];
|
||||
auto &bufsolo1 = outputs[8];
|
||||
auto &bufsolo2 = outputs[9];
|
||||
auto &bufnoise = outputs[10];
|
||||
int i;
|
||||
|
||||
for (i=0; i<samples; i++)
|
||||
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
|
||||
for (i=0; i<buf1.samples(); i++)
|
||||
{
|
||||
/* calculate all voices' envelopes */
|
||||
EG_voices_advance();
|
||||
|
||||
TG_group_advance(0); /* calculate tones group 1 */
|
||||
buf1[i] = o2;
|
||||
buf2[i] = o4;
|
||||
buf3[i] = o8;
|
||||
buf4[i] = o16;
|
||||
buf1.put(i, stream_buffer::sample_t(o2) * sample_scale);
|
||||
buf2.put(i, stream_buffer::sample_t(o4) * sample_scale);
|
||||
buf3.put(i, stream_buffer::sample_t(o8) * sample_scale);
|
||||
buf4.put(i, stream_buffer::sample_t(o16) * sample_scale);
|
||||
|
||||
SAVE_SINGLE_CHANNEL(0,o2)
|
||||
SAVE_SINGLE_CHANNEL(1,o4)
|
||||
@ -760,13 +761,13 @@ void msm5232_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
SAVE_SINGLE_CHANNEL(3,o16)
|
||||
|
||||
TG_group_advance(1); /* calculate tones group 2 */
|
||||
buf5[i] = o2;
|
||||
buf6[i] = o4;
|
||||
buf7[i] = o8;
|
||||
buf8[i] = o16;
|
||||
buf5.put(i, stream_buffer::sample_t(o2) * sample_scale);
|
||||
buf6.put(i, stream_buffer::sample_t(o4) * sample_scale);
|
||||
buf7.put(i, stream_buffer::sample_t(o8) * sample_scale);
|
||||
buf8.put(i, stream_buffer::sample_t(o16) * sample_scale);
|
||||
|
||||
bufsolo1[i] = solo8;
|
||||
bufsolo2[i] = solo16;
|
||||
bufsolo1.put(i, stream_buffer::sample_t(solo8) * sample_scale);
|
||||
bufsolo2.put(i, stream_buffer::sample_t(solo16) * sample_scale);
|
||||
|
||||
SAVE_SINGLE_CHANNEL(4,o2)
|
||||
SAVE_SINGLE_CHANNEL(5,o4)
|
||||
@ -794,6 +795,6 @@ void msm5232_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
|
||||
}
|
||||
}
|
||||
|
||||
bufnoise[i] = (m_noise_rng & (1<<16)) ? 32767 : 0;
|
||||
bufnoise.put(i, (m_noise_rng & (1<<16)) ? 1.0 : 0.0);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ protected:
|
||||
virtual void device_post_load() override;
|
||||
|
||||
// sound stream update overrides
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
private:
|
||||
struct VOICE {
|
||||
|
@ -479,7 +479,7 @@ void multipcm_device::device_start()
|
||||
const float clock_divider = 180.0f;
|
||||
m_rate = (float)clock() / clock_divider;
|
||||
|
||||
m_stream = stream_alloc_legacy(0, 2, m_rate);
|
||||
m_stream = stream_alloc(0, 2, m_rate);
|
||||
|
||||
// Volume + pan table
|
||||
m_left_pan_table = make_unique_clear<int32_t[]>(0x800);
|
||||
@ -628,20 +628,21 @@ void multipcm_device::device_clock_changed()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// clamp_to_int16 - clamp a 32-bit value to 16 bits
|
||||
// convert_to_stream_sample - clamp a 32-bit value to
|
||||
// 16 bits and convert to a stream_buffer::sample_t
|
||||
//-----------------------------------------------------
|
||||
|
||||
int16_t multipcm_device::clamp_to_int16(int32_t value)
|
||||
stream_buffer::sample_t multipcm_device::convert_to_stream_sample(int32_t value)
|
||||
{
|
||||
if (value < -32768)
|
||||
{
|
||||
return -32768;
|
||||
return -1.0;
|
||||
}
|
||||
else if (value > 32767)
|
||||
{
|
||||
return 32767;
|
||||
return 1.0;
|
||||
}
|
||||
return (int16_t)value;
|
||||
return stream_buffer::sample_t(value) * (1.0 / 32768.0);
|
||||
}
|
||||
|
||||
#if MULTIPCM_LOG_SAMPLES
|
||||
@ -677,20 +678,12 @@ void multipcm_device::dump_sample(slot_t &slot)
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------
|
||||
// sound_stream_update_legacy - handle a stream update
|
||||
// sound_stream_update - handle a stream update
|
||||
//-------------------------------------------------
|
||||
|
||||
void multipcm_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int32_t samples)
|
||||
void multipcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
|
||||
{
|
||||
stream_sample_t *datap[2];
|
||||
|
||||
datap[0] = outputs[0];
|
||||
datap[1] = outputs[1];
|
||||
|
||||
memset(datap[0], 0, sizeof(*datap[0]) * samples);
|
||||
memset(datap[1], 0, sizeof(*datap[1]) * samples);
|
||||
|
||||
for (int32_t i = 0; i < samples; ++i)
|
||||
for (int32_t i = 0; i < outputs[0].samples(); ++i)
|
||||
{
|
||||
int32_t smpl = 0;
|
||||
int32_t smpr = 0;
|
||||
@ -741,8 +734,8 @@ void multipcm_device::sound_stream_update_legacy(sound_stream &stream, stream_sa
|
||||
}
|
||||
}
|
||||
|
||||
datap[0][i] = clamp_to_int16(smpl);
|
||||
datap[1][i] = clamp_to_int16(smpr);
|
||||
outputs[0].put(i, convert_to_stream_sample(smpl));
|
||||
outputs[1].put(i, convert_to_stream_sample(smpr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ protected:
|
||||
virtual void device_clock_changed() override;
|
||||
|
||||
// sound stream update overrides
|
||||
virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
|
||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||
|
||||
// device_rom_interface overrides
|
||||
virtual void rom_bank_updated() override;
|
||||
@ -135,7 +135,7 @@ private:
|
||||
|
||||
void write_slot(slot_t &slot, int32_t reg, uint8_t data);
|
||||
|
||||
int16_t clamp_to_int16(int32_t value);
|
||||
stream_buffer::sample_t convert_to_stream_sample(int32_t value);
|
||||
|
||||
#if MULTIPCM_LOG_SAMPLES
|
||||
void dump_sample(slot_t &slot);
|
||||
|
@ -29,34 +29,10 @@ float filterResTable[16];
|
||||
|
||||
#define maxLogicalVoices 4
|
||||
|
||||
const int mix16monoMiddleIndex = 256*maxLogicalVoices/2;
|
||||
uint16_t mix16mono[256*maxLogicalVoices];
|
||||
|
||||
uint16_t zero16bit = 0; /* either signed or unsigned */
|
||||
//uint32_t splitBufferLen;
|
||||
|
||||
void MixerInit(int threeVoiceAmplify)
|
||||
inline stream_buffer::sample_t mix_mono(uint16_t usum)
|
||||
{
|
||||
long si;
|
||||
uint16_t ui;
|
||||
long ampDiv = maxLogicalVoices;
|
||||
|
||||
if (threeVoiceAmplify)
|
||||
{
|
||||
ampDiv = (maxLogicalVoices-1);
|
||||
}
|
||||
|
||||
/* Mixing formulas are optimized by sample input value. */
|
||||
|
||||
si = (-128*maxLogicalVoices) * 256;
|
||||
for (ui = 0; ui < sizeof(mix16mono)/sizeof(uint16_t); ui++)
|
||||
{
|
||||
mix16mono[ui] = (uint16_t)(si/ampDiv) + zero16bit;
|
||||
si+=256;
|
||||
}
|
||||
|
||||
return stream_buffer::sample_t(int16_t(usum - maxLogicalVoices*128)) * (1.0 / (256 * maxLogicalVoices));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
@ -85,22 +61,22 @@ inline void SID6581_t::syncEm()
|
||||
}
|
||||
|
||||
|
||||
void SID6581_t::fill_buffer(stream_sample_t *buffer, uint32_t bufferLen)
|
||||
void SID6581_t::fill_buffer(write_stream_view &buffer)
|
||||
{
|
||||
//void* SID6581_t::fill16bitMono(void* buffer, uint32_t numberOfSamples)
|
||||
|
||||
for (; bufferLen > 0; bufferLen--)
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
{
|
||||
*buffer++ = (int16_t) mix16mono[unsigned(mix16monoMiddleIndex
|
||||
+(*optr[0].outProc)(&optr[0])
|
||||
buffer.put(sampindex, mix_mono(
|
||||
(*optr[0].outProc)(&optr[0])
|
||||
+(*optr[1].outProc)(&optr[1])
|
||||
+(optr[2].outProc(&optr[2])&optr3_outputmask)
|
||||
+((*optr[2].outProc)(&optr[2])&optr3_outputmask)
|
||||
/* hack for digi sounds
|
||||
does n't seam to come from a tone operator
|
||||
ghostbusters and goldrunner everything except volume zeroed */
|
||||
+(masterVolume<<2)
|
||||
// +(*sampleEmuRout)()
|
||||
)];
|
||||
));
|
||||
syncEm();
|
||||
}
|
||||
}
|
||||
@ -227,8 +203,6 @@ void SID6581_t::init()
|
||||
|
||||
enveEmuInit(PCMfreq, true);
|
||||
|
||||
MixerInit(0);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ struct SID6581_t
|
||||
int port_r(running_machine &machine, int offset);
|
||||
void port_w(int offset, int data);
|
||||
|
||||
void fill_buffer(stream_sample_t *buffer, uint32_t bufferLen);
|
||||
void fill_buffer(write_stream_view &buffer);
|
||||
|
||||
private:
|
||||
void syncEm();
|
||||
|
Loading…
Reference in New Issue
Block a user