예제 #1
0
 public void threadStop() {
   soundInputPool.close();
   soundOutputPool.close();
   this.threadState = true;
   this.interrupt();
 }
예제 #2
0
  public void run() {
    Log.d("SoundAllThread", "in run. thread start.");
    SoundVectorUnit dataUnit = null;

    while (threadState) {
      // this.setPriority(MAX_PRIORITY);
      // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
      // Log.d("SoundAllThread", "in run. priority: " + this.getPriority());

      long timeStartMs = System.currentTimeMillis();
      double timeStartNs = System.nanoTime() / 1000000.0;

      // read sound data from microphone.
      dataUnit = soundInputPool.read();

      long timeMs1 = System.currentTimeMillis();
      double timeNs1 = System.nanoTime() / 1000000.0;

      // shift sound frequency.
      dataUnit = frequencyShift.process(dataUnit);

      long timeMs2 = System.currentTimeMillis();
      double timeNs2 = System.nanoTime() / 1000000.0;

      // cut bands and gain db.
      dataUnit = bandGain.process(dataUnit);

      long timeMs3 = System.currentTimeMillis();
      double timeNs3 = System.nanoTime() / 1000000.0;

      // output sound data to speaker.
      soundOutputPool.write(dataUnit);

      // record information.
      long timeStopMs = System.currentTimeMillis();
      double timeStopNs = System.nanoTime() / 1000000;

      Log.d(
          "SoundAllThread",
          "in run. exclude time: " + (timeStopNs - timeStartNs) + " " + (timeStopMs - timeStartMs));

      Log.d(
          "SoundAllThread",
          "in run. module time: "
              + "("
              + (timeNs1 - timeStartNs)
              + " "
              + (timeMs1 - timeStartMs)
              + ") "
              + "("
              + (timeNs2 - timeNs1)
              + " "
              + (timeMs2 - timeMs1)
              + ") "
              + "("
              + (timeNs3 - timeNs2)
              + " "
              + (timeMs3 - timeMs2)
              + ") "
              + "("
              + (timeStopNs - timeNs3)
              + " "
              + (timeStopMs - timeMs3)
              + ")");
    }

    Log.d("SoundAllThread", "in run. thread stop.");
  }
예제 #3
0
 public void threadStart() {
   soundInputPool.open();
   soundOutputPool.open();
   this.threadState = true;
   this.start();
 }