edu.berkeley.guir.ptk.abstraction
Class TelephoneAbstractor

java.lang.Object
  extended byedu.berkeley.guir.ptk.PTK
      extended byedu.berkeley.guir.ptk.abstraction.Abstractor
          extended byedu.berkeley.guir.ptk.abstraction.TelephoneAbstractor

public class TelephoneAbstractor
extends Abstractor

A PTK Library Abstractor that takes an AUDIO event (including volume and frequency samples) and determines if a telephone is ringing. Because it relies on certain frequency sample combinations for recognition, this Abstractor works mainly with "classic" telephone rings (i.e., it does not detect all the ring tones and songs possible with today's mobile phones). Depending on the tone of your phone, the frequency analysis may need some modification.

To customize this abstractor, set the four *_ms_ago data fields. These correspond to the number of milliseconds ago the abstractor will check for ring tones. For a standard U.S. phone ring, if there is a ring tone detected now, then there should be no ring tone 2 seconds ago and 4 seconds ago, and there should be a ring tone 6 seconds ago.

Also, you may need to customize one line of code: the return line of checkForRing. This determines if the past ring events occurred in a pattern that matches a phone ring. For a standard U.S. phone ring, the rings tones for the four events (that happenned now, first_ms_ago, second_ms_ago, and third_ms_ago), should be ring tone = true, false, false, true.

Notes: Standard U.S. phone ring has 2 seconds ring, 4 seconds pause.


Field Summary
 long first_ms_ago
          The number of milliseconds ago for the first historical event to check for ring tones.
 long second_ms_ago
          The number of milliseconds ago for the second historical event to check for ring tones.
 long third_ms_ago
          The number of milliseconds ago for the third historical event to check for ring tones.
 
Fields inherited from class edu.berkeley.guir.ptk.abstraction.Abstractor
data_ids_I_want, replace_data
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
TelephoneAbstractor()
           
 
Method Summary
protected  boolean checkForRing(Event e, Event two_ago, Event four_ago, Event six_ago)
          Analyzes the the past two events and the new event to determine if a phone is ringing.
 boolean doAbstract(Event e, History h)
          Performs the abstraction of the input event data (which consists of several DataNumber objects for volume and frequency samples), replacing it with a DataSwitch that indicates true/false for the presence of a phone ring.
 boolean isRingTone(double[] freq)
           
protected  boolean ringPotential(Event e)
           
 
Methods inherited from class edu.berkeley.guir.ptk.abstraction.Abstractor
addMetadataIWant, canIAbstract, getAllMetadata, getFirstMetadata
 
Methods inherited from class edu.berkeley.guir.ptk.PTK
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first_ms_ago

public long first_ms_ago
The number of milliseconds ago for the first historical event to check for ring tones. For a standard phone, the default is 2000, or 2 seconds ago.


second_ms_ago

public long second_ms_ago
The number of milliseconds ago for the second historical event to check for ring tones. For a standard phone, the default is 4000, or 4 seconds ago.


third_ms_ago

public long third_ms_ago
The number of milliseconds ago for the third historical event to check for ring tones. For a standard phone, the default is 6000, or 6 seconds ago.

Constructor Detail

TelephoneAbstractor

public TelephoneAbstractor()
Method Detail

doAbstract

public boolean doAbstract(Event e,
                          History h)
Performs the abstraction of the input event data (which consists of several DataNumber objects for volume and frequency samples), replacing it with a DataSwitch that indicates true/false for the presence of a phone ring. Uses the past two events that have occurred when abstracting. Returns true if the abstraction was successful and false otherwise. False will be returned if the Event passed to this method does not include AUDIO data (which should not happen since events are filtered by the AbstractionPolicy).

Specified by:
doAbstract in class Abstractor
Parameters:
e - Event that will be abstracted. The event is destructively altered.
h - History of all events passed to this application. May be used to perform abstraction.
Returns:
boolean True/false indication of success/failure of method.

checkForRing

protected boolean checkForRing(Event e,
                               Event two_ago,
                               Event four_ago,
                               Event six_ago)
Analyzes the the past two events and the new event to determine if a phone is ringing.

Returns:
true if a phone is ringing; false if not.

ringPotential

protected boolean ringPotential(Event e)

isRingTone

public boolean isRingTone(double[] freq)