2006-01-20 15:34:02 +00:00
|
|
|
//
|
2006-04-02 15:44:08 +00:00
|
|
|
// BufferChain.m
|
2006-01-20 15:34:02 +00:00
|
|
|
// CogNew
|
|
|
|
//
|
|
|
|
// Created by Zaphod Beeblebrox on 1/4/06.
|
|
|
|
// Copyright 2006 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "BufferChain.h"
|
|
|
|
#import "OutputNode.h"
|
|
|
|
|
|
|
|
@implementation BufferChain
|
|
|
|
|
|
|
|
- (id)initWithController:(id)c
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self)
|
|
|
|
{
|
|
|
|
soundController = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)buildChain
|
|
|
|
{
|
2006-04-02 15:44:08 +00:00
|
|
|
[inputNode release];
|
|
|
|
[converterNode release];
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
inputNode = [[InputNode alloc] initWithController:soundController previous:nil];
|
|
|
|
converterNode = [[ConverterNode alloc] initWithController:soundController previous:inputNode];
|
|
|
|
|
|
|
|
finalNode = converterNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)open:(NSString *)filename
|
|
|
|
{
|
|
|
|
[self buildChain];
|
|
|
|
|
|
|
|
[inputNode open:filename];
|
|
|
|
[converterNode setupWithInputFormat:(AudioStreamBasicDescription)[inputNode format] outputFormat:[[soundController output] format] ];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)launchThreads
|
|
|
|
{
|
|
|
|
DBLog(@"LAUNCHING THREAD FOR INPUT");
|
|
|
|
[inputNode launchThread];
|
|
|
|
DBLog(@"LAUNCHING THREAD FOR CONVERTER");
|
|
|
|
[converterNode launchThread];
|
|
|
|
}
|
|
|
|
|
2006-04-02 15:44:08 +00:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
[inputNode release];
|
|
|
|
[converterNode release];
|
|
|
|
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2006-04-02 20:03:12 +00:00
|
|
|
- (void)seek:(double)time
|
|
|
|
{
|
|
|
|
[inputNode seek:time];
|
|
|
|
[inputNode resetBuffer];
|
|
|
|
[converterNode resetBuffer];
|
|
|
|
}
|
|
|
|
|
2006-01-20 15:34:02 +00:00
|
|
|
|
|
|
|
- (id)finalNode
|
|
|
|
{
|
|
|
|
return finalNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setShouldContinue:(BOOL)s
|
|
|
|
{
|
|
|
|
[inputNode setShouldContinue:s];
|
|
|
|
[converterNode setShouldContinue:s];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|