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