我有一个基于触摸的钢琴应用程序,现在我想在其中添加录音功能。有人能指导我这样做吗。但我需要把这个记录下来并发送到流。
-(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);
}
} }
只是给出一个想法,如何保存按键注释并在本地数据库上记录延迟计时器。之后使用AVAsset组合命中的音频和静音音频以保存或回放。它能帮助吗