Clamp the AX Volume to prevent clipping.  Patch by hk.konpie.  Fixes issue 7519.

Clamp the AX Volume to prevent clipping.  Patch by hk.konpie.  Fixes issue 7519.
Actually, nevermind, the clamping is right. That was the volume ramp
computation loop, it's multiplied with the sample values in the next loop
(addr 02a1 in this UCode version I linked to). The loop applying the volume
ramp is SET40, so ACCn.M writes will clamp.

As to -0x7fff vs. -0x8000, DSPLLE does -0x8000 afaict, and that does make
more sense to me.

On Sun, Oct 19, 2014 at 7:49 PM, Pierre Bourdon <delroth@gmail.com> wrote:

> Here is the relevant part of the code:
> https://github.com/dolphin-emu/dolphin/blob/ca23318089a9bdcd9a7af93667dc30b1c73dc0e8/docs/DSP/DSP_UC_AX_DD7E72D5.txt#L830
>
> Unless there is some DSP magic going on here, I don't see any clamping
> going on. set16 is set when doing envelope processing so there will not be
> any automatic clamping when storing the .M part. Of course, I could be
> convinced by an hwtest (TBH even something showing that DSPLLE clamps here
> would work for me in this case).
>
> On Sun, Oct 19, 2014 at 6:14 PM, Lioncash <notifications@github.com>
> wrote:
>
>> In Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h:
>>
>> > @@ -462,7 +463,7 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl
>> >  	// Apply a global volume ramp using the volume envelope parameters.
>> >  	for (u32 i = 0; i < count; ++i)
>> >  	{
>> > -		samples[i] = ((s32)samples[i] * pb.vol_env.cur_volume) >> 15;
>> > +		samples[i] = MathUtil::Clamp(((s32)samples[i] * pb.vol_env.cur_volume) >> 15, -32767, 32767);	// -32768 ?
>>
>> iirc, I had brought this clipping range up with @delroth
>> <https://github.com/delroth> before (possibly related to something else,
>> and I was told the correct range was [-32767, 32767].
>>
>> This is assuming I'm not misremembering anything.
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/dolphin-emu/dolphin/pull/1337/files#r19061166>.
>>
>
>
>
> --
> Pierre "delroth" Bourdon <delroth@gmail.com>
> Software Engineer @ Zürich, Switzerland
> http://code.delroth.net/
>



-- 
Pierre "delroth" Bourdon <delroth@gmail.com>
Software Engineer @ Zürich, Switzerland
http://code.delroth.net/