Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.3 kB
0
Indexable
Never
import pygame
import time
import random
import os

# Define the colors for each note
COLORS = [
    (255, 0, 0),       # C
    (255, 128, 0),     # C#
    (255, 255, 0),     # D
    (128, 255, 0),     # D#
    (0, 255, 0),       # E
    (0, 255, 128),     # F
    (0, 255, 255),     # F#
    (0, 128, 255),     # G
    (0, 0, 255),       # G#
    (128, 0, 255),     # A
    (255, 0, 255),     # A#
    (255, 0, 128),     # B
]

# Define the frequency for each note
FREQUENCIES = [
    16.35,   # C
    17.32,   # C#
    18.35,   # D
    19.45,   # D#
    20.60,   # E
    21.83,   # F
    23.12,   # F#
    24.50,   # G
    25.96,   # G#
    27.50,   # A
    29.14,   # A#
    30.87,   # B
]

# Define the tempo of the music
BPM = 60
QUARTER_NOTE_DURATION = 60 / BPM

# Define the dimensions of the screen
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800

# Define the number of microtones per semitone
MICROTONE_DIVISIONS = 100

# Define the number of notes to play
NUM_NOTES = 1000

# Define the playing rules
def play_random(colors):
    return random.choice(colors)

def play_left_to_right(colors):
    return colors

def play_right_to_left(colors):
    return list(reversed(colors))

def play_top_to_bottom(colors):
    result = []
    for i in range(12):
        for j in range(100):
            result.append(colors[i])
    return result

def play_bottom_to_top(colors):
    result = []
    for i in reversed(range(12)):
        for j in range(100):
            result.append(colors[i])
    return result

def play_diagonal(colors):
    result = []
    for i in range(12):
        for j in range(100):
            result.append(colors[(i + j) % 12])
    return result

def play_reverse_diagonal(colors):
    result = []
    for i in range(12):
        for j in range(100):
            result.append(colors[(i - j) % 12])
    return result

def play_spiral(colors):
    result = []
    row, col, direction = 0, 0, 0
    matrix = [[None] * 12 for i in range(12)]
    for i in range(12*12):
        matrix[row][col] = colors[i%12]
        result.append(matrix[row][col])
        if direction == 0:
            if col == 11 or matrix[row][col+1] is not None:
                direction = 1
                row += 1
            else:
                col += 1
        elif direction == 1