Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7688827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:00:55+00:00 2026-05-31T20:00:55+00:00

I was implementing an android FFT guitar tuner. Here, I have 2 text views,

  • 0

I was implementing an android FFT guitar tuner. Here, I have 2 text views, 1 for displaying the frequency of the sound coming from the mic port and the other 1 for displaying the pitch notation. To match with the frequency, I wrote an if condition which is having about 35 if else if conditions consisting of 150 lines (approximately). Now, when a sound is heard, the value is updated in the frequency text view, but the note pitch text view is getting late to updated since there are so many conditions to be checked before updating the text view, so when the conditions are checked, again the frequency text view may have changed and got itself updated. What can I do to get rid of this problem? The final output is not efficient..Please help me with this…

if(frequency >= 62 && frequency <= 65)
{
   note.setText("C");
}
else if(frequency >= 70 && frequency <= 74)
{
  note.setText("C#");
}
else if(frequency >= 77 && frequency <= 81)
{
  note.setText("D");
}
else
{
  note.setText("Frequency is out of range");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:00:56+00:00Added an answer on May 31, 2026 at 8:00 pm

    My answer has following assumption:

    • Assuming your bottle-neck is the IF-ELSE

    According to Pitch to Frequency mappings, it can be divided into 8 groups.
    http://peabody.sapp.org/class/st2/lab/notehz/

    Step 1:
    You may consider 2 level IF-ELSE, which the first level is to determine the group, and second level is to determine the individual pitch note. To reduce the potential amount of IF_ELSE executed.

    Example:

     if(frequency <= 31) {
       // Group 1
     } else if (frequency <= 62) {
       // Group 2
     } else if (frequency <= 124) {
       // Group 3
       if(frequency >= 62 && frequency <= 65)
       {
           note.setText("C");
       }
       else if(frequency >= 70 && frequency <= 74)
       {
           note.setText("C#");
       }
       else if(frequency >= 77 && frequency <= 81)
       {
           note.setText("D");
       }
     } etc etc
    

    Step 2: You can make a HashMap for each group. Improving the second level searching.

    Let says Group 3 has a HashMap like this:

     { 62, "C" }
     { 63, "C" }
     { 64, "C" }
     { 65, "C" }
     { 70, "C#" }
     { 71, "C#" }
     { 72, "C#" }
     { 73, "C#" }
     { 74, "C#" }
    

    You code will look similar to this:

     Map<Integer,String> mapGroupThree = new HashMap<Integer,String>();
     String result = "";
    
     if(frequency <= 31) {
       // Group 1
       result = mapGroupOne.get(frequency);
     } else if (frequency <= 62) {
       // Group 2
       result = mapGroupTwo.get(frequency);
     } else if (frequency <= 124) {
       // Group 3
       result = mapGroupThree.get(frequency);
     } etc etc
    
     textView1.setText(result==null?"Out of Range":result);
    

    So finally, you will have 8 IF-ELSE, and each contain 1 map searching.

    ==================================================================================

    Another thing that you can try:

    Try to supply frequency in a sampling of 500ms (Or some reasonable value) instead of real time input.
    This is to prevent the congestion in UI thread’s update.

    ==================================================================================

    Again, I am not a music guy. It is all base on programming perspective. Not sure if it is helpful for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing an Android Activity from which other Activities will be derived from.
I'm implementing an alternative android market, I have the mysql and I'm implementing the
We are trying to implementing Tab Layout in android. I have take the refernce
I am implementing the c2md, in phone android 2.2, I have follow the all
I've thought about implementing an Android application that will download data from a third-party
I have requirement of implementing USB communication in Android phone. I have searched and
I am implementing Google analytic into my android app and I have got all
i have done implementing mobile app on android,webos,blackberry,iphone. now i integrate project with .net
I'm currently implementing Pull To Refresh functionality in Android. Now I have it working
hi all i am implementing android code for getting the contacts from contact list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.