Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Evil-Dog · May 05, 2011 at 08:36 PM · audiosounddelayoffsetlibrary

How to play a sound from the middle of the sound?

I have high quality car engine sounds that I need to play from various point in the sound, say I accelerate to 25% then when I release the accelerator, the decceleration sound should start at 25% to match the acceleration sound, is this possible? Play a sound with an offset(in samples or time)?

If not possible is there more useful sound libraries I can use for Unity that would work on iphone and android?

Thank you

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
16
Best Answer

Answer by Evil-Dog · May 06, 2011 at 02:26 PM

Sorry to answer my own question but the answer is indeed obvious after all. Setting the timeSamples property before calling Play() does the trick. I assumed timeSamples was read-only.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Joshua · May 06, 2011 at 02:35 PM 2
Share

Don't be sorry, it's a good thing. Now if some one else has the same problem they can look it up here :)

avatar image ben.aten · Apr 16, 2014 at 04:50 AM 0
Share

@Evil-Dog - Could you please post a sample script.

Thank you, Ben

avatar image Josh707 · Apr 16, 2014 at 05:58 AM 1
Share

These should give you an idea

https://docs.unity3d.com/Documentation/ScriptReference/AudioSource-time.html

https://docs.unity3d.com/Documentation/ScriptReference/AudioSource-timeSamples.html

avatar image ben.aten · Apr 16, 2014 at 10:14 AM 0
Share

Thanks, Do you have any idea of playing movie texture from middle ins$$anonymous$$d of from starting?

avatar image peterpan2022 · Jul 24, 2021 at 09:44 PM 0
Share

You can use .time instead of .timeSamples, to "set the playback position in seconds" instead of using sample count

avatar image
0

Answer by flaviusxvii · May 05, 2011 at 08:42 PM

You could set the volume to 0 and then set it to 100% after the right amount of time has passed.

But why not just slice up the audio into it's component pieces and play them individually like any sane person would do? This sounds like a seriously problematic work around.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Evil-Dog · May 05, 2011 at 09:06 PM 0
Share

$$anonymous$$aybe I didn't explain myself correctly, I have a sound that's from idle to max speed, a long acceleration sound. And a deccel sound from max speed to idle. So if I accel to 25%, and release the pedal, the deccel sound must start at 75%, so it matches with the accel sound. Anyway I think I can set timeSamples to the right spot and play the sound. I thought it was read-only but I've seen an answer along those lines somewhere. To understand, check my game Road of the Dead which I'm porting to Unity now.
http://www.newgrounds.com/portal/view/550714

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Kindle Fire sound files always delayed 0 Answers

Car engine sound 1 Answer

How to start a sound not from it's start ? 2 Answers

How to dynamically play audio from a folder? 0 Answers

Random footsteps 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges