Domness
Domness

Reputation: 7605

Simple metronome - Play an AIF every x number of milliseconds

I've had a look at the metronome sample given by Apple, however, the sample is too complicated and includes things not needed in my project.

Is there a simple way to make a system sound play every x number of milliseconds?

Upvotes: 0

Views: 1011

Answers (2)

davidcann
davidcann

Reputation: 1419

A word of warning... NSTimer is not accurate, if timing is important or you're trying to keep a steady beat.

Upvotes: 1

Joel Levin
Joel Levin

Reputation: 2888

Look into NSTimer.

You are going to want to do something like this:

[NSTimer scheduledTimerWithTimeInterval:x target:self selector:@selector(yourMethodHere:) userInfo:nil repeats:YES];

The Apple examples can help with the actual code needed to play the sound file, and NSTimer should be pretty straightforward to learn how to use.

Another good NSTimer resource can be found at CocoaDev.

Upvotes: 1

Related Questions