Android Open Source - Spectograph Draw Thread






From Project

Back to project page Spectograph.

License

The source code is released under:

Copyright (c) 2013 Salman aljammaz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the So...

If you think the Android project Spectograph 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

package net.x65.spectograph;
/*from   w w w  . ja  va 2s  .c o  m*/
import android.util.Log;
import android.graphics.Canvas;
import java.util.ArrayList;
import android.view.SurfaceHolder;

public class DrawThread extends Thread {
  private static final String TAG = DrawThread.class.getSimpleName();
  private static final int framerate = 30;

  Spectogram view;
  SurfaceHolder surfaceHolder;
  
  DrawThread(Spectogram view, SurfaceHolder surfaceHolder) {
    super();
    
    this.view = view;
    this.surfaceHolder = surfaceHolder;
  }
  
  @Override
  public void run() {
    Log.d(TAG, "Starting draw loop");
    
    while (true) {
      Canvas canvas = null;
      try {
        canvas = surfaceHolder.lockCanvas();
        synchronized (surfaceHolder) {
          // TODO framerate
          view.update();
          view.render(canvas);
        }
      } finally {
        if (canvas != null) {
          surfaceHolder.unlockCanvasAndPost(canvas);
        }
      }
    }
  }
}




Java Source Code List

net.x65.spectograph.DrawThread.java
net.x65.spectograph.FFT.java
net.x65.spectograph.Spectogram.java
net.x65.spectograph.SpectographApp.java
net.x65.spectograph.Spectograph.java