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’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.
I’m not what you mean here… I have no problem using the play-function (in sidplay2.cpp). But to create a SidTune to play, you must either specify:
* a filename as a string or
* a buffer where the data to the tune is.
So what I was thinking was to get the data that fmod read when opening the file and use that to input to the buffer to create a Sidtune. Is it possible?
OMF what a hazzle it was to compile the whole package… When I at last after several hours got it to compile, sidplay2.exe only gave a "unkown format"-error.
Then I tried to compile with VS 7.1 instead of 8.0 and then it worked!
I’m going back to 7.1 now and wait a few years before upgrading….
Sidplay doesn’t read the file, the read function of sidplay mean "generate me a length byte of data in buffer", it is produced not read from file, where the read function of fmod ex is "read length byte of data from ressource (file/pak…) in buffer", here, the buffer data is inside and not computed, this is why Brett ask you if you can override the read function from Fmod Ex to your own.
Though, when Fmod Ex will read your override read function, you are free to fill the fmod ex buffer the way you want, even computed.
I’m not sure you still understand what I mean. In Sidtune.h there is one contructor that takes a buffer and a length instead of a filename.
[code:256n0ygo]SidTune::SidTune(const uint_least8_t* data, const uint_least32_t dataLen)
You specify a buffer to load the data (the song) from. So I could use this constructor if I can access the read filedata fmod read to load the sidtune. Are you with me?
lengthpcm : it can’t be calculated as the sound is generated by the cpu, it is like the spu of the snes (spc700) though you will have to set the time yourself.
By default, it is 3:00 minutes … BUT !
You can alternatively add support for the HVSC songlength database
format : SIGNED_SHORT
blockalign : (bps >> 3) * numchannels
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]
Please login first to submit.