Skip to content

Commit

Permalink
Complete sound modernization of remaining devices. Legacy callbacks a…
Browse files Browse the repository at this point in the history
…nd stream_sample_t removed. (#7297)

* a2mcms/coco_ssc/gus/cassette/floppy/8364_paula/laserdsc/s2636/spg2xx_audio/arcadia/channelf/cmi01a/cps3/dai_snd: Update to new stream callbacks

* dsbz80/elan_eu3a05/exidy/exidy440/flower/geebee/gomoku/gridlee: Update to new stream callbacks

* hyprolyb/lynx/micro3d/phoenix/pleiads/polepos: Update to new sound stream callback

* redbaron/segag80r/segausb/seibu/snk6502/socrates/special/svis_snd: Update to new stream callbacks.

* tiamc1/turrett/tvc/tx1/vboy/vc4000: Update to new stream callbacks

* warpwarp/wiping/wswan/xavix/esq1/istrebiteli/milton6805/pv1000/mega32x/gic: Update to new stream callback

* sound: Remove legacy stream support and stream_sample_t

* * gomoku/wiping: Remove silly mixer tables in favor of math

* micro3d: Remove tiny vectors in favor of fixed arrays

* phoenix: Went back to std::unique_ptr array for LFSR

* wiping: Fixed the scale factor.
  • Loading branch information
aaronsgiles committed Sep 28, 2020
1 parent 52514f1 commit 7b8913f
Show file tree
Hide file tree
Showing 120 changed files with 561 additions and 856 deletions.
21 changes: 9 additions & 12 deletions src/devices/bus/a2bus/a2mcms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ mcms_device::mcms_device(const machine_config &mconfig, const char *tag, device_
void mcms_device::device_start()
{
m_write_irq.resolve();
m_stream = stream_alloc_legacy(0, 2, 31250);
m_stream = stream_alloc(0, 2, 31250);
m_timer = timer_alloc(0, nullptr);
m_clrtimer = timer_alloc(1, nullptr);
m_enabled = false;
Expand Down Expand Up @@ -252,20 +252,19 @@ void mcms_device::device_timer(emu_timer &timer, device_timer_id tid, int param,
}
}

void mcms_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
void mcms_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
stream_sample_t *outL, *outR;
int i, v;
uint16_t wptr;
int8_t sample;
int32_t mixL, mixR;

outL = outputs[1];
outR = outputs[0];
auto &outL = outputs[1];
auto &outR = outputs[0];

if (m_enabled)
{
for (i = 0; i < samples; i++)
for (i = 0; i < outL.samples(); i++)
{
mixL = mixR = 0;

Expand All @@ -286,16 +285,14 @@ void mcms_device::sound_stream_update_legacy(sound_stream &stream, stream_sample
}
}

outL[i] = (mixL * m_mastervol)>>9;
outR[i] = (mixR * m_mastervol)>>9;
outL.put_int(i, mixL * m_mastervol, 32768 << 9);
outR.put_int(i, mixR * m_mastervol, 32768 << 9);
}
}
else
{
for (i = 0; i < samples; i++)
{
outL[i] = outR[i] = 0;
}
outL.fill(0);
outR.fill(0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/devices/bus/a2bus/a2mcms.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class mcms_device : public device_t, public device_sound_interface
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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:
sound_stream *m_stream;
Expand Down
22 changes: 11 additions & 11 deletions src/devices/bus/coco/coco_ssc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace
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:
sound_stream* m_stream;
Expand Down Expand Up @@ -535,25 +535,25 @@ cocossc_sac_device::cocossc_sac_device(const machine_config &mconfig, const char

void cocossc_sac_device::device_start()
{
m_stream = stream_alloc_legacy(1, 1, machine().sample_rate());
m_stream = stream_alloc(1, 1, machine().sample_rate());
}


//-------------------------------------------------
// sound_stream_update_legacy - handle a stream update
// sound_stream_update - handle a stream update
//-------------------------------------------------

void cocossc_sac_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
stream_sample_t const *src = inputs[0];
stream_sample_t *dst = outputs[0];
auto &src = inputs[0];
auto &dst = outputs[0];

double n = samples;
double n = dst.samples();

while (samples--)
for (int sampindex = 0; sampindex < n; sampindex++)
{
m_rms[m_index] += ( (double)*src * (double)*src );
*dst++ = (*src++);
m_rms[m_index] += src.get(sampindex) * src.get(sampindex);
dst.put(sampindex, src.get(sampindex));
}

m_rms[m_index] = m_rms[m_index] / n;
Expand All @@ -576,7 +576,7 @@ bool cocossc_sac_device::sound_activity_circuit_output()

average /= 16.0;

if( average > 10400.0 )
if( average > 0.317 )
return true;

return false;
Expand Down
25 changes: 11 additions & 14 deletions src/devices/bus/isa/gus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,26 @@ void gf1_device::device_timer(emu_timer &timer, device_timer_id id, int param, v
}
}

void gf1_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
void gf1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int x,y;
int x;
//uint32_t count;

stream_sample_t* outputl = outputs[0];
stream_sample_t* outputr = outputs[1];
memset( outputl, 0x00, samples * sizeof(*outputl) );
memset( outputr, 0x00, samples * sizeof(*outputr) );
auto &outputl = outputs[0];
auto &outputr = outputs[1];

outputl.fill(0);
outputr.fill(0);

for(x=0;x<32;x++) // for each voice
{
stream_sample_t* left = outputl;
stream_sample_t* right = outputr;
uint16_t vol = (m_volume_table[(m_voice[x].current_vol & 0xfff0) >> 4]);
for(y=samples-1; y>=0; y--)
for (int sampindex = 0; sampindex < outputl.samples(); sampindex++)
{
uint32_t current = m_voice[x].current_addr >> 9;
// TODO: implement proper panning
(*left) += ((m_voice[x].sample) * (vol/8192.0));
(*right) += ((m_voice[x].sample) * (vol/8192.0));
left++;
right++;
outputl.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192);
outputr.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192);
if((!(m_voice[x].voice_ctrl & 0x40)) && (m_voice[x].current_addr >= m_voice[x].end_addr) && !m_voice[x].rollover && !(m_voice[x].voice_ctrl & 0x01))
{
if(m_voice[x].vol_ramp_ctrl & 0x04)
Expand Down Expand Up @@ -403,7 +400,7 @@ void gf1_device::device_start()
m_wave_ram.resize(1024*1024);
memset(&m_wave_ram[0], 0, 1024*1024);

m_stream = stream_alloc_legacy(0,2,clock() / (14 * 16));
m_stream = stream_alloc(0,2,clock() / (14 * 16));

// init timers
m_timer1 = timer_alloc(ADLIB_TIMER1);
Expand Down
2 changes: 1 addition & 1 deletion src/devices/bus/isa/gus.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class gf1_device :

// optional information overrides
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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;

protected:
// voice-specific registers
Expand Down
30 changes: 11 additions & 19 deletions src/devices/imagedev/cassette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void cassette_image_device::device_start()
m_state = m_default_state;
m_value = 0;

stream_alloc_legacy(0, (m_stereo? 2:1), machine().sample_rate());
stream_alloc(0, m_stereo? 2:1, machine().sample_rate());
}

image_init_result cassette_image_device::call_create(int format_type, util::option_resolution *format_options)
Expand Down Expand Up @@ -404,37 +404,29 @@ std::string cassette_image_device::call_display()
// Cassette sound
//-------------------------------------------------

void cassette_image_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
void cassette_image_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
stream_sample_t *left_buffer = outputs[0];
stream_sample_t *right_buffer = nullptr;

if (m_stereo)
right_buffer = outputs[1];

cassette_state state = get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER);

if (exists() && (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)))
{
cassette_image *cassette = get_image();
double time_index = get_position();
double duration = ((double) samples) / machine().sample_rate();
double duration = ((double) outputs[0].samples()) / outputs[0].sample_rate();

cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT);
if (m_stereo)
cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT);
if (m_samples.size() < outputs[0].samples())
m_samples.resize(outputs[0].samples());

for (int i = samples - 1; i >= 0; i--)
for (int ch = 0; ch < outputs.size(); ch++)
{
left_buffer[i] = ((int16_t *) left_buffer)[i];
if (m_stereo)
right_buffer[i] = ((int16_t *) right_buffer)[i];
cassette_get_samples(cassette, 0, time_index, duration, outputs[0].samples(), 2, &m_samples[0], CASSETTE_WAVEFORM_16BIT);
for (int sampindex = 0; sampindex < outputs[ch].samples(); sampindex++)
outputs[ch].put_int(sampindex, m_samples[sampindex], 32768);
}
}
else
{
memset(left_buffer, 0, sizeof(*left_buffer) * samples);
if (m_stereo)
memset(right_buffer, 0, sizeof(*right_buffer) * samples);
for (int ch = 0; ch < outputs.size(); ch++)
outputs[ch].fill(0);
}
}
3 changes: 2 additions & 1 deletion src/devices/imagedev/cassette.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class cassette_image_device : public device_t,
void seek(double time, int origin);

// sound stream update overrides
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_sound_interface& set_stereo() { m_stereo = true; return *this; }

protected:
Expand Down Expand Up @@ -133,6 +133,7 @@ class cassette_image_device : public device_t,

image_init_result internal_load(bool is_create);
bool m_stereo;
std::vector<s16> m_samples;
};

// device type definition
Expand Down
12 changes: 6 additions & 6 deletions src/devices/imagedev/floppy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ void floppy_sound_device::device_start()
// If we don't have all samples, don't allocate a stream or access sample data.
if (m_loaded)
{
m_sound = stream_alloc_legacy(0, 1, clock()); // per-floppy stream
m_sound = stream_alloc(0, 1, clock()); // per-floppy stream
}
register_for_save_states();
}
Expand Down Expand Up @@ -1369,21 +1369,21 @@ void floppy_sound_device::step(int zone)
}

//-------------------------------------------------
// sound_stream_update_legacy - update the sound stream
// sound_stream_update - update the sound stream
//-------------------------------------------------

void floppy_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
void floppy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// We are using only one stream, unlike the parent class
// Also, there is no need for interpolation, as we only expect
// one sample rate of 44100 for all samples

int16_t out;
stream_sample_t *samplebuffer = outputs[0];
auto &samplebuffer = outputs[0];
int idx = 0;
int sampleend = 0;

while (samples-- > 0)
for (int sampindex = 0; sampindex < samplebuffer.samples(); sampindex++)
{
out = 0;

Expand Down Expand Up @@ -1477,7 +1477,7 @@ void floppy_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
}

// Write to the stream buffer
*(samplebuffer++) = out;
samplebuffer.put_int(sampindex, out, 32768);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/devices/imagedev/floppy.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class floppy_sound_device : public samples_device

private:
// device_sound_interface overrides
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;
sound_stream* m_sound;

int m_step_base;
Expand Down
14 changes: 7 additions & 7 deletions src/devices/machine/8364_paula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void paula_8364_device::device_start()
}

// create the stream
m_stream = stream_alloc_legacy(0, 4, clock() / CLOCK_DIVIDER);
m_stream = stream_alloc(0, 4, clock() / CLOCK_DIVIDER);
}

//-------------------------------------------------
Expand Down Expand Up @@ -159,10 +159,10 @@ void paula_8364_device::dma_reload(audio_channel *chan)
}

//-------------------------------------------------
// sound_stream_update_legacy - handle a stream update
// sound_stream_update - handle a stream update
//-------------------------------------------------

void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
void paula_8364_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int channum, sampoffs = 0;

Expand All @@ -176,11 +176,11 @@ void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_

// clear the sample data to 0
for (channum = 0; channum < 4; channum++)
memset(outputs[channum], 0, sizeof(stream_sample_t) * samples);
outputs[channum].fill(0);
return;
}

samples *= CLOCK_DIVIDER;
int samples = outputs[0].samples() * CLOCK_DIVIDER;

// update the DMA states on each channel and reload if fresh
for (channum = 0; channum < 4; channum++)
Expand Down Expand Up @@ -215,7 +215,7 @@ void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_
audio_channel *chan = &m_channel[channum];
int volume = (nextvol == -1) ? chan->vol : nextvol;
int period = (nextper == -1) ? chan->per : nextper;
stream_sample_t sample;
s32 sample;
int i;

// normalize the volume value
Expand Down Expand Up @@ -247,7 +247,7 @@ void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_

// fill the buffer with the sample
for (i = 0; i < ticks; i += CLOCK_DIVIDER)
outputs[channum][(sampoffs + i) / CLOCK_DIVIDER] = sample;
outputs[channum].put_int((sampoffs + i) / CLOCK_DIVIDER, sample, 32768);

// account for the ticks; if we hit 0, advance
chan->curticks -= ticks;
Expand Down
2 changes: 1 addition & 1 deletion src/devices/machine/8364_paula.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class paula_8364_device : public device_t, public device_sound_interface
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:
enum
Expand Down
Loading

0 comments on commit 7b8913f

Please sign in to comment.