private void OnEnable() { _deathSound = new SfxrSynth(); _deathSound.parameters.SetSettingsString("3,.574,,.2422,.6861,.2493,.3,.022,,-.0679,,,,,,,,,,,,,,-.1361,-.0574,1,,,,,,"); _hugeGuyScream = new SfxrSynth(); _hugeGuyScream.parameters.SetSettingsString("3,.507,.111,.347,,1,.352,.061,,.03,.035,.023,.145,.038,,,-.005,,,,,,,.1456,-.183,.741,-.01,,.101,,.661,-.01"); }
protected static SfxrItem FindParameters( Component gameComponent, FieldInfo synthFieldInfo, bool autoInitParams) { SfxrParams parameters = null; var synth = (synthFieldInfo.GetValue(gameComponent) as SfxrSynth); if ((synth == null) && autoInitParams) { synth = new SfxrSynth(); synthFieldInfo.SetValue(gameComponent, synth); } if (synth != null) { parameters = synth.parameters; if ((parameters == null) && autoInitParams) { parameters = new SfxrParams(); synth.parameters = parameters; } } SfxrItem item = null; if (parameters != null) { item = new SfxrItem(parameters, gameComponent, synthFieldInfo); } return(item); }
static SfxrSynth SetCachedSound(string name, string parameters) { cachedSounds[name] = new SfxrSynth(); cachedSounds[name].parameters.SetSettingsString(parameters); return cachedSounds[name]; }
private IEnumerator CacheMutationsAsynchronously(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { yield return null; __synth.CacheMutations(__mutationsNum, __mutationAmount, null, true); __callback(); UnityEngine.Object.Destroy(gameObject); }
public void PlayBeepSound() { beepSynth = new SfxrSynth(); beepSynth.parameters.SetSettingsString("0,.237,,.0546,.5509,.2362,.3,.293,,,,,,,,,,,,,,,,,,1,,,,,,"); beepSynth.Play(); }
void Start() { scale = 0.5f + (Random.value * 0.5f); scale *= scale; scale *= transform.localScale.x; health = (int)Mathf.Round(BASE_HEALTH * scale * 0.5f); isAlive = true; spawnTime = Time.realtimeSinceStartup; speed = MIN_SPEED / scale; transform.localScale = new Vector3(0, 0, 0); SfxrSynth synthSpawn = new SfxrSynth(); synthSpawn.parameters.SetSettingsString("0,0.03,0.23,0.05,0.42,0.15,0.07,-0.04,-0.02,,,0.02,0.05,0.11,0.1799,0.03,-0.4599,0.3999,0.38,,0.11,0.02,-0.02,0.5"); if (Main.isModeMutated) { synthSpawn.PlayMutated(0.05f); } else { synthSpawn.Play(); } }
private IEnumerator CacheSoundAsynchronously(SfxrSynth __synth, Action __callback) { yield return null; __synth.CacheSound(null, true); __callback(); UnityEngine.Object.Destroy(gameObject); }
static SfxrSynth SetCachedSound(string name, string parameters) { cachedSounds[name] = new SfxrSynth(); cachedSounds[name].parameters.SetSettingsString(parameters); return(cachedSounds[name]); }
private void PlayDeselectSound() { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("1,.674,,.1398,,.102,,.187,,,,,,,,,,,,,,,,,,.679,,,,,,"); synth.Play(); }
private void PlayPlaceOrderSound() { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("1,.496,.006,.1398,,.082,,.568,,,,,,,,,,,,,,,,,,1,,,.1,,,"); synth.Play(); }
private IEnumerator CacheMutationsAsynchronously(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { yield return(null); __synth.CacheMutations(__mutationsNum, __mutationAmount, null, true); __callback(); UnityEngine.Object.Destroy(gameObject); }
private void Start() { _gameOverSound = new SfxrSynth(); _gameOverSound.parameters.SetSettingsString(GameOverSound); _player = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthComponent>(); StartCoroutine(TestForGameOver()); }
// Use this for initialization void Start() { synth = new SfxrSynth(); HackingAudioSource = gameObject.AddComponent <AudioSource>(); HackingAudioSource.clip = Resources.Load <AudioClip>("HackSuccess"); HackingAudioSource.loop = false; }
private IEnumerator CacheSoundAsynchronously(SfxrSynth __synth, Action __callback) { yield return(null); __synth.CacheSound(null, true); __callback(); UnityEngine.Object.Destroy(gameObject); }
private SfxrSynth sfxrSynth; // SfxrSynth instance that will generate the audio samples used by this #endregion Fields #region Methods public void Destroy() { // Stops audio immediately and destroys self if (!isDestroyed) { isDestroyed = true; sfxrSynth = null; UnityEngine.Object.Destroy(gameObject); } }
public void Play() { Debug.Log("PLAY"); if (Usfxr != "") { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString(Usfxr); synth.Play(); } }
public void Destroy() { // Stops audio immediately and destroys self if (!isDestroyed) { isDestroyed = true; sfxrSynth = null; UnityEngine.Object.Destroy(gameObject); } }
public static void Add(string name, string definition, bool cache = false) { synthsData.Add(name, definition); SfxrSynth sfx = new SfxrSynth(); sfx.parameters.SetSettingsString(definition); if (cache) { sfx.CacheSound(); } synths.Add(name, sfx); }
public SfxrSynth GetSoundEffect(SoundEffect sfx) { if (!SoundEffectSettings.ContainsKey(sfx)) { Debug.LogError("Requested an unimplemented sound effect!"); return(new SfxrSynth()); } SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString(SoundEffectSettings[sfx]); return(synth); }
public void PlayPickupSound() { if (pickupSynth == null) { pickupSynth = new SfxrSynth(); pickupSynth.parameters.SetSettingsString("1,.05,,.2835,,.3565,.3,.2078,,.3427,,,,,,,,,,,,,.5043,,,1,,,,,,"); pickupSynth.SetParentTransform(Camera.main.transform); float ti = Time.realtimeSinceStartup; pickupSynth.CacheMutations(15, 0.03f); } pickupSynth.PlayMutated(); }
public void PlayHitSound() { if (hitSynth == null) { hitSynth = new SfxrSynth(); hitSynth.parameters.SetSettingsString("3,.05,,.227,.5372,.2318,.3,.419,,-.3868,,,,,,,,,,,,,.5877,,,1,,,,,,"); hitSynth.SetParentTransform(Camera.main.transform); float ti = Time.realtimeSinceStartup; hitSynth.CacheMutations(15, 0.03f); } hitSynth.PlayMutated(); }
public void PlayShotSound() { if (shotSynth == null) { shotSynth = new SfxrSynth(); shotSynth.parameters.SetSettingsString("3,.223,,,,.1814,.456,.215,,-.286,-.132,.767,.523,.812,.975,.0487,,,.0397,,,.0469,,-.0094,,.751,-.321,.0016,.256,.03,,"); shotSynth.SetParentTransform(Camera.main.transform); float ti = Time.realtimeSinceStartup; shotSynth.CacheMutations(15, 0.03f); } shotSynth.PlayMutated(); }
private void Explode() { if (isAlive) { isAlive = false; explodeTime = Time.realtimeSinceStartup; SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("3,0.0228,0.2553,0.186,0.4243,0.0935,,0.0139,0.0292,0.0346,0.0599,-0.3396,0.7684,,-0.0209,,-0.0302,,1,-0.0272,0.0043,,0.0493,0.5"); if (Main.isModeMutated) { synth.PlayMutated(); } else { synth.Play(); } } }
/// <summary> /// Plays the sound for the specified parameters. /// </summary> /// <param name="parameters">The parameters that details the sound to be generated.</param> /// <param name="skipIfUnvailable">When set to <c>true</c> and the sound cannot presently be played, simply skip this request.</param> /// <returns><c>true</c> if playing was initiated; otherwise, <c>false</c> when no sound was played.</returns> public static bool PlaySound( SfxrParams parameters, bool skipIfUnvailable = true) { if (skipIfUnvailable && (!CanPlaySound())) { return(false); // Nothing was played } var synth = new SfxrSynth(); synth.parameters.SetSettingsString( parameters.GetSettingsString()); synth.Play(); return(true); // Play was initiated }
public void SpawnShot1(Vector3 position, Vector3 velocity, GameObject Shooter) { GameObject bullet = Instantiate(BulletTemplate, position, new Quaternion()) as GameObject; bullet.GetComponent <Rigidbody2D>().velocity = new Vector2(velocity.x, velocity.y) * GameProperties.BulletSpeedFactor; bullet.GetComponent <BulletScript>().Shooter = Shooter; //bullet.GetComponent<BulletScript>().AttackTarget = Target; bullet.GetComponent <BulletScript>().Damage = AttributeConverter.GetAttackDamageFromAttribute(Shooter.GetComponent <HealthController>().Attribute_Attack, false); bullet.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); bullet.transform.parent = GameObject.FindGameObjectWithTag("ShotGroup").transform; SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("3,.5,,.176,.7906,.17,.3,.287,,-.305,.075,,,,,,,,,,,,.3418,,,1,,,,,,"); synth.PlayMutated(); }
// just decrease Value private void RemoveHealth(float value) { if (this.tag == "Units") { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("0,.85,.006,.0168,,.257,.3,.2546,,-.3348,,,,,,,,,,,.5682,,,,,1,,,.2569,,,"); synth.PlayMutated(); } else { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("0,.75,.006,.0168,,.257,.3,.2546,,-.3348,,,,,,,,,,,.5682,,,,,1,,,.2569,,,"); synth.PlayMutated(); } CurrenteHealth -= value; CheckDead(); }
void OnTriggerEnter2D(Collider2D coll) { if (coll.tag == "Units") { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString("1,.5,,.324,,.569,,.2933,,.3784,,,,,,,,,,,,,.6636,,,1,,,,,,"); synth.PlayMutated(); var gc = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); gc.ResearchPointsAdd(GameProperties.FoundSmallArtifactRPReward); gc.GainedResearchPoints += 5; gc.MoneyAdd(GameProperties.FoundSmallArtifactMoneyReward); gc.FoundArtefacts += GameProperties.FoundSmallArtifactMoneyReward; Destroy(this.gameObject); } }
public void Initialize() { Debug.LogFormat("Event_Audio_uiSystem : INIT SYNTH! "); Debug.Log("Key: F (Random coin/pickup sound, automatically generated)"); this.sOnPress = new SfxrSynth(); this.sOnNeutral = new SfxrSynth(); this.sOnCombo = new SfxrSynth(); this.sOnPress.parameters.GenerateJump(); this.sOnPress.CacheSound(); this.sOnNeutral.parameters.GenerateBlipSelect(); this.sOnNeutral.parameters.masterVolume = 0.05f; this.sOnNeutral.CacheSound(); // this.sOnCombo.parameters.GeneratePickupCoin(); this.sOnCombo.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); this.sOnCombo.CacheSound(); this.sOnCrouch = new SfxrSynth(); this.sOnCrouch.parameters.GenerateHitHurt(); this.sOnCrouch.CacheSound(); }
public void Destroy() { // Stops audio immediately and destroys self if (!isDestroyed) { isDestroyed = true; sfxrSynth = null; if (runningInEditMode || !Application.isPlaying) { // Since we're running in the editor, we need to remove the update event, AND destroy immediately #if UNITY_EDITOR EditorApplication.update -= Update; #endif UnityEngine.Object.DestroyImmediate(gameObject); } else { UnityEngine.Object.Destroy(gameObject); } } }
protected virtual void OnGUI() { // Initializations if (soundParameters == null) { soundParameters = new SfxrParams(); soundParameters.Randomize(); } if (synth == null) { synth = new SfxrSynth(); } bool soundChanged = false; // Begin UI scrollPositionRoot = GUILayout.BeginScrollView(scrollPositionRoot); GUILayout.BeginHorizontal(); // Left column (generator buttons, copy & paste) soundChanged = RenderLeftColumn(soundParameters) || soundChanged; // Main settings column soundChanged = RenderSettingsColumn(soundParameters) || soundChanged; // Ends the UI GUILayout.EndHorizontal(); GUILayout.EndScrollView(); // Play sound if necessary if (soundChanged) { synth.parameters.SetSettingsString(soundParameters.GetSettingsString()); PlaySound(); CreateWavePreview(); } }
protected virtual void OnGUI() { // Initializations if (soundParameters == null) { soundParameters = new SfxrParams(); soundParameters.Randomize(); } if (synth == null) { synth = new SfxrSynth(); } bool soundChanged = false; // Begin UI scrollPositionRoot = GUILayout.BeginScrollView(scrollPositionRoot); GUILayout.BeginHorizontal(); // Left column (generator buttons, copy & paste) soundChanged = RenderLeftColumn(soundParameters) || soundChanged; // Main settings column soundChanged = RenderSettingsColumn(soundParameters) || soundChanged; // Ends the UI GUILayout.EndHorizontal(); GUILayout.EndScrollView(); // Play sound if necessary if (soundChanged) { // ADDED by hsandt for debouncing and avoiding Fatal Error on Play spam isWaitingForPreviewDebounce = true; lastSoundChangeTimeStamp = Time.realtimeSinceStartup; } }
// ================================================================================================================ // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- public void SetSfxrSynth(SfxrSynth __sfxrSynth) { // Sets the SfxrSynth instance that will generate the audio samples used by this sfxrSynth = __sfxrSynth; }
public bool RenderLeftColumn(SfxrParams parameters) { bool soundChanged = false; // Begin generator column GUILayout.BeginVertical("box", GUILayout.Width(110)); GUILayout.Label("GENERATOR", EditorStyles.boldLabel); GUILayout.Space(8); if (GUILayout.Button("PICKUP/COIN")) { suggestedName = "PickupCoin"; parameters.GeneratePickupCoin(); soundChanged = true; } if (GUILayout.Button("LASER/SHOOT")) { suggestedName = "LaserShoot"; parameters.GenerateLaserShoot(); soundChanged = true; } if (GUILayout.Button("EXPLOSION")) { suggestedName = "Explosion"; parameters.GenerateExplosion(); soundChanged = true; } if (GUILayout.Button("POWERUP")) { suggestedName = "Powerup"; parameters.GeneratePowerup(); soundChanged = true; } if (GUILayout.Button("HIT/HURT")) { suggestedName = "HitHurt"; parameters.GenerateHitHurt(); soundChanged = true; } if (GUILayout.Button("JUMP")) { suggestedName = "Jump"; parameters.GenerateJump(); soundChanged = true; } if (GUILayout.Button("BLIP/SELECT")) { suggestedName = "BlipSelect"; parameters.GenerateBlipSelect(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("MUTATE")) { parameters.Mutate(); soundChanged = true; } if (GUILayout.Button("RANDOMIZE")) { suggestedName = "Random"; parameters.Randomize(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("COPY (OLD)")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); } if (GUILayout.Button("COPY")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); } if (GUILayout.Button("PASTE")) { suggestedName = null; parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("PLAY SOUND")) { PlaySound(); } GUILayout.Space(30); if (GUILayout.Button("EXPORT WAV")) { var path = EditorUtility.SaveFilePanel("Export as WAV", "", getSuggestedName() + ".wav", "wav"); if (path.Length != 0) { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString(parameters.GetSettingsString()); File.WriteAllBytes(path, synth.GetWavFile()); } } // End generator column GUILayout.FlexibleSpace(); GUILayout.EndVertical(); return(soundChanged); }
void Update() { if (Input.GetKeyDown("a")) { Debug.Log("Key: A (Coin with synchronous cache)"); if (synthA == null) { // Coin synthA = new SfxrSynth(); synthA.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); synthA.CacheSound(); } synthA.Play(); } if (Input.GetKeyDown("b")) { Debug.Log("Key: B (Coin without caching, generating asynchronously)"); if (synthB == null) { // Coin synthB = new SfxrSynth(); synthB.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); } synthB.Play(); } if (Input.GetKeyDown("c")) { Debug.Log("Key: C (Laser with mutations cached synchronously)"); if (synthC == null) { // Laser synthC = new SfxrSynth(); synthC.parameters.SetSettingsString("0,,0.1783,,0.3898,0.7523,0.2,-0.2617,,,,,,0.261,0.0356,,,,1,,,0.2466,,0.5"); synthC.SetParentTransform(Camera.main.transform); float ti = Time.realtimeSinceStartup; synthC.CacheMutations(15, 0.05f); Debug.Log("Took " + (Time.realtimeSinceStartup - ti) + "s to cache mutations."); // Hit //synthC.paramss.setSettingsString("2,,0.1702,,0.1689,0.7793,0.0224,-0.4882,,,,,,0.271,0.1608,,,,1,,,,,0.5"); } synthC.PlayMutated(); //synthC.play(); } if (Input.GetKeyDown("d")) { Debug.Log("Key: D (Long death with asynchronous caching and callback)"); if (synthD == null) { // Coin synthD = new SfxrSynth(); synthD.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); // http://stackoverflow.com/questions/667742/callbacks-in-c-sharp synthD.CacheSound(() => synthD.Play()); } else { synthD.Play(); } } if (Input.GetKeyDown("e")) { Debug.Log("Key: E (Long death with parallel caching of mutations and callback)"); if (synthE == null) { // Coin synthE = new SfxrSynth(); synthE.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); // http://stackoverflow.com/questions/667742/callbacks-in-c-sharp synthE.CacheMutations(15, 0.05f, () => synthE.PlayMutated()); } else { synthE.PlayMutated(); } } if (Input.GetKeyDown("f")) { Debug.Log("Key: F (Sound that triggers error, no caching)"); SfxrSynth synthF = new SfxrSynth(); synthF.parameters.SetSettingsString("3,,.1536,.604,.8086,.5019,,.1375,.1967,-.1802,-.8501,.8789,.7139,-.3231,-.0025,.059,.0009,.0181,.8003,-.4656,-.1474,.0041,.0022,.5"); synthF.Play(); } }
private void OnEnable() { _hugeGuyScream = new SfxrSynth(); _hugeGuyScream.parameters.SetSettingsString("3,.507,.111,.347,,.384,.352,.061,,.03,.035,.023,.145,.038,,,-.005,,,,,,,.1456,-.183,.741,-.01,,.101,,.661,-.01"); }
void Update() { if (Input.GetKeyDown("a")) { Debug.Log("Key: A (Coin with synchronous cache)"); if (synthA == null) { // Coin synthA = new SfxrSynth(); synthA.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); synthA.CacheSound(); } synthA.Play(); } if (Input.GetKeyDown("b")) { Debug.Log("Key: B (Coin without caching, generating asynchronously)"); if (synthB == null) { // Coin synthB = new SfxrSynth(); synthB.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); } synthB.Play(); } if (Input.GetKeyDown("c")) { Debug.Log("Key: C (Laser with mutations cached synchronously)"); if (synthC == null) { // Laser synthC = new SfxrSynth(); synthC.parameters.SetSettingsString("0,,0.1783,,0.3898,0.7523,0.2,-0.2617,,,,,,0.261,0.0356,,,,1,,,0.2466,,0.5"); synthC.SetParentTransform(Camera.main.transform); float ti = Time.realtimeSinceStartup; synthC.CacheMutations(15, 0.05f); Debug.Log("Took " + (Time.realtimeSinceStartup - ti) + "s to cache mutations."); // Hit //synthC.paramss.setSettingsString("2,,0.1702,,0.1689,0.7793,0.0224,-0.4882,,,,,,0.271,0.1608,,,,1,,,,,0.5"); } synthC.PlayMutated(); } if (Input.GetKeyDown("d")) { Debug.Log("Key: D (Long death with asynchronous caching and callback)"); if (synthD == null) { synthD = new SfxrSynth(); synthD.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); synthD.CacheSound(() => synthD.Play()); } else { synthD.Play(); } } if (Input.GetKeyDown("e")) { Debug.Log("Key: E (Long death with parallel caching of mutations and callback)"); if (synthE == null) { // Coin synthE = new SfxrSynth(); synthE.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); synthE.CacheMutations(15, 0.05f, () => synthE.PlayMutated()); } else { synthE.PlayMutated(); } } if (Input.GetKeyDown("f")) { Debug.Log("Key: F (Random coin/pickup sound, automatically generated)"); SfxrSynth synthF = new SfxrSynth(); synthF.parameters.GeneratePickupCoin(); synthF.Play(); } }
void Update() { bool newIsADown = Input.GetKey("a"); if (newIsADown && !isADown) { // Start benchmarking guiText.text = "Benchmarking..."; string completeText = ""; completeText += "Output sample rate: " + AudioSettings.outputSampleRate + "\n"; completeText += "\n"; int i; float ti; SfxrSynth synth; int count = 100; // Complete short sound caching ti = Time.realtimeSinceStartup; for (i = 0; i < count; i++) { synth = new SfxrSynth(); synth.parameters.SetSettingsString("0,,0.032,0.4138,0.4365,0.834,,,,,,0.3117,0.6925,,,,,,1,,,,,0.5"); synth.CacheSound(); } float newTimeShort = Time.realtimeSinceStartup - ti; completeText += "Time to generate short sound " + count + " times: " + newTimeShort + " seconds (" + (newTimeShort*1000/count) + " ms/sound)\n"; // Complete long sound caching ti = Time.realtimeSinceStartup; for (i = 0; i < count; i++) { synth = new SfxrSynth(); synth.parameters.SetSettingsString("2,,0.0782,0.6203,0.9024,0.5044,,-0.1298,0.0094,-0.0008,-0.5123,0.2868,-0.3859,-0.8811,0.9692,0.3616,0.001,0.0001,0.9528,0.0437,-0.4492,0.1089,,0.5"); synth.CacheSound(); } float newTimeLong = Time.realtimeSinceStartup - ti; completeText += "Time to generate long sound " + count + " times: " + newTimeLong + " seconds (" + (newTimeLong*1000/count) + " ms/sound)\n"; timeShort += newTimeShort; timeLong += newTimeLong; timesRan++; if (timesRan > 1) { completeText += "\n"; completeText += "Averages after " + timesRan + " tests ran:\n"; completeText += "Time to generate short sound " + count + " times: " + (timeShort / timesRan) + " seconds (" + ((timeShort / timesRan)*1000/count) + " ms/sound)\n"; completeText += "Time to generate long sound " + count + " times: " + (timeLong / timesRan) + " seconds (" + ((timeLong / timesRan)*1000/count) + " ms/sound)\n"; } completeText += "\n"; completeText += "Press A to benchmark again"; guiText.text = completeText; } /* if (newIsCDown && !isCDown) { Debug.Log("Key: C"); SfxrSynth synthC = null; if (synthC == null) { synthC = new SfxrSynth(); // Laser synthC.parameters.SetSettingsString("0,,0.1783,,0.3898,0.7523,0.2,-0.2617,,,,,,0.261,0.0356,,,,1,,,0.2466,,0.5"); // Hit //synthC.paramss.setSettingsString("2,,0.1702,,0.1689,0.7793,0.0224,-0.4882,,,,,,0.271,0.1608,,,,1,,,,,0.5"); } synthC.PlayMutated(0.05f); //synthC.play(); } */ //isADown = newIsADown; //isBDown = newIsBDown; //isCDown = newIsCDown; }
/** * usfxr * * Copyright 2013 Zeh Fernando * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * SfxrCacheSurrogate * This is the (internal) behavior script responsible for calling Coroutines for asynchronous audio generation * * @author Zeh Fernando */ // ================================================================================================================ // PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- public void CacheSound(SfxrSynth __synth, Action __callback) { StartCoroutine(CacheSoundAsynchronously(__synth, __callback)); }
public void CacheMutations(SfxrSynth __synth, uint __mutationsNum, float __mutationAmount, Action __callback) { StartCoroutine(CacheMutationsAsynchronously(__synth, __mutationsNum, __mutationAmount, __callback)); }