Saturday, February 27, 2016

11. Names and Frequencies of notes

Note objects may be created by passing in a midi number in the range from 0 to 127. Since we start at 0, we have a total of 128 numbers.


For the Note object, we can find the name, the octave, as well as the nameWithOctave.


We also find the frequency of the associated Pitch object.


# mus11.py
# Names and Frequencies of notes

import music21 as m21

for midi in range(128):
    n = m21.note.Note(midi=midi)
    print_string = 'midi = {} \t{} \t{:.1f} Hz'
    print(print_string.format(midi,
                              n.nameWithOctave,
                              n.pitch.frequency))

This will generate output:


midi = 0  C-1  8.2 Hz
midi = 1  C#-1  8.7 Hz
midi = 2  D-1  9.2 Hz
midi = 3  E--1  9.7 Hz
midi = 4  E-1  10.3 Hz
midi = 5  F-1  10.9 Hz
midi = 6  F#-1  11.6 Hz
midi = 7  G-1  12.2 Hz
midi = 8  G#-1  13.0 Hz
midi = 9  A-1  13.7 Hz
midi = 10  B--1  14.6 Hz
midi = 11  B-1  15.4 Hz
midi = 12  C0  16.4 Hz
midi = 13  C#0  17.3 Hz
midi = 14  D0  18.4 Hz
midi = 15  E-0  19.4 Hz
midi = 16  E0  20.6 Hz
midi = 17  F0  21.8 Hz
midi = 18  F#0  23.1 Hz
midi = 19  G0  24.5 Hz
midi = 20  G#0  26.0 Hz
midi = 21  A0  27.5 Hz
midi = 22  B-0  29.1 Hz
midi = 23  B0  30.9 Hz
midi = 24  C1  32.7 Hz
midi = 25  C#1  34.6 Hz
midi = 26  D1  36.7 Hz
midi = 27  E-1  38.9 Hz
midi = 28  E1  41.2 Hz
midi = 29  F1  43.7 Hz
midi = 30  F#1  46.2 Hz
midi = 31  G1  49.0 Hz
midi = 32  G#1  51.9 Hz
midi = 33  A1  55.0 Hz
midi = 34  B-1  58.3 Hz
midi = 35  B1  61.7 Hz
midi = 36  C2  65.4 Hz
midi = 37  C#2  69.3 Hz
midi = 38  D2  73.4 Hz
midi = 39  E-2  77.8 Hz
midi = 40  E2  82.4 Hz
midi = 41  F2  87.3 Hz
midi = 42  F#2  92.5 Hz
midi = 43  G2  98.0 Hz
midi = 44  G#2  103.8 Hz
midi = 45  A2  110.0 Hz
midi = 46  B-2  116.5 Hz
midi = 47  B2  123.5 Hz
midi = 48  C3  130.8 Hz
midi = 49  C#3  138.6 Hz
midi = 50  D3  146.8 Hz
midi = 51  E-3  155.6 Hz
midi = 52  E3  164.8 Hz
midi = 53  F3  174.6 Hz
midi = 54  F#3  185.0 Hz
midi = 55  G3  196.0 Hz
midi = 56  G#3  207.7 Hz
midi = 57  A3  220.0 Hz
midi = 58  B-3  233.1 Hz
midi = 59  B3  246.9 Hz
midi = 60  C4  261.6 Hz
midi = 61  C#4  277.2 Hz
midi = 62  D4  293.7 Hz
midi = 63  E-4  311.1 Hz
midi = 64  E4  329.6 Hz
midi = 65  F4  349.2 Hz
midi = 66  F#4  370.0 Hz
midi = 67  G4  392.0 Hz
midi = 68  G#4  415.3 Hz
midi = 69  A4  440.0 Hz
midi = 70  B-4  466.2 Hz
midi = 71  B4  493.9 Hz
midi = 72  C5  523.3 Hz
midi = 73  C#5  554.4 Hz
midi = 74  D5  587.3 Hz
midi = 75  E-5  622.3 Hz
midi = 76  E5  659.3 Hz
midi = 77  F5  698.5 Hz
midi = 78  F#5  740.0 Hz
midi = 79  G5  784.0 Hz
midi = 80  G#5  830.6 Hz
midi = 81  A5  880.0 Hz
midi = 82  B-5  932.3 Hz
midi = 83  B5  987.8 Hz
midi = 84  C6  1046.5 Hz
midi = 85  C#6  1108.7 Hz
midi = 86  D6  1174.7 Hz
midi = 87  E-6  1244.5 Hz
midi = 88  E6  1318.5 Hz
midi = 89  F6  1396.9 Hz
midi = 90  F#6  1480.0 Hz
midi = 91  G6  1568.0 Hz
midi = 92  G#6  1661.2 Hz
midi = 93  A6  1760.0 Hz
midi = 94  B-6  1864.7 Hz
midi = 95  B6  1975.5 Hz
midi = 96  C7  2093.0 Hz
midi = 97  C#7  2217.5 Hz
midi = 98  D7  2349.3 Hz
midi = 99  E-7  2489.0 Hz
midi = 100  E7  2637.0 Hz
midi = 101  F7  2793.8 Hz
midi = 102  F#7  2960.0 Hz
midi = 103  G7  3136.0 Hz
midi = 104  G#7  3322.4 Hz
midi = 105  A7  3520.0 Hz
midi = 106  B-7  3729.3 Hz
midi = 107  B7  3951.1 Hz
midi = 108  C8  4186.0 Hz
midi = 109  C#8  4434.9 Hz
midi = 110  D8  4698.6 Hz
midi = 111  E-8  4978.0 Hz
midi = 112  E8  5274.0 Hz
midi = 113  F8  5587.7 Hz
midi = 114  F#8  5919.9 Hz
midi = 115  G8  6271.9 Hz
midi = 116  G#8  6644.9 Hz
midi = 117  A8  7040.0 Hz
midi = 118  B-8  7458.6 Hz
midi = 119  B8  7902.1 Hz
midi = 120  C9  8372.0 Hz
midi = 121  C#9  8869.8 Hz
midi = 122  D9  9397.3 Hz
midi = 123  E-9  9956.1 Hz
midi = 124  E9  10548.1 Hz
midi = 125  F9  11175.3 Hz
midi = 126  F#9  11839.8 Hz
midi = 127  G9  12543.9 Hz

No comments:

Post a Comment