Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal audio branch #5839

Merged
merged 31 commits into from
Apr 14, 2014
Merged

Conversation

kaienfr
Copy link
Contributor

@kaienfr kaienfr commented Apr 11, 2014

Based on my implementation in sceAac #5836
I've created a class AuCtx included in my SimpleAudioDec.cpp/.h which aims at providing a standard and easy implementation to support all codecs in ffmpeg for ppsspp.

Here, I also completely re-code sceMp3 file very fast in using this class and give you as an example to show how to use this class, and also very glad to see that it has almost solved all mp3 issues I've observed in the current master.
Tests on different freq and channels mp3 audios are all right:
Miku custom BGM (48kHz, stereo), Hanayaka Nari Wa ga Ichizoku(32kHz, mono, a little fast but better than before now), downstreet panic (44.1kHz, stereo), and learn jp09(44.1kHz, stero).

Especially, I am very glad to see that Miku's Custom BGMs have no repetition issues in the first tone any more, and no longer stopped in the first second neither :)

We could be coming into a new age of fast implementing new audio formats from now on I hope :D
PS: save/loadstate is also all right.

Test on Fortix is all right. Savestate is also ok.
I've tried a New and Easy way implement and it works well, I think it could be totally applicable to other audio modules as sceMp3 etc.
Code your own way is really much easier to fix other bugs :)
Based on my implementation in sceAac hrydgard#5836
I've created a class AuCtx included in My SimpleAudioDec.cpp/.h which aims at providing a standard easy implementation to support all codecs in ffmpeg.
Here, I also completely re-code sceMp3 file with this class to give an example how to use this class, and it has solved all mp3 issues I've observed in the current master.
Tests on different freq and channels mp3 audios as:
Miku custom BGM (48kHz, stereo), Hanayaka Nari Wa ga Ichizoku(32kHz, mono, a little fast but better than before now), downstreet panic (44.1kHz, stereo), and learn jp09(44.1kHz, stero) are just all right.
Especially, I am very glad to see that Miku's Custom BGMs have no repetition issues in first tone any more and no longer stopped in the first second neither. :)
We will come into a new age to fast support new audio formats from now on I hope :P
@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 11, 2014

What's wrong with unix build tonight? it appears errors as:

lib/libCore.a(ReplaceTables.cpp.o): In function `Matrix4ByMatrix4(float*, float const*, float const*)':
ReplaceTables.cpp:(.text._Z16Matrix4ByMatrix4PfPKfS1_[Matrix4ByMatrix4(float*, float const*, float const*)]+0x27): undefined reference to `fast_matrix_mul_4x4_sse'
lib/libnative.a(matrix4x4.cpp.o): In function `Matrix4x4::operator*(Matrix4x4 const&) const':
matrix4x4.cpp:(.text+0x2ef): undefined reference to `fast_matrix_mul_4x4_sse'
collect2: ld returned 1 exit status
make[2]: *** [PPSSPPSDL] Error 1
make[1]: *** [CMakeFiles/PPSSPPSDL.dir/all] Error 2
make: *** [all] Error 2

I've nothing touched about that two files. Somebody seems forget including headers? @hrydgard

@hrydgard
Copy link
Owner

I just fixed it.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 11, 2014

Ok, I will merge it :) thanks

}
};

u32 sceAuExit();
Copy link
Owner

Choose a reason for hiding this comment

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

As this bunch of functions are not actual Sony sce* functions, I don't think we should name them like that.

Just call them "Exit", "Decode", "GetLoopNum" etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, no problem.

@unknownbrackets
Copy link
Collaborator

You say savestates are "all right", but I'm pretty confident this will break any past savestates. Hopefully not many people use games that use any of these features.

An sceAu, as used by sceMpeg, doesn't seem at all related to an mp3 context, so I'm confused by your naming here.

-[Unknown]

@hrydgard
Copy link
Owner

Yes, this needs savestate conversion code that reads the old style mp3 state blocks into the new structure.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 11, 2014

I have changed all class functions from sceAu... to Au..., since they are class function, generally it could be not confused with other, but I've still changed them. No problem.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 11, 2014

Do we really think we need convert massive of old style mp3 into new? many many things have been changed. I am not sure if it is convertable...but I will try

@unknownbrackets
Copy link
Collaborator

Well, I know of a couple games that use sceMp3 that worked to some degree, and I'm not sure if they will still work with this code, but they are all unpopular minis.

-[Unknown]

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 11, 2014

I've tested some of them, they all work.
and not only for mp3, sceAac works too with this since it comes from that code. and I guess it could work also for atrac etc. Of cours we don't need to replace everything which works good, but we can try solving the ones which works not good such as sceMp3 and the not implemented one sceAac.

@VIRGINKLM
Copy link
Contributor

Doesn't Dead Or Alive Paradise use sceMp3?

@unknownbrackets
Copy link
Collaborator

sceAtrac has all sorts of secondary buffer stuff, and iirc it seemed to be causing (minor) problems in at least 1 or 2 games that it wasn't implemented. I don't think pretending it works the same as sceMp3 would be a good idea.

I don't have Dead or Alive, so I don't know. It's very possible. I guess old savestates would not work unless supported was added to this pull, then.

-[Unknown]

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 11, 2014

I've added a conversion, and now begin to do tests.
I don't have Dead or Alive either. You can test it after I update the savestate.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 12, 2014

Here it is. kaienfr@a769173
Find it's not as hard as I imaged to load and convert old state file. :)

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 12, 2014

Till now, all games with mp3 issues I've tested are all right. I also post a test version on baidu, 9 hours past, I've not received any problem on this new one. Only many people confused that the master branch still can not playing bgm mp3 on Miku, and I had to explain to them since only part of codes is currently merged to master, and old sceMp3 does not work correctly while the new code is still waiting for mergeing... If it's possible, please check and merge this asap to solve mp3 playing issue. Thanks!

For me, since every tests are all right, I don't think I will change anything here, so I am ready for merging now.

@VIRGINKLM
Copy link
Contributor

There's somthing wrong there then. Audio that sounds on the wrong pitch/speed is a result of incorrect resampling/played back into incorrect sample rate.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 13, 2014

I will understand this as the reserved channels issue.
The game reserve the channel with sample rates, channels and samplecounts they want.
The decoded pcm output is just all right, you can dump it into pcm file and play it with cool audio, you will find the speed is all right. So it's not an issue of decoding or resampling, but something else. This is an open issue we have discussed before, but still not solved yet. It's nothing about decode.
Ps:from @hrydgard 's comment, currently our audiooutput only support 44100 setero, so we must resample it into this format except we can support other sample rate playback. AFAIK, the aac audio stream in PMP video is suffering to this and yield nonsmooth sound.

hrydgard added a commit that referenced this pull request Apr 13, 2014
We flag filesystems as being FAT32 instead of checking for "ms0:".
unknownbrackets added a commit that referenced this pull request Apr 13, 2014
More elegant way of solving #5839 (d_private in sceIoDread)
@daniel229
Copy link
Collaborator

Kamen Rider Chou Climax Heroes Custom BGM speed is slow,and get error here.

MP3MAIN_BgmM E[ME]: HLE\sceMp3.cpp:481 UNIMPL sceMp3GetFrameNum(09fbf980)
MP3MAIN_BgmM I[ME]: HLE\sceMp3.cpp:375 sceMp3GetSumDecodedSample(09FBF980)
MP3MAIN_BgmM I[ME]: HLE\sceMp3.cpp:375 sceMp3GetSumDecodedSample(09FBF980)
MP3MAIN_BgmM I[ME]: HLE\sceMp3.cpp:387 sceMp3SetLoopNum(09FBF980, -1)

jpcsp trace

sceMp3ReserveMp3Handle 0x07EC321A sxdxxx
sceMp3LowLevelInit 0x1b839b83 sxdxxx
sceMp3InitResource 0x35750070 sxdxxx
sceMp3TermResource 0x3C2FA058 sxdxxx
sceMp3LowLevelDecode 0xe3ee2c81 sxdxxx
sceMp3GetFrameNum 0x3548AEC8 sxdxxx
sceMp3GetSumDecodedSample 0x354D27EA sxdxxx
sceMp3GetLoopNum 0xD8F54A51 sxdxxx

https://gist.github.com/daniel229/10613774

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

@daniel229 can you send a demo to me ?

@daniel229
Copy link
Collaborator

on baidu message

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

download speed is very slow on baidu, could you please send one from google? thanks.
PS: I implement the function sceMp3GetFrameNum, you could have a test. But not sure this will affect speed or not.

@daniel229
Copy link
Collaborator

Have sent you a google on baidu message,I compiled your latest commit, still get a slow speed.

This method can automatically read audio information from file (as channels, sample rate etc) via ffmpeg,
and create accurate ffmpeg's codec context.
Especially used for unknown audio format but supported  by ffmpeg.
@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

Thanks, I get it.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

@daniel229 I have test it, still haven't found anything wrong, bgm and sound seems all right? nothing slow speed, can you explain your problem more specifically? or upload a save file please.

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

@hrydgard can you merge this branch now? I don't think we need add some new features in this branch. It's already so much. It's better to create new commit if we get a new issue in future.

@sum2012
Copy link
Collaborator

sum2012 commented Apr 14, 2014

support to merge

@hrydgard
Copy link
Owner

OK.

hrydgard added a commit that referenced this pull request Apr 14, 2014
@hrydgard hrydgard merged commit c7ddd45 into hrydgard:master Apr 14, 2014
@daniel229
Copy link
Collaborator

@kaienfr the custom BGM slow

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

@hrydgard Thanks a lot. Now everyone can test and contribute on this now :)

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

@daniel229 can you upload a savefile and explain how to get cunstom BGM, I've no idea on this game's menu...

@kaienfr kaienfr deleted the Universal_Audio_Branch branch April 14, 2014 12:08
@daniel229
Copy link
Collaborator

put a mp3 file into \MemStick\MUSIC\KR_SCH\ ,then load this savefile
rename jpg to rar
npjh506910000

then go to vs.cpu mode,then slect this as 1P,then go to battle ,you can hear the custom BGM.
01

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

Yeah, found a second example need to take sound speed hack on :P
@daniel229 Try sound speed hack on, you will find good performance.
Let's make a rule: if you see slow speed in mp3 playing, always try first switch on the auido hack.

@daniel229
Copy link
Collaborator

yeah,I have not tried that hack before,with that the sound fine.

@dbz400
Copy link
Contributor

dbz400 commented Apr 14, 2014

Wondering DOA and this game have sound parameters similarity?

@kaienfr
Copy link
Contributor Author

kaienfr commented Apr 14, 2014

Could be, I think such games ask for a pcm buffer of two frames for each to play. If we can find a way to know this information, we can definitly solve this problem without hacks.

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.

10 participants