Skip to content

Conversation

@Vincent-Halver
Copy link
Contributor

-cdicdic: Add audio attenuation (fixes #12852) [Vincent Halver]

-cdicdic: Add audio attenuation (fixes  [Vincent Halver]
@galibert
Copy link
Member

galibert commented Nov 5, 2025

Compiling src/mame/philips/cdislavehle.cpp...
../../../../../src/mame/philips/cdislavehle.cpp:233:43: error: 'm_cdic' is a protected member of 'cdi_state'
233 | dynamic_cast<cdi_state*>(m_owner)->m_cdic->atten_w(m_in_buf);
| ^
In file included from ../../../../../src/mame/philips/cdislavehle.cpp:32:
../../../../../src/mame/philips/cdi.h:57:34: note: declared protected here
57 | optional_device<cdicdic_device> m_cdic;
| ^

Also, this is kind of atrocious code. What are you trying to do exactly?

offset += 28 * num_samples;
}
int16_t sampleL = 0, sampleR = 0, outL = 0, outR = 0;
for (uint16_t i = 0; i < 18 * 28 * num_samples; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File uses Allman style.

{
case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7:
case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf:
dynamic_cast<cdi_state*>(m_owner)->m_cdic->atten_w(m_in_buf);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unportable, you should rather provide this communication thru devcb_write8::array<4>.

Copy link
Contributor

@MooglyGuy MooglyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covered some finer points on both OG's and Angelo's comments.

int16_t samples[28];

switch (coding & (CODING_BPS_MASK | CODING_CHAN_MASK))
uint8_t num_samples = coding&CODING_8BPS ? 4 : 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces.

void cdicdic_device::play_xa_group(const uint8_t coding, const uint8_t *data)
void cdicdic_device::play_xa_group(const uint8_t coding, const uint8_t *data, const uint16_t idx)
{
static const uint16_t s_4bit_header_offsets[8] = { 4, 5, 6, 7, 12, 13, 14, 15 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if I originally added these or someone else did, but the s_ prefix is unnecessary, and SHOUTY_CAPS is prefered for constants; something like HEADER_OFFSETS_4BIT et al would be nicer.


m_dmadac[0]->transfer(0, 1, 1, SECTOR_SIZE/4, samples[0]);
m_dmadac[1]->transfer(0, 1, 1, SECTOR_SIZE/4, samples[1]);
m_dmadac[0]->transfer(0, 1, 1, SECTOR_SIZE/4, &m_samples[0][0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More missing spaces. If the line is being changed anyway, might as well fix the spacing along the way. The whole file could use a sweep for operator-spacing normalization.

m_atten[0] = ((args[0] & 0x8) << 7) | args[1];
m_atten[1] = ((args[0] & 0x4) << 7) | args[2];
m_atten[2] = ((args[0] & 0x2) << 7) | args[3];
m_atten[3] = ((args[0] & 0x1) << 7) | args[4];
Copy link
Contributor

@MooglyGuy MooglyGuy Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on from Kale's comment, it's pretty unlikely that the real hardware connection between the SLAVE and CDIC devices is 20 individual traces for the 20 bits of state represented by args here.

The correct way to do this would be to have atten_w take a single uint8_t, have a private member that increments on each call from 0 to 4 and wrapping around, in order to determine how to apply the incoming byte to the m_atten array. You would then have a devcb_write8 with a public callback-registration function in cdislavehle_device - there are plenty of examples throughout the codebase on how to do this - and then in the machine configuration function for cdi_state::cdimono1_base, do -

m_slave_hle->atten_callback().set(m_cdic, FUNC(cdicdic_device::atten_w));

rather than grabbing into a protected class member in a way that doesn't compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a temporary fix to expose the cdic for dynamic casting just so that it compiles so it can be validated it worked. Thanks for the feedback, I'll look into the callback change.

Exposing this variable for dynamic casting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CD-i] Sound mixing not faithful to the real machine

4 participants