mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 05:29:23 +00:00
Implemented non-linear volume.
This commit is contained in:
parent
c24c1bf3b1
commit
cd59eb5f43
@ -64,6 +64,15 @@ AY38910::AY38910() :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set up volume lookup table
|
||||||
|
float max_volume = 8192;
|
||||||
|
float root_two = sqrtf(2.0f);
|
||||||
|
for(int v = 0; v < 16; v++)
|
||||||
|
{
|
||||||
|
_volumes[v] = (int)(max_volume / powf(root_two, (float)(v ^ 0xf)));
|
||||||
|
}
|
||||||
|
_volumes[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AY38910::set_clock_rate(double clock_rate)
|
void AY38910::set_clock_rate(double clock_rate)
|
||||||
@ -147,11 +156,11 @@ void AY38910::get_samples(unsigned int number_of_samples, int16_t *target)
|
|||||||
#undef channel_volume
|
#undef channel_volume
|
||||||
|
|
||||||
// Mix additively. TODO: non-linear volume.
|
// Mix additively. TODO: non-linear volume.
|
||||||
target[c] = (int16_t)((
|
target[c] = (int16_t)(
|
||||||
volumes[0] * channel_levels[0] +
|
_volumes[volumes[0]] * channel_levels[0] +
|
||||||
volumes[1] * channel_levels[1] +
|
_volumes[volumes[1]] * channel_levels[1] +
|
||||||
volumes[2] * channel_levels[2]
|
_volumes[volumes[2]] * channel_levels[2]
|
||||||
) * 512);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ class AY38910: public ::Outputs::Filter<AY38910> {
|
|||||||
int _channel_dividers[3];
|
int _channel_dividers[3];
|
||||||
int _channel_output[3];
|
int _channel_output[3];
|
||||||
|
|
||||||
|
int _volumes[16];
|
||||||
|
|
||||||
int _master_divider;
|
int _master_divider;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user