views:

975

answers:

2

I've got an app in development where you press a button to play a sound using System beep.

Instead of recording the output, I was thinking of recording the timing of when the buttons were pressed, so when the user presses a 'Play' button, the buttons are pressed in the same timing the user has pressed them, so it acts like the iPhone has recorded the sounds, but it's just playing them in sequence. I'd like this to occur once the user has pressed a Record button.

Example:

  1. User presses record
  2. Timing starts
  3. > records timing of each button pressed and when
  4. Timing stops after a button has been pressed
  5. PLay button plays back the sequence of events

Can anybody give any ideas on coding, documents to read etc.

Thanks a lot!

A: 

http://pastie.org/376474

This should hopefully help you out a bit. It works in essence, though I haven't actually tested it, so I'm not positive it works. I assume you can read through it and find a way to fit it in your own code.

Good luck!

itaiferber
Hmm that seems alright, but the timer seems to be messing up:http://pastie.org/376712
Domness
A: 

Many system time methods have a way to get the value in seconds since the epoch. Depending on the granularity of the system clock you can just grab the system time of the start button press and grab the time again when each button is pressed. To calculate the timing just subtract the start time from the button press time.

Chris Nava