Desperation about Sounds/SPU

Audio and Music (Sound Processing Unit) based area of development, including VAB, XA, etc
Post Reply
User avatar
Jaberwocky
Curious PSXDEV User
Curious PSXDEV User
Posts: 18
Joined: October 31st, 2019, 5:53 am

Desperation about Sounds/SPU

Post by Jaberwocky » January 9th, 2020, 8:07 am

Hey again xO

slowly I start to feel really bad about constantly asking stuff about PSYQ, seems like I'm the only one having those questions...
However, I'm close to giving up so I thought I could ruin my non existing reputation by asking my questions.

After I learned a bit about rendering, I thought it would be a great moment to start experimenting with sounds - but I'm completely overwhelmed with everything right now!

I actually wanted to just play some music and some SFX - but I found a jungle of file formats. My first entry point was actually "Orions Website", there he wrote:
"On the Playstation, the Sound format is called VAG, it's a compressed sound format, and you only have 512Kbytes of space for compressed sound.
To convert a WAV to VAG, you can use a tool called VAGedit. It's pretty straightforward to use."

Okay! Seems easy! So I loaded some random .wav file and created two ~4MB .vag files >_> Yeah... Well I thought, no big deal - I can stream the music from the disk... right? So I started to search through the PSYQ samples for a tutorial how to handle .VAG files. And even though I found an folder with .VAG files, they were NEVER used! Instead they used .VAB, .VH and .VB files who seem to be related to each other. Sooo after problems with the VABTOOL and some research I ran over the thread "[Tutorial] Converting MIDI + Samples to SEQ + VAB" from ArthCarvalho. Which made things even worse for me... I still have no idea how .VAG integrates into .VAB - as I understood, I design an instrument with the .VAG files, load multiple of them into the .VAB file and... Confusion... I simply wanted to stream my oversized .VAG file...

So I kept searching and encountered the thread "VAG Example (VAG DEMO)" from Shadow. So I looked into that code and - yeah! Loading .VAG files but... dang! His .VAG file was small enough to fit the 512KB, also I didn't understood what it is about those multiple channels. So I looked into Orions code how he handles the .VAG files. I saw a lot of similarities to Shadows example, but he wrote stuff like:
u_long size = (adrs[12] << 24) | (adrs[13] << 16) | (adrs[14] << 8) | adrs[15];
u_short freq = (adrs[18] << 8) | adrs[19];

Where adrs was the address of the .VAG file - how did he knew those values? Also I read the the first 16bytes of VAG files must be 0 - so how can he read a size from this? Max confusion!

Last thing I found was the "XMPlay Example + Tools" by zeroZshadow. But what on earth are xm files and how do I generate them?

Now I sit here, and I'm confused as all hell...
The only thing I seem to understand is, that I could be happy with .VAG files smaller then 512KB, but... I still don't get the thing with the multiple channels and how to playback bigger files and stuff...
Maybe I stream my big file into a 512KB buffer and do a SpuWrite? But how do I know it is time to read next? Also... If I fill the 512KB Sound RAM, how could I also play SFX when they are also .VAG?
My gut feeling tells me that .VAB files would be good for SFX buuuut... I'm confusion.

I'm not sure if this reflects my desperation :/ I really feel lost but honestly, I don't want to drop PSX development because of this... It is to interesting to just quit like that :/

Also sorry if this question is dumb.

User avatar
Jaberwocky
Curious PSXDEV User
Curious PSXDEV User
Posts: 18
Joined: October 31st, 2019, 5:53 am

Re: Desperation about Sounds/SPU

Post by Jaberwocky » January 11th, 2020, 3:56 am

After calming down I decided to try the code examples of the PSYQ regarding the sound. I hope to get there VB files running, maybe I understand enough to answer my questions....

Help and tips are still welcome of course xO

rama3
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 484
Joined: April 16th, 2017, 10:54 pm

Re: Desperation about Sounds/SPU

Post by rama3 » January 12th, 2020, 2:16 am

Not sure if that helps you, but you need to keep the hardware in mind.
The SPU is basically a synthesizer chip with limited memory. You create tiny samples and play them like an automated keyboard.

There's no way your 4MB file can be played like that. It simply won't fit in RAM.
Instead, you can use CD audio or XA audio to stream from disk.
These streams can't be modified with the SPU synth features, they're basically just pass-through.

So you have these 2 methods to play sound.
If you want to use the SPU to play synth, you need to use fitting samples.
Only then the various file formats come into play :)

User avatar
Jaberwocky
Curious PSXDEV User
Curious PSXDEV User
Posts: 18
Joined: October 31st, 2019, 5:53 am

Re: Desperation about Sounds/SPU

Post by Jaberwocky » January 13th, 2020, 3:26 am

rama3 wrote:
January 12th, 2020, 2:16 am
There's no way your 4MB file can be played like that. It simply won't fit in RAM.
Instead, you can use CD audio or XA audio to stream from disk.
These streams can't be modified with the SPU synth features, they're basically just pass-through.
Are there any examples or tutorials to learn that? All I see uses those VB and VH files...
rama3 wrote:
January 12th, 2020, 2:16 am
So you have these 2 methods to play sound.
If you want to use the SPU to play synth, you need to use fitting samples.
Only then the various file formats come into play :)
So uhm.... I noticed that the VB files of the example where 488KB in size - that is why they can use the synth correct? But how could you make BG music with that?

Edit:
So I found a .WAV to .XA converter and a coding example for .XA
Also I read that you can convert .wav to midi and from midi to .XM oo"
So... .XA and .XM are both for direct SPU streaming from CD correct? >_x

Which still makes me wonder how to make a background music then....

rama3
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 484
Joined: April 16th, 2017, 10:54 pm

Re: Desperation about Sounds/SPU

Post by rama3 » January 13th, 2020, 9:08 am

Well, the synth part is just like MIDI.
You have samples to play and programmed notes make up your song.
So this is pretty hard, unless you're already making tracker / midi style music.

The example probably has a few samples in a bank (hence VB?).
So you need to get some notes instructions to the SPU and play them.
Maybe the example tells you how to do this?

rama3
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 484
Joined: April 16th, 2017, 10:54 pm

Re: Desperation about Sounds/SPU

Post by rama3 » January 15th, 2020, 9:10 am

Again, I'm not sure what you've learned up until now.
This video should help illustrate. It's for the SNES, but the SNES APU is comparable to the PSX SPU ;p
https://www.youtube.com/watch?v=yse3a7ALZYA

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest