C# Class GAudio.GATData

A wrapper for audio data, with a suite of audio processing methods. Used throughout G-Audio. Note: When requesting GATData instances from GATManager.GetDataContainer( int size ), you will in fact be handed an instance of a managed subclass ( GATDataAllocator.GATManagedData ) which responds to Retain() and Release() calls. See the example scenes that comes with G-Audio for examples of typical use.
Inheritance: RetainableObject, IGATDataOwner
显示文件 Open project: gregzo/G-Audio Class Usage Examples

Protected Properties

Property Type Description
_offset int
_parentArray float[]

Private Properties

Property Type Description

Public Methods

Method Description
ApplyFilter ( AGATFilter filter, int fromIndex, int length, bool emptyData ) : void

Applies a filter to the instance's audio data.

CheckSampleBounds ( ) : bool

Checks that no data exceeds the -1f to 1f range.

Clear ( ) : void

Clears all audio data

Clear ( int fromIndex, int length ) : void

Clears audio data at specified range

ClearInterlaced ( int channelNb, int nbOfInterlacedChannels, int length ) : void

Clears a specific channel of interleaved data

ConvertAndSetInt16 ( System source, int sourceOffset, int targetOffset, int length ) : void

Converts an Int16 array and set it at targetOffset

CopyFrom ( float sourceArray, int destinationIndex, int sourceIndex, int length ) : void

Copies data from a float[] to a GATData instance.

CopyFromInterlaced ( float sourceArray, int targetLength, int channelNb, int nbOfChannels ) : void

Performs a copy of a single channel from an interlaced source array.

CopyFromInterlaced ( float sourceArray, int targetLength, int targetOffset, int channelNb, int nbOfChannels ) : void

Performs a copy of a single channel from an interlaced source array.

CopyFromInterlaced ( float sourceArray, int sourceOffset, int targetLength, int targetOffset, int channelNb, int nbOfChannels ) : void

Performs a copy of a single channel from an interlaced source array. sourceOffset is samples offset for channel 0.

CopyGainTo ( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain ) : void

Copies and multuplies by gain data from one GATData instance to another.

CopySmoothedGainFrom ( float sourceArray, int sourceIndex, int destinationIndex, int length, float fromGain, float toGain ) : void

Copies data from a float[] to a GATData instance and applies interpolated gain.

CopySmoothedGainTo ( int sourceIndex, GATData destination, int destinationIndex, int length, float fromGain, float toGain ) : void

Copies data from a GATData instance to another and applies interpolated gain.

CopyTo ( GATData destinationData, int destinationIndex, int sourceIndex, int length ) : void

Copies data from a GATData instance to another.

CopyTo ( float destinationArray, int destinationIndex, int sourceIndex, int length ) : void

Copies data from a GATData instance to a float array.

CopyToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, int channelNb ) : void

Copy to an interleaved float[]

Fade ( float fromGain, float toGain, int fadeLength, int offset ) : void
FadeIn ( int fadeLength ) : void

In place fade-in from offset 0 to fadeLength

FadeInSquared ( int fadeLength ) : void
FadeOut ( int fadeLength ) : void

In-place fade-out from offset this.Count - fadeLength to this.Count - 1

FadeOut ( int offset, int fadeLength ) : void

In-place fade out with offset control

FadeOutSquared ( int fadeLength ) : void
GATData ( float parentArray ) : System

Initializes a new instance of the GATData class. If you need a managed data chunk, use GATManager.GetDataContainer instead

Gain ( int fromIndex, int length, float gain ) : void
GainCopyToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATChannelGain channelGain ) : void

Copy and gain to an interleaved float[]

GainMixTo ( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain ) : void

Additive copy and gain to another GATData instance

GainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATChannelGain channelGain ) : void

Additive copy and gain to an interleaved float[]

GainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATChannelGain channelGain, float igain ) : void

Additive copy and gain to an interleaved float[] with extra gain parameter.

GetPointer ( ) : IntPtr

Gets an IntPtr pointer to the parent array. Only valid for GATData instances obtained through GATManager.GetDataContainer calls.

GlissCopyFrom ( GATData sourceData, int fromIndex, double fromPitch, double toPitch ) : void
GlissCopyFrom ( float sourceArray, int fromIndex, int targetLength, double fromPitch, double toPitch ) : void
MixFrom ( float sourceArray, int destinationIndex, int sourceIndex, int length ) : void

Additive copy from a float[]

MixFromInterlaced ( float sourceArray, int sourceFrameOffset, int targetLength, int targetOffset, int channelNb, int nbOfChannels ) : void

Performs a copy of a single channel from an interlaced source array.

MixSmoothedGainFrom ( float sourceArray, int sourceIndex, int destinationIndex, int length, float fromGain, float toGain ) : void

Additive copy and interpolated gain from a float[]

MixSmoothedGainTo ( int sourceIndex, GATData destination, int destinationIndex, int length, float fromGain, float toGain ) : void

Additive copy and interpolated gain to another GATData instance

MixTo ( GATData destination, int destinationIndex, int sourceIndex, int length ) : void

Additive copy to another GATData instance

MixTo ( float destinationArray, int destinationIndex, int sourceIndex, int length ) : void

Additive copy to a float[]

NextZeroCrossing ( int fromIndex, bool &positive ) : int

Finds the next zero crossing.

Normalize ( float normalizedMax ) : void

Applies gain to the instance's data so that the maximum value matches normalizedMax

ResampleCopyFrom ( float sourceArray, double trueInterpolatedIndex, int targetLength, int targetOffset, double resamplingFactor ) : double

Performs a resampled copy from an array to the GATData instance it is called on. The resampling algorithm performs naive linear interpolation.

ResampleCopyTo ( double trueInterpolatedIndex, GATData destinationSample, int targetLength, double resamplingFactor ) : double

Performs a resampled copy to another GATData instance. The resampling algorithm performs naive linear interpolation.

ResampleCopyTo ( int sourceIndex, GATData destinationSample, int targetLength, double resamplingFactor ) : void

Performs a resampled copy to another GATData instance The resampling algorithm performs naive linear interpolation. Warning: for resampling in chunks, use the method of the same name which returns a double interpolated index.

Reverse ( ) : void

Reverses the entire audio data.

Reverse ( int offset, int length ) : void
SmoothedGain ( int fromIndex, int length, float fromGain, float toGain ) : void

In-place Interpolated gain

SmoothedGainCopyToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain ) : void

Copy and interpolated gain to an interleaved float[]

SmoothedGainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain ) : void

Additive copy and interpolated gain to an interleaved float[]

SmoothedGainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain, float igain ) : void

Additive copy and interpolated gain to an interleaved float[] with extra gain parameter

this ( int index ) : float

Gets or sets the float in the parent array at the specified index. The indexer should only be used for quick prototyping, as it is roughly 30% slower than caching ParentArray for direct access in an extension method.

Protected Methods

Method Description
Discard ( ) : void

Method Details

ApplyFilter() public method

Applies a filter to the instance's audio data.
public ApplyFilter ( AGATFilter filter, int fromIndex, int length, bool emptyData ) : void
filter AGATFilter
fromIndex int
length int
emptyData bool
return void

CheckSampleBounds() public method

Checks that no data exceeds the -1f to 1f range.
public CheckSampleBounds ( ) : bool
return bool

Clear() public method

Clears all audio data
public Clear ( ) : void
return void

Clear() public method

Clears audio data at specified range
public Clear ( int fromIndex, int length ) : void
fromIndex int
length int
return void

ClearInterlaced() public method

Clears a specific channel of interleaved data
public ClearInterlaced ( int channelNb, int nbOfInterlacedChannels, int length ) : void
channelNb int
nbOfInterlacedChannels int
length int
return void

ConvertAndSetInt16() public method

Converts an Int16 array and set it at targetOffset
public ConvertAndSetInt16 ( System source, int sourceOffset, int targetOffset, int length ) : void
source System
sourceOffset int
targetOffset int
length int
return void

CopyFrom() public method

Copies data from a float[] to a GATData instance.
public CopyFrom ( float sourceArray, int destinationIndex, int sourceIndex, int length ) : void
sourceArray float
destinationIndex int
sourceIndex int
length int
return void

CopyFromInterlaced() public method

Performs a copy of a single channel from an interlaced source array.
public CopyFromInterlaced ( float sourceArray, int targetLength, int channelNb, int nbOfChannels ) : void
sourceArray float
targetLength int
channelNb int
nbOfChannels int
return void

CopyFromInterlaced() public method

Performs a copy of a single channel from an interlaced source array.
public CopyFromInterlaced ( float sourceArray, int targetLength, int targetOffset, int channelNb, int nbOfChannels ) : void
sourceArray float
targetLength int
targetOffset int
channelNb int
nbOfChannels int
return void

CopyFromInterlaced() public method

Performs a copy of a single channel from an interlaced source array. sourceOffset is samples offset for channel 0.
public CopyFromInterlaced ( float sourceArray, int sourceOffset, int targetLength, int targetOffset, int channelNb, int nbOfChannels ) : void
sourceArray float
sourceOffset int
targetLength int
targetOffset int
channelNb int
nbOfChannels int
return void

CopyGainTo() public method

Copies and multuplies by gain data from one GATData instance to another.
public CopyGainTo ( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain ) : void
destinationData GATData
sourceIndex int
destinationIndex int
length int
gain float
return void

CopySmoothedGainFrom() public method

Copies data from a float[] to a GATData instance and applies interpolated gain.
public CopySmoothedGainFrom ( float sourceArray, int sourceIndex, int destinationIndex, int length, float fromGain, float toGain ) : void
sourceArray float
sourceIndex int
destinationIndex int
length int
fromGain float
toGain float
return void

CopySmoothedGainTo() public method

Copies data from a GATData instance to another and applies interpolated gain.
public CopySmoothedGainTo ( int sourceIndex, GATData destination, int destinationIndex, int length, float fromGain, float toGain ) : void
sourceIndex int
destination GATData
destinationIndex int
length int
fromGain float
toGain float
return void

CopyTo() public method

Copies data from a GATData instance to another.
public CopyTo ( GATData destinationData, int destinationIndex, int sourceIndex, int length ) : void
destinationData GATData
destinationIndex int
sourceIndex int
length int
return void

CopyTo() public method

Copies data from a GATData instance to a float array.
public CopyTo ( float destinationArray, int destinationIndex, int sourceIndex, int length ) : void
destinationArray float
destinationIndex int
sourceIndex int
length int
return void

CopyToInterlaced() public method

Copy to an interleaved float[]
public CopyToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, int channelNb ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelNb int
return void

Discard() protected method

protected Discard ( ) : void
return void

Fade() public method

public Fade ( float fromGain, float toGain, int fadeLength, int offset ) : void
fromGain float
toGain float
fadeLength int
offset int
return void

FadeIn() public method

In place fade-in from offset 0 to fadeLength
public FadeIn ( int fadeLength ) : void
fadeLength int
return void

FadeInSquared() public method

public FadeInSquared ( int fadeLength ) : void
fadeLength int
return void

FadeOut() public method

In-place fade-out from offset this.Count - fadeLength to this.Count - 1
public FadeOut ( int fadeLength ) : void
fadeLength int
return void

FadeOut() public method

In-place fade out with offset control
public FadeOut ( int offset, int fadeLength ) : void
offset int
fadeLength int
return void

FadeOutSquared() public method

public FadeOutSquared ( int fadeLength ) : void
fadeLength int
return void

GATData() public method

Initializes a new instance of the GATData class. If you need a managed data chunk, use GATManager.GetDataContainer instead
public GATData ( float parentArray ) : System
parentArray float
return System

Gain() public method

public Gain ( int fromIndex, int length, float gain ) : void
fromIndex int
length int
gain float
return void

GainCopyToInterlaced() public method

Copy and gain to an interleaved float[]
public GainCopyToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATChannelGain channelGain ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelGain GATChannelGain
return void

GainMixTo() public method

Additive copy and gain to another GATData instance
public GainMixTo ( GATData destinationData, int sourceIndex, int destinationIndex, int length, float gain ) : void
destinationData GATData
sourceIndex int
destinationIndex int
length int
gain float
return void

GainMixToInterlaced() public method

Additive copy and gain to an interleaved float[]
public GainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATChannelGain channelGain ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelGain GATChannelGain
return void

GainMixToInterlaced() public method

Additive copy and gain to an interleaved float[] with extra gain parameter.
public GainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATChannelGain channelGain, float igain ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelGain GATChannelGain
igain float
return void

GetPointer() public method

Gets an IntPtr pointer to the parent array. Only valid for GATData instances obtained through GATManager.GetDataContainer calls.
public GetPointer ( ) : IntPtr
return System.IntPtr

GlissCopyFrom() public method

public GlissCopyFrom ( GATData sourceData, int fromIndex, double fromPitch, double toPitch ) : void
sourceData GATData
fromIndex int
fromPitch double
toPitch double
return void

GlissCopyFrom() public method

public GlissCopyFrom ( float sourceArray, int fromIndex, int targetLength, double fromPitch, double toPitch ) : void
sourceArray float
fromIndex int
targetLength int
fromPitch double
toPitch double
return void

MixFrom() public method

Additive copy from a float[]
public MixFrom ( float sourceArray, int destinationIndex, int sourceIndex, int length ) : void
sourceArray float
destinationIndex int
sourceIndex int
length int
return void

MixFromInterlaced() public method

Performs a copy of a single channel from an interlaced source array.
public MixFromInterlaced ( float sourceArray, int sourceFrameOffset, int targetLength, int targetOffset, int channelNb, int nbOfChannels ) : void
sourceArray float
sourceFrameOffset int
targetLength int
targetOffset int
channelNb int
nbOfChannels int
return void

MixSmoothedGainFrom() public method

Additive copy and interpolated gain from a float[]
public MixSmoothedGainFrom ( float sourceArray, int sourceIndex, int destinationIndex, int length, float fromGain, float toGain ) : void
sourceArray float
sourceIndex int
destinationIndex int
length int
fromGain float
toGain float
return void

MixSmoothedGainTo() public method

Additive copy and interpolated gain to another GATData instance
public MixSmoothedGainTo ( int sourceIndex, GATData destination, int destinationIndex, int length, float fromGain, float toGain ) : void
sourceIndex int
destination GATData
destinationIndex int
length int
fromGain float
toGain float
return void

MixTo() public method

Additive copy to another GATData instance
public MixTo ( GATData destination, int destinationIndex, int sourceIndex, int length ) : void
destination GATData
destinationIndex int
sourceIndex int
length int
return void

MixTo() public method

Additive copy to a float[]
public MixTo ( float destinationArray, int destinationIndex, int sourceIndex, int length ) : void
destinationArray float
destinationIndex int
sourceIndex int
length int
return void

NextZeroCrossing() public method

Finds the next zero crossing.
public NextZeroCrossing ( int fromIndex, bool &positive ) : int
fromIndex int
positive bool /// true if the crossing /// is from a negative to a positive value. ///
return int

Normalize() public method

Applies gain to the instance's data so that the maximum value matches normalizedMax
public Normalize ( float normalizedMax ) : void
normalizedMax float
return void

ResampleCopyFrom() public method

Performs a resampled copy from an array to the GATData instance it is called on. The resampling algorithm performs naive linear interpolation.
public ResampleCopyFrom ( float sourceArray, double trueInterpolatedIndex, int targetLength, int targetOffset, double resamplingFactor ) : double
sourceArray float
trueInterpolatedIndex double
targetLength int
targetOffset int
resamplingFactor double
return double

ResampleCopyTo() public method

Performs a resampled copy to another GATData instance. The resampling algorithm performs naive linear interpolation.
public ResampleCopyTo ( double trueInterpolatedIndex, GATData destinationSample, int targetLength, double resamplingFactor ) : double
trueInterpolatedIndex double
destinationSample GATData
targetLength int
resamplingFactor double
return double

ResampleCopyTo() public method

Performs a resampled copy to another GATData instance The resampling algorithm performs naive linear interpolation. Warning: for resampling in chunks, use the method of the same name which returns a double interpolated index.
public ResampleCopyTo ( int sourceIndex, GATData destinationSample, int targetLength, double resamplingFactor ) : void
sourceIndex int
destinationSample GATData
targetLength int
resamplingFactor double
return void

Reverse() public method

Reverses the entire audio data.
public Reverse ( ) : void
return void

Reverse() public method

public Reverse ( int offset, int length ) : void
offset int
length int
return void

SmoothedGain() public method

In-place Interpolated gain
public SmoothedGain ( int fromIndex, int length, float fromGain, float toGain ) : void
fromIndex int
length int
fromGain float
toGain float
return void

SmoothedGainCopyToInterlaced() public method

Copy and interpolated gain to an interleaved float[]
public SmoothedGainCopyToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelGain GATDynamicChannelGain
return void

SmoothedGainMixToInterlaced() public method

Additive copy and interpolated gain to an interleaved float[]
public SmoothedGainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelGain GATDynamicChannelGain
return void

SmoothedGainMixToInterlaced() public method

Additive copy and interpolated gain to an interleaved float[] with extra gain parameter
public SmoothedGainMixToInterlaced ( float destinationArray, int destinationOffset, int sourceIndex, int length, GATDynamicChannelGain channelGain, float igain ) : void
destinationArray float
destinationOffset int
sourceIndex int
length int
channelGain GATDynamicChannelGain
igain float
return void

this() public method

Gets or sets the float in the parent array at the specified index. The indexer should only be used for quick prototyping, as it is roughly 30% slower than caching ParentArray for direct access in an extension method.
public this ( int index ) : float
index int
return float

Property Details

_offset protected_oe property

protected int _offset
return int

_parentArray protected_oe property

protected float[] _parentArray
return float[]