Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Skeletim · Jul 17, 2013 at 12:53 AM · audioaudiosourcemicrophonerecording

Recording audio from another audio source

If I were to open up any audio recording program, the basic function is that I can click record, speak into a microphone, and then click stop, and that portion of audio is recorded to a file. How would that principle work if instead of audio coming into a microphone as the input, the input audio to capture would be audio playing from another audio file?

I know there is convenient method calls like Microphone.start() and Microphone.stop(), but I doubt that can be used without a microphone. If this is something I will need to use GetOutputData(), then I have no idea how to use that call.

I appreciate any help.

Comment
Add comment · Show 8
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 Anotheryeti · Jul 17, 2013 at 01:11 AM 0
Share

It looks like you're going to need to use GetOutputData(), which clearly isn't very well documented. I would suggest doing some tests with GetOutputData() to see exactly how it behaves. $$anonymous$$y guess is that there's some standard audio block size.

You could set up a script that samples the audio listener occasionally, uses GetOutputData() to put that in a buffer, and use SetData() on an audio clip to hear exactly what was recorded, just to see what's going on.

avatar image Skeletim · Jul 17, 2013 at 01:34 AM 0
Share

I'm doing that now, I'm just struggling to figure out what exactly the data that GetOutputData is returning. It seems to be an array of sorts. I have no idea what to do with it. I guess I'm not really sure how to do what you say just yet.

avatar image Anotheryeti · Jul 17, 2013 at 02:19 AM 0
Share

The data is likely just pure sample data from the master audio. So as a guess, floats normalized between 0 and 1. If you want to record it, you're going to need to save all of that data to disk/memory on the fly as new blocks come in. The biggest issue will be deter$$anonymous$$ing when you hit the next block, and not missing any.

avatar image Skeletim · Jul 17, 2013 at 02:36 AM 0
Share

based on it's definition

 function GetOutputData (samples : float[], channel : int) : void

isn't samples defining the size of the block?

avatar image aldonaletto · Jul 17, 2013 at 02:05 PM 0
Share

Yes, you must allocate the samples array with the necessary size, and GetOutputData fills it with audio samples (floats between -1 and 1). Use AudioSettings.outputSampleRate to define how big the array must be: if you want to sample 10 seconds, for instance, allocate the array like this:

 var samples = new float[10 * AudioSettings.outputSampleRate];

If you want to save the sound as a file, take a look at this question.

Show more comments

1 Reply

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

Answer by Skeletim · Jul 21, 2013 at 04:39 AM

You can follow up on this here

http://forum.unity3d.com/threads/191599-Creating-a-custom-AudioClip-from-another-AudioClip-with-GetOutputData

Comment
Add comment · 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

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Microphone capture different channels 0 Answers

Trying to monitor the incoming audio from external usb interface 0 Answers

How can I set audio to play as if it was into the recording device? 1 Answer

How to calculate buffer size of OnAudioFilterRead? 1 Answer

Delay with Microphone.Start 1 Answer


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