- Home /
Long Save time on Audioclip
Hi,
I am setting up a system for recording audio on a mobile device, everything is working. The length of the audio can be any length and this is where the problem is. I am finding that on any clip over a minute long, whilst saving the app just hangs, it looks as though it has frozen but then returns to normal when the clip is saved.
The only thing that seems worth mentioning is that I am using Easy Save 2.
Any suggestions on how to make this a background task or something so that the app can continue to run whilst saving is handled elsewhere?
I have looked at threading but this does not word due to the usage restrictions on the main thread.
EDIT: I thought I would add my current code in case that helps or shows any performance flaws.
private void SaveRecording()
{
recordingText.text = "Start Recording";
pressed = false;
Debug.Log((int)clipLength);
Microphone.End("");
AudioClip ac = aud.clip;
float lengthL = ac.length;
float samplesL = ac.samples;
float samplesPerSec = (float)samplesL / lengthL;
float[] samples = new float[(int)(samplesPerSec * clipLength)];
ac.GetData(samples, 0);
aud.clip = AudioClip.Create("TestLenght", (int)(clipLength * samplesPerSec), 1, 44100, false, false);
aud.clip.SetData(samples, 0);
audioName = ("" + DateTime.Now.ToString("dd-MM-yyyy HH.mm.ss"));
int tempNumber = UnityEngine.Random.Range(0, 20);
string tempName = tempNumber.ToString();
Debug.Log(audioName);
ES2.Save(aud.clip, audioName);
//memManager.AddNewButton();
memManager.SaveRecording(name);
clipLength = 0;
}
Thanks in advance all.
Your answer
![](https://koobas.hobune.stream/wayback/20220613193339im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Record/Save/Playback of Audio clips.. How to? 3 Answers
Remembering the state of a scene 1 Answer
How do I open a PC project/scene on MAC? 1 Answer
Save and Load 2 Answers
Get the order of scenes from a text file 0 Answers