public virtual void Clear() { name = truename = null; cache = null; registration_sequence = 0; bufferId = -1; isCached = false; }
public static sfxcache_t LoadSound(sfx_t s) { if (s.name[0] == '*') { return(null); } sfxcache_t sc = s.cache; if (sc != null) { return(sc); } string name; if (s.truename != null) { name = s.truename; } else { name = s.name; } string namebuffer; if (name[0] == '#') { namebuffer = name.Substring(1); } else { namebuffer = "sound/" + name; } byte[] data = FS.LoadFile(namebuffer); if (data == null) { Com.DPrintf("Couldn't load " + namebuffer + "\\n"); return(null); } int size = data.Length; wavinfo_t info = GetWavinfo(s.name, data, size); if (info.channels != 1) { Com.Printf(s.name + " is a stereo sample - ignoring\\n"); return(null); } float stepscale; if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL) { stepscale = 1; } else { stepscale = (float)info.rate / S.GetDefaultSampleRate(); } int len = (int)(info.samples / stepscale); len = len * info.width * info.channels; if (len >= maxsamplebytes) { Com.Printf(s.name + " is too long: " + len + " bytes?! ignoring.\\n"); return(null); } sc = s.cache = new sfxcache_t(len); sc.length = info.samples; sc.loopstart = info.loopstart; sc.speed = info.rate; sc.width = info.width; sc.stereo = info.channels; ResampleSfx(s, sc.speed, sc.width, data, info.dataofs); data = null; return(sc); }