# of Simultaneous Audio Voices

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
shifty
Posts: 32
Joined: Thu Jun 16, 2005 8:59 am
Location: MIT
Contact:

# of Simultaneous Audio Voices

Post by shifty »

Hi!

This question is for people who have implemented mod players,
midi players and other audio/music stuff. What is the most # of
channels you have gotten playing (active) at once on PSP? And
are you using floating point or fixed. And are you using bilinear,
cubic, sinc, or non-interpolated, etc? Synthesis method.
Also, are you using the media engine, or not, C, assembly, optimized C, optimized assembly, etc.

Using fixed-point, non-optimized C, with no cop, bilinear interp, I've
gotten 24 mono voices wavetable playback to work. But 24 voices
takes a lot of CPU away from the user. 18 voices has almost no
interference.
davo
Posts: 2
Joined: Thu Mar 09, 2006 3:58 am
Location: Visby
Contact:

Re: # of Simultaneous Audio Voices

Post by davo »

Why hasn't anyone replied to this? Is this posting a retorical question? I mean,
is that the answer to the question? That there are up to 24 voices on the PSP,
but you should try keeping it down to 18. Are there only mono-channels, so
that you can decide on your own if you want to distribute them in a 7.1 system,
or maybe just a stereo system? I've been searching for a spec. on the PSP's
audio, but I can't find any usable information.

All I've found this far is that the audio is played back at 44.1kHz. I found this
information through a pdf by Groepaz/Hitmen. It's 154 pages, and the audio-section
looks like this:
Audio-section wrote: 12 Audio Processing
12.1 Overview

44100 Hz Sample Frequency
And that's it... Some posts imply that you can use SDL_mixer with the PSP,
but still, how many channels (voices that is) can I use, are they in stereo or
mono? Can I use ogg-audio and load them as wav into ram? Or should I
use mp3? Should the audio be played from host? Should the audio be wav
on disk?

I would be very greatful for any help. I hope I haven't reposted, I really
searched this forum, but I can't find anything..
starman2049
Posts: 75
Joined: Mon Sep 19, 2005 5:41 am

Post by starman2049 »

I needed to playback audio and was against using SDL or other opensource packages, and since I wasn't able to find a turnkey solution I wrote my own audio player code.

It is for games and allows playback of one stereo .WAV file that is streamed from memory/disc, while at the same time playing several smaller one-shot sound effects that are memory resident, and at the same time streaming in from memory/disc playing medium length Voice-Over one-shots.

It's the kind of thing you wound want for a video game not for a general purpose audio player.

I use the 8 channels that the system has and do not mix audio on a given channel.

It does have some overhead, but I have not gotten around to optimizing it yet and so I think it can be done with minimal overhead once optimized.

Hope this helps...
davo
Posts: 2
Joined: Thu Mar 09, 2006 3:58 am
Location: Visby
Contact:

Post by davo »

starman2049 wrote:I use the 8 channels that the system has
Ok, this means that I now know that the playback frequency is 44.1k, and at
8 channels. Are these 8 mono-channels, giving me 8 voices, or are they
stereo, giving me a total of 16 voices?

And I'm asking this cause I'm trying to create a videogame, not a media
player. So this information was really helpful. Thanks.

I have been a bit puzzled over the memory size. I was kinda guessing there
would be a way of streaming wav from disk. That, or being able to play midi-files.
starman2049 wrote:I wrote my own audio player code.
Are you sharing? ;)
starman2049
Posts: 75
Joined: Mon Sep 19, 2005 5:41 am

Post by starman2049 »

If you look in pspaudio.h you will see the def:

#define PSP_AUDIO_CHANNEL_MAX 8

I assume that this is the machine, and not the SDK interface to the hardware.

You can support any frequency by adjusting the stride and your buffer filling routines. I use 22kHz, 16 bit mono on the argument that the fidelity of the two tiny speakers in the PSP is so low that you can't really tell the difference anyway.

1) On init allocate a fixed HW channel for music playback via sceAudioChReserve() so its always there (two for stereo if you want)

2) When you want to play music, start a new thread to handle file IO and buffer filling and sit in a tight loop doing:

(READ A SAMPLE INTO A SAMPLE BUFFER)
sceAudioOutputBlocking() to output sample

Sound effects and VO are similiar, except I allocate a channel at request time. it would be possible this way to run out of channels, but since I am doing only mono it has not yet happened, and to be honest if you have 8 channels all rocking I doubt anybody know if a sfx was not playing.

I hate threads and tried to conceive a way to do this w/o threads and I can tell you there is not a way - especialy if you are streaming.

People talk about double and triple buffering to get rid of clicks, but I have never heard any so I must be doing something different.

I have a 3 SKU game on display at GDC and another app at MIX so I can't take the time right now to seperate my audio code and put it up - sorry...
RCON
Posts: 16
Joined: Wed Aug 03, 2005 1:02 am
Contact:

Post by RCON »

The PSP Rhythm audio sample engine works on one audio channel. It has a basic mixer that mixes samples into the audio callback. it was loosely based off of the drumpiler code off of source forge.

http://drumpiler.sourceforge.net/.

My samples have a struct with a variable that tells the mixer if a sound is playing then mix it in. If not it resets the sample pointer to the begining and doesn't mix it in. That way I can play at least 32 samples at a time. I'm not sure how much it taxes the processor because my graphics are very minimal.

There was a wavloader thread in these forums that works for playing samples and it is pretty solid. I tried the sceAudioOutputBlocking but it had that clicking problem (it could have been the way I was implementing it). If you want a simple audio playback method I would search for that wavloader code.
User avatar
dsn
Posts: 47
Joined: Wed Nov 09, 2005 11:48 am
Location: Indianapolis, Indiana, USA

Post by dsn »

I was able to prevent sceAudioOutputBlocking from clicking by triple-buffering.
Post Reply