Recording voice iphone

Hello,

I create a 3d character of unity and I want to repeat everything he hears (the application is dedicated to iphone),otherwise i want to record sound and play it back immediately.

is that possible to do this in unity?
if not you can help me with examples or documentation
Thank you for your help and advice

Unity can’t handle external sounds yet - it only reproduces audio files. You should use some DLL to record the sound in any format, and then use the resulting file inside Unity.

EDITED: Oops! You’re going to use it in an iPhone… and DLLs are for PCs! Anyway, you should have some external program doing the record and save job, then use the saved file, at least while Unity doesn’t include some feature to acquire sounds from mic or aux inputs.

EDITED2: Don’t mind, that’s what Unity Answers is for: answer questions about Unity. By the way, UA is different from forums: you should use add new comment to reply to answers, not the Answer box, or else other people will think there’s a lot of answers to the same question (I agree, there should exist some warning about this! But don’t mind, everybody does this same mistake at first).

I’m not a Mac user, so I can’t tell you exactly how to do this stuff, but I suppose it’s similar to the PC. In a PC, I would create a DLL (which is a library of routines written in any language, like C, C#, Pascal etc.) with the functions I would need, store it in the Plugins folder of my project and declare these functions in a C# script, like this:

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class RecordSound : MonoBehaviour {
 	[DllImport("DllRecord")]
 	public static extern void RecordToFile(String fileName, double duration);

 	void Update(){
 		if (Input.GetMouseButtonDown(0)){
 			RecordToFile("Sound1.wav", 10f);
 		}
 	}
}

In this example my DLL file is called DllRecord.dll, and I have inside it a function called RecordToFile which records sound during duration seconds and save it to the file fileName. As an example, I placed a simple code in Update that records 10 seconds and save it to Sound1.wav when the left mouse button is clicked.

I believe the process is similar in a Mac - but using the Mac DLL equivalent, which I suppose is dylib, a XCode Dynamic Library.

This whole process may be painful, since in the dylib you must use obscure system functions to record sounds and save files. But maybe you have a simpler solution: I read somewhere that the FMOD plugin for Unity can accept input sounds, and that it works for Mac - but I’m not sure if it can be used in the iPhone. As a plugin, the connection with Unity is probably done like the example above - and I believe the plugin files already include the function declarations, which would greatly easy your job.

Google around for FMOD and Mac, and maybe you find something easier to implement. I’ll do some research too, and let you know about what I’ve found.

Thank you for your answer, really this part of sound is unclear.

1 - From the research I did them, it is the objective-C and this is the first time I use the Mac OS so I have no conaissance in this language. I wonder if you can help me with an example of sound recording and playback that will be guided that I can understand what it is ?

2-Method:
I think that in the first step i must have a file with x-code development then we must find a way to integrate this file into unity. It is logical what I just said?
In this case, is it necessary to use a DLL file? I’m sorry if I say anything

I am very sorry for the inconvenience I know I ask many questions but just at the beginning that the matter will be clear, I would very much like your advice and your help.

I hope you answer my questions (1 and 2).Thank you

thank you very very much aldonaletto you are so gentil, i m very interessted in your advice and i m waiting for more details about this subject.

thank you aldonaletto

I found a project called SpeakHear with objective-C, it records the sounds with one button and one for playback. I want to repeat what he hears a voice that makes you laugh like Tom cat.

Before doing this I want to know if there is another method with C # because I have no knowledge of objective-C and when I wanted to do the Laison between unity and objective-C
I lost myself I found also the editor Mono I do not know if practicable to use it … I am very worried.

I still have that two weeks for the submission of the project and I’m still not managed to find the solution

Help me please please