Skip to content

Instantly share code, notes, and snippets.

@davebren
Created October 4, 2021 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebren/1c258af87bd1f0ab8598acd2f48b5984 to your computer and use it in GitHub Desktop.
Save davebren/1c258af87bd1f0ab8598acd2f48b5984 to your computer and use it in GitHub Desktop.
Some
/// The model object representation of a musical note.
class Note {
/// The index of the note in the [allNotes] list starting from 0 with C0 and ending with 107 with B8.
final int index;
/// The physical frequency in Hz of the note.
///
/// The following table lists the frequency for each note:
/// Octave C C# D D# E F F# G G# A A# B
/// 0 16.35 17.32 18.35 19.45 20.60 21.83 23.12 24.50 25.96 27.50 29.14 30.87
/// 1 32.70 34.65 36.71 38.89 41.20 43.65 46.25 49.00 51.91 55.00 58.27 61.74
/// 2 65.41 69.30 73.42 77.78 82.41 87.31 92.50 98.00 103.8 110.0 116.5 123.5
/// 3 130.8 138.6 146.8 155.6 164.8 174.6 185.0 196.0 207.7 220.0 233.1 246.9
/// 4 261.6 277.2 293.7 311.1 329.6 349.2 370.0 392.0 415.3 440.0 466.2 493.9
/// 5 523.3 554.4 587.3 622.3 659.3 698.5 740.0 784.0 830.6 880.0 932.3 987.8
/// 6 1047 1109 1175 1245 1319 1397 1480 1568 1661 1760 1865 1976
/// 7 2093 2217 2349 2489 2637 2794 2960 3136 3322 3520 3729 3951
/// 8 4186 4435 4699 4978 5274 5588 5920 6272 6645 7040 7459 7902
final double frequency;
/// The string representation for the note containing a sharp (♯) symbol if appropriate.
final String name;
/// The string representation for the note containing a flat (♭) symbol if appropriate.
final String nameFlat;
Note(this.index, this.frequency, this.name, this.nameFlat);
static final c0 = Note(0, 16.35, "C", "C");
static final cs0 = Note(1, 17.32, "C♯", "D♭");
static final d0 = Note(2, 18.35, "D", "D");
static final ds0 = Note(3, 19.45, "D♯", "E♭");
static final e0 = Note(4, 20.60, "E", "E");
static final f0 = Note(5, 21.83, "F", "F");
static final fs0 = Note(6, 23.12, "F♯", "G♭");
static final g0 = Note(7, 24.50, "G", "G");
static final gs0 = Note(8, 25.96, "G♯", "A♭");
static final a0 = Note(9, 27.50, "A", "A");
static final as0 = Note(10, 29.14, "A♯", "B♭");
static final b0 = Note(11, 30.87, "B", "B");
static final c1 = Note(12, 32.70, "C", "C");
static final cs1 = Note(13, 34.65, "C♯", "D♭");
static final d1 = Note(14, 36.71, "D", "D");
static final ds1 = Note(15, 38.89, "D♯", "E♭");
static final e1 = Note(16, 41.20, "E", "E");
static final f1 = Note(17, 43.65, "F", "F");
static final fs1 = Note(18, 46.25, "F♯", "G♭");
static final g1 = Note(19, 49.00, "G", "G");
static final gs1 = Note(20, 51.91, "G♯", "A♭");
static final a1 = Note(21, 55.00, "A", "A");
static final as1 = Note(22, 58.27, "A♯", "B♭");
static final b1 = Note(23, 61.74, "B", "B");
static final c2 = Note(24, 65.41, "C", "C");
static final cs2 = Note(25, 69.30, "C♯", "D♭");
static final d2 = Note(26, 73.42, "D", "D");
static final ds2 = Note(27, 77.78, "D♯", "E♭");
static final e2 = Note(28, 82.41, "E", "E");
static final f2 = Note(29, 87.31, "F", "F");
static final fs2 = Note(30, 92.50, "F♯", "G♭");
static final g2 = Note(31, 98.00, "G", "G");
static final gs2 = Note(32, 103.8, "G♯", "A♭");
static final a2 = Note(33, 110.0, "A", "A");
static final as2 = Note(34, 116.5, "A♯", "B♭");
static final b2 = Note(35, 123.5, "B", "B");
static final c3 = Note(36, 130.8, "C", "C");
static final cs3 = Note(37, 138.6, "C♯", "D♭");
static final d3 = Note(38, 146.8, "D", "D");
static final ds3 = Note(39, 155.6, "D♯", "E♭");
static final e3 = Note(40, 164.8, "E", "E");
static final f3 = Note(41, 174.6, "F", "F");
static final fs3 = Note(42, 185.0, "F♯", "G♭");
static final g3 = Note(43, 196.0, "G", "G");
static final gs3 = Note(44, 207.7, "G♯", "A♭");
static final a3 = Note(45, 220.0, "A", "A");
static final as3 = Note(46, 233.1, "A♯", "B♭");
static final b3 = Note(47, 246.9, "B", "B");
static final c4 = Note(48, 261.6, "C", "C");
static final cs4 = Note(49, 277.2, "C♯", "D♭");
static final d4 = Note(50, 293.7, "D", "D");
static final ds4 = Note(51, 311.1, "D♯", "E♭");
static final e4 = Note(52, 329.6, "E", "E");
static final f4 = Note(53, 349.2, "F", "F");
static final fs4 = Note(54, 370.0, "F♯", "G♭");
static final g4 = Note(55, 392.0, "G", "G");
static final gs4 = Note(56, 415.3, "G♯", "A♭");
static final a4 = Note(57, 440.0, "A", "A");
static final as4 = Note(58, 466.2, "A♯", "B♭");
static final b4 = Note(59, 493.9, "B", "B");
static final c5 = Note(60, 523.3, "C", "C");
static final cs5 = Note(61, 554.4, "C♯", "D♭");
static final d5 = Note(62, 587.3, "D", "D");
static final ds5 = Note(63, 622.3, "D♯", "E♭");
static final e5 = Note(64, 659.3, "E", "E");
static final f5 = Note(65, 698.5, "F", "F");
static final fs5 = Note(66, 740.0, "F♯", "G♭");
static final g5 = Note(67, 784.0, "G", "G");
static final gs5 = Note(68, 830.6, "G♯", "A♭");
static final a5 = Note(69, 880.0, "A", "A");
static final as5 = Note(70, 932.3, "A♯", "B♭");
static final b5 = Note(71, 987.8, "B", "B");
static final c6 = Note(72, 1047, "C", "C");
static final cs6 = Note(73, 1109, "C♯", "D♭");
static final d6 = Note(74, 1175, "D", "D");
static final ds6 = Note(75, 1245, "D♯", "E♭");
static final e6 = Note(76, 1319, "E", "E");
static final f6 = Note(77, 1397, "F", "F");
static final fs6 = Note(78, 1480, "F♯", "G♭");
static final g6 = Note(79, 1568, "G", "G");
static final gs6 = Note(80, 1661, "G♯", "A♭");
static final a6 = Note(81, 1760, "A", "A");
static final as6 = Note(82, 1865, "A♯", "B♭");
static final b6 = Note(83, 1976, "B", "B");
static final c7 = Note(84, 2093, "C", "C");
static final cs7 = Note(85, 2217, "C♯", "D♭");
static final d7 = Note(86, 2349, "D", "D");
static final ds7 = Note(87, 2489, "D♯", "E♭");
static final e7 = Note(88, 2637, "E", "E");
static final f7 = Note(89, 2794, "F", "F");
static final fs7 = Note(90, 2960, "F♯", "G♭");
static final g7 = Note(91, 3136, "G", "G");
static final gs7 = Note(92, 3322, "G♯", "A♭");
static final a7 = Note(93, 3520, "A", "A");
static final as7 = Note(94, 3729, "A♯", "B♭");
static final b7 = Note(95, 3951, "B", "B");
static final c8 = Note(96, 4186, "C", "C");
static final cs8 = Note(97, 4435, "C♯", "D♭");
static final d8 = Note(98, 4699, "D", "D");
static final ds8 = Note(99, 4978, "D♯", "E♭");
static final e8 = Note(100, 5274, "E", "E");
static final f8 = Note(101, 5588, "F", "F");
static final fs8 = Note(102, 5920, "F♯", "G♭");
static final g8 = Note(103, 6272, "G", "G");
static final gs8 = Note(104, 6645, "G♯", "A♭");
static final a8 = Note(105, 7040, "A", "A");
static final as8 = Note(106, 7459, "A♯", "B♭");
static final b8 = Note(107, 7902, "B", "B");
/// All of the notes in list form starting from [c0] and ending with [b8].
static final allNotes = [
c0,cs0,d0,ds0,e0,f0,fs0,g0,gs0,a0,as0,b0,
c1,cs1,d1,ds1,e1,f1,fs1,g1,gs1,a1,as1,b1,
c2,cs2,d2,ds2,e2,f2,fs2,g2,gs2,a2,as2,b2,
c3,cs3,d3,ds3,e3,f3,fs3,g3,gs3,a3,as3,b3,
c4,cs4,d4,ds4,e4,f4,fs4,g4,gs4,a4,as4,b4,
c5,cs5,d5,ds5,e5,f5,fs5,g5,gs5,a5,as5,b5,
c6,cs6,d6,ds6,e6,f6,fs6,g6,gs6,a6,as6,b6,
c7,cs7,d7,ds7,e7,f7,fs7,g7,gs7,a7,as7,b7,
c8,cs8,d8,ds8,e8,f8,fs8,g8,gs8,a8,as8,b8
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment