- Home /
How to edit audioclip?
Is there a way to merge two clip into one or replace part of clip? ex. replace 9~10 seconds sound for another short clip ...
BTW should I use GetData() and SetData() ?
Answer by gregzo · May 02, 2012 at 10:54 AM
Yes, you should use GetData and SetData, as well as AudioClip.Create
Look it up in the docs, it's all there!
Do ask again if you can't manage.
Tips: -GetData() will fill the float array you feed it. If your array is longer than the clip's samples, expect a crash.
-Same applies to SetData: the float array needs to be shorter or equal to the number of samples in your clip.
-You can offset both with set and get data. Handy in many cases.
Actually, I followed the doc, but I got an error "Cannot get data from streamed sample"
I still can't figure out why....
In your assets, select your clip, and set LoadType to Load in $$anonymous$$emory. I've never tried GetData with mp3's, so if that's your format it might be a problem too.
Yes, I chose Compressed in memory, hmm..
what kind of audio clip type could be used??
native (wav) if you want to do any kind of real time manipulation
what's the offset meaning? Does it decide where the start pos?
I use it
int middle = audio.clip.samples * audio.clip.channel / 2;
audio.clip.SetData(samples, middle);
but it crashed...
Your answer
![](https://koobas.hobune.stream/wayback/20220613071010im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Record and play audio-edits in-game 1 Answer
Recorded Audio empty when used in app 0 Answers
Microphone capture different channels 0 Answers
Screenshot Movie with Audio Capture 1 Answer
Breathing volume increases as player gets more tired 0 Answers