quicktime.sound
Class SndHandle

java.lang.Object
  |
  +--quicktime.QTObject
        |
        +--quicktime.util.QTHandleRef
              |
              +--quicktime.util.QTHandle
                    |
                    +--quicktime.sound.SndHandle
All Implemented Interfaces:
quicktime.jdirect.InterfaceLib, quicktime.jdirect.PrimitivesLib, quicktime.jdirect.QuickTimeLib, quicktime.jdirect.SharedLibrary, com.apple.jdirect.SharedLibrary, quicktime.jdirect.SoundLib

public final class SndHandle
extends QTHandle
implements quicktime.jdirect.QuickTimeLib, quicktime.jdirect.SoundLib


Fields inherited from interface quicktime.jdirect.QuickTimeLib
JDirect_MacOSX, libraryInstance, name
 
Fields inherited from interface quicktime.jdirect.SoundLib
JDirect_MacOSX, libraryInstance
 
Constructor Summary
SndHandle()
          Construct an empty handle that must be initialized by the setupHeader call.
SndHandle(int size, boolean clear)
          Construct an empty handle that must be initialized by the setupHeader call.
SndHandle(int numChannels, float sampleRate, int sampleSize, int compressionType)
          Construct a sound resource for containing sampled sound that can be used to record and play sound.
SndHandle(int numChannels, float sampleRate, int sampleSize, int compressionType, int baseNote)
          Construct a sound resource for containing sampled sound that can be used to record and play sound.
 
Method Summary
 void appendSoundBuffer(int bufferSize)
          Appends the specified number of bytes to the SoundHandle after the header.
 void appendSoundData(QTPointerRef buffer)
          Appends the sound buffer to the end of this handle.
 QTPointerRef getSoundData()
          Return a Pointer to the sound data that is contained within the SndHandle.
 int getSoundHeaderOffset()
          The number of bytes from the beginning of the sound resource specified by the sndHdl parameter to the sound header that is contained within.
 SndInfo parseSndHeader()
          You use this function to retrieve information about a SndHandle.
 void setSoundData(QTPointerRef buffer)
          Sets the internal buffer Pointer of this sound header to the incomding buffer.
 int setupHeader(int numChannels, float sampleRate, int sampleSize, int compressionType, int numBytes)
          You can use the SetupSndHeader function to construct a sound resource containing sampled sound that can be passed to the SndPlay function.
 int setupHeader(int numChannels, float sampleRate, int sampleSize, int compressionType, int baseNote, int numBytes)
          You can use the SetupSndHeader function to construct a sound resource containing sampled sound that can be passed to the SndPlay function.
 
Methods inherited from class quicktime.util.QTHandle
clone, concatenate, fromEncodedImage, fromGraphicsExporterInput, fromGraphicsExporterOutput, fromGraphicsExporterText, fromGraphicsImporterAlias, fromGraphicsImporterData, fromSoundDescription, fromTimeCoderCurrent, fromTimeCoderSource, fromTimeCoderTime, fromTrack, reserveMemory, setSize
 
Methods inherited from class quicktime.util.QTHandleRef
copyFromArray, copyFromArray, copyFromArray, copyFromArray, copyFromArray, copyFromArray, copyFromArray, copyToArray, copyToArray, copyToArray, copyToArray, copyToArray, copyToArray, copyToArray, fromCompressionDialogState, fromSCSequence, getBytes, getSize, inMemory, isLocked, lock, lockHigh, moveHigh, toQTPointer, toQTPointer, toString, unlock
 
Methods inherited from class quicktime.QTObject
disposeQTObject, equals, ID
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SndHandle

public SndHandle()
          throws QTException
Construct an empty handle that must be initialized by the setupHeader call.

SndHandle

public SndHandle(int size,
                 boolean clear)
          throws QTException
Construct an empty handle that must be initialized by the setupHeader call.
Parameters:
size - how many bytes to allocate
clear - if true the handle's memory is cleared to zeroes.

SndHandle

public SndHandle(int numChannels,
                 float sampleRate,
                 int sampleSize,
                 int compressionType)
          throws QTException
Construct a sound resource for containing sampled sound that can be used to record and play sound. You must append the actual sample data to the created SndHandle before it can be used to record or play.

QuickTime::SetupSndHeader

Parameters:
numChannels - the number of channels for the sound
sampleRate - the rate at which the sound was recorded
sampleSize - The sample size for the original sound (that is, bits per sample).
compressionType - The compression type for the sound ('NONE', 'MAC3', 'MAC6', or other third-party types).

SndHandle

public SndHandle(int numChannels,
                 float sampleRate,
                 int sampleSize,
                 int compressionType,
                 int baseNote)
          throws QTException
Construct a sound resource for containing sampled sound that can be used to record and play sound. You must append the actual sample data to the created SndHandle before it can be used to record or play.

QuickTime::SetupSndHeader

Parameters:
numChannels - the number of channels for the sound
sampleRate - the rate at which the sound was recorded
sampleSize - The sample size for the original sound (that is, bits per sample).
compressionType - The compression type for the sound ('NONE', 'MAC3', 'MAC6', or other third-party types).
baseNote - The base note for the sound, expressed as a MIDI note value.
Method Detail

setupHeader

public int setupHeader(int numChannels,
                       float sampleRate,
                       int sampleSize,
                       int compressionType,
                       int numBytes)
                throws SoundException
You can use the SetupSndHeader function to construct a sound resource containing sampled sound that can be passed to the SndPlay function.

QuickTime::SetupSndHeader

Parameters:
numChannels - the number of channels for the sound
sampleRate - the rate at which the sound was recorded
sampleSize - The sample size for the original sound (that is, bits per sample).
compressionType - The compression type for the sound ('NONE', 'MAC3', 'MAC6', or other third-party types).
numBytes - The number of bytes of audio data that are to be stored in the handle. (This value is not necessarily the same as the number of samples in the sound.)
Returns:
the size (in bytes) of the 'snd ' resource header that is created

setupHeader

public int setupHeader(int numChannels,
                       float sampleRate,
                       int sampleSize,
                       int compressionType,
                       int baseNote,
                       int numBytes)
                throws SoundException
You can use the SetupSndHeader function to construct a sound resource containing sampled sound that can be passed to the SndPlay function.

QuickTime::SetupSndHeader

Parameters:
numChannels - the number of channels for the sound
sampleRate - the rate at which the sound was recorded
sampleSize - The sample size for the original sound (that is, bits per sample).
compressionType - The compression type for the sound ('NONE', 'MAC3', 'MAC6', or other third-party types).
baseNote - The base note for the sound, expressed as a MIDI note value.
numBytes - The number of bytes of audio data that are to be stored in the handle. (This value is not necessarily the same as the number of samples in the sound.)
Returns:
the size (in bytes) of the 'snd ' resource header that is created

getSoundHeaderOffset

public final int getSoundHeaderOffset()
                               throws SoundException
The number of bytes from the beginning of the sound resource specified by the sndHdl parameter to the sound header that is contained within.

QuickTime::GetSoundHeaderOffset

Returns:
the offset to the sound header

getSoundData

public QTPointerRef getSoundData()
                          throws QTException
Return a Pointer to the sound data that is contained within the SndHandle. The SndHandle will be locked by this call and should remain locked for the life of the returned data object.
Returns:
a QTPointer to the Sound data

appendSoundData

public void appendSoundData(QTPointerRef buffer)
                     throws QTException
Appends the sound buffer to the end of this handle. This is required before the SndHandle can be used for recording or playing sound. If a pre-existing buffer has been appended this will be removed and replace with the incoming buffer. This will copy the incoming buffer.
Parameters:
buffer - the buffer that contains the actual sound data.

appendSoundBuffer

public void appendSoundBuffer(int bufferSize)
                       throws QTException
Appends the specified number of bytes to the SoundHandle after the header. The call resizes the SndHandle to the sound header offset + buffer size.
Parameters:
bufferSize - the number of bytes to append for the sound buffer

setSoundData

public void setSoundData(QTPointerRef buffer)
                  throws QTException
Sets the internal buffer Pointer of this sound header to the incomding buffer. This does NOT copy memory and is therefore the most efficient means of storing the data.
Parameters:
buffer - the buffer that contains the actual sound data.

parseSndHeader

public final SndInfo parseSndHeader()
                             throws SoundException
You use this function to retrieve information about a SndHandle.

QuickTime::ParseSndHeader

Returns:
a SndInfo object