This module defines classes for representing Scala scale data, including Scala pitch representations, storage, and files.

The Scala format is defined at the following URL:

We thank Manuel Op de Coul for allowing us to include the repository (as of May 11, 2011) with music21

Utility functions are also provided to search and find scales in the Scala scale archive. File names can be found with the search() function.

To create a ScalaScale instance, simply provide a root pitch and the name of the scale. Scale names are given as a the scala .scl file name.

>>> mbiraScales ='mbira')
>>> mbiraScales
['mbira_banda.scl', 'mbira_banda2.scl', 'mbira_gondo.scl', 'mbira_kunaka.scl', 'mbira_kunaka2.scl', 'mbira_mude.scl', 'mbira_mujuru.scl', 'mbira_zimb.scl']

For most people you’ll want to do something like this:

>>> sc = scale.ScalaScale('a4', 'mbira_banda.scl')
>>> [str(p) for p in sc.pitches]
['A4', 'B4(-15c)', 'C#5(-11c)', 'D#5(-7c)', 'E~5(+6c)', 'F#5(+14c)', 'G~5(+1c)', 'B-5(+2c)']



Get all scala scale paths. This is called once or the module and cached as SCALA_PATHS, which should be used instead of calls to this function.

>>> from music21 import scala
>>> a = scala.getPaths()
>>> len(a) >= 3800

Get a ScalaData object from the bundled SCL archive or a file path.

>>> from music21 import scala
>>> ss = scala.parse('balafon6')
>>> ss.description
u'Observed balafon tuning from Burma, Helmholtz/Ellis p. 518, nr.84'
>>> [str(i) for i in ss.getIntervalSequence()]
['<music21.interval.Interval m2 (+14c)>', '<music21.interval.Interval M2 (+36c)>', '<music21.interval.Interval M2>', '<music21.interval.Interval m2 (+37c)>', '<music21.interval.Interval M2 (-49c)>', '<music21.interval.Interval M2 (-6c)>', '<music21.interval.Interval M2 (-36c)>']
>>> scala.parse('incorrectFileName.scl') == None
>>> ss = scala.parse('barbourChrom1')
>>> print(ss.description)
Barbour's #1 Chromatic
>>> ss.fileName
>>> ss = scala.parse('blackj_gws.scl')
>>> ss.description
u'Detempered Blackjack in 1/4 kleismic marvel tuning'

Search the scala archive for matches based on a string

>>> mbiraScales ='mbira')
>>> mbiraScales
['mbira_banda.scl', 'mbira_banda2.scl', 'mbira_gondo.scl', 'mbira_kunaka.scl', 'mbira_kunaka2.scl', 'mbira_mude.scl', 'mbira_mujuru.scl', 'mbira_zimb.scl']


class music21.scala.ScalaData(sourceString=None, fileName=None)

Object representation of data stored in a Scale scale file. This object is used to access Scala information stored in a file. To create a music21 scale with a Scala file, use ScalaScale.

This is not called ScalaScale, as this name clashes with the ScalaScale that uses this object.

ScalaData methods


Get cents values between adjacent intervals.


Return a list of cent values above the implied tonic.


Return a string suitable for writing a Scale file


Get the scale as a list of Interval objects.


Parse a scala file delivered as a long string with line breaks


Given a list of adjacent cent values, create the necessary ScalaPitch objects and update the


Set the scale from a list of Interval objects.


class music21.scala.ScalaFile(data=None)

Interface for reading and writing scala files. On reading, returns a ScalaData object.

>>> sf = scala.ScalaFile() 

ScalaFile methods

ScalaFile.close(), mode='r')

Open a file for reading


Assign a file-like object, such as those provided by StringIO, as an open file object.

Read a file. Note that this calls readstring, which processes all tokens.

If number is given, a work number will be extracted if possible.


Read a string and process all Tokens. Returns a ABCHandler instance.



class music21.scala.ScalaPitch(sourceString=None)

Representation of a scala pitch notation

>>> sp = scala.ScalaPitch(' 1066.667 cents')
>>> print(sp.parse())
>>> sp = scala.ScalaPitch(' 2/1')
>>> sp.parse()
>>> sp.parse('100.0 C#')
>>> [sp.parse(x) for x in ['89/84', '55/49', '44/37', '63/50', '4/3', '99/70', '442/295', '27/17', '37/22', '98/55', '15/8', '2/1']]
[100.09920982..., 199.9798432913..., 299.973903610..., 400.108480470..., 498.044999134..., 600.08832376157..., 699.9976981706..., 800.90959309..., 900.02609638..., 1000.020156708..., 1088.268714730..., 1200.0]

ScalaPitch methods


Parse the source string and set self.cents.