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
2010-05-31 09:49:14
thanx, i just don't know how to initialize the arrays...
blacksheep
2010-05-31 14:50:37
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
2010-05-31 16:33:49
well, i must admit that i don't have any idea how to save and play again the recorded sounds...
blacksheep
2010-06-02 11:15:56