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
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

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: 139
Joined: Dec 19, 2012
Motto: /\OX[]
PlayStation Model: SCPH-5502
Location: Australia

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

XA_SOUND.PDF
You do not have the required permissions to view the files attached to this post.
"Nostalgia isn't a big enough word to describe the PlayStation from my eyes"

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

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
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

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: 139
Joined: Dec 19, 2012
Motto: /\OX[]
PlayStation Model: SCPH-5502
Location: Australia

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
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

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.

Yuri^Cybdyn
Verified
Cybdyn Systems
Cybdyn Systems
Posts: 406
Joined: Jan 13, 2012
I am a: Embedded Developer (MCU & FPGA)
PlayStation Model: 5502
Location: Belarus (Minsk)

Post by Yuri^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: 37
Joined: Jun 11, 2019

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 5 guests