Signal Class |
Namespace: Accord.Audio
The Signal type exposes the following members.
Name | Description | |
---|---|---|
Signal(Int32, Int32, Int32, SampleFormat) |
Constructs a new Signal.
| |
Signal(Byte, Int32, Int32, Int32, SampleFormat) |
Constructs a new signal.
|
Name | Description | |
---|---|---|
Channels |
Gets the number of channels of this signal.
| |
Data |
Gets a pointer to the first sample of the signal.
| |
Duration |
Gets the signal duration in milliseconds.
| |
Length |
Gets the number of samples in each channel of this signal,
as known as the number of frames in the signal.
| |
RawData |
Gets the raw binary data representing the signal.
| |
SampleFormat |
Gets the sample format used by this signal.
| |
SampleRate |
Gets the number of samples per second for this signal.
| |
Samples |
Gets the total number of samples in this signal.
|
Name | Description | |
---|---|---|
CopyTo(Array) |
Copies this signal to a given array.
| |
CopyTo(Double) |
Copies this signal to a given array.
| |
CopyTo(Single) |
Copies this signal to a given array.
| |
Dispose |
Performs application-defined tasks associated with freeing,
releasing, or resetting unmanaged resources.
| |
Dispose(Boolean) |
Releases unmanaged and - optionally - managed resources
| |
DurationOfSamples |
Gets the duration of each sample in a signal with the given number of samples and sampling rate.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize |
Releases unmanaged resources and performs other cleanup operations
before the Signal is reclaimed by garbage collection.
(Overrides ObjectFinalize.) | |
FromArray(Array, Int32, SampleFormat) |
Creates a new Signal from a float array.
| |
FromArray(Array, Int32, Int32, SampleFormat) |
Creates a new Signal from a float array.
| |
FromArray(Array, Int32, Int32, Int32, SampleFormat) |
Creates a new Signal from a float array.
| |
FromFile |
Loads a signal from a file, such as a ".wav" file.
| |
GetEnergy |
Computes the signal energy.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetSample |
Gets the value of the specified sample in the Signal.
| |
GetSampleSize |
Gets the size (in bits) of a sample format.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
NumberOfSamples |
Gets the number of samples contained in a signal of given duration and sampling rate.
| |
SetSample |
Sets the value of the specified sample in the Signal.
| |
ToComplex |
Converts this signal to a ComplexSignal object.
| |
ToDouble |
Converts this signal into a array of floating-point samples.
| |
ToFloat |
Converts this signal into a array of floating-point samples.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
Split(Int32, Int32) | Overloaded.
Splits a signal using a window
(Defined by Extensions.) | |
Split(IWindow, Int32) | Overloaded.
Splits a signal using a window
(Defined by Extensions.) | |
To(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.) | |
ToT | 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.) |
A real discrete-time signal is defined as any real-valued function of the integers.
In signal processing, sampling is the reduction of a continuous signal to a discrete signal. A common example is the conversion of a sound wave (a continuous-time signal) to a sequence of samples (a discrete-time signal).
A sample refers to a value or set of values at a point in time and/or space.
// create an empty audio signal Signal signal = new Signal(channels, length, sampleRate, format);
float[,] data = { { 0.00f, 0.2f }, { 0.32f, 0.1f }, { 0.22f, 0.2f }, { 0.12f, 0.42f }, { -0.12f, 0.1f }, { -0.22f, 0.2f }, }; // or create an audio signal from an array of audio frames Signal target = Signal.FromArray(data, sampleRate: 8000);
It is also possible to load signals from a file or stream, as long as you have a decoder for the given format available. For example, in order to load a .wav file using DirectSound, please add a reference to Accord.Audio.DirectSound and run the following code snippet:
// Let's say we would like to compute the energy of an audio signal. For this, // we will take an example signal from the Free Spoken Digits Dataset (FSDD): FreeSpokenDigitsDataset fsdd = new FreeSpokenDigitsDataset(basePath); Signal signal = fsdd.GetSignal(digit: 3, speaker: "jackson", index: 0); // The energy is defined as the sum of squared values in all // channels of the audio signal. In this case, it should be: double energy = signal.GetEnergy(); // 19.448728048242629