开发者

Record sounds using a two-dimensional array

i'd开发者_StackOverflow中文版 like to record sounds played by tapping with a two dimensional array using the time and the sound id. is there any code example anywhere? thanx blacksheep


The code could look a bit like this:

@interface Recorder : NSObject
{
    NSMutableArray *times;
    NSMutableArray *samples;
}
@end

@implementation Recorder

- (id) init
{
    [super init];
    times = [[NSMutableArray alloc] init];
    samples = [[NSMutableArray alloc] init];
    return self;
}

- (void) recordSound: (id) someSound
{
    CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
    NSNumber *wrappedTime = [NSNumber numberWithDouble:now];
    [times addObject:wrappedTime];
    [samples addObject:someSound];
}

@end

Now you’ll have the sample times in the times array and samples in the samples array. You could create a two-dimensional array to hold the data, but this looks easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜