0
0

I’m having performance troubles on iPhone 3G with applying DSP’s to sounds. Can i adjust quality/buffer or do anything else to optimize it?

  • You must to post comments
0
0

Can you elaborate some more on what your specific troubles are?

If you are using too much CPU (see FMOD Profiler or GetCPUUsage for values) you may need to do less processing, what are you currently doing? what effects are you using? how many sounds are you playing? are they streams? are they compressed? etc…

If you give us some details perhaps we can suggest some optimizations.

  • You must to post comments
0
0

Hi popgoblin,

On the flip side, i am astounded at the power of this little handheld device. What DSP code are you running?

  • You must to post comments
0
0

Hey guys – thanks for the responses…. I’ve been busy pitching a prototype of our app the last couple of days… ๐Ÿ˜‰

Anyways; we’re (in a funny and novel way, i think) allowing the user to build small loops and breakbeats by triggering samples (some are "oneshots", others are loops of 1 to two bars). There can many samples playing at once.

Furthermore, we’re allowing the user to add DSP effects and to change, in real time, some of the parameters while the thing is running. We’re playing around with a lowpass filter, echo, reverb and flange – but having them all run at the same time, while being a sonic-koas, is also too heavy for the cpu. Off course, thats no surprise – we could limit this, and only allow one or two DSP’s at the time. But even that eats just a weee bit to much performance on the iPhone 3G (the iPod Touch and 3GS have better performance).

Also, i’d like better performance in just triggering the samples;
I’ve been testing the music-system, which had too long latency, and the event-system (which still ate too many resources), and are now playing all sounds through direct sound->play. I have my own quantification system in place, and it’s working nicely (but still, even with out the DSP and with just 4-5 sounds triggered) is a bit too heavy for comfort.

I’m still a fmod noob – so theres probably a whole lot of things that could/should be done differently.

I’m initializing the system with:

[code:34nyzam2]
FMOD_RESULT result = FMOD_OK;

result = FMOD::System_Create(&soundSystem);
ERRCHECK(result);

result = soundSystem->init(32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL);
ERRCHECK(result);

[[NSString stringWithFormat:@"%@/mybank.fsb", [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
result = soundSystem->createSound(buffer, FMOD_CREATESAMPLE, NULL, &fsb);
ERRCHECK(result);

result = fsb->getNumSubSounds(&numsubsounds);
ERRCHECK(result);

[/code:34nyzam2]
And – the triggering is done with something like this:

(I’m organizing sound pointers in an wrapper object with some other stuff in it. Sounds are also stopped if retriggered while still playing))
[code:34nyzam2]

if (ps->channel!=nil) {
bool isPlaying;
ps->channel->isPlaying(&isPlaying);
if (isPlaying)
ps->channel->stop();
}

result = soundSystem->playSound(FMOD_CHANNEL_FREE, ps->subSound, false, &ps->channel);
ERRCHECK(result);
[/code:34nyzam2]

Regarding the DSP stuff, i add all dsp to the system before hand, and then activate by bypassing if they should not be played:
[code:34nyzam2]
result = soundSystem->createDSPByType(FMOD_DSP_TYPE_REVERB, &dspReverb);
ERRCHECK(result);

result = dspReverb->setParameter(FMOD_DSP_REVERB_ROOMSIZE, 0.3);
ERRCHECK(result);
result = dspReverb->setParameter(FMOD_DSP_REVERB_DAMP, 0.2);
ERRCHECK(result);
result = dspReverb->setParameter(FMOD_DSP_REVERB_WIDTH, 1.0);
ERRCHECK(result);

result = soundSystem->addDSP(dspReverb, NULL);
ERRCHECK(result);

[/code:34nyzam2]

Pretty straightforward stuff, really!

In my fsb, i’ve constructed a lot of events, that uses the samples encoded as *.ogg’s

So; any ideas on how to optimize would be very welcome!!

best regards!!!

  • You must to post comments
0
0

You mention that you are creating FSBs using OGG Vorbis compression, however this is not supported by the runtime. Do you mean you are using OGG Vorbis source files?

With iPhone the simpler the compression the faster the decoding, so PCM is obviously the fastest but largest choice, next is adpcm, then mp2 then mp3, these are all the formats supported by FSB for iPhone. You can load independent OGG files however decoding them is very expensive.

Depending on how you load the files into FMOD depends on the runtime expense of playing them, so if you use FMOD_CREATESAMPLE the file will be decompressed to PCM at create time, this will cost a fair bit of memory. You can also choose FMOD_CREATECOMPRESSEDSAMPLE which will load the file into memory compressed and decode from there, there is also FMOD_CREATESTREAM that will decode from the iPhone harddrive.

Also pay attention to whether your source files need to be stereo or not, often you can get away with mono sounds saving you precious resources. Also try to match the sample rate of the source files to the rate FMOD runs at, for instance this is 24KHz by default.

How much CPU are you using at the moment and what do you consider acceptable for your application? Also how is your memory situation? are you running out and can you afford to have more things loaded as PCM?

You mention requiring better performance in triggering samples, do you mean playback latency or CPU cost?

  • You must to post comments
0
0

Yeah, I’m using OGG source files; i was thinking that the distribution size of the app would profit from that. I’m using CREATESAMPLE when initialising (before playing) – as I do not (yet) have memory issues.

Does CREATESAMPLE automatically make 24Khz sounds in memory – or would I profit from changing the OGG sources to 24Khz, mono?

I’ll try to get some specifik %’s from the profiler later – but i think one of the greatest issues i have right now, is that i’m running my own quantification loop, which, if "disturbed" by surges in CPU use by other threads, looses some "ticks", resulting in rythmic hickups… which is a problem…

  • You must to post comments
0
0

Ok so you are loading .ogg files with FMOD, at the end of your other post you mention FSB files so I was a bit confused.

Doing create sample for all files will use quite a bit of memory, but if this is working within your memory budget then that is good. Since you are using create sample the expense of using ogg will be all up front at createSound time, so if you find loading slow (or you switch to compressed samples or streams) you will probably want a less expensive format such as adpcm or mp2.

Create sample will only decompress your file into memory, it will be resampled to 24KHz at runtime which will cost you some CPU time. You would benefit from re-encoding them, and if appropriate for your app using mono will save you more.

  • You must to post comments
0
0

Thx. I’ll try that – and report back ๐Ÿ˜‰

(BTW, i think i am being unclear; i’m using an FSB file – into which i’ve added waves from ogg’s… – i’m not loading seperate ogg files…)

  • You must to post comments
0
0

Ok, well in that case what compression format are you using for your FSBs? Also ideally you want your source files to be the original PCM data (not ogg) so the best quality is given to FSBank for compression.

In case it is a bit unclear what FSBank is doing when it makes your FSB files I will explain briefly. If you give it ogg files it will decompress them to PCM then pass that PCM data to the encoder you have chosen to compress with, i.e. MP3, MP2, ADPCM, etc, then it will join all these files together as one big package. So you want the source files to be the original PCM wav files if possible so you don’t suffer from degraded quality from ogg, then your chosen compression.

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.