Forum Archive

Random music scale generator

craigmrock

Looking to create a database that retrieves scales for guitar practice. At the moment, I just want it to list a major or minor scale when you answer the question: “Major or minor scale?”
I’m a noob, trying to take some class examples and make them into what I’d like to work on.

import random

class scale:
    def __init__(self,minor=False, major=True, **kwargs):
        for key,value in kwargs.items():
            setattr(self,key,value)

class Ionian(scale):
    def __init__(self):
        data = {
            "value": 'major'
        }
        super().__init__(**data)

class Dorian(scale):
    def __init__(self):
        data = {
            "value": 'minor'
        }
        super().__init__(**data)

class Phrygian(scale):
    def __init__(self):
        data = {
            "value": 'minor'
        }
        super().__init__(**data)

class Lydian(scale):
    def __init__(self):
        data = {
            "value": 'major'
        }
        super().__init__(**data)

class Mixolydian(scale):
    def __init__(self):
        data = {
            "value": 'major'
        }
        super().__init__(**data)

class Aeolian(scale):
    def __init__(self):
        data = {
            "value":'minor'
        }
        super().__init__(**data)

class Locrian(scale):
    def __init__(self):
        data = {
            "value": 'minor'
        }
        super().__init__(**data)

scales = [Ionian(), Dorian(), Phrygian(), Lydian(), Mixolydian(), Aeolian(), Locrian()]

for scale in scales:
    arguments = [scale,scale.value]
    string = "{}: - value:{}".format(*arguments)

while True:
    choice = input("Major or Minor scale?: ").strip().title()

    if choice in scale:
        mode = int(input("Do you like a particular mode?").strip())
ccc

The second last line is a problem... Two solutions to try...
1. Change scale to scales (plural).
2. Change scale to ('Major', 'Minor') .

I think the second is what you really intended.

craigmrock

@ccc thanks, that cleared up one of the errors I was getting through experimenting.
Craig