Пример #1
0
 private void generateLeft()
 {
     toneOutput.attribute("Frequency").value = leftFrequency;
     toneOutput.Generate();
     leftAudioClip        = toneOutput.audioClip;
     leftAudioSource.loop = false;
 }
Пример #2
0
 private void FindSound()
 {
     DarkArtsStudios.SoundGenerator.Composition   bounceComposition = SoundType.GetComponent <DarkArtsStudios.SoundGenerator.Composition>();
     DarkArtsStudios.SoundGenerator.Module.Output output            = null;
     foreach (DarkArtsStudios.SoundGenerator.Module.BaseModule module in bounceComposition.modules)
     {
         if (module.GetType() == typeof(DarkArtsStudios.SoundGenerator.Module.Output))
         {
             output = module as DarkArtsStudios.SoundGenerator.Module.Output;
             break;
         }
     }
     if (output)
     {
         output.Generate();
         Sound = output.audioClip;
     }
 }
Пример #3
0
    void Start()
    {
        float ballSize  = Random.value;
        float ballPitch = (1f - ballSize) + 1f;

        transform.localScale = Vector3.one * (0.1f + ballSize);

        DarkArtsStudios.SoundGenerator.Composition   bounceComposition = ballCompositionPrefab.GetComponent <DarkArtsStudios.SoundGenerator.Composition>();
        DarkArtsStudios.SoundGenerator.Module.Output output            = null;
        foreach (DarkArtsStudios.SoundGenerator.Module.BaseModule module in bounceComposition.modules)
        {
            if (module.GetType() == typeof(DarkArtsStudios.SoundGenerator.Module.Output))
            {
                output = module as DarkArtsStudios.SoundGenerator.Module.Output;
                break;
            }
        }
        if (output)
        {
            output.attribute("Frequency").value = Mathf.Pow(ballPitch, 2) * 100;
            output.Generate();
            bounceSound = output.audioClip;
        }
    }
Пример #4
0
    void OnGUI()
    {
        GUILayout.BeginVertical();
        {
            GUILayout.Space(16);

            foreach (AudioClip sound in sounds)
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(16);

                    GUILayout.Label(sound.name);

                    GUILayout.Space(16);

                    if (GUILayout.Button("Original"))
                    {
                        GetComponent <AudioSource>().PlayOneShot(sound);
                    }

                    GUILayout.Space(16);

                    if (GUILayout.Button("Monkey"))
                    {
                        audioClipModule.audioClip = sound;
                        audioClipModule.audioData = null;
                        outputModule.Generate();
                        GetComponent <AudioSource>().PlayOneShot(outputModule.audioClip);
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndVertical();

/*
 *              Rect labelPlacement = new Rect( 10, 10, Screen.width - 20, 20 );
 *
 *              // No Microphones plugged in
 *              if ( Microphone.devices.Length < 1 )
 *              {
 *                      GUI.Label( labelPlacement, "Please plug a microphone into your computer");
 *                      microphoneDevice = null;
 *                      return;
 *              }
 *
 *              // Select which microphone to use
 *              if (microphoneDevice == null)
 *              {
 *                      GUI.Label( labelPlacement, "Please select a microphone to use:");
 *                      int deviceEnumerator = 1;
 *                      foreach (string deviceName in Microphone.devices) {
 *                              Rect deviceButtonPlacement = new Rect(labelPlacement);
 *                              deviceButtonPlacement.y = deviceEnumerator * labelPlacement.height*1.5f + labelPlacement.y;
 *                              if (GUI.Button(deviceButtonPlacement,deviceName))
 *                              {
 *                                      microphoneDevice = deviceName;
 *                                      break;
 *                              }
 *                      }
 *                      return;
 *              }
 *
 *              if ( GUI.Button( labelPlacement, "Stop" ) )
 *              {
 *                      microphoneDevice = null;
 *              }
 */
    }