DSPSerialPortDevice Class Reference

The DSPSerialPortDevice class corresponds to a device that plugs into the DSP serial port. Instantiating an instance of the DSPSerialPortDevice class itself provides you with a serial port protocol that is used by many devices such as the Ariel Digital Microphone and the Metaresearch Digital Ears. For other devices that don't follow that protocol, or for access to "customization" commands, you may instantiate an instance of a subclass of DSPSerialPortDevice. The Music Kit provides a number of such subclasses:. More...

#import <DSPSerialPortDevice.h>

Inheritance diagram for DSPSerialPortDevice:

ArielProPort SSAD64x StealthDAI2400

List of all members.

Public Member Functions

(id) - setUpSerialPort:
 This is invoked by Orchestra open to set up the serial port.
(id) - setSendsSettings:
 Set whether settings, such as the sampling rate are sent by the object (via the SCI port) to the device.
(BOOL) - sendsSettings
 Returns value of sendsSettings instance variable.
(BOOL) - supportsSamplingRate:
 This method returns YES if the device supports the specified sampling rate or if that sampling rate is obtainable as half of one of the sampling rates the device supports.
(BOOL) - hardwareSupportsSamplingRate:
 This returns YES if rate is a sampling rate actually supported by the device.
(int) - hardwareSupportedSamplingRates:
 This method mallocs and returns in *rates an array of sampling rates supported by the hardware.
(BOOL) - supportsHalfSamplingRate:
 This returns YES if rate is available only as half of one of the sampling rates supported by the hardware.
(double) - defaultSamplingRate
 This method returns a default sampling rate for this device.
(int) - inputSampleSkip
 Returns samples skipped for sound input (i.e.
(int) - outputSampleSkip
 Returns samples skipped for sound output (i.e.
(int) - inputInitialSampleSkip
 Returns samples initially skipped for input.
(int) - outputInitialSampleSkip
 Returns samples initially skipped for output.
(int) - inputChannelCount
 Returns number of input sound channels.
(int) - outputChannelCount
 Returns number of output sound channels.
(int) - inputPadding
 Returns number of extra samples to append to each input sample frame.
(BOOL) - setUpAfterStartingSoundOut
 This is invoked by Orchestra open to determine whether to send setUpSerialPort: before or after calling DSPMKStartSoundOut().
(id) - unMuteSerialPort:
 This is invoked by Orchestra open to unmute the serial port device.
(id) - closeDownSerialPort:
 Subclass may override this method to do any special muting or other things needed for clean shut-down.
(id) - adjustMonitor:forOrchestra:
 Implement this to make any adjustments to the DSP monitor before it is loaded.


Detailed Description

The DSPSerialPortDevice class corresponds to a device that plugs into the DSP serial port. Instantiating an instance of the DSPSerialPortDevice class itself provides you with a serial port protocol that is used by many devices such as the Ariel Digital Microphone and the Metaresearch Digital Ears. For other devices that don't follow that protocol, or for access to "customization" commands, you may instantiate an instance of a subclass of DSPSerialPortDevice. The Music Kit provides a number of such subclasses:.

SSAD64x Singular Solutions AD64x ADC & DAT interface. StealthDAI2400 Stealth DAI2400 DAT interface. ArielProPort Ariel ProPort interface.

These class descriptions appear at the end of this document. The file DSPSerialPortDevice.h contains the interface declarations for these classes. It also contains defines for "classes" that are fully represented by the DSPSerialPortDevice class itself:

ArielDigitalMic Ariel Digital Microphone MRDigitalEars Metaresearch Digital Ears

To use a DSPSerialPortDevice or subclass instance, you simply send the orchestra instance the message setSerialPortDevice: with an argument of your DSPSerialPortDevice instance. In order to access the device for sound output, you must also send to the orchestra the message setSerialSoundOut:YES. Similarly, to access the device for sound input, you must send the orchestra setSerialSoundIn:YES. To find out if you can use a particular sampling rates, you send the message supportsSamplingRate: to the DSPSerialPortDevice or subclass instance. To find the default sampling rate, send it the message defaultSamplingRate.

To implement a new DSPSerialPortDevice subclass for a new device, you override a number of methods. The most important is setUpSerialPort:. Other methods you might want to override include hardwareSupportedSamplingRates:, inputSampleSkip and outputSampleSkip.

The DSPSerialPortDevice class also supports "half sampling rates". For example, if the hardware supports 44100, 48000 and 32000, then the Music Kit software will also allow the device to be used at 22050, 42000 and 16000. These half sampling rates are entirely automatic - the designer of a subclass need not think about this at all. He need only implement hardwareSupportedSamplingRates:.

If you have several Orchestra instances (for example, if you have a cube with an Ariel QuintProcessor) and each has its own serial port, each can have its own instance of DSPSerialPortDevice or one of its subclasses.


Member Function Documentation

- (id) setUpSerialPort: (id)  orchestra  

This is invoked by Orchestra open to set up the serial port.

Parameters:
orchestra is an id.
Returns:
Returns an id. A subclass may override this method to provide appropriate values. The default version of this method uses these settings: scr = 0x302, sccr = 0x18, cra = 0x4100 and crb = 0xa00. If sendsSettings is NO, does not set scr or sccr. See the DSP56001 manual for details. A subclass may also override this method and invoke the orchestra method sendSCIByte: to send a command to the device hardware.

Reimplemented in SSAD64x, StealthDAI2400, and ArielProPort.

- (id) setSendsSettings: (BOOL)  yesOrNo  

Set whether settings, such as the sampling rate are sent by the object (via the SCI port) to the device.

Parameters:
yesOrNo is a BOOL.
Returns:
Returns an id. It is up to the subclass implementation of setUpSerialPort: to support this flag. The default value is YES.

- (BOOL) sendsSettings  

Returns value of sendsSettings instance variable.

Returns:
Returns a BOOL.

- (BOOL) supportsSamplingRate: (double)  rate  

This method returns YES if the device supports the specified sampling rate or if that sampling rate is obtainable as half of one of the sampling rates the device supports.

Parameters:
rate is a double.
Returns:
Returns a BOOL. This method is implemented as:
return ([self hardwareSupportsSamplingRate:rate] || [self hardwareSupportsSamplingRate:rate*2])

Subclass should not override this method, but should implement hardwareSupportedSamplingRates: instead.

- (BOOL) hardwareSupportsSamplingRate: (double)  rate  

This returns YES if rate is a sampling rate actually supported by the device.

Parameters:
rate is a double.
Returns:
Returns a BOOL. Does not return YES for half sampling rates. A subclass should not override this method.

- (int) hardwareSupportedSamplingRates: (double **)  rates  

This method mallocs and returns in *rates an array of sampling rates supported by the hardware.

Parameters:
rates is a double **.
Returns:
Returns an int. In addition, it returns the length of the array. A subclass may override this method.

Reimplemented in SSAD64x, StealthDAI2400, and ArielProPort.

- (BOOL) supportsHalfSamplingRate: (double)  rate  

This returns YES if rate is available only as half of one of the sampling rates supported by the hardware.

Parameters:
rate is a double.
Returns:
Returns a BOOL. Implemented as: return ([self supportsSamplingRate:rate] && ![self hardwareSupportsSamplingRate:rate]);
Subclass should not override this method, but should implement hardwareSupportedSamplingRates: instead.

- (double) defaultSamplingRate  

This method returns a default sampling rate for this device.

Returns:
Returns a double. For Music Kit synthesis, this should be the lowest sampling rate (within reason) so that naive users have the least trouble with running out of DSP resources. Half of a hardware-supported sampling rate may be returned. Default version returns 22050. A subclass may override this method.

- (int) inputSampleSkip  

Returns samples skipped for sound input (i.e.

Returns:
Returns an int. sound entering the DSP via the serial port.) Default is no skipping and this method returns 0. A subclass may override this method.

Reimplemented in SSAD64x.

- (int) outputSampleSkip  

Returns samples skipped for sound output (i.e.

Returns:
Returns an int. sound exiting the DSP via the serial port.) Default is no skipping and this method returns 0. A subclass may override this method.

Reimplemented in SSAD64x.

- (int) inputInitialSampleSkip  

Returns samples initially skipped for input.

Returns:
Returns an int. For example, if inputSampleSkip is 1 and the samples arrive in the DSP as 0,<sample>,0,<sample>, then inputInitialSampleSkip should return 1. On the other hand, if inputSampleSkip is 1 and the samples arrive in the DSP as <sample>,0,<sample>,0, then inputInitialSampleSkip should be 0. Default is no initial skipping and this method returns 0. A subclass may override this method.

- (int) outputInitialSampleSkip  

Returns samples initially skipped for output.

Returns:
Returns an int. For example, if outputSampleSkip is 1 and the samples are sent out the DSP as 0,<sample>,0,<sample>, then outputInitialSampleSkip should return 1. On the other hand, if outputSampleSkip is 1 and the samples are sent out the DSP as <sample>,0,<sample>,0, then outputInitialSampleSkip should be 0. Default is no initial skipping and this method returns 0. A subclass may override this method.

- (int) inputChannelCount  

Returns number of input sound channels.

Returns:
Returns an int. Default version returns 2 for stereo. A subclass may override this method.

- (int) outputChannelCount  

Returns number of output sound channels.

Returns:
Returns an int. Default version returns 2 for stereo. A subclass may override this method.

- (int) inputPadding  

Returns number of extra samples to append to each input sample frame.

Returns:
Returns an int. Default implementation returns 0. Subclasses may override this method.

- (BOOL) setUpAfterStartingSoundOut  

This is invoked by Orchestra open to determine whether to send setUpSerialPort: before or after calling DSPMKStartSoundOut().

Returns:
Returns an id. The default implementation returns YES. Subclasses may override this method.

- (id) unMuteSerialPort: (id)  orchestra  

This is invoked by Orchestra open to unmute the serial port device.

Parameters:
orchestra is an id.
Returns:
Returns an id. A subclass may override this method to provide appropriate behaviour, when it is inclined to produce unwanted noise after setting up the serial port, before the DSP produces output. The default version of this method does nothing.

Reimplemented in SSAD64x.

- (id) closeDownSerialPort: (id)  orchestra  

Subclass may override this method to do any special muting or other things needed for clean shut-down.

Parameters:
orchestra is an id.
Returns:
Returns an id.

Reimplemented in SSAD64x.

- (id) adjustMonitor: (DSPLoadSpec *)  system
forOrchestra: (id)  orchestra 

Implement this to make any adjustments to the DSP monitor before it is loaded.

Parameters:
system is a DSPLoadSpec *.
orchestra is an MKOrchestra *.
Returns:
Returns an id. If you implement this method, you must first call DSPSetSystem(system); in the implementation. Normally, it's better if you can make your adjustments in setUpSerialPort:.


The documentation for this class was generated from the following file:

Generated on Sat Dec 5 17:01:14 2009 for MusicKit by  doxygen 1.5.6