- Home /
Playing part of audio file
I am working on a game where player can play several music instruments at the same time.
The way I have done this is, I created number of small audio files (80) for each sound the instrument makes. And play them using “PlayOneShot” when the player touch the instrument. It is possible for the player to play up to 8 instruments at the same time.
When I test the game on some Android devices the audio does not play smoothly (when all 8 instruments playing). There are very short breaks.
I assume this is because I have large number of audio files.
To solve this, I wanted to create a single audio file for each instrument with all the sounds it makes. Then I can jump to different positions in it to get the appropriate sound.
Can anyone suggest a method to do this or a solution to my problem?
use AudioSource.timeSamples AudioSource.timeSamples
Ok, that will get me where I am at the audio file But how do I jump to a specific position in the audio file?
Answer by rbeldessi · May 25, 2017 at 02:54 PM
You can set the playback time through either AudioSource.time or AudioSource.timeSamples. What I would suggest is making each instrument have their own AudioSource and then enable/disable playback depending on the input to the instrument.
Your answer
Follow this Question
Related Questions
WWW Audio and PlayOneShot: Playing the same AudioClip Twice Cuts off First Instance 1 Answer
What is the difference between PlayClipAtPoint and PlayOneShot? 1 Answer
Making a song play once when using bool variables 1 Answer
Audio not playing on TriggerEnter (Pic Included) 3 Answers
Need help with AudioSources 1 Answer