BPM = 180
QUARTER = 60.0 / BPM
HALF = QUARTER * 2

NOTE_TO_FREQ = {
    "C1": 32.70, "C#1": 34.65, "D1": 36.71, "D#1": 38.89, "E1": 41.20, "F1": 43.65,
    "F#1": 46.25, "G1": 49.00, "G#1": 51.91, "A1": 55.00, "A#1": 58.27, "B1": 61.74,
    "C2": 65.41, "C#2": 69.30, "D2": 73.42, "D#2": 77.78, "E2": 82.41, "F2": 87.31,
    "F#2": 92.50, "G2": 98.00, "G#2": 103.83, "A2": 110.00, "A#2": 116.54, "B2": 123.47,
    "C3": 130.81, "C#3": 138.59, "D3": 146.83, "D#3": 155.56, "E3": 164.81, "F3": 174.61,
    "F#3": 185.00, "G3": 196.00, "G#3": 207.65, "A3": 220.00, "A#3": 233.08, "B3": 246.94,
    "C4": 261.63, "C#4": 277.18, "D4": 293.66, "D#4": 311.13, "E4": 329.63, "F4": 349.23,
    "F#4": 369.99, "G4": 392.00, "G#4": 415.30, "A4": 440.00, "A#4": 466.16, "B4": 493.88,
    "C5": 523.25, "C#5": 554.37, "D5": 587.33, "D#5": 622.25, "E5": 659.25, "F5": 698.46,
    "F#5": 739.99, "G5": 783.99, "G#5": 830.61, "A5": 880.00, "A#5": 932.33, "B5": 987.77
}

NOTE_TO_MIDI = {
    "C1": 24, "C#1": 25, "D1": 26, "D#1": 27, "E1": 28, "F1": 29, "F#1": 30, "G1": 31, "G#1": 32, "A1": 33, "A#1": 34, "B1": 35,
    "C2": 36, "C#2": 37, "D2": 38, "D#2": 39, "E2": 40, "F2": 41, "F#2": 42, "G2": 43, "G#2": 44, "A2": 45, "A#2": 46, "B2": 47,
    "C3": 48, "C#3": 49, "D3": 50, "D#3": 51, "E3": 52, "F3": 53, "F#3": 54, "G3": 55, "G#3": 56, "A3": 57, "A#3": 58, "B3": 59,
    "C4": 60, "C#4": 61, "D4": 62, "D#4": 63, "E4": 64, "F4": 65, "F#4": 66, "G4": 67, "G#4": 68, "A4": 69, "A#4": 70, "B4": 71,
    "C5": 72, "C#5": 73, "D5": 74, "D#5": 75, "E5": 76, "F5": 77, "F#5": 78, "G5": 79, "G#5": 80, "A5": 81, "A#5": 82, "B5": 83
}

NOTES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]


SOUNDFONTS = {
    'Bassoon': 'SJO - Bassoon.sf2',
    'Cello': 'SJO - Cello.sf2',
    'Choir Aahs': 'SJO - Choir Aahs.sf2',
    'Clarinet': 'SJO - Clarinet.sf2',
    'Double Bass': 'SJO - Double Bass.sf2',
    'English Horn': 'SJO - English Horn.sf2',
    'Flute': 'SJO - Flute.sf2',
    'French Horn': 'SJO - French Horn.sf2',
    'Glockenspiel': 'SJO - Glockenspiel.sf2',
    'Harp': 'SJO - Harp.sf2',
    'Marimbas': 'SJO - Marimbas.sf2',
    'Strings slow': 'SJO - Strings slow.sf2',
    'Strings': 'SJO - Strings.sf2',
    'Timpani': 'SJO - Timpani.sf2',
    'Trombone': 'SJO - Trombone.sf2',
    'Trumpet - Velocity fix': 'SJO - Trumpet - Velocity fix.sf2',
    'Tuba': 'SJO - Tuba.sf2',
    'Vibes': 'SJO - Vibes.sf2',
    'Viola': 'SJO - Viola.sf2',
    'Xylophone': 'SJO - Xylophone.sf2'
}

GENERAL_MIDI_PROGRAMS = {
    'Glockenspiel': 9,
    'Vibes': 11,
    'Marimbas': 12,
    'Xylophone': 13,
    'Harp': 46,
    'Timpani': 47,
    'Strings': 48,
    'Strings slow': 49,
    'Viola': 41,
    'Cello': 42,
    'Double Bass': 43,
    'Choir Aahs': 52,
    'Trumpet - Velocity fix': 56,
    'Trombone': 57,
    'Tuba': 58,
    'French Horn': 60,
    'Flute': 73,
    'English Horn': 69,
    'Clarinet': 71,
    'Bassoon': 70
}


RESET = "\033[0m"
BOLD = "\033[1m"
REVERSE = "\033[7m"
BLACK = "\033[30m"
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
MAGENTA = "\033[35m"
CYAN = "\033[36m"
WHITE = "\033[37m"


README1 = f'''
{REVERSE}ATONATUI README{RESET}

The main page consists of a 12 Tone Matrix.

The only part of the main page that really needs explaining is the tri-colored table below the matrix.
- The TONE row contains the tones of P0 row.
- RTHM is the rhythmic division assigned to a given note.
- OCTV is the octave assigned to a given note.

The rhythmic division and octave will always be the same for their associated note, the order just changes when you play a row other than P0.

When you do begin playback, this tri-colored table will be replaced with the row that is currently being played.
'''

README2 = f'''
{REVERSE}{GREEN}| Command                    | Action                         | Page                 |{RESET}
| P0-P11                     | Play Prime Row                 | Main Page            |
| I0-I11                     | Play Inversion Row             | Main Page            |
| R0-R11                     | Play Retrograde Row            | Main Page            |
| i0-i11                     | Play Retrograde Inversion Row  | Main Page            |
| loop <count> <P0-i11>      | Play row X times in loop       | Main Page            |
| seq <P0-i11>,<P0-i11>...   | Play sequence, comma separated | Main Page            |
| r OR regen                 | Regenerate Matrix              | Main Page            |
| s OR settings              | Go To Settings Page            | Main Page            |
| h OR help                  | Open This Document             | Main Page            |
| q OR quit                  | Quit Application               | Main, Settings Page  |
| Setting ID                 | Edit Setting                   | Settings Page        |

Advanced Commands:
- Loop a sequence:
    - loop <x> seq <P0-i11>,<P0-i11>
    - Example: loop 5 seq P0,R3,i11,I0
- Debug
    - debug: Open up python console via breakpoint()
'''

README3 = f'''
{REVERSE}{GREEN}Settings:{RESET}
- BPM
    - Set the BPM of the overall project, between 30 - 300 BPM
- INSTRUMENT
    - Select an instrument for playback
- OCTAVE
    - Select base octave for playback
- OCTAVE_RANDOMIZATION
    - [0] Only play base octave
    - [1] Randomize octaves, increasing octave range by +1 and -1 (example: base octave = 3, octave range = 2-4)
    - [2] Randomize octaves, increasing octave range by +2 and -2 (example: base octave = 3, octave range = 1-5)
    - [3] Randomize octaves, increasing octave range by +3 and -3 (example: base octave = 1, octave range = 1-4)
        - When the range would result in an octave higher than 5 or lower than 0, it clamps range to fit 0-5
- RHYTHM_COMPLEXITY
    - [0] No Rhythmic Complexity, Will play default division
    - [1] Will play a rhythm based on sequence generated by tone matrix
    - [2] Will play a rhythm based on sequence generated by tone matrix, Including rests (if rest probability is greater than 0)
    - [3] Will play a random rhythm not based on a sequence
'''

README4 = f'''
{REVERSE}{GREEN}Settings Continued:{RESET}
- DEFAULT_DIVISION
    - 0 Whole Note
    - 1 Half Note
    - 2 Quarter Note
    - 3 Eight Note
- REST_PROBABILITY
    - The probability in which a rest will occur during playback when RHYTHM_COMPLEXITY = 2
- SAVE_SETTINGS
    - Save current settings to a file, will automatically load when you restart the program
- SAVE_MATRIX
    - Save the current tone matrix to a file, you can manually load this later
- LOAD_MATRIX
    - Load a previously saved tone matrix
'''

README5 = f'''
{REVERSE}{GREEN}Thank you for using atonatui{RESET}

Creator: Dominic DiTaranto
Website: https://www.domdit.com/
Email:   me@domdit.com

v.0.1.2
'''
