如何录制钢琴?

时间:2013-08-20 06:08:08

标签: ios streaming audio-streaming icecast piano

我有一个基于触控音色的钢琴应用程序,现在我想在其中添加录音功能。任何人都可以指导我这样做。但是我需要记录下来并发送到流中。

-(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);
        }
    } }

1 个答案:

答案 0 :(得分:0)

只是想一下如何保存关键命中记录并记录本地数据库延迟的计时器。之后使用AVAsset将命中音频和静音音频组合起来保存或重放。可能有帮助