Click or drag to resize
Accord.NET (logo)

ComplexSignal Class

Complex audio signal.
Inheritance Hierarchy
SystemObject
  Accord.AudioSignal
    Accord.AudioComplexSignal

Namespace:  Accord.Audio
Assembly:  Accord.Audio (in Accord.Audio.dll) Version: 3.8.0
Syntax
public class ComplexSignal : Signal
Request Example View Source

The ComplexSignal type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyChannels
Gets the number of channels of this signal.
(Inherited from Signal.)
Public propertyData
Gets a pointer to the first sample of the signal.
(Inherited from Signal.)
Public propertyDuration
Gets the signal duration in milliseconds.
(Inherited from Signal.)
Public propertyLength
Gets the number of samples in each channel of this signal, as known as the number of frames in the signal.
(Inherited from Signal.)
Public propertyRawData
Gets the raw binary data representing the signal.
(Inherited from Signal.)
Public propertySampleFormat
Gets the sample format used by this signal.
(Inherited from Signal.)
Public propertySampleRate
Gets the number of samples per second for this signal.
(Inherited from Signal.)
Public propertySamples
Gets the total number of samples in this signal.
(Inherited from Signal.)
Public propertyStatus
Gets the status of the signal - Fourier transformed, Hilbert transformed (analytic) or real.
Top
Methods
  NameDescription
Public methodBackwardFourierTransform
Applies backward fast Fourier transformation to the complex signal.
Public methodBackwardHilbertTransform
Applies backward Hilbert transformation to the complex signal.
Public methodStatic memberCombine
Combines a set of windows into one full signal.
Public methodCopyTo(Array)
Copies this signal to a given array.
(Inherited from Signal.)
Public methodCopyTo(Double)
Copies this signal to a given array.
(Inherited from Signal.)
Public methodCopyTo(Single)
Copies this signal to a given array.
(Inherited from Signal.)
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from Signal.)
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources
(Inherited from Signal.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases unmanaged resources and performs other cleanup operations before the Signal is reclaimed by garbage collection.
(Inherited from Signal.)
Public methodForwardFourierTransform
Applies forward fast Fourier transformation to the complex signal.
Public methodForwardHilbertTransform
Applies forward Hilbert transformation to the complex signal.
Public methodStatic memberFromArray(Complex, Int32)
Create complex signal from complex array.
Public methodStatic memberFromArray(Single, Int32)
Create multichannel complex signal from floating-point matrix.
Public methodStatic memberFromArray(Complex, Int32, ComplexSignalStatus)
Create complex signal from complex array.
Public methodStatic memberFromSignal
Create multichannel complex signal from floating-point matrix.
Public methodGetChannel
Extracts a channel from the signal.
Public methodCode exampleGetEnergy
Computes the signal energy.
(Inherited from Signal.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetSample
Gets the value of the specified sample in the Signal.
(Inherited from Signal.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSetSample
Sets the value of the specified sample in the Signal.
(Inherited from Signal.)
Public methodToArray
Converts the complex signal to a complex array.
Public methodToArray(Int32)
Converts the complex signal to a complex array.
Public methodToComplex
Converts this signal to a ComplexSignal object.
(Inherited from Signal.)
Public methodToDouble
Converts this signal into a array of floating-point samples.
(Inherited from Signal.)
Public methodToFloat
Converts this signal into a array of floating-point samples.
(Inherited from Signal.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodSplit(Int32, Int32)Overloaded.
Splits a signal using a window
(Defined by Extensions.)
Public Extension MethodSplit(Int32, Int32)Overloaded.
Splits a signal using a window
(Defined by Extensions.)
Public Extension MethodSplit(IWindow, Int32)Overloaded.
Splits a signal using a window
(Defined by Extensions.)
Public Extension MethodSplit(IWindow, Int32)Overloaded.
Splits a signal using a window
(Defined by Extensions.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

A complex discrete-time signal is any complex-valued function of integers. This class is used to keep audio signals represented in complex numbers so they are suitable to be converted to and from the frequency domain in either analytic or Fourier transformed forms.

References:

Examples

If your signal has a length that is a power of two, you can use the following code directly to create your audio signal and obtain its spectrogram:

// Create complex audio signal
ComplexSignal complexSignal = ComplexSignal.FromSignal( signal );

// Do forward Fourier transformation
complexSignal.ForwardFourierTransform( );

// Generate spectrogram
complexSignal.ToBitmap(512,512);

However, if your signal is too lengthy, or if your signal is not yet in a power of two size, you can use a temporal window to slice your signal into smaller cuts, as shown below. In the example, an audio file is being read and its contents are being decoded and stored into a Signal object. Afterwards, an audio window is being used to cut the signal into smaller, power-of-two size signals which can then be transformed into the frequency (Fourier) domain.

string fileName = "audio.wav";

WaveDecoder sourceDecoder = new WaveDecoder(fileName);

// Decode the file and store into a signal
Signal sourceSignal = sourceDecoder.Decode();

// Create Hamming window so that signal will fit into power of 2:           
RaisedCosineWindow window = RaisedCosineWindow.Hamming(1024);

// Splits the source signal by walking each 512 samples, then creating 
// a 1024 sample window. Note that this will result in overlapped windows.
Signal[] windows = sourceSignal.Split(window, 512);

// You might need to import Accord.Math in order to call this:
ComplexSignal[] complex = windows.Apply(ComplexSignal.FromSignal);

// Forward to the Fourier domain
complex.ForwardFourierTransform();
See Also