This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
xuggle atrac3 audio support
#1
Newbie to jpcsp and java here.

I think I'm maybe halfway to implementing xuggle-based atrac3 decoding in Jpcsp. When running Disgaea, it plays several notes of the background music before crashing with a decoding error. That might be related to me not checking that I have data before decoding, nor giving feedback on how much data has been processed.
I'm attaching the current state of the code in case I don't get any further or people are curious.

By the way, we could use a method like copyToMemory in the other direction. It's silly to be reading bytewise for these 24KiB copies.


Attached Files
.txt   jpcsp-at3-broken.diff.txt (Size: 7.68 KB / Downloads: 172)
Reply
#2
(08-17-2010, 07:47 AM)yann Wrote: Newbie to jpcsp and java here.

I think I'm maybe halfway to implementing xuggle-based atrac3 decoding in Jpcsp. When running Disgaea, it plays several notes of the background music before crashing with a decoding error. That might be related to me not checking that I have data before decoding, nor giving feedback on how much data has been processed.
I'm attaching the current state of the code in case I don't get any further or people are curious.

By the way, we could use a method like copyToMemory in the other direction. It's silly to be reading bytewise for these 24KiB copies.

Hm? Does "Disgaea" use AT3 or AT3+?
For AT3, you can use the code in the MediaEngine (instead of throwing "No Audio Streams Found" it will throw "No Video Streams Found"), but the code does need some improvements and cleaning, especially to support future AT3+ decoding. Wink
Anyway, we already have AT3 decoding and playing, but not on sceAtrac3plus. So, could you please tell me which files "Disgaea" is loading? Most recent games seem to only use AT3+... Undecided
Reply
#3
It uses sceAtrac3plus functions, but only uncompressed or ATRAC3 audio. Enabling the Media Engine option appears not to affect it at all, other than making the emulator fail if it doesn't find xuggle.

Specifically, it plays two streams (music and speech), and uses sceAtracSetHalfwayBuffer to set the music one up as well as sceAtracSetLoopNum to loop it. It doesn't seem to want to use sceAtracAddStreamData, and the HalfwayBuffer is 64KiB although the initial data is 24KiB, so I'm guessing there's some implicitly synchronized double buffering that needs to be done right.

Also, in my initial tests on a Windows machine, sound effects played just fine; on my Linux/amd64 machine, they don't seem to play at all, and I can't start the game from the first menu. Sound itself does work, considering that my patched AtracCodec.java makes the music play.
Reply
#4
(08-17-2010, 07:53 PM)yann Wrote: It uses sceAtrac3plus functions, but only uncompressed or ATRAC3 audio. Enabling the Media Engine option appears not to affect it at all, other than making the emulator fail if it doesn't find xuggle.

Sorry, I meant you can use the code in MediaEngine.java. You can easily rewrite the AtracCodec to work with the MediaEngine instead of creating a new separate Xuggler instance.

(08-17-2010, 07:53 PM)yann Wrote: Specifically, it plays two streams (music and speech), and uses sceAtracSetHalfwayBuffer to set the music one up as well as sceAtracSetLoopNum to loop it. It doesn't seem to want to use sceAtracAddStreamData, and the HalfwayBuffer is 64KiB although the initial data is 24KiB, so I'm guessing there's some implicitly synchronized double buffering that needs to be done right.

Ah, I see.

(08-17-2010, 07:53 PM)yann Wrote: Also, in my initial tests on a Windows machine, sound effects played just fine; on my Linux/amd64 machine, they don't seem to play at all, and I can't start the game from the first menu. Sound itself does work, considering that my patched AtracCodec.java makes the music play.

There seems to be a random issue with sound in 64-bit machines, but the problem resides in the native Java sound library, so, the sound from Xuggler should work just fine.
Reply
#5
Note that I'm not playing from xuggler (although their examples do play fine too); the sound is decoded and fed back into PSP memory, so clearly some sound makes it out of the emulator but not all. MediaEngine seems to expect filenames and play on its own, which may not be quite the right timing, and requires somehow acquiring the whole file first. My main problem right now is just that; I have the initial 24K, and don't know how to get the rest. Beyond that, there's the fact that the game won't run, which it did in Windows.
Reply
#6
(08-18-2010, 07:57 PM)yann Wrote: Note that I'm not playing from xuggler (although their examples do play fine too); the sound is decoded and fed back into PSP memory, so clearly some sound makes it out of the emulator but not all. MediaEngine seems to expect filenames and play on its own, which may not be quite the right timing, and requires somehow acquiring the whole file first. My main problem right now is just that; I have the initial 24K, and don't know how to get the rest. Beyond that, there's the fact that the game won't run, which it did in Windows.

You can easily use the MediaEngine in JPCSP to playback audio data.
You just need something like this in AtracCodec:
Code:
// Initialize the MediaEngine and a new PacketChannel (atChannel in this case).
protected MediaEngine me = new MediaEngine();
protected PacketChannel atChannel = new PacketChannel();

// Under atracSetData and atracAddStreamData:
atChannel.writePacket(address, length);

// Under atracDecodeData:
if(me.getContainer() != null) {
    me.step();
} else {
    me.init(atChannel.getFilePath());
}

// Under atracResetPlayPosition:
me.getContainer().seekKeyFrame(0, 0, 8);

The file handling you see in the PacketChannel is all internal. It creates a temporary file to act as a buffer (this is due to issues with ByteChannel when operating on large data, but the final goal is to get rid of the temporary file).
You can then obtain all the necessary data (sizes, timestamps) from the MediaEngine instance.
Of course that full integration with sceAtrac3plus needs more work around this, especially in terms of data handling. That's why we're still waiting for the ATRAC3+ codec before starting to work on this.
Reply
#7
Disgaea use only uncompressed (some sfx) and atrac3 audio(sfx, speech,music). Also atrac3 decoder in ffmpeg have very bad quality on output sound. BTW main problem - no support loop's in soundtracks: loop can easy detect by "smpl" chunk in wav header, but i can't implement this hack in emu, so i used quick&dity trick: copy music raws in the end of herself (~1gb on each track Smile )
Reply
#8
I've added AT3 playback in r1745.
Based on yann's idea, I've updated the MediaEngine and ported the AtracCodec's code to work with it.
The playback still have some issues and looping is currently disabled.
Anyway, I've also added a new log message to tell if the game is using AT3 or AT3+. It would be interesting to track down games using AT3 to aid in testing this feature. Smile
Reply
#9
Just tested the r1745 build. When presented with a functioning xuggle, it behaves as my patch did with Disgaea - the first few notes play, but no more. We still need to figure out what the HalfwayBuffer interface does to feed the codec more data. Other games might use AtracAddStreamData though, which is the currently supported variant.
Would you have any ideas where to look for the sceAtrac3plus API?
Reply
#10
seems to work in crisis core with the voice audio, i think the bgm is atrac+ ..but still good improvement can cut back on files on the hdd now,

tested games
partial play
Disgaea (about 3 notes)

games that playback sound
crisis core
tales of eternia
dissidia

I also updated the convertie program to only convert atrac3+ files and an option to delete the standard atrac3 files since jpcsp can play them back now (can save hdd space).
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)