CoCo Speech/Sound Pak: fix noise on reset (#8098)

This commit is contained in:
tim lindner 2021-05-26 04:25:22 -07:00 committed by GitHub
parent 9d2a5245ff
commit e43e9b68f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 26 deletions

View File

@ -141,7 +141,7 @@ namespace
static constexpr int BUFFER_SIZE = 4; static constexpr int BUFFER_SIZE = 4;
private: private:
sound_stream* m_stream; sound_stream* m_stream;
double m_rms[BUFFER_SIZE]; float m_rms[BUFFER_SIZE];
int m_index; int m_index;
}; };
}; };
@ -237,7 +237,7 @@ void coco_ssc_device::device_start()
void coco_ssc_device::device_reset() void coco_ssc_device::device_reset()
{ {
m_reset_line = 0; m_reset_line = 1;
m_tms7000_busy = false; m_tms7000_busy = false;
} }
@ -314,7 +314,6 @@ u8 coco_ssc_device::ff7d_read(offs_t offset)
data & 0x02 ? '1' : '0', data & 0x02 ? '1' : '0',
data & 0x01 ? '1' : '0', data & 0x01 ? '1' : '0',
data ); data );
break; break;
} }
@ -338,15 +337,12 @@ void coco_ssc_device::ff7d_write(offs_t offset, u8 data)
m_spo->reset(); m_spo->reset();
} }
if( (m_reset_line & 1) == 1 ) if( ((m_reset_line & 1) == 1) && ((data & 1) == 0) )
{
if( (data & 1) == 0 )
{ {
m_tms7040->reset(); m_tms7040->reset();
m_ay->reset(); m_ay->reset();
m_tms7000_busy = false; m_tms7000_busy = false;
} }
}
m_reset_line = data; m_reset_line = data;
break; break;
@ -415,9 +411,9 @@ void coco_ssc_device::ssc_port_c_w(u8 data)
} }
} }
if( (data & C_ALD) == 0 ) if( ((m_tms7000_portc & C_ALD) == C_ALD) && ((data & C_ALD) == 0) && (m_tms7000_portd < 64) )
{ {
m_spo->ald_w(m_tms7000_portd); m_spo->ald_w(m_tms7000_portd); /* load allophone */
} }
if( ((m_tms7000_portc & C_BSY) == 0) && ((data & C_BSY) == C_BSY) ) if( ((m_tms7000_portc & C_BSY) == 0) && ((data & C_BSY) == C_BSY) )
@ -485,7 +481,7 @@ cocossc_sac_device::cocossc_sac_device(const machine_config &mconfig, const char
m_stream(nullptr), m_stream(nullptr),
m_index(0) m_index(0)
{ {
std::fill(std::begin(m_rms), std::end(m_rms), 0); std::fill(std::begin(m_rms), std::end(m_rms), 0.0f);
} }
@ -515,10 +511,9 @@ void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<r
{ {
for( int sampindex = 0; sampindex < count; sampindex++ ) for( int sampindex = 0; sampindex < count; sampindex++ )
{ {
// sum the squares auto source_sample = src.get(sampindex);
m_rms[m_index] += src.get(sampindex) * src.get(sampindex); m_rms[m_index] += source_sample * source_sample;
// copy from source to destination dst.put(sampindex, source_sample);
dst.put(sampindex, src.get(sampindex));
} }
m_rms[m_index] = m_rms[m_index] / count; m_rms[m_index] = m_rms[m_index] / count;
@ -526,7 +521,7 @@ void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<r
} }
m_index++; m_index++;
m_index &= BUFFER_SIZE; m_index &= (BUFFER_SIZE-1);
} }
@ -536,8 +531,8 @@ void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<r
bool cocossc_sac_device::sound_activity_circuit_output() bool cocossc_sac_device::sound_activity_circuit_output()
{ {
double sum = std::accumulate(std::begin(m_rms), std::end(m_rms), 0.0); float sum = std::accumulate(std::begin(m_rms), std::end(m_rms), 0.0f);
double average = (sum / BUFFER_SIZE); float average = (sum / BUFFER_SIZE);
return average < 0.08; return average < 0.317f;
} }

View File

@ -433,6 +433,7 @@ void coco_state::coco_sound(machine_config &config)
void coco_state::coco_floating_map(address_map &map) void coco_state::coco_floating_map(address_map &map)
{ {
map(0x0000, 0xFFFF).r(FUNC(coco_state::floating_bus_r)); map(0x0000, 0xFFFF).r(FUNC(coco_state::floating_bus_r));
map(0x0000, 0xFFFF).nopw(); /* suppress log warnings */
} }