2
我有一个基于触摸的音调的钢琴应用程序,现在我想把一个录音功能。任何人都可以指导我做到这一点。但我需要记录这一点并发送到一个流。如何录制钢琴?
-(void) viewDidLoad {
[super viewDidLoad];
[keyboardView setVisibleKeyRange: NSMakeRange(48, 5)];
if (audio == nil) {
[self setAudio:[NSMutableArray arrayWithCapacity:0]];
}
[drawingView setShowOutsideLedger:YES];
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"keyboardLayout" ofType:@"plist"];
NSArray* names = [NSArray arrayWithContentsOfFile:plistPath];
// Load Audio
for (int i = 0; i < [names count]; i++) {
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:names[i] ofType:@"aif"]], &soundID);
NSNumber* audioId = @(soundID);
[audio addObject:audioId];
}
[[self keyboardView] setDelegate:self];
[[self octaveSelectionView] setDelegate:self];
}
- (void) keysPressed:(NSSet *)keys {
NSLog(@"keysPressed=%d", [keys count]);
[drawingView addNotes:keys];
for (NSNumber* keyIndex in keys) {
if ([audio count] > [keyIndex intValue]) {
SystemSoundID soundID = [audio[[keyIndex intValue]] unsignedLongValue];
AudioServicesPlaySystemSound(soundID);
}
} }
在这种情况下,我wouldnt能够记录多个剧本。如果用户同时播放两个音调,则只会记录一个音调。 – koherent