|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmckay.utilities.sound.sampled.AudioMethodsDSP
public class AudioMethodsDSP
A holder class for general static methods relating to processing signals in the form of samples stored as arrays of doubles.
Constructor Summary | |
---|---|
AudioMethodsDSP()
|
Method Summary | |
---|---|
static void |
applyClickAvoidanceAttenuationEnvelope(double[][] sample_values,
double click_avoid_env_length,
float sample_rate)
Applies linear attenuation to either end of the given samples. |
static double[][] |
applyGain(double[][] samples,
double gain)
Applies a gain to the given samples. |
static void |
applyGainAndPanning(double[][] samples_to_modify,
double gain,
double panning)
Apply an overall gain and panning to the provided set of samples. |
static double[][] |
clipSamples(double[][] original_samples)
Clips the given samples so that all values below -1 are set to -1 and all values above 1 are set to 1. |
static double |
convertSampleToTime(int sample,
float sampling_rate)
Returns the time corresponding to the given sample indice with the given sampling rate. |
static int |
convertTimeToSample(double time,
float sampling_rate)
Returns the sample corresponding to the given time with the given sampling rate. |
static double |
findMaximumSampleValue(int bit_depth)
Returns the maximum possible value that a signed sample can have under the given bit depth. |
static double[] |
getAutoCorrelation(double[] signal,
int min_lag,
int max_lag)
Calculates the auto-correlation of the given signal. |
static double[] |
getAutoCorrelationLabels(double sampling_rate,
int min_lag,
int max_lag)
Returns the bin labels for each bin of an auto-correlation calculation that involved the given paremeters (most likely using the getAutoCorrelation method). |
static double[][] |
getCopyOfSamples(double[][] original_samples)
Returns a copy of the given array of samples. |
static double[] |
getSamplesMixedDownIntoOneChannel(double[][] audio_samples)
Returns the given set of samples as a set of samples mixed down into one channel. |
static double[] |
normalizeSamples(double[] samples_to_normalize)
Normalizes the given samples so that the absolute value of the highest sample amplitude is 1. |
static double[][] |
normalizeSamples(double[][] samples_to_normalize)
Normalizes the given samples dependantly so that the absolute value of the highest sample amplitude is 1. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AudioMethodsDSP()
Method Detail |
---|
public static double[][] applyGain(double[][] samples, double gain)
samples
- Audio samles to modify, usually with a minimum value
of -1 and a maximum value of +1. The first indice
corresponds to the channel and the second indice
corresponds to the sample number.gain
- The gain to apply.
public static void applyGainAndPanning(double[][] samples_to_modify, double gain, double panning) throws java.lang.Exception
It should be noted that gain and panning do not amplify samples, but rather attenuate them. The provided samples should already take advantage of the full available dynamic range (-1 to +1), and a gain of 1 and and a panning of 0 will maintain this. Other values of gain or panning will cause attenuation.
samples_to_modify
- A 2-D array of doubles whose first
indice indicates channel and whose
second indice indicates sample value. In
stereo, indice 0 corresponds to left and
1 to right. All samples should fall
between -1 and +1.gain
- The overall gain to apply to the
samples. This value must be between 0
and 1, with 0 being silence and 1 being
maximum amplitude.panning
- The relative strength of the two stereo
channels. This parameter is ignored in
non-stereo cases. Value must be between
-1 and +1, with -1 corresponding to full
amplitude on the left channel and
silence on the right, and +1
corresponding to the reverse. A value of
0 indicates a balance, and no
attenuation is applied to either
channel.
java.lang.Exception
- Throws an exception if an invalid
gain or panning value is
specified, of if the
samples_to_modify parameter is
null or contains empty channels.public static double[] getSamplesMixedDownIntoOneChannel(double[][] audio_samples)
audio_samples
- Audio samles to modify, with a minimum value of -1
and a maximum value of +1. The first indice
corresponds to the channel and the second indice
corresponds to the sample number.
public static double[][] clipSamples(double[][] original_samples) throws java.lang.Exception
original_samples
- A 2-D array of doubles whose first
indice indicates channel and whose
second indice indicates sample value. In
stereo, indice 0 corresponds to left and
1 to right.
java.lang.Exception
- If a null parameter is passed.public static double[] normalizeSamples(double[] samples_to_normalize)
samples_to_normalize
- The samples to normalize.
public static double[][] normalizeSamples(double[][] samples_to_normalize)
samples_to_normalize
- The samples to normalize. The first
indice denotes channel and the second
denotes sample number.
public static double[][] getCopyOfSamples(double[][] original_samples)
original_samples
- Audio samles to modify, usually with a
minimum value of value of- 1 and a maximum
value of +1. The first indice corresponds to
the channel and the second indice corresponds
to the sample number.
public static int convertTimeToSample(double time, float sampling_rate)
time
- The time in seconds to convert to a sample indice.sampling_rate
- The sampling rate of the audio in question.
public static double convertSampleToTime(int sample, float sampling_rate)
sample
- The sample indice to convert to time.sampling_rate
- The sampling rate of the audio in question.
public static double findMaximumSampleValue(int bit_depth)
bit_depth
- The bit depth to examine.
public static double[] getAutoCorrelation(double[] signal, int min_lag, int max_lag)
The getAutoCorrelationLabels method can be called to find the labels in Hz for each of the returned bins.
signal
- The digital signal to auto-correlate.min_lag
- The minimum lag in samples to look for in the
auto-correlation.max_lag
- The maximum lag in samples to look for in the
auto-correaltion.
public static double[] getAutoCorrelationLabels(double sampling_rate, int min_lag, int max_lag)
sampling_rate
- The sampling rate that was used to encode the
signal that was auto-correlated.min_lag
- The minimum lag in samples that was used in the
auto-correlation.max_lag
- The maximum lag in samples that was used in the
auto-correlation.
public static void applyClickAvoidanceAttenuationEnvelope(double[][] sample_values, double click_avoid_env_length, float sample_rate) throws java.lang.Exception
sample_values
- A 2-D array of doubles whose first
indice indicates channel and whose
second indice indicates sample value. In
stereo, indice 0 corresponds to left and
1 to right. All samples should fall
between -1 and +1.click_avoid_env_length
- The duration in seconds of the envelope
applied at the beginning and end of the
synthesized audio in order to avoid
clicks.sample_rate
- The sampling rate that was used to
encode the sample_values.
java.lang.Exception
- Throws an exception if an invalid
parameter is passed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |