EmulatorArchive / jpcsp

Automatically exported from code.google.com/p/jpcsp
1 stars 0 forks source link

[patch] Atrac3 sound looping & playing issues - fixes (some?) Corpse Party issues #347

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Patch attached.

The issues it fixes:
1) sceAtracAddStreamData doesn't seem to work correctly - it adds the old data 
to the stream, not the new data.
2) If the PacketChannel is written in parts while it is also being read (caused 
by sceAtracAddStreamData), it might end up too small to seek inside (e.g. so 
it's not possible to loop from end to beginning). My fix for this is to 
initialize the PacketChannel with the buffer size.

The patch hasn't been tested with many games - it might be a good idea for 
someone with the library to do so before committing - especially if someone 
knows which other games use the affected code.

Original issue reported on code.google.com by a.secret...@gmail.com on 2 Apr 2013 at 1:03

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Patch attached to this comment.

Original comment by a.secret...@gmail.com on 2 Apr 2013 at 1:08

Attachments:

GoogleCodeExporter commented 9 years ago
I found another fixable issue - voices don't stop after advancing the text in 
most cases. 
Looks like I might end up using this game as a guide for things to fix... 
Assuming the developers will find this issue.

The cause for this issue is that the game seems to call __sceSasSetADSR but 
doesn't call __sceSasSetADSRmode.
Since the default VoiceADSREnvelope.ReleaseCurveType is 0 (linear increasing), 
that means the voice never gets realeased (the envelope just grows and grows, 
it seems).
Now, I don't have the tools to test what happens on the real psp - it's 
possible that there are reasonable defaults for the ADSR curve types (which 
would include 'linear decreasing' for Release), and it's possible that 
something else is going wrong (less likely).
Someone (gid15?) should test this.
Meanwhile, the attached additional patch sets a reasonable default for the 
release curve type.

Original comment by a.secret...@gmail.com on 3 Apr 2013 at 1:36

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Not all people are good at building jpcsp from code, I downloaded eclipse and 
really tried, it was too complicated, got errors, ect..I would need to lose 
hours until I figure out how to do it.

I am sure a lot of other people are in the game boat.

It would be great if you can please provide usable jpcsp so more people can 
test, before gid15 implement your fixes into master ( he probably will )

Original comment by digiadve...@gmail.com on 3 Apr 2013 at 9:17

GoogleCodeExporter commented 9 years ago
Well I tested your patch and I am sorry to say it breaks other games..
This is from the log:

17:47:33  INFO hle.sceAtrac3plus - SoundDevice - hleAtracSetData atracID=0, 
buffer=0x096B28F0, readSize=0x3E00, bufferSize=0x7E00, fileSize=0xFDB50

17:47:34  WARN hle.sceAtrac3plus - SoundDevice - Unknown atracID=0xFF

Original comment by digiadve...@gmail.com on 3 Apr 2013 at 3:53

GoogleCodeExporter commented 9 years ago
Which game(s) does it break?

Original comment by a.secret...@gmail.com on 3 Apr 2013 at 8:54

GoogleCodeExporter commented 9 years ago
Tactics ogre, music only playes for 2-3 seconds...
It has same problem as Corpse Party, music doesn't loop, but without your patch 
you get atleast 30-40 seconds of music if not more..with your patch only 3 
seconds :)
I will test more games and report

Original comment by digiadve...@gmail.com on 3 Apr 2013 at 9:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Okay, I'll see if I can check it out.

As for your request for a build, I'm not sure if I'm allowed to post personal 
builds (mods, please delete the link if not), but the following build 
(jpcsp.jar, hopefully that's all you need) contains both patches:
http://www.freeuploadsite.com/do.php?id=8014

Original comment by a.secret...@gmail.com on 3 Apr 2013 at 9:08

GoogleCodeExporter commented 9 years ago
Not needed anymore, I just used netbeans it's much easier didn't get any errors 
and compiled without problems.
Eclipse was giving me problems...but it's good that you posted it, maybe some 
other users dont have enough knowledge to use even netbeans, and it's good they 
can test too.

I will test other games, I have been waiting for years for Tactics Ogre to be 
fixed, if you can do it, you would be my hero :)
And lot of other people, just checked how much replies are in Tactics Ogre 
thread

Original comment by digiadve...@gmail.com on 3 Apr 2013 at 9:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Tested around 20 games, everything seems to work fine except Tactics Ogre...

Original comment by digiadve...@gmail.com on 3 Apr 2013 at 10:00

GoogleCodeExporter commented 9 years ago
I can make a small change to turn the 2-3 seconds of music to 10-20 (still less 
than before), but doing more seems like it would require a rewrite of the 
atrac3 module.
It looks like ogre tactics needs the atrac3 module to treat its memory as some 
sort of circular buffer ("halfway buffer").
I might try doing it, though.

Original comment by a.secret...@gmail.com on 3 Apr 2013 at 11:39

GoogleCodeExporter commented 9 years ago
If you can do it and have the time, then please do it :)
This error has been present for ever, even gid15 wasn't able to fix it !

Original comment by digiadve...@gmail.com on 4 Apr 2013 at 12:11

GoogleCodeExporter commented 9 years ago
Also, I realized that my first patch isn't good at all - it may cause a psp 
memory corruption :p.

Original comment by a.secret...@gmail.com on 4 Apr 2013 at 1:37

GoogleCodeExporter commented 9 years ago
See http://www.emunewz.net/forum/showthread.php?tid=14619&pid=178967#pid178967

I will work on a proper circular atrac3 buffer implementation.

Thank you for your investigation! :-)

I will also check the PSP default ADSR parameters.

Original comment by gi...@web.de on 5 Apr 2013 at 7:24

GoogleCodeExporter commented 9 years ago
From what I could see, the following ADSR curve types are set at initialization:

            AttackCurveType = PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE;
            DecayCurveType = PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE;
            SustainCurveType = PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE;
            ReleaseCurveType = PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE;

Also, the volume is set to maximum (in SoundVoice init):
        leftVolume = PSP_AUDIO_VOLUME_MAX;
        rightVolume = PSP_AUDIO_VOLUME_MAX;

Could you confirm this is working for this game?

Original comment by gi...@web.de on 5 Apr 2013 at 8:27

GoogleCodeExporter commented 9 years ago
Thanks for checking this out, gid15!

You'll probably have better luck with the circular buffer implementation than I 
did.
A few things to note about the current atrac3 code (you may already know this):
a) The inputBufferOffset variable appears to currently be used for both the 
write offset and the decode offset. (So it's usage is completely messed up)
b) I don't know of any game that uses it, but the inputBufferNeededBytes 
variable appears to be currently uninitialized (and is used in 
getBufferInfoForResetting).

Yes, those default values work well with this game.

Original comment by a.secret...@gmail.com on 5 Apr 2013 at 1:54

GoogleCodeExporter commented 9 years ago
sceMp3 has already such a circular buffer implemented.

Original comment by gi...@web.de on 5 Apr 2013 at 3:15

GoogleCodeExporter commented 9 years ago
Default ADSR curve types now correctly set in r3087. The default volume is now 
already set.

Original comment by gi...@web.de on 5 Apr 2013 at 7:38

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Circular buffer for sceAtrac3plus implemented in r3096.

Original comment by gi...@web.de on 12 Apr 2013 at 6:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The circular buffer fixes the sound corruption issue, but not the sound looping 
issue (sounds in corpse party stop on loop).

Original comment by a.secret...@gmail.com on 12 Apr 2013 at 11:16

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Even with circular buffer implemented, music is still not looping in tactics 
ogre either...
It is looping in ppsspp ( media build by oioitff ), so maybe comparing the code 
can help ?

Original comment by digiadve...@gmail.com on 14 Apr 2013 at 12:06