/** * Plays a mutation of the sound. If the parameters are dirty, synthesises sound as it plays, caching it for later. * If they're not, plays from the cached sound. * Won't play if caching asynchronously. * @param mutationAmount Amount of mutation * @param mutationsNum The number of mutations to cache before picking from them */ public void PlayMutated(float __mutationAmount = 0.05f, uint __mutationsNum = 15) { Stop(); if (_cachingAsync) { return; } _mutation = true; _cachedMutationsNum = __mutationsNum; if (_params.paramsDirty || _cachedMutations == null) { // New set of mutations _cachedMutations = new float[_cachedMutationsNum][]; _cachingMutation = 0; } if (_cachingMutation != -1) { // Continuing caching new mutations Reset(true); // To get _envelopeFullLength _cachedMutation = new float[_envelopeFullLength]; _cachedMutationPos = 0; _cachedMutations[_cachingMutation] = _cachedMutation; _waveData = null; _original = _params.Clone(); _params.Mutate(__mutationAmount); Reset(true); } else { // Play from random cached mutation _waveData = _cachedMutations[(uint)(_cachedMutations.Length * getRandom())]; _waveDataPos = 0; } createGameObject(); }