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.
- bLAZER asked 12 years ago
I set it to 0xffffffff now,
But as I wrote, if I set both frequencies to 22050 or both to 44100 I get the same stuttering except that the sond plays twice as fast… so there must be something else that’s also is wrong, but I don’t understand what…
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?
Have you read the sourcecode of sidplay 2 ?
See sid2_config_t struct, here, you set the propertie of the sound to produce and then, according to what you have set, you will have to create appropriate buffer : ie. signed short * for a 16 bits sound, signed char * for a 8 bits sound … (the "signed" keyword can be an option as it is signed by default for the compiler).
Don’t produce the sound for the first callback, create a flag wich tell you to mix or not when fmodex update it’s mixer, sid format is a special case.
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:
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?
Now I got it working. By mistake in the read callback I returned twice as much as it should. And about the stuttering…. I realised my cpu was 99% while playing, and saw that I hade forgot to comment out writing to my logfile, which it did every block.. 😳
So now on to the next problem, what is the easiest way to get the filename from FMOD to the plugin?
you’re actually supposed to use the filesystem provided with fmod, it has already used the filename to open the file and check it through other codecs to see what type of file it is. It also could be loaded from memory, or an internet file, part of a pak file, or using an overriden filesystem (ie the programmer used System::setFileSystem), so if you want to use your own filesystem that stuff just won’t work (who knows what the end programmer will do).
is it possible to make the sid library read file data though fmod’s file functions? (ie do they provide a file callback system or you could just change the code to point to other file reading functions)
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.
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 😀
Hope you get the subsongs part working 8)
- ixilom answered 11 years ago
can I read the file from a buffer using this function in libsid
[code:1h80vfqa]bool read(const uint_least8_t* sourceBuffer, const uint_least32_t bufferLen)[/code:1h80vfqa]
can I get hold of the contents that Fmod read from the file/memory/whetever?
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.
unsigned int* myBuffer;
myBuffer = new unsigned int[codec->filesize];
unsigned int *read=0;
result = codec->fileread(codec,myBuffer,codec->filesize,read,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:
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 */
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.
Please login first to submit.