- Home /
i need to make an app in c# that records sounds input by user and is able to be played back
this is my first post..i am working on an audio app that has a piano on the screen with different notes laid out on the keys. so far i have when the user presses one of the keys that sound attached to that key gets added to an array in the order the user presses them...i would like to know how to go about recording the time in between presses so the user can play back their recorded track on real time im not quite sure how to approach this problem and if unity has any built in functions to ease this process any help would be great thanks
Depending on accuracy, this problem is fairly simple. You will want to record the start time of each note, or perhaps better, the difference in time from the previous note. Unity gives you a variety of mechanisms for checking time (Time.time, Time.deltaTime, Time.realtimeSinceStartup). For what you've outlined, those should be accurate enough. You also have access through .NET the OS time functionality if you need something more accurate. I'd start with a simple coroutine for playback.
For each note do this to record record:
waitFromPreviousNote = Time.time - previousTime;
previousTime = Time.time;
Pseudo-code for playback:
whlie (notes are available) {
load new note to be played
yield WaitForSeconds(waitFromPreviousNote);
play the note;
}
Your answer
Follow this Question
Related Questions
How can we change default playback device in unity? 2 Answers
Audio Question 2 Answers
Unity 3.5 Beta Audio in SWF issue ! 2 Answers
Walking sound Help 2 Answers