0
0

I’m trying to use libsidplay2 so create a plugin for FMOD to play .sid-files. I’ve looked at the codec_raw-example and the ape-plugin by Danny Dulai. However my sound programmingknowledge could be better… there’s some parameters in FMOD_CODEC_WAVEFORMAT im not sure what to assign.

lengthpcm? "length in seconds * frequency" says the docs… but I don’t know the length of a sid… don’t think it’s possble to get the length.

format? FMOD_SOUND_FORMAT_PCM16 or FMOD_SOUND_FORMAT_PCM8?

blockalign? I have no idea?

I’ve managed to create a dll-file that fmod successfully loads. Playing a .sid-file now opens it and trying to play it which results in 100% cpu-usage (and no sound), can’t find any errors from fmod or libsidplay though.

  • You must to post comments
0
0

I don’t use Linux, but if you do there isn’t very much work to make one. The plugin source is the same, you basically just have to compile it for linux.

  • You must to post comments
0
0

Any chance this plugins will be ported to linux?

There seams to be very few codecs for fmodex linux, if any at all.

  • You must to post comments
0
0

I’ve now added support for subsongs.

Get it at [url:1nxofmhr]http://andreas.blazer.nu/programs.php[/url:1nxofmhr]

  • You must to post comments
0
0

Thank you for your kind words ๐Ÿ˜€

Lemme know how the IK+ development goes :)

  • You must to post comments
0
0

Sweet! … I’ve been eyeballing this thread while trying to get allegro to play SID files, either with FMOD or allegros basic streaming sound functions.
I got as far(?) as getting allegro to play SIDs with in_sid.dll plugin but it sounded just awful ๐Ÿ˜•

To be honest, I just registered to say, thank you ๐Ÿ˜€
I will give you full credit for the SID support in my IK+ remake for the PC ๐Ÿ˜€

—EDIT—
Hope you get the subsongs part working 8)

  • You must to post comments
0
0

Get the plugin here [url:1r13d1cd]http://andreas.blazer.nu/programs.php[/url:1r13d1cd]!!!

I haven’t got subsongs to work yet, but I uploaded the plugin along with the source. If anyone knows how to add support for it please let me know.

  • You must to post comments
0
0

I’m not sure how to tackle the subsongs…

I’ve created an array of FMOD_CODEC_WAVEFORMAT for the number of subsongs. But when a user selects a subsound with getSubSound I need to change subsong in my plugin with:

[code:35fnidqb]
m->tune->selectSong(index);
m->load(m->tune);
[/code:35fnidqb]

I can’t do that for all songs initially since the songs are interpreted at playtime. So I need to now when the getSubSound is called and change subsound then. Is that possible or is there some other way?

  • You must to post comments
0
0

[quote="Heffo":35anogak][quote="bLAZER":35anogak]I’ll put it up for download if someone is interested.[/quote:35anogak]

I am interested! :lol:[/quote:35anogak]

I am interested too!

Good work

  • You must to post comments
0
0

[quote:2f3871wn]I am interested! [/quote:2f3871wn]

Cool!

Got the opening fixed now, so now it first looks if its a sid-file. Got some memory leaks somewhere though ๐Ÿ˜•

Moving on to subsounds…

  • You must to post comments
0
0

[quote="bLAZER":37iwm1dt]I’ll put it up for download if someone is interested.[/quote:37iwm1dt]

I am interested! ๐Ÿ˜†

  • You must to post comments
0
0

What are you supposed to return in the open callback if the opening fails? I’ve tried FMOD_ERR_FILE_BAD and FMOD_ERR_FORMAT but when using

[code:2n5v3y4s]result = system->createSound("dummyfile.dum", FMOD_SOFTWARE|FMOD_CREATESTREAM, 0, &sound1);[/code:2n5v3y4s]

it crashed even if I return FMOD_ERR_FILE_BAD in the first line in the open callback.[/code]

  • You must to post comments
0
0

Yes it works! ๐Ÿ˜€

So now I’ll just add so you can access subsongs and clean up the code, then I’ll put it up for download if someone is interested.

  • You must to post comments
0
0

Ahhh, I used fileseek to "rewind" the filepointer to 0, now it reads the whole file! yey! So now I’ll try to get that data to sidplay…

  • You must to post comments
0
0

Brett, when you said [quote:9z6dkaa8]you use the fmod file function to read in the whole sid into memory[/quote:9z6dkaa8]. How do you do that?

I moved around some stuff now so when the read callback is called the first time I though that I read in the whole tune in memory. Something like this:

[code:9z6dkaa8]
FMOD_RESULT F_CALLBACK sidread(FMOD_CODEC_STATE codec, void *buffer, unsigned int size, unsigned int *read)
{
/
here is some code I left out /
signed short
mybuffer;
myBuffer = new signed short[codec->filesize];
result = codec->fileread(codec->filehandle,mybuffer,codec->filesize,read,0);
/* here is some code I left out */
}

[/code:9z6dkaa8]

I get an error:

(21) End of file unexpectedly reached while trying to read essential data (truncated data?).

read contains 123, and I can only read 123 bytes.

  • You must to post comments
0
0

I’m way over my head here… I’m trying to read the whole sid-file into memory. Is this anywhere nea correct? It crashes at the last line.

[code:1ck666p1]
unsigned int* myBuffer;
myBuffer = new unsigned int[codec->filesize];
unsigned int *read=0;
result = codec->fileread(codec,myBuffer,codec->filesize,read,0);
[/code:1ck666p1]

  • You must to post comments
0
0

wow… that’s really strange… I started to check around a bit, tried a couple of things and now it works. However it’s exactly the same code and libs I use as yesterday…. that’s odd… must have been some crap in my memory yesterday or seomthing.

  • You must to post comments
0
0

verify all the callbacks are correct and that it matches the latest interface, some things may have changed since then.

  • You must to post comments
0
0

I recompiled this plugin with latest version of FMOD and as far as I know I have’nt changed anything in the code.

I’m using playsound from the examples:

[code:3h7mvg6w]system->createSound("Commando.sid", FMOD_SOFTWARE|FMOD_CREATESTREAM, 0, &sound1);[/code:3h7mvg6w]

I get no errors. The application eats about 1.5gb virtual mem and doesn’t get past that line.

Any ideas? Anything changed in FMOD last 6 months so that the plugin doesn’t work any longer?

  • You must to post comments
0
0

I don’t quite understand what you mean… for example how do I know where fmod read the file into (and how big the file was)? And I don’t uderstand how I should use the read callback in the plugin to read the file… because that just read the sampledata the sidplayer produces… here’s the code, could you give some more hints?

[code:3tpsexrh]FMOD_RESULT F_CALLBACK sidopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo);
FMOD_RESULT F_CALLBACK sidclose(FMOD_CODEC_STATE *codec);
FMOD_RESULT F_CALLBACK sidread(FMOD_CODEC_STATE *codec, void *buffer, unsigned int size, unsigned int *read);
FMOD_RESULT F_CALLBACK sidsetposition(FMOD_CODEC_STATE *codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype);

FMOD_CODEC_DESCRIPTION sidcodec =
{
"FMOD Sid player plugin", // Name.
0x00010000, // Version 0xAAAABBBB A = major, B = minor.
0, // Don’t force everything using this codec to be a stream
FMOD_TIMEUNIT_PCMBYTES, // The time format we would like to accept into setposition/getposition.
&sidopen, // Open callback.
&sidclose, // Close callback.
&sidread, // Read callback.
0, // Getlength callback. (If not specified FMOD return the length in FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCMBYTES units based on the lengthpcm member of the FMOD_CODEC structure).
&sidsetposition, // Setposition callback.
0, // Getposition callback. (only used for timeunit types that are not FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS and FMOD_TIMEUNIT_PCMBYTES).
0 // Sound create callback (don’t need it)
};
class macio : public sidplay2
{
FMOD_CODEC_STATE *_codec;
int _pos;

public:
    macio(FMOD_CODEC_STATE *codec)
    {
        _codec = codec;
        _pos = 0;
        LogFile = new CLogFile("sid.log");
        tune = NULL;

        memset(&sidwaveformat, 0, sizeof(sidwaveformat));
    }

    ~macio()
    {
        delete tune;
    }
    SidTune *tune;
    FMOD_CODEC_WAVEFORMAT sidwaveformat;

};

/*
FMODGetCodecDescription is mandatory for every fmod plugin. This is the symbol the registerplugin function searches for.
Must be declared with F_API to make it export as stdcall.
MUST BE EXTERN’ED AS C! C++ functions will be mangled incorrectly and not load in fmod.
*/

ifdef __cplusplus

extern "C" {

endif

F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()
{
return &sidcodec;
}

ifdef __cplusplus

}

endif

static FMOD_CODEC_WAVEFORMAT sidwaveformat;

FMOD_RESULT F_CALLBACK sidopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo)
{

macio *m = new macio(codec);

m->tune = new SidTune("c:\\sid\\1.sid");



m->tune->selectSong(0);
m->load(m->tune);

m->sidwaveformat.channels     = 2;
m->sidwaveformat.format       = FMOD_SOUND_FORMAT_PCM16;
m->sidwaveformat.frequency    = 44100;
m->sidwaveformat.blockalign   = (16 >> 3) * m->sidwaveformat.channels;
m->sidwaveformat.lengthpcm    = 0xffffffff; //inifite length

codec->waveformat   = &(m->sidwaveformat);
codec->numsubsounds = s.songs;
codec->plugindata   = m;                    //user data value


return FMOD_OK;

}

FMOD_RESULT F_CALLBACK sidclose(FMOD_CODEC_STATE codec)
{
delete (macio
)codec->plugindata;

return FMOD_OK;

}

FMOD_RESULT F_CALLBACK sidread(FMOD_CODEC_STATE codec, void *buffer, unsigned int size, unsigned int *read)
{
macio *m = (macio
)codec->plugindata;
read = m->play((signed short)buffer,codec->waveformat->blockalign*sizeof(signed short));
return FMOD_OK;
}

FMOD_RESULT F_CALLBACK sidsetposition(FMOD_CODEC_STATE *codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
{
//seeking can’t be done, so just return ok
return FMOD_OK;
}
[/code:3tpsexrh]

  • You must to post comments
0
0

in your open callback you should do a fast check to see if it is a sid file or not first. This is usually done by checking a 4 byte code at the start of the file or something like this. Remember there are about 20 codecs to scan through, it has to be as fast as possible.

Next it looks like if it succeeds, you use the fmod file function to read in the whole sid into memory, then the read callback of the plugin would just call that getFromBuffer function using the memory you just loaded the whole file into, and that buffer interface you mentioned, instead of the filename interface.

If all the sid library supplies is ‘here is the filename’ and hides all the file access stuff (ie you can’t speficy file callbacks or something?), then you would have to use the memory based function, you really have to use fmod’s file functions to do the file access, and dont allow any other library to do any disk access. Remember as i said, it could be a http file, on a harddisk, loaded from memory, depending on what the programmer of the application might be doing.

  • You must to post comments
Showing 1 - 20 of 43 results
Your Answer

Please first to submit.