I need some clearing up of fmod concepts.
In a 3d sound environment, if I am standing and surrounded by(at different distances) say 15 men all shooting me, each of the shots from the gun produce a “bang” sound. Now the key here is that they are all at diff. positions, firing at diff times. Add to this that the volumes might be different(not just due to distance) because they use a silencer.
So granted all the difference in the way each object is using this “bang” sound, is it correct to have 15 fsound_sample’s loaded, one per guy shooting at me, or am I spose to be able to use just one loaded fsound_sample to produce this effect?
Thanks in advance for clearing up this.
- bobb asked 14 years ago
You should probably be using a “resource manager” i.e. some kind of map or hash that makes sure that the same file does not get loaded into ram many times. It uses the full path of the file as a key, and the sample as the data. There is a gotchya though: you need separate lists for HW2D, HW3D, SW2D and SW3D (i.e. the same map can be used for 2 and 3d sofware sounds). Also streams must not be resource managed.
it isn’t really that complicated- it only gets complicated when you try using a garbage collection system too
What I’m doing is I have a Sample class that takes a filename as a parameter in its constructor along with an isHW bool and an is3D bool. I use a static New method and have made the constructor/destructor private to make sure the object can’t be instantiated normally or on the stack. The New method tests if the file has already been loaded into the appropriate map, and if it has it just returns the already loaded instance, otherwise it creates a new instance and puts it in the map using the filename as the key.
There are many more elaborations such as usage tracking i.e. loading/unloading samples depending on frequency of use and the amount of ram set aside for sample storage.
After acmipark has been installed in Federation Square (Dec 1) I do a code cleanup and update my docs and release my new code under the GPL. It is a hybrid system that whilst it is written almost entirely in C++ it is completely controllable from the ruby (http://www.ruby-lang.org) scripting language. It is an “engine” written on top of fmod rather than a simple ruby wrapper of the fmod api.
I am just writing C++ wrapper -classes vor fmod, for a given framework.
In this wrapper I also have a kind of resource management, wich will just load a sample once (or twice, once for 3D once for 2D, as I mix 2D sounds allways in Software, 3D-Sounds allways in Hardware) and gives back a sample pointer to every objekt wants to play that sample.
Problems would just occur if those samples are in fact the same, but with different looppoints or a different MinMaxDistance, because those are set per sample not per channel. So in the case that those values should have other than the default-settings by now I create an own sample-pointer per request…..
This makes me ask one question: that the looppoints are sample-specific is quite logical because it depends on the length of the sample (which could be made even not sample specific, if it would be made relative to the length of the sample per channel eg. between 0.0f and 1.0f with 0.0 marking the beginning, 1.0 marking the end, 0.5f marking the half-length of the sample….), but won’t it be nicer if you would also be able to adjust the MinMaxDistance per channel? For the sample a default- value could be set, but if you realy need you can differ it from channel to channel…
- gruebel answered 14 years ago
I’ve hacked minMax distance to be per-channel by having a manager class that sets things like this just prior to playback. A manager is rather like an entity, has it’s own position, volume, minMax dist, EAX material preset, etc, and keeps a list of the sounds it is currently playing (managing). Having it per-channel natively would be v. nice
I find loop points being per-sample to be rather annoying, and ended up writing a SampleStream class (i.e. a user stream that loads a sample into ram, locks it to get the pointer, and looks after its own looping) to work around this limitation. I think channels must have their own loop points anyway because this seems to be how the fmod streams work.
Please login first to submit.