Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate an app look like Guitar Hero
    text
    copied!<p>I want to create an application like an Guitar Hero Game. So, I've six button named a1, a2, a3, a4, a5, a6 that played sounds. Then, I play a music consist of Guitar instrument strings.</p> <p>My Question is how can I create a function to tones follow the music played?</p> <p>@Derek: I'm sorry for my bad english.</p> <p>Now, I've create six button with IB that each button have different sound. I use IBAction to create button and use AVAudioPlayer to play the sound. This is my code: `</p> <pre><code>in .h .................{ AVAudioPlayer *av1, *av2, *av3, *av4, *av5, *av6; } @property (nonatomic, retain) AVAudioPlayer *av1, *av2, *av3, *av4, *av5, *av6; -(IBAction)one:(id)sender; -(IBAction)two:(id)sender; -(IBAction)three:(id)sender; -(IBAction)four:(id)sender; -(IBAction)five:(id)sender; -(IBAction)six:(id)sender; -(IBAction)play:(id)sender; in.m - (void)viewDidLoad { [super viewDidLoad]; //load file audio dan persiapkan untuk play //saron1 NSString *path1 = [[NSBundle mainBundle] pathForResource:@"sp1" ofType:@"wav"]; av1 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path1] error:NULL]; av1.delegate = self; [av1 setVolume:1.0]; [av1 prepareToPlay]; //saron2 NSString *path2 = [[NSBundle mainBundle] pathForResource:@"sp2" ofType:@"wav"]; av2 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path2] error:NULL]; av2.delegate = self; [av2 setVolume:1.0]; [av2 prepareToPlay]; //saron3 NSString *path3 = [[NSBundle mainBundle] pathForResource:@"sp3" ofType:@"wav"]; av3 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path3] error:NULL]; av3.delegate = self; [av3 setVolume:1.0]; [av3 prepareToPlay]; //saron4 NSString *path4 = [[NSBundle mainBundle] pathForResource:@"sp4" ofType:@"wav"]; av4 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path4] error:NULL]; av4.delegate = self; [av4 setVolume:1.0]; [av4 prepareToPlay]; //saron5 NSString *path5 = [[NSBundle mainBundle] pathForResource:@"sp5" ofType:@"wav"]; av5 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path5] error:NULL]; av5.delegate = self; [av5 setVolume:1.0]; [av5 prepareToPlay]; //saron6 NSString *path6 = [[NSBundle mainBundle] pathForResource:@"sp6" ofType:@"wav"]; av6 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path6] error:NULL]; av6.delegate = self; [av6 setVolume:1.0]; [av6 prepareToPlay]; } - (IBAction)one:(id)sender{ [av1 play]; } - (IBAction)two:(id)sender{ [av2 play]; } - (IBAction)three:(id)sender{ [av3 play]; } - (IBAction)four:(id)sender{ [av4 play]; } - (IBAction)five:(id)sender{ [av5 play]; } - (IBAction)six:(id)sender{ [av6 play]; } </code></pre> <p>av1-av5 are guitar string and av6 is the guitar music (30 second played). From that code, How can I make an PlayButton to follow the other button one-six when the music played?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload