Class IAudioResampler
- java.lang.Object
-
- com.avpkit.ferry.RefCounted
-
- com.avpkit.core.IAudioResampler
-
public class IAudioResampler extends RefCounted
Used to resample {IAudioSamples} to different sample rates or number of channels.
-
-
Field Summary
-
Fields inherited from class com.avpkit.ferry.RefCounted
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIAudioResampler(long cPtr, boolean cMemoryOwn)Internal Only.protectedIAudioResampler(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)Internal Only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IAudioResamplercopyReference()Create a new IAudioResampler object that is actually referring to the exact same underlying native object.booleanequals(java.lang.Object obj)Compares two values, returning true if the underlying objects in native code are the same object.static longgetCPtr(IAudioResampler obj)Internal Only.doublegetCutoffFrequency()What is the cuttoff frequency used?intgetFilterLen()Get the length of each filter in the resampler filter bank.intgetInputChannels()number of channels expected in input audio.IAudioSamples.FormatgetInputFormat()Get the sample format we expect to resample from.intgetInputRate()sample rate expected in input audio.intgetLog2PhaseCount()Get log2(number of entries in filter bank).intgetMinimumNumSamplesRequiredInOutputSamples(int numSamples)Get the minimum number of samples that must be placeable in an
output set of samples in order for a resample with this resampler
to succeed.
intgetMinimumNumSamplesRequiredInOutputSamples(IAudioSamples inSamples)Get the minimum number of samples that must be placeable in an
output set of samples in order for a resample with this resampler
to succeed.
longgetMyCPtr()Internal Only.intgetOutputChannels()number of channels in output audio.IAudioSamples.FormatgetOutputFormat()Get the sample format we expect to resample to.intgetOutputRate()sample rate of output audio.inthashCode()Get a hashable value for this object.booleanisLinear()Are we linearly interpolating between filters?static IAudioResamplermake(int outputChannels, int inputChannels, int outputRate, int inputRate)Create a new {IAudioResampler} object.static IAudioResamplermake(int outputChannels, int inputChannels, int outputRate, int inputRate, IAudioSamples.Format outputFmt, IAudioSamples.Format inputFmt)Create a new {IAudioResampler} object.static IAudioResamplermake(int outputChannels, int inputChannels, int outputRate, int inputRate, IAudioSamples.Format outputFmt, IAudioSamples.Format inputFmt, int filterLen, int log2PhaseCount, boolean isLinear, double cutoffFrequency)Create a new {IAudioResampler} object.intresample(IAudioSamples outputSamples, IAudioSamples inputSamples, int numSamples)Re-sample up to numSamples from inputSamples to outputSamples.-
Methods inherited from class com.avpkit.ferry.RefCounted
acquire, delete, getCPtr, getCurrentRefCount, getJavaRefCount, release
-
-
-
-
Constructor Detail
-
IAudioResampler
protected IAudioResampler(long cPtr, boolean cMemoryOwn)
Internal Only.
-
IAudioResampler
protected IAudioResampler(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)
Internal Only.
-
-
Method Detail
-
getCPtr
public static long getCPtr(IAudioResampler obj)
Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.- Parameters:
obj- The java proxy object for a native object.- Returns:
- The raw pointer obj is proxying for.
-
getMyCPtr
public long getMyCPtr()
Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.- Overrides:
getMyCPtrin classRefCounted- Returns:
- The raw pointer we're proxying for.
-
copyReference
public IAudioResampler copyReference()
Create a new IAudioResampler object that is actually referring to the exact same underlying native object.- Overrides:
copyReferencein classRefCounted- Returns:
- the new Java object.
-
equals
public boolean equals(java.lang.Object obj)
Compares two values, returning true if the underlying objects in native code are the same object. That means you can have two different Java objects, but when you do a comparison, you'll find out they are the EXACT same object.- Overrides:
equalsin classjava.lang.Object- Returns:
- True if the underlying native object is the same. False otherwise.
-
hashCode
public int hashCode()
Get a hashable value for this object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashable value.
-
getOutputChannels
public int getOutputChannels()
number of channels in output audio.- Returns:
- Number of channels we'll resample the output to.
-
getOutputRate
public int getOutputRate()
sample rate of output audio.- Returns:
- Sample Rate we'll resample the output to.
-
getInputChannels
public int getInputChannels()
number of channels expected in input audio.- Returns:
- Number of channels we'll expect in the input samples
-
getInputRate
public int getInputRate()
sample rate expected in input audio.- Returns:
- Sample rate we'll expect in the input samples
-
resample
public int resample(IAudioSamples outputSamples, IAudioSamples inputSamples, int numSamples)
Re-sample up to numSamples from inputSamples to outputSamples.
This function re-samples the audio in inputSamples to have the same
number of channels, and the same sample rate, as this {IAudioResampler} was
initialized with.
Caller is responsible for making sure that the IAudioSamples object
passed in has enough space. This object requires space for an
additional 16-samples * output-channels
per {IAudioSamples} passed in.
If the {outputSamplesis not large enough to fit the required resamples, then theIAudioResamplerwill attempt to allocate a new output buffer and override the buffer set onoutputSamples. To ensure you have enough space in your output buffer, use thegetMinimumNumSamplesRequiredInOutputSamples(int)method.- Parameters:
outputSamples- [out] The sample buffer we output to.inputSamples- [in] The samples we're going to re-sample.numSamples- [in] The number of samples from inputSamples to use. if 0, this defaults to inputSamples.getNumSamples().- Returns:
- Number of samples written to outputSamples, or <0 on error. }
-
make
public static IAudioResampler make(int outputChannels, int inputChannels, int outputRate, int inputRate)
Create a new {IAudioResampler} object.
Creation of {IAudioResampler} objects is relatively expensive compared
to the {#resample(IAudioSamples, IAudioSamples, long)} method,
so users are encouraged to create once and use often.
This method assumes all samples are in IAudioSamples.Format.FMT_S16 format.
- Parameters:
outputChannels- The number of channels you will want
in resampled audio we output.inputChannels- The number of channels you will pass
in the source audio for resampling.outputRate- The sample rate you will want
in resampled audio we output.inputRate- The sample rate you will pass
in the source audio for resampling.- Returns:
- A new object, or null if we can't allocate one.
-
getOutputFormat
public IAudioSamples.Format getOutputFormat()
Get the sample format we expect to resample to.- Returns:
- the sample format for output.
-
getInputFormat
public IAudioSamples.Format getInputFormat()
Get the sample format we expect to resample from.- Returns:
- the sample format for input.
-
getFilterLen
public int getFilterLen()
Get the length of each filter in the resampler filter bank.- Returns:
- the filter length
-
getLog2PhaseCount
public int getLog2PhaseCount()
Get log2(number of entries in filter bank).- Returns:
- log2(number of entries in filter bank).
-
isLinear
public boolean isLinear()
Are we linearly interpolating between filters?- Returns:
- true if interpolating, false if just choosing closest.
-
getCutoffFrequency
public double getCutoffFrequency()
What is the cuttoff frequency used?- Returns:
- the cuttoff frequency
-
make
public static IAudioResampler make(int outputChannels, int inputChannels, int outputRate, int inputRate, IAudioSamples.Format outputFmt, IAudioSamples.Format inputFmt)
Create a new {IAudioResampler} object.
Creation of {IAudioResampler} objects is relatively expensive compared
to the {#resample(IAudioSamples, IAudioSamples, long)} method,
so users are encouraged to create once and use often.
"Sensible" defaults are passed in for filter length and other
parameters.
- Parameters:
outputChannels- The number of channels you will want
in resampled audio we output.inputChannels- The number of channels you will pass
in the source audio for resampling.outputRate- The sample rate you will want
in resampled audio we output.inputRate- The sample rate you will pass
in the source audio for resampling.outputFmt- The format of the output samples.inputFmt- The format of the input samples.
- Returns:
- A new object, or null if we can't allocate one.
-
make
public static IAudioResampler make(int outputChannels, int inputChannels, int outputRate, int inputRate, IAudioSamples.Format outputFmt, IAudioSamples.Format inputFmt, int filterLen, int log2PhaseCount, boolean isLinear, double cutoffFrequency)
Create a new {IAudioResampler} object.
Creation of {IAudioResampler} objects is relatively expensive compared
to the {#resample(IAudioSamples, IAudioSamples, long)} method,
so users are encouraged to create once and use often.
- Parameters:
outputChannels- The number of channels you will want
in resampled audio we output.inputChannels- The number of channels you will pass
in the source audio for resampling.outputRate- The sample rate you will want
in resampled audio we output.inputRate- The sample rate you will pass
in the source audio for resampling.outputFmt- The format of the output samples.inputFmt- The format of the input samples.filterLen- The length of each filter in the filterbank, relative to the cutoff frequency.log2PhaseCount- log2 of the number of entries in the polyphase filterbankisLinear- If true, the used filter will be linearly interpolated between the 2 closest filters.
if false, the closest will be used.cutoffFrequency- Cutoff frequency. 1.0 is 1/2 the output sampling rate.
- Returns:
- A new object, or null if we can't allocate one.
-
getMinimumNumSamplesRequiredInOutputSamples
public int getMinimumNumSamplesRequiredInOutputSamples(IAudioSamples inSamples)
Get the minimum number of samples that must be placeable in an
output set of samples in order for a resample with this resampler
to succeed.
- Parameters:
inSamples- The input samples that will be passed to
{#resample}.- Returns:
- The minimum number of samples, or < 0 on error.
- Since:
- 3.2
-
getMinimumNumSamplesRequiredInOutputSamples
public int getMinimumNumSamplesRequiredInOutputSamples(int numSamples)
Get the minimum number of samples that must be placeable in an
output set of samples in order for a resample with this resampler
to succeed.
- Parameters:
numSamples- The number of input samples.- Returns:
- The minimum number of samples, or < 0 on error.
- Since:
- 3.2
-
-