views:

50

answers:

1

i'd 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

A: 

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.

zoul
thanx, i just don't know how to initialize the arrays...
blacksheep
thanx again - next step will be to save the recordings and play them again - eventually while playing new sonds.i'll try to find out - if i don't succed, i'tell it here...
blacksheep
well, i must admit that i don't have any idea how to save and play again the recorded sounds...
blacksheep