2006-01-20 12:34:02 -03:00
|
|
|
//
|
2006-04-02 11:44:08 -04:00
|
|
|
// InputNode.m
|
2006-01-20 12:34:02 -03:00
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Zaphod Beeblebrox on 8/2/05.
|
|
|
|
// Copyright 2005 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "InputNode.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation InputNode
|
|
|
|
|
|
|
|
- (void)open:(NSString *)filename
|
|
|
|
{
|
|
|
|
soundFile = [SoundFile open:filename];
|
|
|
|
|
|
|
|
[soundFile getFormat:&format];
|
|
|
|
|
2006-04-02 11:44:08 -04:00
|
|
|
shouldContinue = YES;
|
2006-01-20 12:34:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)process
|
|
|
|
{
|
|
|
|
const int chunk_size = CHUNK_SIZE;
|
|
|
|
char buf[chunk_size];
|
|
|
|
int amountRead;
|
|
|
|
|
|
|
|
DBLog(@"Playing file.\n");
|
|
|
|
|
2006-04-02 11:44:08 -04:00
|
|
|
while ([self shouldContinue] == YES && [self endOfStream] == NO)
|
2006-01-20 12:34:02 -03:00
|
|
|
{
|
|
|
|
amountRead = [soundFile fillBuffer:buf ofSize: chunk_size];
|
|
|
|
if (amountRead <= 0)
|
|
|
|
{
|
2006-04-02 11:44:08 -04:00
|
|
|
endOfStream = YES;
|
2006-01-20 12:34:02 -03:00
|
|
|
NSLog(@"END OF INPUT WAS REACHED");
|
|
|
|
[controller endOfInputReached];
|
|
|
|
[soundFile close];
|
|
|
|
return; //eof
|
|
|
|
}
|
|
|
|
[self writeData:buf amount:amountRead];
|
|
|
|
}
|
2006-04-02 11:44:08 -04:00
|
|
|
|
2006-01-20 12:34:02 -03:00
|
|
|
[soundFile close];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (AudioStreamBasicDescription) format
|
|
|
|
{
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|