mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#939 Adds MP3 encoder preferences to the User Preferences dialog and provides user control over sample rate and MP3 encoder settings. MP3 preferences are global and affect both recording and streaming. (#1159)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -26,6 +26,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Real sample buffer resampler
|
||||
@@ -54,14 +56,59 @@ public class RealResampler
|
||||
mBufferManager = new BufferManager(bufferSize, outputArrayLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resample factor (output rate / input rate)
|
||||
*/
|
||||
public double getResampleFactor()
|
||||
{
|
||||
return mResampleFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resamples all of the audio packets
|
||||
* @param audioPackets to resample
|
||||
* @return resampled audio packets
|
||||
*/
|
||||
public List<float[]> resample(List<float[]> audioPackets)
|
||||
{
|
||||
List<float[]> resampled = new ArrayList<>();
|
||||
|
||||
mResampledListener = resampledAudio -> resampled.add(resampledAudio);
|
||||
|
||||
for(int x = 0; x < audioPackets.size(); x++)
|
||||
{
|
||||
if(x == audioPackets.size() - 1)
|
||||
{
|
||||
resample(audioPackets.get(x), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
resample(audioPackets.get(x));
|
||||
}
|
||||
}
|
||||
|
||||
mResampledListener = null;
|
||||
return resampled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary input method to the resampler
|
||||
* @param samples to resample
|
||||
*/
|
||||
public void resample(float[] samples)
|
||||
{
|
||||
resample(samples, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary input method to the resampler
|
||||
* @param samples to resample
|
||||
* @param lastBatch set to true if this is the last set of samples
|
||||
*/
|
||||
public void resample(float[] samples, boolean lastBatch)
|
||||
{
|
||||
mBufferManager.load(samples);
|
||||
mResampler.process(mResampleFactor, mBufferManager, false);
|
||||
mResampler.process(mResampleFactor, mBufferManager, lastBatch);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user