org.jcodec.algo
Class StreamInterpolator

java.lang.Object
  extended by org.jcodec.algo.StreamInterpolator
Direct Known Subclasses:
BiliearStreamInterpolator, CubicSplineStreamInterpolator

public abstract class StreamInterpolator
extends Object

This class is part of JCodec ( www.jcodec.org ) This software is distributed under FreeBSD License Interpolates a sequence of signal samples into another sequence of samples taken at a different frequency Interpolation algorithm depends on a specific implementation The input stream is supplied in chunks represented as integer arrays. The output is produced in chunks as well. The first sample of each chunk is the next sample to the last sample of a previous chunk in the sequence. The interpolator is stateful and each stream requires a separate instance. Example ( interpolates 48000 signal to 44100 ):

 
 WavInput inp = null;
 WavOutput out = null;
 try {
     inp = new WavInput(new File(args[0]));
     out = new WavOutput(new File(args[1]), new WavHeader(inp.getHeader(), 44100));
     
     StreamInterpolator in = new CubicSplineStreamInterpolator(new Rational(44100, 48000));
     
     int[] samples;
     while ((samples = inp.read(1024)) != null) {
         int[] outSamples = in.interpolate(samples);
         out.write(outSamples);
     }
     
 } finally {
     inp.close();
     out.close();
 }
 
 

Author:
The JCodec project

Field Summary
protected  Rational ratio
           
 
Constructor Summary
StreamInterpolator(Rational ratio)
           
 
Method Summary
abstract  int[] interpolate(int[] in)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ratio

protected Rational ratio
Constructor Detail

StreamInterpolator

public StreamInterpolator(Rational ratio)
Method Detail

interpolate

public abstract int[] interpolate(int[] in)


Copyright © 2013. All Rights Reserved.