audio "chopping"

Hi guys. I was just wondering if anyone else encountered this one:

I have an audio file (in this case, an MP3 file). Using scripting, I want to just play out a particular portion of said audio file when I press a particular key. Like between 0:23 and 0:28.

Is this possible with the current tools Unity3D has? At the moment, the only solution I can think of to address this is by just taking a particular portion of the said audio file, and use it to create another audio file to use.

BTW, I’m using the Indie version.

Thanks in advance! :slight_smile:

AudioSource.time or AudioSource.timeSamples look like they could do the trick :

AudioSource.time      
var time : float
Description

Playback position in seconds.

Use this to read current playback time or to seek to a new playback time.

See Also: timeSamples variable.

sweet! Thanks argien! Imma test it out, and let you know how it goes.

hi.

Finally was able to test out the 2 functions AudioSource.time and AudioSource.timeSamples. Unfortunately, they don’t function the way I wanted them to. They simply return back the time where they are in the audio file.

For example, the audiofile is an MP3 file that is 2 minutes long. If I put it into a variable that tracks the value of the function (via the function Update()), it just displays the point of playback.

Unless I’m still lacking proper knowledge of the use of the two functions, plus the scarcity of forum discussions for this, I might have to find another way to play back portions of a particular audio clip.

Help please?

Hey: Try this:

How does that relate to the OP’s question exactly? Can you clarify?