Up

# NSSound

### Authors

Enrico Sersale (`enrico@imago.ro`)

> Load, manipulate and play sounds

Copyright: (C) 2002, 2009 Free Software Foundation, Inc.

### Contents -

1. Software documentation for the NSSound class
2. Software documentation for the NSBundle(NSSoundAdditions) category
3. Software documentation for the NSObject(NSSoundDelegate) informal protocol

# Software documentation for the NSSound class

## NSSound : NSObject

> Declared in:
>   AppKit/NSSound.h

> Conforms to:
>   NSCoding
>   NSCopying

Availability: OpenStep
Description forthcoming.

Instance Variables
Method summary

- +canInitWithPasteboard:
- +soundNamed:
- +soundUnfilteredFileTypes
- +soundUnfilteredPasteboardTypes
- +soundUnfilteredTypes
- -channelMapping
- -currentTime
- -delegate
- -duration
- -initWithContentsOfFile:byReference:
- -initWithContentsOfURL:byReference:
- -initWithData:
- -initWithPasteboard:
- -isPlaying
- -loops
- -name
- -pause
- -play
- -playbackDeviceIdentifier
- -resume
- -setChannelMapping:
- -setCurrentTime:
- -setDelegate:
- -setLoops:
- -setName:
- -setPlaybackDeviceIdentifier:
- -setVolume:
- -stop
- -volume
- -writeToPasteboard:

### canInitWithPasteboard:

+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard;
Availability: OpenStep
Description forthcoming.

### soundNamed:

+ (id) soundNamed: (NSString*)name;
Availability: OpenStep
Description forthcoming.

### soundUnfilteredFileTypes

+ (NSArray*) soundUnfilteredFileTypes;
Availability: OpenStep
Provides an array of file types that NSSound can understand. The returning array may be directly passed to [NSOpenPanel -runModalForTypes:].

Built with libsndfile:

wav, aiff, aifc, aif, au, snd, mat, mat4, mat5, paf, sf, voc, w64, xi, caf, sd2, flac, ogg, oga

Built without libsndfile:

wav, aiff, aifc, aif, au, snd

### soundUnfilteredPasteboardTypes

+ (NSArray*) soundUnfilteredPasteboardTypes;
Availability: OpenStep
Description forthcoming.

### soundUnfilteredTypes

+ (NSArray*) soundUnfilteredTypes;
Availability: MacOS-X 10.5.0
Description forthcoming.

### channelMapping

- (NSArray*) channelMapping;
Availability: MacOS-X 10.5.0
Description forthcoming.

### currentTime

- (NSTimeInterval) currentTime;
Availability: MacOS-X 10.5.0
Returns the current position of the audio playback.

### delegate

- (id) delegate;
Availability: OpenStep
Returns the receiver's delegate

### duration

- (NSTimeInterval) duration;
Availability: MacOS-X 10.5.0
Returns the length, in seconds, of the receiver.

### initWithContentsOfFile: byReference:

- (id) initWithContentsOfFile: (NSString*)path byReference: (BOOL)byRef;
Availability: OpenStep
This is a designated initialiser for the class.
Initalizes the receiver object with the contents of file located at path. If byRef is set to `YES` only the name of the NSSound is encoded with -encodeWithCoder: ; if set to `NO` the data is encoded.

See Also:

- -initWithContentsOfURL:byReference:
- -initWithData:

### initWithContentsOfURL: byReference:

- (id) initWithContentsOfURL: (NSURL*)url byReference: (BOOL)byRef;
Availability: OpenStep
This is a designated initialiser for the class.
Initializes the receiver object with the contents of the data located in url. If byRef is set to `YES` only the name of the NSSound is encoded with -encodeWithCoder: ; if set to `NO` the data is encoded.

See Also:

- -initWithContentsOfFile:byReference:
- -initWithData:

### initWithData:

- (id) initWithData: (NSData*)data;
Availability: OpenStep
This is a designated initialiser for the class.
Initializes the receiver object with the contents of data with a valid magic number.

See Also:

- -initWithContentsOfFile:byReference:
- -initWithContentsOfURL:byReference:

### initWithPasteboard:

- (id) initWithPasteboard: (NSPasteboard*)pasteboard;
Availability: OpenStep
Description forthcoming.

### isPlaying

- (BOOL) isPlaying;
Availability: OpenStep
Description forthcoming.

### loops

- (BOOL) loops;
Availability: MacOS-X 10.5.0
Returns the current loop property of the receiver. `YES` indicates this NSSound will restart once it reaches the end, otherwise `NO`.

### name

- (NSString*) name;
Availability: OpenStep
Returns the name of the receiver. Use -setName: to set the name.

### pause

- (BOOL) pause;
Availability: OpenStep
Pauses audio playback.

Returns `NO` if receiver could not be paused or is already paused, and `YES` if receiver was successfully paused.

### play

- (BOOL) play;
Availability: OpenStep
Start audio playback. Playback is done asynchronously.

Returns `NO` if receiver is already playing or if an error occurred, and `YES` if receiver was started successfully.

### playbackDeviceIdentifier

- (NSString*) playbackDeviceIdentifier;
Availability: MacOS-X 10.5.0
Description forthcoming.

### resume

- (BOOL) resume;
Availability: OpenStep
Resume audio playback after a -pause .

Returns `NO` if receiver is already playing or if an error occurred, and `YES` if receiver was successfully restarted/resumed.

### setChannelMapping:

- (void) setChannelMapping: (NSArray*)channelMapping;
Availability: MacOS-X 10.5.0
Description forthcoming.

### setCurrentTime:

- (void) setCurrentTime: (NSTimeInterval)currentTime;
Availability: MacOS-X 10.5.0
Sets the current time of the audio playback.

### setDelegate:

- (void) setDelegate: (id)aDelegate;
Availability: OpenStep
Sets the receiver's delegate

### setLoops:

- (void) setLoops: (BOOL)loops;
Availability: MacOS-X 10.5.0
Sets the loop property of the receiver. `YES` indicates this NSSound will restart once it reaches the end, otherwise `NO`.

### setName:

- (BOOL) setName: (NSString*)aName;
Availability: OpenStep
Sets the receiver's name. Method -name will return aName.

### setPlaybackDeviceIdentifier:

- (void) setPlaybackDeviceIdentifier: (NSString*)playbackDeviceIdentifier;
Availability: MacOS-X 10.5.0
Description forthcoming.

### setVolume:

- (void) setVolume: (float)volume;
Availability: MacOS-X 10.5.0
Sets the volume of the receiver. Volume must be between 0.0 and 1.0.

### stop

- (BOOL) stop;
Availability: OpenStep
Stop audio playback.

Return `YES` if receiver was successfully stopped.

This method will close the playback device.

### volume

- (float) volume;
Availability: MacOS-X 10.5.0
Returns the volume of the receiver. Volume will be between 0.0 and 1.0.

### writeToPasteboard:

- (void) writeToPasteboard: (NSPasteboard*)pasteboard;
Availability: OpenStep
Description forthcoming.

## Instance Variables for NSSound Class

### _channelMapping

@protected NSArray* _channelMapping;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _data

@protected NSData* _data;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _delegate

@protected id _delegate;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _name

@protected NSString* _name;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _onlyReference

@protected BOOL _onlyReference;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _playbackDeviceIdentifier

@protected NSString* _playbackDeviceIdentifier;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _playbackLock

@protected NSLock* _playbackLock;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _readLock

@protected NSConditionLock* _readLock;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _shouldLoop

@protected BOOL _shouldLoop;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _shouldStop

@protected BOOL _shouldStop;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _sink

@protected id _sink;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _source

@protected id _source;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

# Software documentation for the NSBundle(NSSoundAdditions) category

## NSBundle(NSSoundAdditions)

> Declared in:
>   AppKit/NSSound.h

Availability: OpenStep
Description forthcoming.
Method summary

- -pathForSoundResource:

### pathForSoundResource:

- (NSString*) pathForSoundResource: (NSString*)name;
Availability: OpenStep
Description forthcoming.

# Software documentation for the NSObject(NSSoundDelegate) informal protocol

## NSObject(NSSoundDelegate)

> Declared in:
>   AppKit/NSSound.h

Availability: OpenStep
Description forthcoming.
Method summary

- -sound:didFinishPlaying:

### sound: didFinishPlaying:

- (void) sound: (NSSound*)sound didFinishPlaying: (BOOL)aBool;
Availability: OpenStep
Method called when sound has finished playing. Currently this method is not called.

Up