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 GKdev1980 · Feb 03, 2015 at 05:26 PM · audiosourcemicrophone

Multiple Audiosources recording from the same microphone

I'm working on an app, it's supposed to be a mobile app, hence there's only one microphone available..

I'm wondering if I can use this single microphone to manipulate recordings of audioclips to different AudioSource objects.

I mean, in one case I may want one audiosource to constantly record for 20 seconds for example, while in the other audiosource I may want to start recording after 3 seconds, record for 10 seconds and then stop..

Is it possible to handle simultaneous recordings for 2 different audiosources in the same time and manipulate them independently from one another?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GKdev1980 · Feb 04, 2015 at 09:04 AM

I'm probably going to answer my own question after a few tests I made..

What I wanted to know if at any time a microphone is dedicated in recording to a single AudioClip or if it could record to multiple AudioClips at the same time. After trying the following code though:

 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
 
 
     AudioSource aud;
     AudioClip rec1;
     AudioClip rec2;
 
     void Start() {
         Debug.Log ("Testing sound recording");
 
         aud = GetComponent<AudioSource>();
         rec1 = Microphone.Start(null, false, 5, 44100);
         rec2 = Microphone.Start(null, false, 10, 44100);
 
     }
 
     void Update(){
         if(Input.GetKeyUp(KeyCode.A) || Input.touchCount >0){
             Debug.Log("Playing clip 1!!!");
             aud.clip = rec1;
             aud.Play();
         }
 
         else if(Input.GetKeyUp(KeyCode.B) || Input.touchCount >0){
             Debug.Log("Playing clip 2!!!");
             aud.clip = rec2;
             aud.Play();
 
         }
     }
 }


I get the feeling that this is not possible. I manage to play AudioClip 2, but when I try to play AudioClip 1 I get no sound.

I'll probably have to think of a different approach to what I have in mind...

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
avatar image
0

Answer by beyonderic · Jul 01, 2018 at 06:57 PM

Any luck @abracadabra1980 ? I'm having the same issue.

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
avatar image
0

Answer by Remjie · May 06, 2020 at 07:20 PM

I know it an old post but since nobody answer, maybe it could help. according to your own anwer, if you cant record 2 audioclip form same source ( i 'm asking the same that how i fall there), the workaround is to get the sound from the previous audioclip at defined time.

Here an exemple of what u could use :

 private string mic = null;
     private int micPos = 0;
     private int samplerate = 16000;
 
     private AudioClip GetAudioClip (AudioClip AC, int startPos)
     {
         micPos = Microphone.GetPosition(mic);
         
         // be sure start pos is minimum 0
         startPos = startPos < 0 ? 0 : startPos;
         // clip lenght
         int clipSize = micPos - startPos;
 
         float[] clipSampleData = new float[clipSize];
         // get sample from original clip
         AC.GetData(clipSampleData, startPos);
         // create a new one
         AudioClip fullclip = AudioClip.Create("sample", clipSize, 1, samplerate, false);
         // fill the new clip
         fullclip.SetData(clipSampleData, 0);
 
         return fullclip;
     }

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

22 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Microphone Noise Reduction speech enhancement 1 Answer

Microphone.GetComponent () not working + Microphone.devices empty? 0 Answers

Microphone capture different channels 0 Answers

Get volume from microphone to make something happen 0 Answers

Save Mic input and have it load when game starts up again 0 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