play parts of audio

Is it possible to play only a specific part of an audio file with unity?
For examplae the File contains a word and i like to play a spcial letter of this word using a scripting mechanism??

1 Answer

1

AudioSource.timeSamples is what you’re looking for. So long as you know the start time/duration of the sample you want, you should be able to do it.

hmm don't really understand how it works. But it seems that the precision is not good enough. I need a precision within fractions of seconds. Whole words are often under a second in length.

"But it seems that the precision is not good enough" Why do you say that? It should be perfectly accurate so long as you use it correctly.

Ah, you are right, I've messes around a little bit with it and it seems to work fine. The Question is: Will it work the same way on Android or iOS devices? Under windows ist sounds smooth but if you cut a mp3 audio at some position you can get unwanted artefacts. Or does Unity always convert audio files temporarily to uncompressed format whle playing?

You'll need to play with compression and so on. I'm not knowledgeable with iOS etc. Glad to help though. Please mark question as answered :)