Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import re
import unittest
from typing import Union, Optional
from music21 import base
from music21 import exceptions21
from music21 import interval
from music21 import note
from music21 import pitch
from music21 import scale
from music21 import style
from music21.common.decorators import cacheMethod
from music21 import environment
_MOD = 'key'
environLocal = environment.Environment(_MOD)
# ------------------------------------------------------------------------------
# store a cache of already-found values
_sharpsToPitchCache = {}
def convertKeyStringToMusic21KeyString(textString):
'''
Utility function to change strings in the form of "Eb" to
"E-" (for E-flat major) and leaves alone proper music21 strings
(like "E-" or "f#"). A little bit complex because of parsing
bb as B-flat minor and Bb as B-flat major.
import unittest
import unicodedata
import sys, os, string, types
import struct
try:
import StringIO # python 2
except ImportError:
from io import StringIO # python3 (also in python 2.6+)
from music21 import common
from music21 import exceptions21
from music21 import environment
_MOD = "midi.base.py"
environLocal = environment.Environment(_MOD)
# good midi reference:
# http://www.sonicspot.com/guide/midifiles.html
#-------------------------------------------------------------------------------
class EnumerationException(exceptions21.Music21Exception):
pass
class MidiException(exceptions21.Music21Exception):
pass
requires LaTeX. (MacTeX, etc.; I suggest Basic TeX instead of the full MacTeX for this,
since it's only 100MB instead of 2.5GB)
'''
import re
import unittest
import os.path
from music21 import clef
from music21 import common
from music21 import exceptions21
from music21 import note
from music21 import stream
from music21 import environment
_MOD = "chant.py"
environLocal = environment.Environment(_MOD)
def fromStream(inputStream):
if inputStream.metadata is not None:
incipit = inputStream.metadata.title
else:
incipit = "Benedicamus Domino"
out = ''
out += 'name: ' + incipit + ';\n'
out += "%%\n"
return out
class GregorianStream(stream.Stream):
r'''
>>> s = alpha.chant.GregorianStream()
import time
import unittest
import zlib
from typing import Union
from music21 import base
from music21 import common
from music21 import defaults
from music21 import derivation
from music21 import exceptions21
# from music21.tree.trees import ElementTree
from music21 import environment
_MOD = 'freezeThaw'
environLocal = environment.Environment(_MOD)
# -----------------------------------------------------------------------------
class FreezeThawException(exceptions21.Music21Exception):
pass
# -----------------------------------------------------------------------------
class StreamFreezeThawBase:
'''
Contains a few methods that are used for both
StreamFreezer and StreamThawer
'''
# Copyright: Copyright © 2013-14 Michael Scott Cuthbert and the music21
# Project
# License: BSD, see license.txt
# -----------------------------------------------------------------------------
'''
Tools for performing voice-leading analysis with trees.
'''
import collections.abc
import unittest
# from music21 import base
# from music21 import common
from music21 import environment
from music21 import exceptions21
# from music21 import key
environLocal = environment.Environment('tree.analysis')
class HorizontalityException(exceptions21.TreeException):
pass
# -----------------------------------------------------------------------------
class Horizontality(collections.abc.Sequence):
r'''
A horizontality of consecutive PitchedTimespan objects.
It must be initiated with a list or tuple of Timespan objects.
'''
'''
import enum
import unittest
from music21 import bar
from music21 import base
from music21 import clef
from music21 import environment
from music21 import exceptions21
from music21 import layout
from music21 import note
from music21 import pitch
from music21 import spanner
from music21 import stream
environLocal = environment.Environment('volpiano.py')
class VolpianoException(exceptions21.Music21Exception):
pass
ErrorLevel = enum.Enum('ErrorLevel', 'WARN LOG')
class Neume(spanner.Spanner):
'''
A spanner that represents a Neume. No name of the neume, just that it is a Neume.
'''
class LineBreak(base.Music21Object):
'''
Indicates that the line breaks at this point in the manuscript.
'''
Classes and functions for creating and manipulating dynamic symbols. Rather than
subclasses, the :class:`~music21.dynamics.Dynamic` object is often specialized by parameters.
'''
import unittest
from music21 import base
from music21 import exceptions21
from music21 import common
from music21 import spanner
from music21 import style
from music21 import environment
_MOD = 'dynamics'
environLocal = environment.Environment(_MOD)
shortNames = ['pppppp', 'ppppp', 'pppp', 'ppp', 'pp', 'p', 'mp',
'mf', 'f', 'fp', 'sf', 'ff', 'fff', 'ffff', 'fffff', 'ffffff']
longNames = {'ppp': 'pianississimo',
'pp': 'pianissimo',
'p': 'piano',
'mp': 'mezzopiano',
'mf': 'mezzoforte',
'f': 'forte',
'fp': 'fortepiano',
'sf': 'sforzando',
'ff': 'fortissimo',
'fff': 'fortississimo'}
# could be really useful for automatic description of musical events
from music21 import base
from music21 import common
from music21 import exceptions21
from music21 import features
from music21 import metadata
from music21 import note
from music21 import pitch
from music21 import scale
from music21 import stream
from music21.audioSearch import recording
from music21.audioSearch import transcriber
from music21 import environment
_MOD = 'audioSearch'
environLocal = environment.Environment(_MOD)
audioChunkLength = 1024
recordSampleRate = 44100
def histogram(data, bins):
'''
Partition the list in `data` into a number of bins defined by `bins`
and return the number of elements in each bins and a set of `bins` + 1
elements where the first element (0) is the start of the first bin,
the last element (-1) is the end of the last bin, and every remaining element (i)
is the dividing point between one bin and another.
>>> data = [1, 1, 4, 5, 6, 0, 8, 8, 8, 8, 8]
>>> outputData, bins = audioSearch.histogram(data, 8)
>>> print(outputData)
import csv
import unittest
from music21 import common
from music21 import key
from music21 import metadata
from music21 import meter
from music21 import note
from music21 import roman
from music21 import stream
from music21 import exceptions21
from music21 import environment
environLocal = environment.Environment()
# ------------------------------------------------------------------------------
class TsvException(exceptions21.Music21Exception):
pass
# ------------------------------------------------------------------------------
class TabChord:
'''
An intermediate representation format for moving between tabular data and music21 chords.
'''
def __init__(self):
self.combinedChord = None # 'chord' in ABC original, otherwise names the same
import unittest
import math, codecs
#try:
# import StringIO # python 2
#except:
# from io import StringIO # python3 (also in python 2.6+)
from music21 import common
from music21 import interval
# scl is the library of scala files
from music21.scala import scl
from music21 import environment
_MOD = "pitch.py"
environLocal = environment.Environment(_MOD)
#-------------------------------------------------------------------------------
# global variable to cache the paths returned from getPaths()
SCALA_PATHS = None
def getPaths():
'''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
True
'''