Advertisement
Guest User

Untitled

a guest
Jan 16th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4.         public static double getMIDIFreq(int note)
  5.         {
  6.             //structure:  MIDI note value, frequency
  7.             Dictionary<int, double> noteValues = new Dictionary<int, double>()
  8.             {
  9.                 {0, 8.1757989156},
  10.                 {1, 8.6619572180},
  11.                 {2, 9.1770239974},
  12.                 {3, 10.3008611535},
  13.                 {4, 10.3008611535},
  14.                 {5, 10.9133822323},
  15.                 {6, 11.5623257097},
  16.                 {7, 12.2498573744},
  17.                 {8, 12.9782717994},
  18.                 {9, 13.7500000000},
  19.                 {10, 14.5676175474},
  20.                 {11, 15.4338531643},
  21.                 {12, 16.3515978313},
  22.                 {13, 17.3239144361},
  23.                 {14, 18.3540479948},
  24.                 {15, 19.4454364826},
  25.                 {16, 20.6017223071},
  26.                 {17, 21.8267644646},
  27.                 {18, 23.1246514195},
  28.                 {19, 24.4997147489},
  29.                 {20, 25.9565435987},
  30.                 {21, 27.5000000000},
  31.                 {22, 29.1352350949},
  32.                 {23, 30.8677063285},
  33.                 {24, 32.7031956626 },
  34.                 {25, 34.6478288721},
  35.                 {26, 36.7080959897},
  36.                 {27, 38.8908729653},
  37.                 {28, 41.2034446141},
  38.                 {29, 43.6535289291},
  39.                 {30, 46.2493028390},
  40.                 {31, 48.9994294977},
  41.                 {32, 51.9130871975},
  42.                 {33, 55.0000000000},
  43.                 {34, 58.2704701898},
  44.                 {35, 61.7354126570},
  45.                 {36, 65.4063913251},
  46.                 {37, 69.2956577442},
  47.                 {38, 73.4161919794},
  48.                 {39, 77.7817459305},
  49.                 {40, 82.4068892282},
  50.                 {41, 87.3070578583},
  51.                 {42, 92.4986056779},
  52.                 {43, 97.9988589954},
  53.                 {44, 103.8261743950},
  54.                 {45, 110.0000000000},
  55.                 {46, 116.5409403795},
  56.                 {47, 123.4708253140},
  57.                 {48, 130.8127826503},
  58.                 {49, 138.5913154884},
  59.                 {50, 146.8323839587},
  60.                 {51, 155.5634918610},
  61.                 {52, 164.8137784564},
  62.                 {53, 174.6141157165},
  63.                 {54, 184.9972113558},
  64.                 {55, 195.9977179909},
  65.                 {56, 207.6523487900},
  66.                 {57, 220.0000000000},
  67.                 {58, 233.0818807590},
  68.                 {59, 246.9416506281},
  69.                 {60, 261.6255653006},
  70.                 {61, 277.1826309769},
  71.                 {62, 293.6647679174},
  72.                 {63, 311.1269837221},
  73.                 {64, 329.6275569129},
  74.                 {65, 349.2282314330},
  75.                 {66, 369.9944227116},
  76.                 {67, 391.9954359817},
  77.                 {68, 415.3046975799},
  78.                 {69, 440.0000000000},
  79.                 {70, 466.1637615181},
  80.                 {71, 493.8833012561},
  81.                 {72, 523.2511306012},
  82.                 {73, 554.3652619537},
  83.                 {74, 587.3295358348},
  84.                 {75, 622.2539674442},
  85.                 {76, 659.2551138257},
  86.                 {77, 698.4564628660},
  87.                 {78, 739.9888454233},
  88.                 {79, 783.9908719635},
  89.                 {80, 830.6093951599},
  90.                 {81, 880.0000000000},
  91.                 {82, 932.3275230362},
  92.                 {83, 987.7666025122},
  93.                 {84, 1046.5022612024},
  94.                 {85, 1108.7305239075},
  95.                 {86, 1174.6590716696},
  96.                 {87, 1244.5079348883},
  97.                 {88, 1318.5102276515},
  98.                 {89, 1396.9129257320},
  99.                 {90, 1479.9776908465},
  100.                 {91, 1567.9817439270},
  101.                 {92, 1661.2187903198},
  102.                 {93, 1760.0000000000},
  103.                 {94, 1864.6550460724},
  104.                 {95, 1975.5332050245},
  105.                 {96, 2093.0045224048},
  106.                 {97, 2217.4610478150},
  107.                 {98, 2349.3181433393},
  108.                 {99, 2489.0158697766},
  109.                 {100, 2637.0204553030},
  110.                 {101, 2793.8258514640},
  111.                 {102, 2959.9553816931},
  112.                 {103, 3135.9634878540},
  113.                 {104, 3322.4375806396},
  114.                 {105, 3520.0000000000},
  115.                 {106, 3729.3100921447},
  116.                 {107, 3951.0664100490},
  117.                 {108, 4186.0090448096},
  118.                 {109, 4434.9220956300},
  119.                 {110, 4698.6362866785},
  120.                 {111, 4978.0317395533},
  121.                 {112, 5274.0409106059},
  122.                 {113, 5587.6517029281},
  123.                 {114, 5919.9107633862},
  124.                 {115, 5919.9107633862},
  125.                 {116, 6644.8751612791},
  126.                 {117, 7040.0000000000},
  127.                 {118, 7458.6201842894},
  128.                 {119, 7902.1328200980},
  129.                 {120, 8372.0180896192},
  130.                 {121, 8869.8441912599},
  131.                 {122, 9397.2725733570},
  132.                 {123, 9956.0634791066},
  133.                 {124, 10548.0818212118},
  134.                 {125, 11175.3034058561},
  135.                 {126, 11839.8215267723},
  136.                 {127, 12543.8539514160}
  137.             };
  138.            
  139.             double result;
  140.             noteValues.TryGetValue(note, out result);
  141.             return result;
  142.            
  143.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement