dynamic ringtone adjustment using on demand sampling on android smartphones casey o’leary –...
TRANSCRIPT
Dynamic Ringtone Adjustment using On Demand Sampling on Android Smartphones
Casey O’Leary – Washington State University
CURENT REU
Mentor: Yong Li
Project Manager: Dr. Wei Gao
7/17/2014
Knoxville, Tennessee
Goals of Research
• Implement current method of sampling and adjusting in the Android Kernel
• Adjust the current method to implement demand sampling (done)
• Improve upon current method using frequency analysis (future work)
• Originally created and developed by Christopher Daffron and Alex Hoppe
3
Algorithm for Sampling and Processing
Frequency and Intensity Categorized
Contrasting ringtone selected Volume set based on Intensity level
Calculating Frequency and IntensityWeighted Average Frequency Average Intensity
Fast Fourier Transform Simplicity vs. Speed Princeton CS Library
On Demand Sampling500 millisecond audio sample Raw audio data stored in WAV file
4
Frequency and Intensity Calculations
• Weighted average frequency – calculated by takes the summation of intensity at each frequency multiplied by the frequency and then divide that by the summation of all frequency intensity values
• for(int i = 0; i < transformData.length/2; i++) {
numVals++;
rawSum = rawSum+ transformData[i].abs();
sum = sum + transformData[i].abs()*I;
}avgVal = sum / rawSum;• Average Intensity – calculated by taking the average value of the absolute
value of all of the samples• for(int i = 0; i < channel1Data.length; i++) {
sum = sum + Math.abs(channel1Data[i]); counter++; } avIntensity = sum / counter;
5
Ringtone and Intensity Thresholds
• Frequency Thresholds
• Intensity Thresholds
6
2000 Hz
• Cat 1 <• -> 3
3300 Hz
• Cat 2 <• -> 4
4500 Hz
• Cat 3 <• -> 5
6000 Hz
• Cat 4 < • -> 4
6000 Hz <
X• Cat 5• -> 1
< .01
2• Stream
0
< .03
0• Stream
1
< .04
8• Stream
2
< .06
7• Stream
3
< .08
5• Stream
4
< .10
3• Stream
5
< .14
• Stream 6
.14 < X
• Stream 7 (Max)
Reasoning for Thresholds
• Device specific – Using LG Nexus 4
• Microphone samples audio at 44,100Hz
• .5s provides 22,000 samples
• Different phone may need adjustment
7
Source Code Integration
Incoming Call -> Broadcast Message• Telephony Service broadcast receive• Abstract layer between phone application and radio hardware
Message is then handled in the CallNotifier class• Contains instance of Ringer class• Controls when the Ringer is played
Ringer.ring() Function• Called by CallNotifier class • Modifications placed within this function• Executed only before first ring using ring counter
9
Source Code Integration
Audio Sampling• Audio buffer Created• Start recording thread• 500 ms delay using SystemClock static methods• Recording thread stopped
Processing• Raw audio data put into WAV file• Fast Fourier Transform applied producing complex data• Frequency and Intensity Algorithms applied • Average Frequency and Intensity set and categorized• Series of Logic statements and switch statements set ringtone and
volume• Call UI displayed and ringing starts
10
Testing
11
1 2 3 4 50
1500
3000
4500
6000
Calculated Avg. Frequency in Varying Environments using Modified Android
System Driving at NightVideo Games and TVPadeo at NightWalking Hallway in HandWalking Hallway in PocketMarket Square Af-ternoon
Trial Run
Avera
ge F
requency
(Hz)
Testing
12
1 2 3 4 50
0.05
0.1
0.15
0.2
0.25
Calculated Average Intensity of Samples in Varying Environments
Driving at NightVideo Games and TVPadeo at NightWalking Hallway in HandWalking Hallway in PocketMarket Square Af-ternoon
Trial
Avera
ge I
nte
sity
Testing
• Algorithm Run Time
• About 150-200ms
longer than on
Ringtone Selector
Application
13
Total Runtime of Algorithm for each sample (ms) Sample
35301B36252B36503B36304B35665B36481C35352C35093C35374C35265C36441D35532D36513D37004D37065D35471E35872E35823E36444E36175E38091F36292F37263F36574F37625F38091G36992G42803G45034G44145G
3709.166667Average Runtime (ms)
Conclusion and Future Work
Algorithm Optimization• Average runtime of about 3.5 seconds• Eliminate unnecessary complexity or looping• Use multi-threading strategy to process data
Noise Reduction using Signal Processing Techniques• Identify any unwanted “noisy” frequencies to get a more
accurate representation of environment
Data Processing via Cloud Computing• Use a cloud, such as Amazon EC2, to perform necessary data
processing• Need to consider wireless signal strength and speed to
determine if this method would be efficient
14