- Home /
Question by
TheTurkeydipking · Jul 26, 2015 at 10:27 AM ·
audiomicrophone
Deleting an AudioClip created by the microphone
Hey Unity, I need the script to delete the audio clip the microphone created after its played once, and I have no idea how to make it do that. Here is my script:
using UnityEngine;
using System.Collections;
using System;
public class MicrophoneInput_00 : MonoBehaviour {
bool audioExists;
float startTime; // declare this outside any function
private MoraleManager_00 moraleManager;
void Start() {
foreach (string device in Microphone.devices) {
Debug.Log("Name: " + device);
audioExists = false;
moraleManager = GameObject.FindGameObjectWithTag ("MoraleManager").GetComponent<MoraleManager_00>();
}
}
void Update () {
if (Input.GetKey("3")){
// key pressed: save the current time
AudioSource aud = GetComponent<AudioSource>();
aud.clip = Microphone.Start("Samson C01U", false, 2, 44100);
Debug.Log("recording!!!!");
StartCoroutine(AudioCutOff());
aud.Play();
audioExists = true;
moraleManager.increaseMorale(3f);
}
if (audioExists = true) {
}
}
IEnumerator AudioCutOff() {
yield return new WaitForSeconds(1.0f);
audioExists = false;
}
}
Any help would be greatly appreciated!
Comment
Your answer
Follow this Question
Related Questions
Mac Built-In Microphone Not Working 2 Answers
Unity 5 and using a microphone 1 Answer
Capture audio without playing it back 2 Answers
Voice Recording issue ?? 0 Answers
Get volume from microphone to make something happen 0 Answers