开发者

Record sounds using a two-dimensional array

开发者 https://www.devze.com 2023-01-01 02:39 出处:网络
i\'d开发者_StackOverflow中文版 like to record sounds played by tapping with a two dimensional array using the time and the sound id.

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

精彩评论

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