This is SoundSubInspector.m in view mode; [Download] [Up]
//----------------------------------------------------------------------------------------------------
//
// SoundSubInspector
//
// Inherits From: DefaultSubInspector
//
// Declared In: SoundSubInspector.h
//
// Disclaimer
//
// You may freely copy, distribute and reuse this software and its
// associated documentation. I disclaim any warranty of any kind,
// expressed or implied, as to its fitness for any particular use.
//
//----------------------------------------------------------------------------------------------------
#import "SoundSubInspector.h"
#import <appkit/appkit.h>
@implementation SoundSubInspector
static id _SELF = nil;
//----------------------------------------------------------------------------------------------------
// Initialization and Free Methods
//----------------------------------------------------------------------------------------------------
+ new
{
// Only allow one instance...
if (_SELF) return _SELF;
_SELF = self = [super new];
sound = [[Sound alloc] init];
return _SELF;
}
- free
{
if (sound) [sound free];
return [super free];
}
//----------------------------------------------------------------------------------------------------
// Inspection Methods
//----------------------------------------------------------------------------------------------------
- inspect: (STR) path
{
// Read the soundfile and display information...
int readStatus;
if (! path) return self;
readStatus = [sound readSoundfile: path];
if (readStatus != SND_ERR_NONE)
{
[sound deleteSamples];
return [self inspectionError: path];
}
[size setIntValue: [sound dataSize]];
[samples setIntValue: [sound sampleCount]];
[seconds setFloatValue: [sound duration]];
[format setIntValue: [sound dataFormat]];
[rate setDoubleValue: [sound samplingRate]];
[channels setIntValue: [sound channelCount]];
[info setStringValue: [sound info]];
return self;
}
//----------------------------------------------------------------------------------------------------
// Action Methods
//----------------------------------------------------------------------------------------------------
- play: sender
{
[sound play];
return self;
}
//----------------------------------------------------------------------------------------------------
// Accessing Inspection View
//----------------------------------------------------------------------------------------------------
- clearInspectorView
{
// Clear view before...
[size setStringValue: ""];
[samples setStringValue: ""];
[seconds setStringValue: ""];
[format setStringValue: ""];
[rate setStringValue: ""];
[channels setStringValue: ""];
[info setStringValue: ""];
return self;
}
@endThese are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.