Exemple #1
0
# Authors:      Jose Cabal-Ugaz
#               Michael Scott Cuthbert
#
# Copyright:    Copyright © 2012, 2016 Michael Scott Cuthbert and the music21 Project
# License:      LGPL or BSD, see license.txt
# ------------------------------------------------------------------------------
import unittest

from collections import OrderedDict

from music21 import environment
from music21.braille import basic
from music21.braille.basic import BrailleBasicException
from music21.braille.lookup import symbols

environRules = environment.Environment('braille/noteGrouping.py')


class NoteGroupingTranscriber:
    '''
    Object that can transcribe note groupings...
    '''
    def __init__(self, brailleElementGrouping=None):
        self.showLeadingOctave = True
        self.brailleElementGrouping = brailleElementGrouping
        self._upperFirstInFingering = None
        self._showClefSigns = None

        # duplicate of reset...
        self.previousNote = None
        self.previousElement = None
Exemple #2
0
    def run(self, runWithEnviron=True):
        '''
        Main code runner for testing. To set a new test, update the self.callTest attribute in __init__().

        Note that the default of runWithEnviron imports music21.environment.  That might
        skew results
        '''
        suffix = '.png' # '.svg'
        outputFormat = suffix[1:]
        _MOD = "test.timeGraphs"

        if runWithEnviron:
            from music21 import environment
            environLocal = environment.Environment(_MOD)
            fp = environLocal.getTempFile(suffix)
        # manually get a temporary file
        else:
            import tempfile
            import os
            import sys
            if os.name in ['nt'] or sys.platform.startswith('win'):
                platform = 'win'
            else:
                platform = 'other'

            tempdir = os.path.join(tempfile.gettempdir(), 'music21')
            if platform != 'win':
                fd, fp = tempfile.mkstemp(dir=tempdir, suffix=suffix)
                if isinstance(fd, int):
                # on MacOS, fd returns an int, like 3, when this is called
                # in some context (specifically, programmatically in a
                # TestExternal class. the fp is still valid and works
                # TODO: this did not work on MacOS 10.6.8 w/ py 2.7
                    pass
                else:
                    fd.close()
            else:
                tf = tempfile.NamedTemporaryFile(dir=tempdir, suffix=suffix)
                fp = tf.name
                tf.close()


        if self.includeList is not None:
            gf = pycallgraph.GlobbingFilter(include=self.includeList, exclude=self.excludeList)
        else:
            gf = pycallgraph.GlobbingFilter(exclude=self.excludeList)
        # create instance; will call setup routines
        ct = self.callTest()

        # start timer
        print('%s starting test' % _MOD)
        t = Timer()
        t.start()

        graphviz = pycallgraph.output.GraphvizOutput(output_file=fp)
        graphviz.tool = '/usr/local/bin/dot'

        config = pycallgraph.Config()
        config.trace_filter = gf

        from music21 import meter
        from music21 import note
        #from music21 import converter
        #from music21 import common
        #beeth = common.getCorpusFilePath() + '/beethoven/opus133.mxl'
        #s = converter.parse(beeth, forceSource=True)
        #beeth = common.getCorpusFilePath() + '/bach/bwv66.6.mxl'
        #s = converter.parse(beeth, forceSource=True)

        with pycallgraph.PyCallGraph(output=graphviz, config=config):
            note.Note()
            meter.TimeSignature('4/4')
            ct.testFocus() # run routine
            pass
        print('elapsed time: %s' % t)
        # open the completed file
        print('file path: ' + fp)
        try:
            environLocal = environment.Environment(_MOD)
            environLocal.launch(outputFormat, fp)
        except NameError:
            pass
Exemple #3
0
users of 64-bit windows but 32-bit python should download the win32 port


users of 64-bit windows and 64-bit python should download the amd64 port
 

'''
import os
import unittest
import wave

from music21 import exceptions21
from music21 import common
from music21 import environment
_MOD = "audiosearch.recording.py"
environLocal = environment.Environment(_MOD)

###
# to download pyaudio for windows 64-bit go to http://www.lfd.uci.edu/~gohlke/pythonlibs/
# users of 64-bit windows but 32-bit python should download the win32 port
# users of 64-bit windows and 64-bit python should download the amd64 port
# requires portaudio to be installed http://www.portaudio.com/download.html

default_recordChannels = 1
default_recordSampleRate = 44100
default_recordChunkLength = 1024


def samplesFromRecording(seconds=10.0,
                         storeFile=True,
                         recordFormat=None,
Exemple #4
0
#import importlib
with warnings.catch_warnings():
    warnings.simplefilter('ignore', DeprecationWarning)
    warnings.simplefilter('ignore', PendingDeprecationWarning)
    import imp

import unittest.runner
from unittest.signals import registerResult

import music21

from music21 import common
from music21 import environment

environLocal = environment.Environment('test.commonTest')


def defaultDoctestSuite(name=None):
    globs = __import__('music21').__dict__.copy()
    docTestOptions = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
    kwArgs = {
        'globs': globs,
        'optionflags': docTestOptions,
    }
    # in case there are any tests here, get a suite to load up later
    if name is not None:
        s1 = doctest.DocTestSuite(name, **kwArgs)
    else:
        s1 = doctest.DocTestSuite(**kwArgs)
    return s1
'''
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.
    '''

Exemple #6
0
# Copyright:    Copyright © 2013-15 Michael Scott Cuthbert and the music21
#               Project
# License:      LGPL or BSD, see license.txt
# -----------------------------------------------------------------------------
'''
Tools for grouping notes and chords into a searchable tree
organized by start and stop offsets.
'''

import copy
import unittest

from music21 import environment
from music21 import exceptions21

environLocal = environment.Environment("tree.spans")


# -----------------------------------------------------------------------------
class TimespanException(exceptions21.TreeException):
    pass


# -----------------------------------------------------------------------------
class Timespan:
    r'''
    A span of time, with a start offset and stop offset.

    Useful for demonstrating various properties of the timespan-collection class
    family.
    def run(self, runWithEnviron=False):
        '''Main code runner for testing. To set a new test, update the self.callTest attribute in __init__(). 
        '''
        suffix = '.svg'
        fmt = suffix[1:]
        _MOD = "test.timeGraphs.py"

        if runWithEnviron:
            from music21 import environment
            environLocal = environment.Environment(_MOD)
            fp = environLocal.getTempFile(suffix)
        # manually get a temporary file
        else:
            import tempfile
            import os
            import sys
            if os.name in ['nt'] or sys.platform.startswith('win'):
                platform = 'win'
            else:
                platform = 'other'

            tempdir = os.path.join(tempfile.gettempdir(), 'music21')
            if platform != 'win':
                fd, fp = tempfile.mkstemp(dir=tempdir, suffix=suffix)
                if isinstance(fd, int):
                    # on MacOS, fd returns an int, like 3, when this is called
                    # in some context (specifically, programmatically in a
                    # TestExternal class. the fp is still valid and works
                    # TODO: this did not work on MacOS 10.6.8 w/ py 2.7
                    pass
                else:
                    fd.close()
            else:
                tf = tempfile.NamedTemporaryFile(dir=tempdir, suffix=suffix)
                fp = tf.name
                tf.close()

        if self.includeList is not None:
            gf = pycallgraph.GlobbingFilter(include=self.includeList,
                                            exclude=self.excludeList)
        else:
            gf = pycallgraph.GlobbingFilter(exclude=self.excludeList)
        # create instance; will call setup routines
        ct = self.callTest()

        # start timer
        print('%s starting test' % _MOD)
        t = Timer()
        t.start()

        pycallgraph.start_trace(filter_func=gf)
        ct.testFocus()  # run routine

        pycallgraph.stop_trace()
        pycallgraph.make_dot_graph(fp, format=fmt, tool='/usr/local/bin/dot')
        print('elapsed time: %s' % t)
        # open the completed file
        print('file path: ' + fp)
        try:
            environLocal = environment.Environment(_MOD)
            environLocal.launch(format, fp)
        except NameError:
            pass
Exemple #8
0
import itertools
import unittest

from music21 import chord
from music21 import common
from music21 import environment
from music21 import exceptions21
from music21 import note
from music21 import prebase
from music21 import tie
# from music21 import key
# from music21 import pitch

from music21.tree import spans

environLocal = environment.Environment('tree.verticality')


class VerticalityException(exceptions21.TreeException):
    pass


class Verticality(prebase.ProtoM21Object):
    r'''
    A collection of information about elements that are sounding at a given
    offset or just finished at that offset or are continuing from before, etc..


    Create a timespan-stream from a score:

    >>> score = corpus.parse('bwv66.6')
Exemple #9
0
# Copyright:    Copyright © 2013-15 Michael Scott Cuthbert and the music21 Project
# License:      BSD, see license.txt
# ------------------------------------------------------------------------------

import os
import pathlib
import re
import shutil

from music21 import common
from music21 import exceptions21

from more_itertools import windowed

from music21 import environment
environLocal = environment.Environment('docbuild.writers')

from . import documenters
from . import iterators


class DocumentationWritersException(exceptions21.Music21Exception):
    pass


class DocumentationWriter:
    '''
    Abstract base class for writers.

    Call .run() on the object to make it work.
    '''
Exemple #10
0
# Copyright:    Copyright © 2013-14 Michael Scott Cuthbert and the music21
#               Project
# License:      LGPL or BSD, see license.txt
#------------------------------------------------------------------------------
'''
Tools for performing voice-leading analysis with timespans.
'''
import collections
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("timespans.analysis")


class HorizontalityException(exceptions21.TimespanException):
    pass


#------------------------------------------------------------------------------


class Horizontality(collections.Sequence):
    r'''
    A horizontality of consecutive elementTimespan objects.
    
    It must be initiated with a list or tuple of Timespan objects.
    '''
Exemple #11
0

if __name__ == '__main__':
    from music21 import corpus, converter, note, base, volume, duration, stream, environment
    p = converter.parse('tinynotation: 3/4 c4 d4 e4 f4 g4 a4').makeMeasures()
    s = stream.Score()
    s.insert(0, p)
    p2 = converter.parse('tinynotation: 3/4 A4 B4 c d e f').makeMeasures()
    s.insert(0, p2)
    s = corpus.parse('bwv66.6')

    n = note.Note()
    #s = stream.Stream()

    b = base.Music21Object()
    v = volume.Volume()
    d = duration.Duration()
    dataStr = fillTemplate(s)

    environLocal = environment.Environment()
    ext = '.html'
    fp = environLocal.getTempFile(ext)

    f = open(fp, 'w')
    f.write(dataStr)
    f.close()
    environLocal.launch(ext, fp)

####
# eof
Exemple #12
0
'''
import typing as t

import io
import math
import os
import pathlib
import unittest

from music21 import common
from music21 import interval
# scl is the library of scala files
from music21.scale.scala import scl

from music21 import environment
environLocal = environment.Environment('scale.scala')

# ------------------------------------------------------------------------------
# global variable to cache the paths returned from getPaths()
SCALA_PATHS: t.Dict[str, t.Optional[t.Dict[str, t.List[str]]]] = {
    'allPaths': 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.

    >>> a = scale.scala.getPaths()
    >>> len(a) >= 3800
Exemple #13
0
# ------------------------------------------------------------------------------
'''
Object models of barlines, including repeat barlines.
'''
import unittest
import typing as t

from music21 import base
from music21 import exceptions21

from music21 import expressions
from music21 import repeat

from music21 import environment

environLocal = environment.Environment('bar')

# ------------------------------------------------------------------------------


class BarException(exceptions21.Music21Exception):
    pass


# store alternative names for types; use this dictionary for translation
# reference
barTypeList = [
    'regular',
    'dotted',
    'dashed',
    'heavy',
Exemple #14
0
    to prepare for next release.

18. Announce on the blog, to the list, and twitter.

DO NOT RUN THIS ON A PC -- the Mac .tar.gz has an incorrect permission if you do.
'''
import hashlib
import os
import sys
import tarfile

from music21 import base
from music21 import common

from music21 import environment
environLocal = environment.Environment('..dist.dist')

PY = sys.executable
environLocal.warn("using python executable at %s" % PY)


class Distributor:
    def __init__(self):
        # self.fpEgg = None
        # self.fpWin = None
        self.fpTar = None

        self.buildNoCorpus = True
        # self.fpEggNoCorpus = None
        self.fpTarNoCorpus = None
Exemple #15
0
        {0.0} <music21.stream.Measure 0 offset=0.0>
            {0.0} <music21.clef.BassClef>
            {0.0} <music21.meter.TimeSignature 4/4>
            {0.0} <music21.note.Note G>
            {1.0} <music21.note.Note F>
            {2.0} <music21.note.Note E>
            {3.0} <music21.note.Note G>
        {4.0} <music21.stream.Measure 0 offset=4.0>
            {0.0} <music21.note.Note C>

'''
import struct
from music21 import environment
from music21 import exceptions21

environLocal = environment.Environment('noteworthy.translate')


class NoteworthyBinaryTranslateException(exceptions21.Music21Exception):
    pass


class NWCConverter:
    '''
    A converter object for binary .nwc files.  Do not normally use directly; use converter.parse.

    >>> fp = '/Users/cuthbert/test.nwc'
    >>> nwcc = noteworthy.binaryTranslate.NWCConverter(fp=fp)
    >>> nwcc
    <music21.noteworthy.binaryTranslate.NWCConverter object at 0x...>
    >>> nwcc.fp
Exemple #16
0
import copy
import unittest

from music21 import clef
from music21 import common
from music21 import environment
from music21 import exceptions21
from music21 import meter
from music21 import stream
from music21 import tie
from music21 import articulations
from music21 import note
from music21 import chord
from music21 import spanner

environLocal = environment.Environment('abcFormat.translate')


def abcToStreamPart(abcHandler, inputM21=None, spannerBundle=None):
    '''
    Handler conversion of a single Part of a multi-part score.
    Results are added into the provided inputM21 object
    or a newly created Part object

    The part object is then returned.
    '''
    from music21 import abcFormat

    if inputM21 is None:
        p = stream.Part()
    else:
Exemple #17
0
# Purpose:      functionality for reporting on the notational status of streams
#
# Authors:      Josiah Wolf Oberholtzer
#
# Copyright:    Copyright © 2013 Michael Scott Cuthbert and the music21
#               Project
# License:      BSD, see license.txt
# -----------------------------------------------------------------------------

import unittest

from music21 import environment
from music21 import common
from music21.common.objects import SlottedObjectMixin

environLocal = environment.Environment(__file__)

# -----------------------------------------------------------------------------


class StreamStatus(SlottedObjectMixin):
    '''
    An object that stores the current notation state for the client stream.

    Separates out tasks such as whether notation has been made, etc.

    >>> s = stream.Stream()
    >>> ss = s.streamStatus
    >>> ss
    <music21.stream.streamStatus.StreamStatus object at 0x...>
    >>> s.streamStatus.client is s
Exemple #18
0
#
# Authors:      Christopher Ariza
#
# Copyright:    Copyright © 2011 Michael Scott Cuthbert and the music21 Project
# License:      BSD, see license.txt
# ------------------------------------------------------------------------------

import unittest

from music21 import exceptions21

from music21 import scale
from music21 import stream

from music21 import environment
environLocal = environment.Environment('alpha.analysis.search')


class SearchModuleException(exceptions21.Music21Exception):
    pass


def findConsecutiveScale(source, targetScale, degreesRequired=5,
                         stepSize=1, comparisonAttribute='name',
                         repeatsAllowed=True, restsAllowed=False):
    '''
    Given a pitch source and a concrete scale, return references to all
    elements found that represent consecutive scale segments in one direction.

    The `targetScale` is a concrete scale instance.
Exemple #19
0
'''
This module defines numerous subclasses of
:class:`~music21.clef.Clef`, providing object representations for all
commonly used clefs. Clef objects are often found
within :class:`~music21.stream.Measure` objects.
'''
import unittest
import typing as t

from music21 import base
from music21 import exceptions21
from music21 import environment
from music21 import pitch  # for typing only
from music21 import style

environLocal = environment.Environment('clef')


class ClefException(exceptions21.Music21Exception):
    pass


# ------------------------------------------------------------------------------
class Clef(base.Music21Object):
    '''
    A Clef is a basic `music21` object for representing musical clefs
    (Treble, Bass, etc.)

    Some clefs only represent the graphical element of the clef,
    such as G clef, which is subclassed by TrebleClef() and FrenchViolinClef().
Exemple #20
0
import collections
import itertools
import unittest
from music21 import chord
from music21 import exceptions21
from music21 import environment
from music21 import meter
from music21 import note
from music21 import pitch
from music21 import stream
from music21 import tree

#from music21 import tie

environLocal = environment.Environment('reduceChords')


#------------------------------------------------------------------------------


def testMeasureStream1():
    '''
    returns a simple measure stream for testing:


    >>> s = analysis.reduceChords.testMeasureStream1()
    >>> s.show('text')
    {0.0} <music21.meter.TimeSignature 4/4>
    {0.0} <music21.chord.Chord C4 E4 G4 C5>
    {2.0} <music21.chord.Chord C4 E4 F4 B4>
Exemple #21
0
#------------------------------------------------------------------------------
'''
Object for dealing with vertical simultaneities in a fast way w/o Chord's overhead.
'''
import collections
import unittest

from music21 import note
from music21 import tie
from music21 import chord
from music21 import environment
from music21 import exceptions21
#from music21 import key
from music21 import pitch

environLocal = environment.Environment("timespans.verticality")

class VerticalityException(exceptions21.TimespanException):
    pass

class Verticality(object):
    r'''
    A collection of information about elements that are sounding at a given
    offset or just finished at that offset or are continuing from before, etc..


    Create a timespan-stream from a score:

    >>> score = corpus.parse('bwv66.6')
    >>> tree = timespans.streamToTimespanTree(score, flatten=True, 
    ...        classList=(note.Note, chord.Chord))
Exemple #22
0
# Copyright:    Copyright © 2013-14 Michael Scott Cuthbert and the music21
#               Project
# License:      LGPL or 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.
    '''
Exemple #23
0
'''
Tools for grouping elements, timespans, and especially
pitched elements into kinds of searchable tree organized by start and stop offsets
and other positions.
'''
import collections.abc
import random
import unittest

from music21 import common
from music21 import exceptions21

from music21.tree import spans, trees

from music21 import environment
environLocal = environment.Environment("tree.timespanTree")

# -----------------------------------------------------------------------------

class TimespanTreeException(exceptions21.TreeException):
    pass

# -----------------------------------------------------------------------------

class TimespanTree(trees.OffsetTree):
    r'''
    A data structure for efficiently slicing a score for pitches.

    While you can construct an TimespanTree by hand, inserting timespans one at
    a time, the common use-case is to construct the offset-tree from an entire
    score at once:
Exemple #24
0
import copy
import unittest

from music21 import chord
from music21 import common
from music21 import environment
from music21 import exceptions21
from music21 import note
from music21 import prebase
from music21 import tie
# from music21 import key
# from music21 import pitch

from music21.tree import spans

environLocal = environment.Environment("tree.verticality")

class VerticalityException(exceptions21.TreeException):
    pass

class Verticality(prebase.ProtoM21Object):
    r'''
    A collection of information about elements that are sounding at a given
    offset or just finished at that offset or are continuing from before, etc..


    Create a timespan-stream from a score:

    >>> score = corpus.parse('bwv66.6')
    >>> scoreTree = tree.fromStream.asTimespans(score, flatten=True,
    ...        classList=(note.Note, chord.Chord))
Exemple #25
0
#
# Authors:      Christopher Ariza
#
# License:      BSD, see license.txt
# ------------------------------------------------------------------------------

import unittest

# some lines must be this long, because of sources.
# pylint: disable=line-too-long

# abc standard
# http://abcnotation.com/abc2mtex/abc.txt

from music21 import environment
environLocal = environment.Environment('abcFormat.testFiles')

_DOC_IGNORE_MODULE_OR_PACKAGE = True

# http://abcnotation.com/tunePage?a=www.folkwiki.se/pub/cache/_Fyrareprisarn_0bf5b5/0001
# noinspection SpellCheckingInspection
fyrareprisarn = '''
%%abc-charset utf-8

X: 1
T: Fyrareprisarn
O: Jät, Småland
S: efter August Strömberg
D: Svensson, Gustafsson mfl - Bålgetingen
Z: Till abc av Jon Magnusson 100517
R: Hambo
Exemple #26
0
# ------------------------------------------------------------------------------
'''
Utility routines for processing text in scores and other musical objects.
'''
import unittest
import random

# import music21  # needed to properly do isinstance checking

from music21 import base
from music21 import common
from music21 import exceptions21
from music21 import environment
from music21 import style

environLocal = environment.Environment('text')



# using ISO 639-1 Code from here:
# http://www.loc.gov/standards/iso639-2/php/code_list.php
# nice article reference here:
# https://en.wikipedia.org/wiki/Article_(grammar)
# noinspection SpellCheckingInspection
articleReference = {
    # arabic
    'ar': ['al-'],
    # english
    'en': ['the', 'a', 'an'],
    # german
    'de': ['der', 'die', 'das', 'des', 'dem', 'den', 'ein', 'eine', 'einer', 'einem', 'einen'],
Exemple #27
0
    def __init__(self,
                 bassNote: Union[str, note.Note] = 'C3',
                 notationString: Optional[str] = None,
                 fbScale: Optional[realizerScale.FiguredBassScale] = None,
                 fbRules: Optional[rules.Rules] = None,
                 numParts=4,
                 maxPitch: Union[str, pitch.Pitch] = 'B5',
                 listOfPitches=None):
        '''
        A Segment corresponds to a 1:1 realization of a bassNote and notationString
        of a :class:`~music21.figuredBass.realizer.FiguredBassLine`.
        It is created by passing six arguments: a
        :class:`~music21.figuredBass.realizerScale.FiguredBassScale`, a bassNote, a notationString,
        a :class:`~music21.figuredBass.rules.Rules` object, a number of parts and a maximum pitch.
        Realizations of a Segment are represented
        as possibility tuples (see :mod:`~music21.figuredBass.possibility` for more details).

        Methods in Python's `itertools <http://docs.python.org/library/itertools.html>`_
        module are used extensively. Methods
        which generate possibilities or possibility progressions return iterators,
        which are turned into lists in the examples
        for display purposes only.

        if fbScale is None, a realizerScale.FiguredBassScale() is created

        if fbRules is None, a rules.Rules() instance is created.  Each Segment gets
        its own deepcopy of the one given.


        Here, a Segment is created using the default values: a FiguredBassScale in C,
        a bassNote of C3, an empty notationString, and a default
        Rules object.

        >>> from music21.figuredBass import segment
        >>> s1 = segment.Segment()
        >>> s1.bassNote
        <music21.note.Note C>
        >>> s1.numParts
        4
        >>> s1.pitchNamesInChord
        ['C', 'E', 'G']
        >>> [str(p) for p in s1.allPitchesAboveBass]
        ['C3', 'E3', 'G3', 'C4', 'E4', 'G4', 'C5', 'E5', 'G5']
        >>> s1.segmentChord
        <music21.chord.Chord C3 E3 G3 C4 E4 G4 C5 E5 G5>
        '''
        if isinstance(bassNote, str):
            bassNote = note.Note(bassNote)
        if isinstance(maxPitch, str):
            maxPitch = pitch.Pitch(maxPitch)

        if fbScale is None:
            if _defaultRealizerScale['scale'] is None:
                _defaultRealizerScale['scale'] = realizerScale.FiguredBassScale()
            fbScale = _defaultRealizerScale['scale']  # save making it

        if fbRules is None:
            self.fbRules = rules.Rules()
        else:
            self.fbRules = copy.deepcopy(fbRules)

        self._specialResolutionRuleChecking = None
        self._singlePossibilityRuleChecking = None
        self._consecutivePossibilityRuleChecking = None

        self.bassNote = bassNote
        self.numParts = numParts
        self._maxPitch = maxPitch
        if notationString is None and listOfPitches is not None:
            # must be a chord symbol or roman num.
            self.pitchNamesInChord = listOfPitches
        # ------ Added to accommodate harmony.ChordSymbol and roman.RomanNumeral objects ------
        else:
            self.pitchNamesInChord = fbScale.getPitchNames(self.bassNote.pitch, notationString)

        self.allPitchesAboveBass = getPitches(self.pitchNamesInChord,
                                              self.bassNote.pitch,
                                              self._maxPitch)
        self.segmentChord = chord.Chord(self.allPitchesAboveBass,
                                        quarterLength=bassNote.quarterLength)
        self._environRules = environment.Environment(_MOD)
Exemple #28
0
Run test/testDocumentation after this.
'''
import dataclasses
import multiprocessing
import os
import sys
import time
import unittest
import typing as t

from music21 import environment
from music21 import common
from music21.test import testRunner
from music21.test import commonTest

environLocal = environment.Environment('test.multiprocessTest')


@dataclasses.dataclass
class ModuleResponse:
    returnCode: t.Optional[str] = None
    fp: t.Any = None
    moduleName: t.Optional[str] = None
    success: t.Any = None
    testRunner: t.Any = None
    errors: t.Any = None
    failures: t.Any = None
    testsRun: t.Any = None
    runTime: t.Any = None

Exemple #29
0
from music21.ext import six

from music21.metadata import bundles
from music21.metadata import caching
from music21.metadata import primitives
from music21.metadata.primitives import (Date, DateSingle, DateRelative,
                                         DateBetween, DateSelection, Text,
                                         Contributor, Creator, Imprint,
                                         Copyright)

from music21.metadata import testMetadata
#------------------------------------------------------------------------------

from music21 import environment
environLocal = environment.Environment(os.path.basename(__file__))

#------------------------------------------------------------------------------


class Metadata(base.Music21Object):
    r'''
    Metadata represent data for a work or fragment, including title, composer,
    dates, and other relevant information.

    Metadata is a :class:`~music21.base.Music21Object` subclass, meaing that it
    can be positioned on a Stream by offset and have a
    :class:`~music21.duration.Duration`.

    In many cases, each Stream will have a single Metadata object at the zero
    offset position.
Exemple #30
0
# ------------------------------------------------------------------------------
'''
Classes and functions for creating and manipulating dynamic symbols. Rather than
subclasses, the :class:`~music21.dynamics.Dynamic` object is often specialized by parameters.
'''
import typing as t
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
environLocal = environment.Environment('dynamics')

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',