Package com.talixa.specan.dsp

Source Code of com.talixa.specan.dsp.GainController

package com.talixa.specan.dsp;

import java.io.IOException;

import com.talixa.audio.wav.WaveFile;
import com.talixa.audio.wav.WaveGenerator;

public class GainController {
 
  /*
   * To change gain, multiply sample by gain
   */
 
  // input and output are PCM samples
  public static short[] setGain(short[] data, double gain) {
    short[] newData = new short[data.length];
    for(int i = 0; i < data.length; ++i) {
      newData[i] = (short)(data[i] * gain);
    }
    return newData;
  }   
 
  public static void setGain(short[] data, double gain, String outputFile) throws IOException {
    short[] newData = setGain(data,gain);
    byte[] byteData = SharedDSPFunctions.shortArrayToByteArray(newData);   
    WaveFile w = WaveGenerator.generateWaveFromRaw16bitPcm(byteData);   
    w.outputToFile(outputFile);   
  }   
}
TOP

Related Classes of com.talixa.specan.dsp.GainController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.