Android Open Source - APSK Window






From Project

Back to project page APSK.

License

The source code is released under:

GNU General Public License

If you think the Android project APSK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * This file is part of znudigi.//from ww  w . j  a  v a  2s . c o m
 * Released under GNU GENERAL PUBLIC LICENSE Version 2
 * See file COPYING.
 * Copyright (C) 2007-2008 Leigh L. Klotz, Jr. <Leigh@WA5ZNU.org>
 * Portions derived from 
 * fldigi Copyright (C) 2006 Dave Freese, W1HKJ
 * gmfsk Copyright (C) 2001, 2002, 2003 Tomi Manninen (oh2bns@sral.fi)
 */


package org.wa5znu.znuradio.dsp;

// From fldigi by Dave Freese W1HKJ
public abstract class Window {

  private static double blackman(double x)
  {
    return (0.42 - 0.50 * Math.cos(2 * Math.PI * x) + 0.08 * Math.cos(4 * Math.PI * x));
  }

  private static double hamming(double x)
  {
    return 0.54 - 0.46 * Math.cos(2 * Math.PI * x);
  }

  private static double hanning(double x)
  {
    return 0.5 - 0.5 * Math.cos(2 * Math.PI * x);
  }

  // Rectangular - no pre filtering of data array
  public static void rectWindow(double array[], int n) {
    for (int i = 0; i < n; i++)
      array[i] = 1.0;
  }
    
  // Hamming - used by gmfsk
  public static void hammingWindow(double array[]) {
    int n = array.length;
    double pwr = 0.0;
    for (int i = 0; i < n; i++) {
      array[i] = hamming((double)i/(double)n);
      pwr += array[i] * array[i];
    }
    pwr = Math.sqrt((double)n/pwr);
    for (int i = 0; i < n; i++)
      array[i] *= pwr;
  }
    
  // Hanning - used by winpsk
  public static void hanningWindow(double array[]) {
    int n = array.length;
    double pwr = 0.0;
    for (int i = 0; i < n; i++) {
      array[i] = hanning((double)i/(double)n);
      pwr += array[i] * array[i];
    }
    pwr = Math.sqrt((double)n/pwr);
    for (int i = 0; i < n; i++)
      array[i] *= pwr;
  }

  // Best lobe suppression - least in band ripple
  public static void blackmanWindow(double array[]) {
    int n = array.length;
    double pwr = 0.0;
    for (int i = 0; i < n; i++) {
      array[i] = blackman((double)i/(double)n);
      pwr += array[i] * array[i];
    }
    pwr = Math.sqrt((double)n/pwr);
    for (int i = 0; i < n; i++)
      array[i] *= pwr;
  }

  // Simple about effective as Hamming or Hanning
  public static void triangularWindow(double array[]) {
    int n = array.length;
    double pwr = 0.0;
    for (int i = 0; i < n; i++) array[i] = 1.0;
    for (int i = 0; i < n / 4; i++) {
      array[i] = 4.0 * (double)i / (double)n;
      array[n-i] = array[i];
    }
    for (int i = 0; i < n; i++)
      pwr += array[i] * array[i];
    pwr = Math.sqrt((double)n/pwr);
    for (int i = 0; i < n; i++)
      array[i] *= pwr;
  }
}




Java Source Code List

net.thinkindifferent.apsk.APSK.java
net.thinkindifferent.apsk.AudioInputThread.java
net.thinkindifferent.apsk.Waterfall.java
org.wa5znu.znuradio.dsp.BaseFIRFilter.java
org.wa5znu.znuradio.dsp.Complex.java
org.wa5znu.znuradio.dsp.FFT.java
org.wa5znu.znuradio.dsp.FilterDesign.java
org.wa5znu.znuradio.dsp.IQFIRFilter.java
org.wa5znu.znuradio.dsp.LowPassFilterDesign.java
org.wa5znu.znuradio.dsp.Mixer.java
org.wa5znu.znuradio.dsp.RealFIRFilter.java
org.wa5znu.znuradio.dsp.Subsampler.java
org.wa5znu.znuradio.dsp.UnitPhasor.java
org.wa5znu.znuradio.dsp.Window.java
org.wa5znu.znuradio.modems.bpsk.BPSKDemodulator.java
org.wa5znu.znuradio.modems.bpsk.PSKVaricode.java
org.wa5znu.znuradio.receiver.Controller.java
org.wa5znu.znuradio.receiver.Demodulator.java
org.wa5znu.znuradio.receiver.FrequencyHandler.java
org.wa5znu.znuradio.receiver.ModemThread.java
org.wa5znu.znuradio.receiver.PhaseHandler.java
org.wa5znu.znuradio.receiver.ReceiverHandler.java
org.wa5znu.znuradio.receiver.Receiver.java
org.wa5znu.znuradio.receiver.SpectrumHandler.java
org.wa5znu.znuradio.receiver.SpectrumThread.java
org.wa5znu.znuradio.receiver.StageHandler.java
org.wa5znu.znuradio.receiver.TextHandler.java
org.wa5znu.znuradio.receiver.WaveHandler.java