XMPlay Example + Tools

Programming examples for the Psy-Q SDK
Post Reply
zeroZshadow
What is PSXDEV?
What is PSXDEV?
Posts: 3
Joined: Jun 29, 2013

XMPlay Example + Tools

Post by zeroZshadow » July 3rd, 2013, 12:48 am

I made a small example that shows how to use the XMPlay library and tools to add music to your application.
Please read the README.TXT included to see how the example is used.

The .BAT files are commented to show what each action does.
I tried to comment the main.c as clear and simple as possible to show the workings of XMPlay

Have fun!
You do not have the required permissions to view the files attached to this post.

zeroZshadow
What is PSXDEV?
What is PSXDEV?
Posts: 3
Joined: Jun 29, 2013

Post by zeroZshadow » July 3rd, 2013, 11:30 am

Small addition
I am using the cpe2psx tool here (its in the MAKE_AND_PLAY.BAT)
if you do not have this, please change this command to CPE2X
and remove the line "ren main.psx main.exe"
Sorry for not adding this in the readme

Nikoomba
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: Aug 28, 2013

Post by Nikoomba » August 28th, 2013, 4:42 am

If I follow the instructions in the readme file, the .exe does not compile.
This is without changing the .xm. It comes up with a parsing error.
I did change the .bat file as you instructed in your post since I wanted to use cpe2x.
I think cpe2x can't compile the code properly or something.

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » January 8th, 2017, 3:47 am

I have had the XMPLAY.LIB file on my PC for ages, but I never got around to using it nor uploading it. I checked the MD5, and it matches yours so both versions are the same. I was hoping yours would be newer since I've been playing around with it, and a few XM's don't play correctly which lead me to the library being not that accurately coded. As an example, I made a song from scratch using Fast Tracker, and the timing is off, even with a fixed BPM. The library isn't perfect, but this is a fantastic way to play several minute long songs with everything running from SPU RAM which is why it's being implemented into PSIO's Menu System.

I also contacted Jason Page (since he wrote the library) and I asked if he still had the source code. Unfortunately he does not, but, he did give me the PlayStation 2 source code which can be downloaded below.

Code: Select all

<!-- Sample code showing how to play .XM files -->
***** XMPlayer *****

PS2 Example code. 12.Dec.2000 - Jason Page (Technology Group (a division of SCEI R&D))

Plays XM files (converted into .XM, .XMH and .XMB files using the utility XM2PSX)
Main code runs on the IOP.
See "Info.TXT" for full list of commands.
Full source code included for xm player.

Handles playback of a maximum of 32 songs, using a maximum of 8 XM files.

To run:
From the EE directory:
dsedb -r run main.elf
xmplay.zip
You do not have the required permissions to view the files attached to this post.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

Mills
Curious PSXDEV User
Curious PSXDEV User
Posts: 16
Joined: May 03, 2016

Post by Mills » June 21st, 2023, 10:10 pm

Does anyone know if the included SEQ players in the psyq, are faster than this library?.

I imagine the included MID/SEQ player is just another software program that reads midi files, so it will be as fast as any other program (like this XM player).

I read some psyq samples and docs, and it looks like there is no "hardware" midi player, some programs send samples to the SPU with a few parameters, so I think the CPU has to read and process the MIDI/SEQ.

User avatar
MottZilla
Verified
Serious PSXDEV User
Serious PSXDEV User
Posts: 88
Joined: Jul 04, 2015
Location: North America

Post by MottZilla » July 7th, 2023, 2:23 pm

Correct the CPU has to tell the SPU what to do, it can't play a sequence on it's own. I wish I had something to add, but I haven't yet messed around with sequenced music, only standard CD audio.

Mills
Curious PSXDEV User
Curious PSXDEV User
Posts: 16
Joined: May 03, 2016

Post by Mills » August 4th, 2023, 8:56 pm

MottZilla wrote: July 7th, 2023, 2:23 pm Correct the CPU has to tell the SPU what to do, it can't play a sequence on it's own. I wish I had something to add, but I haven't yet messed around with sequenced music, only standard CD audio.
Thanks!

User avatar
nocash
Verified
PSX Aficionado
PSX Aficionado
Posts: 541
Joined: Nov 12, 2012
Contact:

Post by nocash » August 4th, 2023, 10:29 pm

Mills wrote: June 21st, 2023, 10:10 pm Does anyone know if the included SEQ players in the psyq, are faster than this library?.
I don't know. But the SPU-ADPCM playback is done by hardware, and the CPU does merely need to send some parameters (for things like changing the sound frequency, sending key on messages). The CPU load should be less than 1%, so there shouldn't be much of a difference between faster or slower sound drivers (or completely disabling the music).

soundy
What is PSXDEV?
What is PSXDEV?
Posts: 1
Joined: Mar 26, 2024
PlayStation Model: PSX
Discord: soundy4264
Location: Switzerland

Post by soundy » March 27th, 2024, 8:27 pm

I have the same timing problem here. Not a question of CPU or performance. Even at slow BPM, notes are not played on time. It sounds like VSyncCallback(XMPlayer::vbl); was not stable in term of time interval.

User avatar
nocash
Verified
PSX Aficionado
PSX Aficionado
Posts: 541
Joined: Nov 12, 2012
Contact:

Post by nocash » Yesterday, 12:07 am

The same timing problem than what? Nobody mentioned any timing problems.

Anyways, the timing problems I could think of:

Vblank accuracy is approx +/-0.001 minutes, but I doubt that even audiophiles could hear differences between 119.999 bpm and 120.001 bpm.
PAL vs NTSC have different vblank timings.
Don't block audio playback by doing things like disabling IRQs for longer periouds, or doing huge DMA transfers with hundreds of kilobytes.
That callback thing sounds as if you need to call it (exactly?) once per frame. Which would be up to you to do so accurately. It may be best to call it from within vblank interrupt handler. Or when manually polling vblanks: Be sure to do that polling often enough (eg. poll several times during slow initialization functions).

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests