Need help on looping XA audio tracks

Audio and Music (Sound Processing Unit) based area of development, including VAB, XA, etc
Post Reply
User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 344
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Skype: lameguy64
Location: Philippines

Need help on looping XA audio tracks

Post by LameGuy64 » November 20th, 2013, 1:09 am

Man its been quite a while since I've last posted something here. Anyway, I'm currently working on a PlayStation game project (which I won't explain in detail yet as I want to surprise everyone once CodeBlast '14 starts 8-)) which uses XA audio tracks for music.

I got the game to play the XA tracks properly but the problem is, I don't know of a good way to loop such tracks. Sure you can make a predefined array containing the length of each XA audio channel but that method sounds extremely cumbersome to me. I think this can be done nicely by checking for the 'End of Record' bit inside the subheader structure in each XA audio sector being played but I don't know of a way to extract the subheader during playback.

Any help will be gladly appreciated!
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
t0rxe
C Programming Expert
C Programming Expert
Posts: 140
Joined: December 19th, 2012, 8:08 pm
IRC: t0rxe
Motto: /\OX[]
PlayStation Model: SCPH-5502
Location: Australia

Re: Need help on looping XA audio tracks

Post by t0rxe » November 20th, 2013, 2:08 pm

XA_SOUND.PDF
XA_SOUND.PDF
(258.86 KiB) Downloaded 467 times
"Nostalgia isn't a big enough word to describe the PlayStation from my eyes"

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 344
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Skype: lameguy64
Location: Philippines

Re: Need help on looping XA audio tracks

Post by LameGuy64 » November 20th, 2013, 10:44 pm

That seems to be helpful enough... Thanks t0rxe!
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 344
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Skype: lameguy64
Location: Philippines

Re: Need help on looping XA audio tracks

Post by LameGuy64 » November 22nd, 2013, 12:08 pm

I now got a new problem, these lines inside my callback function:

Code: Select all

XAID = *(unsigned short *)(CdBuffer+3);
		
// video sector channel number format = 1CCCCC0000000001
XAgotChannel = *((unsigned short *)(CdBuffer+3)+1);
XAgotChannel = (XAgotChannel&31744)>>10;
Gives me an Address Error (Command Fetch or Data Load) message when executed.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
t0rxe
C Programming Expert
C Programming Expert
Posts: 140
Joined: December 19th, 2012, 8:08 pm
IRC: t0rxe
Motto: /\OX[]
PlayStation Model: SCPH-5502
Location: Australia

Re: Need help on looping XA audio tracks

Post by t0rxe » November 22nd, 2013, 7:41 pm

Execute each line separately (comment them out) and find the line that is causing the crash.
From there, check your pointers and bit shifts. Maybe output them to a printf to ensure you are getting the results needed. Also check the Psy-Q Library References PDF to make sure the functions do no exceed their data type.
"Nostalgia isn't a big enough word to describe the PlayStation from my eyes"

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 344
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Skype: lameguy64
Location: Philippines

Re: Need help on looping XA audio tracks

Post by LameGuy64 » November 22nd, 2013, 10:37 pm

Even when

Code: Select all

XAID = *(unsigned short *)(CdBuffer+3);
is the only line being executed, I still get that error.

EDIT: Never mind, I eventually found a way to fix it... Just gotta tweak/clean it up first before I'll release it as an XA player sample with auto-stop and looping.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
cybdyn
Cybdyn Systems
Cybdyn Systems
Posts: 405
Joined: January 13th, 2012, 1:56 am
I am a: Embedded Developer (MCU & FPGA)
PlayStation Model: 5502
Location: Belarus (Minsk)

Re: Need help on looping XA audio tracks

Post by cybdyn » January 3rd, 2015, 1:27 am

I think this can be done nicely by checking for the 'End of Record' bit inside the subheader structure in each XA audio sector being played but I don't know of a way to extract the subheader during playback.

yeah, one of the way is chk for EOR flag in subhader. by CdgetlocL command.

another way, dunno how they make it, but at the end of exact track (file/channell ) they put data frame, so when INT1 or dataready event comes it means it reach end of current xa track.

smf
Active PSXDEV User
Active PSXDEV User
Posts: 35
Joined: June 11th, 2019, 11:48 pm

Re: Need help on looping XA audio tracks

Post by smf » January 3rd, 2015, 9:42 pm

LameGuy64 wrote:Even when

Code: Select all

XAID = *(unsigned short *)(CdBuffer+3);
is the only line being executed, I still get that error.
I'm guessing that CdBuffer is a unsigned char *, and adding 3 will make it odd.

If so then the you'd get an exception because the PlayStation can only access 16 bit values on addresses divisible by 2 (mess enforces that but most emulators don't). Some compilers can be forced into creating code that will work by using a packed struct, otherwise you have to do something like CdBuffer[3] | (CdBuffer[4] << 8). I have no idea about the validity of what you're doing, but that is likely the cause of the exception.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest