scamp_extensions.pitch.scale.ScaleType

class scamp_extensions.pitch.scale.ScaleType(*intervals)[source]

Bases: SavesToJSON

A ScaleType represents the intervallic relationships in a scale without specifying a specific starting point. This maps closely to what is represented in a Scala .scl file, which is why this object can load from and save to that format. In fact, the one difference between the data stored here and that stored in a .scl file is that this object allows a scale degree to be defined by both a cents offset and a subsequently applied ratio.

Parameters:

intervals – a sequence of intervals above the starting note. These can be either PitchInterval objects or anything that can be interpreted by PitchInterval.parse().

Methods

aeolian()

Convenience method for creating an aeolian ScaleType.

blues()

Convenience method for creating a blues ScaleType.

chromatic()

Returns a 12-tone equal tempered chromatic ScaleType.

diatonic([modal_shift])

Returns a diatonic ScaleType with the specified modal shift.

dorian()

Convenience method for creating a dorian ScaleType.

harmonic_minor([modal_shift])

Returns a harmonic minor ScaleType with the specified modal shift.

ionian([modal_shift])

Alias of ScaleType.diatonic().

load_from_scala(file_path)

Loads a ScaleType from a scala file.

locrian()

Convenience method for creating an locrian ScaleType.

lydian()

Convenience method for creating a lydian ScaleType.

major([modal_shift])

Alias of ScaleType.diatonic().

melodic_minor([modal_shift])

Returns a melodic minor ScaleType with the specified modal shift.

mixolydian()

Convenience method for creating a myxolydian ScaleType.

natural_minor()

Alias of ScaleType.aeolian().

octatonic([whole_step_first])

Convenience method for creating an octatonic (alternating whole and half steps) ScaleType

pentatonic([modal_shift])

Returns a pentatonic ScaleType with the specified modal shift.

pentatonic_minor()

Convenience method for creating a pentatonic minor ScaleType.

phrygian()

Convenience method for creating a phrygian ScaleType.

rotate(steps[, in_place])

Rotates the step sizes of this scale type in the manner of a modal shift.

save_to_scala(file_path[, description])

Converts and saves this ScaleType to a scala file at the given file path.

to_half_steps()

Returns a list of floats representing the number of half steps from the starting pitch for each scale degree.

whole_tone()

Convenience method for creating a whole tone ScaleType.

Inherited Methods

duplicate()

Returns a copy of this object by serializing to and from JSON.

json_dumps()

Dump this object as a JSON string.

json_loads(s)

Load this object from a JSON string.

load_from_json(file_path)

Load this object from a JSON file with the given path.

save_to_json(file_path)

Save this object to a JSON file using the given path.

to_half_steps() Sequence[float][source]

Returns a list of floats representing the number of half steps from the starting pitch for each scale degree.

rotate(steps: int, in_place: bool = True) ScaleType[source]

Rotates the step sizes of this scale type in the manner of a modal shift. E.g. going from ionian to lydian would be a rotation of 3.

Parameters:
  • steps – the number of steps to shift the starting point of the scale up or down by. Can be negative.

  • in_place – whether to modify this ScaleType in place, or to return a modified copy.

Returns:

the modified ScaleType

classmethod chromatic()[source]

Returns a 12-tone equal tempered chromatic ScaleType.

classmethod diatonic(modal_shift: int = 0) ScaleType[source]

Returns a diatonic ScaleType with the specified modal shift.

Parameters:

modal_shift – how many steps up or down to shift the starting note of the scale. 0 returns ionian, 1 returns dorian, 2 returns phrygian, etc. (There are also convenience methods for creating these modal scale types.)

classmethod major(modal_shift: int = 0) ScaleType[source]

Alias of ScaleType.diatonic().

classmethod ionian(modal_shift: int = 0) ScaleType[source]

Alias of ScaleType.diatonic().

classmethod dorian() ScaleType[source]

Convenience method for creating a dorian ScaleType.

classmethod phrygian() ScaleType[source]

Convenience method for creating a phrygian ScaleType.

classmethod lydian() ScaleType[source]

Convenience method for creating a lydian ScaleType.

classmethod mixolydian() ScaleType[source]

Convenience method for creating a myxolydian ScaleType.

classmethod aeolian() ScaleType[source]

Convenience method for creating an aeolian ScaleType.

classmethod natural_minor() ScaleType[source]

Alias of ScaleType.aeolian().

classmethod locrian() ScaleType[source]

Convenience method for creating an locrian ScaleType.

classmethod harmonic_minor(modal_shift: int = 0) ScaleType[source]

Returns a harmonic minor ScaleType with the specified modal shift.

Parameters:

modal_shift – How many steps up or down to shift the starting note of the scale. The default value of zero creates the standard harmonic minor scale.

classmethod melodic_minor(modal_shift: int = 0) ScaleType[source]

Returns a melodic minor ScaleType with the specified modal shift.

Parameters:

modal_shift – How many steps up or down to shift the starting note of the scale. The default value of zero creates the standard melodic minor scale.

classmethod whole_tone() ScaleType[source]

Convenience method for creating a whole tone ScaleType.

classmethod octatonic(whole_step_first: bool = True) ScaleType[source]

Convenience method for creating an octatonic (alternating whole and half steps) ScaleType

Parameters:

whole_step_first – whether to start with a whole step or a half step.

classmethod pentatonic(modal_shift: int = 0) ScaleType[source]

Returns a pentatonic ScaleType with the specified modal shift.

Parameters:

modal_shift – how many steps up or down to shift the starting note of the scale. A shift of 3 creates a minor pentatonic scale.

classmethod pentatonic_minor() ScaleType[source]

Convenience method for creating a pentatonic minor ScaleType.

classmethod blues() ScaleType[source]

Convenience method for creating a blues ScaleType.

save_to_scala(file_path: str, description: str = 'Mystery scale saved using SCAMP') None[source]

Converts and saves this ScaleType to a scala file at the given file path. Note that any intervals that combine cents and ratio information will be flattened out to only cents information, since the combination is not possible in scala files.

Parameters:
  • file_path – path of the file to save

  • description – description of the scale for the file header

classmethod load_from_scala(file_path: str) ScaleType[source]

Loads a ScaleType from a scala file.

Parameters:

file_path – file path of a correctly formatted scala file

duplicate() T

Returns a copy of this object by serializing to and from JSON.

json_dumps() str

Dump this object as a JSON string. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.

classmethod json_loads(s: str) T

Load this object from a JSON string. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).

Parameters:

s – a string representing this object in JSON format

classmethod load_from_json(file_path: str) T

Load this object from a JSON file with the given path. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).

Parameters:

file_path – path for loading the file

save_to_json(file_path: str) None

Save this object to a JSON file using the given path. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.

Parameters:

file_path – path for saving the file