Cue2cu2: A Python script to create CU2 sheets

Generic Customer Feedback, Content and Reviews based directly on PSIO
User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » May 8th, 2019, 2:07 am

It makes more sense in these cases to go for something other than milliseconds. It's the same with video timecodes where you have hours, minutes, seconds, frames. You can cut at any sector/frame, but not any millisecond as it might be midway through the indivisible base unit.
Last edited by NRGDEAD on May 27th, 2019, 4:47 am, edited 1 time in total.
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

User avatar
Takehaniyasubiko
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 1304
Joined: March 13th, 2018, 5:04 am
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Takehaniyasubiko » May 8th, 2019, 2:12 am

NRGDEAD wrote:
May 8th, 2019, 2:07 am
It makes more sense in these cases to go for somthing other than milliseconds. It's the same with video timecodes where you have hours, minutes, seconds, frames. You can cut at any sector/frame, but not any millisecond as it might be midway through the indivisible base unit.
Yes, you are right, but it's counter-intuitive and rather obscure, unless you were mastering PS1 discs back in the day. :)

User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » May 27th, 2019, 4:51 am

I released a small update that should technically improve performance a bit, although as a user, one wouldn't notice unless using a really slow storage device. And added a proper line ending for the last line in non-compatibility mode, which shouldn't be used anyway at this time.
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

Orion_
Just Joined
Just Joined
Posts: 9
Joined: August 13th, 2012, 2:48 am
Location: France
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Orion_ » June 10th, 2019, 12:30 am

If you can generate a CU2 file from the original CUE and BIN file size, then why don't PSIO do it on its side ? that's easy enough
I really don't get the point of having a separated CU2 file ..
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
Matt
Cybdyn Systems - Admin
Cybdyn Systems - Admin
Posts: 2644
Joined: December 31st, 2012, 5:37 pm
I am a: Systems Designer
PlayStation Model: H2000/5502
Location: Australia
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Matt » June 10th, 2019, 1:10 am

Orion_ wrote:
June 10th, 2019, 12:30 am
If you can generate a CU2 file from the original CUE and BIN file size, then why don't PSIO do it on its side ? that's easy enough
I really don't get the point of having a separated CU2 file ..
Merging multiple binaries that are audio tracks into a single binary file on PSIO would be very, very slow. It's faster to have a modern computer do it and to then copy it to the SD Card manually. The CUE to CU2 sheet conversion could be done on PSIO, but we can't currently write to the SD Card (we're working on that though).

Orion_
Just Joined
Just Joined
Posts: 9
Joined: August 13th, 2012, 2:48 am
Location: France
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Orion_ » June 10th, 2019, 2:12 am

Matt wrote:
June 10th, 2019, 1:10 am
The CUE to CU2 sheet conversion could be done on PSIO, but we can't currently write to the SD Card (we're working on that though).
but, if you parse the CU2 file for internal use, why not just parsing the CUE file which basically contain the same information, beside the trk end/size info, which can be computed easily with the binary file size (that you already know since it's an option that you can show in the menu system)
From what I could tell, the trackXX info in the CU2 file is just the INDEX 01 info + 2 seconds in the CUE file.
I really don't understand why you didn't use the CUE file and went for another custom file format ...
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
Matt
Cybdyn Systems - Admin
Cybdyn Systems - Admin
Posts: 2644
Joined: December 31st, 2012, 5:37 pm
I am a: Systems Designer
PlayStation Model: H2000/5502
Location: Australia
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Matt » June 10th, 2019, 3:22 am

Because we don't support multiple streams for multiple binary files in parallel, hence, we need to merge multiple binary files into a single binary and produce a new data format to handle it.

It is possible to do what you're recommending though, and in the future we will look into simplifying things.

Orion_
Just Joined
Just Joined
Posts: 9
Joined: August 13th, 2012, 2:48 am
Location: France
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Orion_ » June 10th, 2019, 4:13 am

Matt wrote:
June 10th, 2019, 3:22 am
Because we don't support multiple streams for multiple binary files in parallel, hence, we need to merge multiple binary files into a single binary and produce a new data format to handle it.
I'm sorry I don't understand this part, are you talking about multiple CD ?
since I can't run the System Menu tool I can't look at how the CU2 file format is working with multiple CD
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
Matt
Cybdyn Systems - Admin
Cybdyn Systems - Admin
Posts: 2644
Joined: December 31st, 2012, 5:37 pm
I am a: Systems Designer
PlayStation Model: H2000/5502
Location: Australia
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Matt » June 10th, 2019, 4:24 am

No. Disc images generally use multi-bin format for audio tracks so they must be merged first into a single-bin image which is why the CU2 sheet is needed so PSIO can understand the track timings.

User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » August 24th, 2019, 10:53 am

I have updated Cue2cu2 with a few improvements:
Most importantly a new option to manually specify the file size of the binary file in bytes instead of obtaining that from the actual file. This comes in handy when you have only the cue sheet and want to convert it for someone else. The argument/parameter/switch for it is -s, or --size if you want to be more verbose.
Other than that, there's some basic sanity checks for the binary file and cue sheet. The binary file's file size must be a multitude of 2352, the cue sheet must have exactly one FILE statement, no more, no less. There's also some error catching now, with a descriptive message on what went wrong. Still not for everything, though, so if you run into a cryptic Python error, please let me know.
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » November 20th, 2019, 12:41 am

James-F wrote:
November 19th, 2019, 6:50 pm
There's even a third party Python tool which fails to run on my Windows 7 machine.
Can you elaborate on that? Any error messages?
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

User avatar
bikerspade
Active at Cybdyn Systems
Active at Cybdyn Systems
Posts: 39
Joined: December 18th, 2018, 3:16 am
PlayStation Model: SCPH-1001
Location: USA
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by bikerspade » November 28th, 2019, 3:06 am

NRGDEAD wrote:
November 20th, 2019, 12:41 am
James-F wrote:
November 19th, 2019, 6:50 pm
There's even a third party Python tool which fails to run on my Windows 7 machine.
Can you elaborate on that? Any error messages?
Python script works fine on my Windows 7 machine.
NRGDEAD: in case it gets missed on the other thread, your script on Windows seems to be adding an extraneous carriage-return (0x0D) byte before the pair of standard CRLF bytes for Windows text files. Change lines 196 and 197 of cue2cu2.py to the following, which should make it produce the same output in UNIX or Windows, with the latter now matching PSIO Systems Console exactly:

Code: Select all

	cu2file = open(cu2sheet,"wb")
	cu2file.write(output.encode())

User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » November 28th, 2019, 5:19 am

Awesome, thanks! I'll have a look at that in the upcoming days. Probably won't be able to do it before Friday, though.

Edit: and this.
bikerspade wrote:
November 28th, 2019, 4:16 am
Not sure if it matters, but there is a difference in the CU2 file generated by cue2cu2 vs PSIO Systems Console if a track offset happens to fall at the sector offset 0 (e.g. MM:SS:00). The PSIO Systems Console app may set the track to minute M and sector 75, while cue2cu2 sets the track to minute M+1 and sector 0. Logically, they have the same meaning since there are 75 sectors per minute, but I think cue2cu2's output is clearer (valid sector values should 0 thru 74, inclusive). This is illustrated when producing a CU2 file from the redump-verified merged BIN of AirGrave (Japan); see track25:

cue2cu2:

Code: Select all

track25   65:29:00
PSIO Systems Console:

Code: Select all

track25   65:28:75
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

sajdor
Just Joined
Just Joined
Posts: 8
Joined: September 18th, 2019, 9:42 pm
I am a: Miner
PlayStation Model: 7502

Re: Cue2cu2: A Python script to create CU2 sheets

Post by sajdor » November 29th, 2019, 12:44 am

can someone create any "noob tutorial" for using binmerge on windows ?
PSX SCPH-7502 + PSIO + OSSC with Sun X7146A = amazing !

User avatar
krisk77
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 403
Joined: December 9th, 2015, 1:37 pm

Re: Cue2cu2: A Python script to create CU2 sheets

Post by krisk77 » November 29th, 2019, 1:04 am

sajdor wrote:
November 29th, 2019, 12:44 am
can someone create any "noob tutorial" for using binmerge on windows ?
Credit to James-F for this:

Install the latest Python (3.8).
Make sure you include the PATH option during installation.
Restart the PC.

Copy binmerge into the folder with the multi bins and cue.
Now go to the folder with all the bin files, and hold SHIFT and rightclick an empty space in the window and click "Open command window here".

Run this command:

Code: Select all

python binmerge "your game.cue" "new cue" 
Make sure you use ("") marks with the example.

Then use System Console on the new .cue file to create CU2.
NTSC JP 5000 PU-8/PSIO Switchboard
NTSC JP 7000 PU-20/Mayumi 4 chip + PSIO Switchboard

PAL 7502 PU-22/Mayumi 4 Chip + PSIO Switchboard

User avatar
Matt
Cybdyn Systems - Admin
Cybdyn Systems - Admin
Posts: 2644
Joined: December 31st, 2012, 5:37 pm
I am a: Systems Designer
PlayStation Model: H2000/5502
Location: Australia
Contact:

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Matt » November 29th, 2019, 1:24 am

Why don't you compile the Python code into a binary to run on Windows without the shell/interpreter?

Xero9009
Member
Member
Posts: 11
Joined: November 22nd, 2019, 12:12 am

Re: Cue2cu2: A Python script to create CU2 sheets

Post by Xero9009 » November 29th, 2019, 11:23 am

just to clarify, is using binmerge only required on games with multiple discs to have them be 100% "correct"? and games that are single disc merge fine with PSIO System Console? thanks!

User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » November 29th, 2019, 11:33 am

No, both are to be used on multi-bin images. Which are not to be confused with multi-disc games.

Either way, please open a separate thread for binmerge; I'd prefer this one not to be derailed too far or hijacked. ;-) Thank you!
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

User avatar
NRGDEAD
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 658
Joined: September 22nd, 2017, 3:10 am
I am a: Noob
PlayStation Model: SCPH-1002

Re: Cue2cu2: A Python script to create CU2 sheets

Post by NRGDEAD » December 1st, 2019, 3:00 pm

I just published a few updates to Cue2cu2 on Github:
bikerspade wrote:
November 28th, 2019, 3:06 am
in case it gets missed on the other thread, your script on Windows seems to be adding an extraneous carriage-return (0x0D) byte before the pair of standard CRLF bytes for Windows text files. Change lines 196 and 197 of cue2cu2.py to the following, which should make it produce the same output in UNIX or Windows, with the latter now matching PSIO Systems Console exactly:

Code: Select all

	cu2file = open(cu2sheet,"wb")
	cu2file.write(output.encode())
This has been implemented. The output seems to be the same on Linux. I haven't had the time for proper testing; no Python on my Windows as of yet. Will do this later on, though. In the meantime, bikerspade, please give it a try and report back? :-)
bikerspade wrote:
November 28th, 2019, 4:16 am
Not sure if it matters, but there is a difference in the CU2 file generated by cue2cu2 vs PSIO Systems Console if a track offset happens to fall at the sector offset 0 (e.g. MM:SS:00). The PSIO Systems Console app may set the track to minute M and sector 75, while cue2cu2 sets the track to minute M+1 and sector 0. Logically, they have the same meaning since there are 75 sectors per minute, but I think cue2cu2's output is clearer (valid sector values should 0 thru 74, inclusive). This is illustrated when producing a CU2 file from the redump-verified merged BIN of AirGrave (Japan); see track25:

cue2cu2:

Code: Select all

track25   65:29:00
PSIO Systems Console:

Code: Select all

track25   65:28:75
I have implemented the :75 notation as well - for the default compatibility mode. While I agree that the :74 notation should be the way to go, I want Cue2cu2 to be 100% compatible to Systems Console's CU2 sheets.
When using non-compatibility mode, Cue2cu2 will continue to output the :74 notation.

New is --offset to further adjust offsets for the tracks and trk_end. This is for experimenting in case of audio trouble during gameplay. Will, however, not help to adjust existing CU2 sheets as Cue2cu2 can still only handle single-bin images.

Again, I didn't have much time to test all this. I'd be happy to do more bugfixing during next week; in emergencies, Github offers the version from August in the "commits" area.

And thanks again to bikerspade for reporting his findings!
Cue2cu2 - Python script for creating CU2 sheets via command line on Linux/Mac/Windows.

PSIO wallpaper template in PSD format.

User avatar
James-F
/// CYBDYN SYSTEMS ELITE ///
/// CYBDYN SYSTEMS ELITE ///
Posts: 365
Joined: August 11th, 2019, 11:01 pm

Re: Cue2cu2: A Python script to create CU2 sheets

Post by James-F » December 10th, 2019, 6:37 am

This part of the github page doesn't seem to be accurate/true:
"trk end" is 6 seconds beyond the bin file's end.
The "trk end" specifies the last track start + last track length.

Here is a calculator I use (75 frames):
https://www.zapstudio.net/framecalc/

For example with Moto Racer: http://redump.org/disc/18878/
The last track should be exactly 03:33:00 long,, that means it starts at 47:59:61 and ends ("trk end") at 51:32:61.
Cue2cu2 (--nocompat) cuts it at 51:30:61 resulting in 03:31:00 length, making the last track 2 seconds short.
And (--compat) 03:35:00 making the last track 2 seconds too long.

EDIT:
I think I'm wrong on this one.
--nocompat produces the correct length of 03:31:00 and "trk end" is the exact same size as total data.
Mounting this to Daemon Tools and playing in my music player shows that the last track is exactly 03:31 long.
Last edited by James-F on December 10th, 2019, 10:17 pm, edited 4 times in total.
SCPH-7000 (x2), SCPH-7501, SCPH-101, SCPH-102

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest