0
0

When using

[code:25zxzy9k]channel->setPosition(0,FMOD_TIMEUNIT_MS)[/code:25zxzy9k]

and

[code:25zxzy9k]channel->setPosition(1,FMOD_TIMEUNIT_MS);[/code:25zxzy9k]

in my input plugin:
[code:25zxzy9k]
FMOD_RESULT F_CALLBACK setposition(FMOD_CODEC_STATE codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
{
//this is ised to selects subsongs, for example "setposition(5,FMOD_TIMEUNIT_MS)" selects and plays subsong 5
gameplugin
gp = (gameplugin*)codec->plugindata;
LogFile->Print( "sound: %i\n", position);
return handle_error( gme_start_track( gp->emu, position ) );
}
[/code:25zxzy9k]

this will create the output:

[code:25zxzy9k]
sound:0
sound:0
[/code:25zxzy9k]

And the same if call setposition with 10 and 11… position will be 10 for both calls. So every argument supplied that’s not ending with a 0 is ending up beeing 1 to small.

I open the sound like this:
[code:25zxzy9k]
system->createSound("Gradius.hes", FMOD_SOFTWARE|FMOD_CREATESTREAM, 0, &sound1);
[/code:25zxzy9k]
I also tried with FMOD_ACCURATETIME but with same results. So is this a bug or is there some other way of opening the file to get correct values?

  • You must to post comments
0
0

it’s probably something to do with the block size / alignment of the codec, its not going to translate directly from the user call to your code, there is buffering going on in fmod, you should just do as it says.

  • You must to post comments
0
0

What do you mean "do what it says"?

I mean if I use

[code:5twfsjv2]channel->setPosition(5,FMOD_TIMEUNIT_MS)[/code:5twfsjv2]

the only thing that I use from the soundlib is

[code:5twfsjv2]gme_start_track( gp->emu, 5)[/code:5twfsjv2]

  • You must to post comments
0
0

I mean, if you say setposition(5, ms) and you get a callback saying seek to 0ms, then you should seek to 0ms just as it told you to in the callback.

The 5ms seek is most likely handled internally through buffering.

  • You must to post comments
0
0

Ok, so in other words you should only use setposition to seek? It can’t be used for other purposes like selecting a subsong?

If not how do you call custom functions through a plugin? Let’s say I want to call
[code:nopi00q8]aCoolSoundLib->setMode(MODE_COOL)[/code:nopi00q8]

how do I call that function from the plugin?

  • You must to post comments
0
0

you could use a custom timeunit value, from the application, and that would most likely make it all the way to the plugin untouched. A bit like FMOD_TIMEUNIT_MOD_ORDER (it gets passed straight through to the codec).

  • You must to post comments
0
0

And how do you make a custom timeunit value? I don’t have the source for FMOD so there’s not much code to look at how FMOD_TIMEUNIT_MODORDER is handled. I mean the only thing I can change is to add a define to fmod.h

define FMOD_TIMEUNIT_SUBSONG 0x20000000

but that obviously doesn’t do very much…

  • You must to post comments
0
0

Ok apologies for the first few replies from me I realize now that you are trying to play a different timeunit, so at the end I was on the right track.

I was thinking your subsong 0x20000000 idea might have worked, but what do you mean it didnt?

Anyway the correct way to do it is create a codec with multiple subsounds, then all you have to do is call getSubSound from the main app with the track you want to play, then setposition is called with the ‘subsound’ parameter you selected (position will be 0).

In short you were using position when you should have been using the subsound parameter in the callback.

  • You must to post comments
0
0

Well about the define: so I create my own define, but what next? The setposition gets another fmod time unit but there can’t be anything happening unless you change fmod’s source code…

I took a look at using subsounds to select subsongs a year ago when I did the sid input plugin and I couldn’t understand how that would work… so I gave up. I mean you can’t store the subsongs as audio data, since they only are producing the data when the emulated machinery is emulating/playing the song (nes/c64 etc). I’m not sure it can be done using subsounds – and no one else did it before either to my knowledge.

It’s a pity that FMOD_TIMEUNIT_MS skips every 10th ms otherwise is works fine. I should also mention that this "problem" occurs in two different plugins using different soundlibs (sidplay and game music emu).

  • You must to post comments
0
0

I realized that I forgot to change the time unit to FMOD_TIMEUNIT_SUBSONG in the FMOD_CODEC_DESCRIPTION…

However when I use anything but FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCMBYTES in the codec description I get an FMOD_ERR_FORMAT when opening the file. So what have I missed here?

  • You must to post comments
0
0

I got this working fine now. I use FMOD_TIMEUNIT_MS|FMOD_TIMEUNIT_SUBSONG in the codec description and also implemented getlength and getposition callbacks.

  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.