Android Open Source - APSK Modem Thread






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./*ww w  .ja va 2s  . co m*/
 * Released under GNU GENERAL PUBLIC LICENSE Version 2
 * See file COPYING.
 * Copyright (C) 2007-2008 Leigh L. Klotz, Jr. <Leigh@WA5ZNU.org>
 */

package org.wa5znu.znuradio.receiver;

public class ModemThread extends Thread
    implements WaveHandler
{
  Demodulator demodulator;
  double waveDataIn[]=null;
  int dataLengthIn;
  int dataFrameIn;

  private static final Object lock = new Object();

  public ModemThread(Demodulator demodulator) {
    this.demodulator = demodulator;
  }

  public void setFrequency(double f) {
    demodulator.setFrequency(f);
  }

  public double getFrequency() {
    return demodulator.getFrequency();
  }

  public void showNextStage() {
    if (demodulator instanceof FrequencyHandler)
      ((FrequencyHandler)demodulator).showNextStage();
  }

  public void run() {
    while (true) {
      double waveData[]=null;
      int dataLength=0;
      int dataFrame=0;
      synchronized(lock) {
  try {
    lock.wait();
    dataFrame = dataFrameIn;
    waveData = waveDataIn;
    dataLength = dataLengthIn;
    // Dropping the lock before processing casues us to drop frames, which we don't want to do in a Modem.
    // Dropping the lock after we process serializes all demodulators.
    // We really need to queue the frames.
    if (waveData != null)
      demodulator.handleWave(dataFrame, waveData, dataLength);
  } catch(InterruptedException exp) { }
      }
    }
  }

  // Accept the incoming sound samples
  public void handleWave(int frame, double data[], int length) {
    synchronized(lock) {
      dataFrameIn = frame;
      waveDataIn = data;
      dataLengthIn = length;
      lock.notifyAll();
    }
  }

}




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