plectrum

Plectrum: instrument tuner for Android
Log | Files | Refs | README | LICENSE

NoteName.java (852B)


      1 package com.github.cythara;
      2 
      3 public enum NoteName {
      4 
      5     C("C", "Do"),
      6     D("D", "Re"),
      7     E("E", "Mi"),
      8     F("F", "Fa"),
      9     G("G", "Sol"),
     10     A("A", "La"),
     11     B("B", "Si");
     12 
     13     private final String scientific;
     14     private final String sol;
     15 
     16     NoteName(String scientific, String sol) {
     17         this.scientific = scientific;
     18         this.sol = sol;
     19     }
     20 
     21     public String getScientific() {
     22         return scientific;
     23     }
     24 
     25     public String getSol() {
     26         return sol;
     27     }
     28 
     29     public static NoteName fromScientificName(String scientificName) {
     30         for (NoteName noteName : NoteName.values()) {
     31             if (noteName.getScientific().equalsIgnoreCase(scientificName)) {
     32                 return noteName;
     33             }
     34         }
     35 
     36         throw new IllegalArgumentException("Could not convert from name: " + scientificName);
     37     }
     38 }