コード例 #1
0
ファイル: spanners.py プロジェクト: vpadilla/music21
 def testWeakref(self):
     from music21 import note
     n = note.Note()
     idStored = id(n)
     wn = common.wrapWeakref(n)
     n2 = common.unwrapWeakref(n)
     self.assertEqual(id(n), id(n2))
コード例 #2
0
ファイル: derivation.py プロジェクト: ABC-B/music21
 def client(self, client):
     # client is the Stream that this derivation lives on
     if client is None:
         self._clientId = None
         self._client = None
     else:
         self._clientId = id(client)
         self._client = common.wrapWeakref(client)
コード例 #3
0
ファイル: spanners.py プロジェクト: jamesdoherty/music21
    def testWeakref(self):
        from music21 import note

        n = note.Note()
        idStored = id(n)
        wn = common.wrapWeakref(n)
        n2 = common.unwrapWeakref(n)
        self.assertEqual(id(n), id(n2))
コード例 #4
0
ファイル: derivation.py プロジェクト: chrislehrich/music21
 def wrapWeakref(self):
     '''Wrap all stored objects with weakrefs.
     '''
     if not common.isWeakref(self._container):
         # update id in case it has changed
         self._containerId = id(self._container)
         post = common.wrapWeakref(self._container)
         self._container = post
コード例 #5
0
 def client(self, client: t.Optional['music21.base.Music21Object']):
     # client is the Stream that this derivation lives on
     if client is None:
         self._clientId = None
         self._client = None
     else:
         self._clientId = id(client)
         self._client = common.wrapWeakref(client)
コード例 #6
0
 def wrapWeakref(self):
     '''Wrap all stored objects with weakrefs.
     '''
     if not common.isWeakref(self._container):
         # update id in case it has changed
         self._containerId = id(self._container)
         post = common.wrapWeakref(self._container)
         self._container = post
コード例 #7
0
 def setContainer(self, container):
     # container is the Stream that contains
     if container is None:
         self._containerId = None
         self._container = None
     else:
         self._containerId = id(container)
         self._container = common.wrapWeakref(container)
コード例 #8
0
ファイル: derivation.py プロジェクト: chrislehrich/music21
 def setContainer(self, container):
     # container is the Stream that this derivation lives on
     if container is None:
         self._containerId = None
         self._container = None
     else:
         self._containerId = id(container)
         self._container = common.wrapWeakref(container)
コード例 #9
0
 def client(self, client):
     # client is the Stream that this derivation lives on
     if client is None:
         self._clientId = None
         self._client = None
     else:
         self._clientId = id(client)
         self._client = common.wrapWeakref(client)
コード例 #10
0
ファイル: spanners.py プロジェクト: vpadilla/music21
    def add(self, spanner, component):
        '''Add a spanner and one or more component references.

        The `spanner` is the object represent the connections, such as a Slur or GroupBracket.

        The `component` is one or more (a list) objects, such as Note or Part.
        
        If the spanner already exists, the component will be added to the components list.


        >>> from music21 import *
        >>> class TestMock(object): pass
        >>> tm1 = TestMock()
        >>> n1 = note.Note('c2')
        >>> n2 = note.Note('g3')
        >>> sp1 = Spanners()
        >>> sp1.add(tm1, [n1, n2])
        >>> len(sp1)
        1
        '''
        idSpanner = id(spanner)
        if idSpanner not in self.keys():
            self._storage[idSpanner] = (common.wrapWeakref(spanner), [])
            self._idRef[idSpanner] = []  # just a list

        refPair = self._storage[idSpanner]
        idList = self._idRef[idSpanner]

        # presently this does not look for redundant entries
        # store component as weak ref
        if common.isListLike(component):
            bundle = component
        else:  # just append one
            bundle = [component]

        for sub in bundle:  # permit a lost of spanners
            refPair[1].append(common.wrapWeakref(sub))
            idList.append(id(sub))
コード例 #11
0
ファイル: spanners.py プロジェクト: jamesdoherty/music21
    def add(self, spanner, component):
        """Add a spanner and one or more component references.

        The `spanner` is the object represent the connections, such as a Slur or GroupBracket.

        The `component` is one or more (a list) objects, such as Note or Part.
        
        If the spanner already exists, the component will be added to the components list.


        >>> from music21 import *
        >>> class TestMock(object): pass
        >>> tm1 = TestMock()
        >>> n1 = note.Note('c2')
        >>> n2 = note.Note('g3')
        >>> sp1 = Spanners()
        >>> sp1.add(tm1, [n1, n2])
        >>> len(sp1)
        1
        """
        idSpanner = id(spanner)
        if idSpanner not in self.keys():
            self._storage[idSpanner] = (common.wrapWeakref(spanner), [])
            self._idRef[idSpanner] = []  # just a list

        refPair = self._storage[idSpanner]
        idList = self._idRef[idSpanner]

        # presently this does not look for redundant entries
        # store component as weak ref
        if common.isListLike(component):
            bundle = component
        else:  # just append one
            bundle = [component]

        for sub in bundle:  # permit a lost of spanners
            refPair[1].append(common.wrapWeakref(sub))
            idList.append(id(sub))
コード例 #12
0
ファイル: tinyNotation.py プロジェクト: Trzyszcz/Derp
 def __init__(self, modifierData, modifierString, parent):
     self.modifierData = modifierData
     self.modifierString = modifierString
     self.parent = common.wrapWeakref(parent)
コード例 #13
0
ファイル: tinyNotation.py プロジェクト: Trzyszcz/Derp
 def __init__(self, parent=None, stateInfo=None):
     self.affectedTokens = []
     self.parent = common.wrapWeakref(parent)
     self.stateInfo = stateInfo
コード例 #14
0
 def client(self, client):
     # client is the Stream that this status lives on
     self._client = common.wrapWeakref(client)
コード例 #15
0
ファイル: streamStatus.py プロジェクト: Aminor7/music21
 def __setstate__(self, state):
     SlottedObject.__setstate__(self, state)
     self._client = common.wrapWeakref(self._client)
コード例 #16
0
ファイル: timespanTree.py プロジェクト: snarrenberg/music21
 def element(self, expr):
     self._source = common.wrapWeakref(expr)
コード例 #17
0
ファイル: volume.py プロジェクト: msampaio/music21
 def _setParent(self, parent):
     if parent is not None:
         if hasattr(parent, 'classes') and 'NotRest' in parent.classes:
             self._parent = common.wrapWeakref(parent)
     else:
         self._parent = None
コード例 #18
0
 def corpus(self, newCorpus):
     self._corpus = common.wrapWeakref(newCorpus)
コード例 #19
0
ファイル: bundles.py プロジェクト: sbrother/music21
 def corpus(self, newCorpus):
     self._corpus = common.wrapWeakref(newCorpus)
コード例 #20
0
ファイル: volume.py プロジェクト: YiqianZh/msps
 def client(self, client):
     if client is not None:
         if hasattr(client, 'classes') and 'NotRest' in client.classes:
             self._client = common.wrapWeakref(client)
     else:
         self._client = None
コード例 #21
0
ファイル: sites.py プロジェクト: spyamine/music21
 def _setAndWrapSite(self, site):
     if WEAKREF_ACTIVE:
         self.siteWeakref = common.wrapWeakref(site)
     else:
         self.siteWeakref = site
コード例 #22
0
ファイル: axis.py プロジェクト: cuthbertLab/music21
 def client(self, referent):
     self._client = common.wrapWeakref(referent)
コード例 #23
0
ファイル: sites.py プロジェクト: 05565/music21
 def __setstate__(self, state):
     common.SlottedObject.__setstate__(self, state)
     if WEAKREF_ACTIVE:
         self.siteWeakref = common.wrapWeakref(self.siteWeakref)
コード例 #24
0
ファイル: sites.py プロジェクト: starxcheng/music21
 def _setAndWrapSite(self, site):
     if WEAKREF_ACTIVE:
         self.siteWeakref = common.wrapWeakref(site)
     else:
         self.siteWeakref = site
     self.isDead = False
コード例 #25
0
ファイル: sites.py プロジェクト: ifitz/music21
 def _setAndWrapSite(self, site):
     self.siteWeakref = common.wrapWeakref(site)
コード例 #26
0
ファイル: timespanTree.py プロジェクト: blakme/music21
 def element(self, expr):
     self._source = common.wrapWeakref(expr)
コード例 #27
0
 def client(self, referent):
     self._client = common.wrapWeakref(referent)
コード例 #28
0
ファイル: sites.py プロジェクト: musescore/randomsheetmusic
 def __setstate__(self, state):
     common.SlottedObject.__setstate__(self, state)
     if WEAKREF_ACTIVE:
         self.siteWeakref = common.wrapWeakref(self.siteWeakref)
コード例 #29
0
 def parent(self, parent):
     if parent is not None:
         if hasattr(parent, 'classes') and 'NotRest' in parent.classes:
             self._parent = common.wrapWeakref(parent)
     else:
         self._parent = None
コード例 #30
0
ファイル: clercqTemperley.py プロジェクト: matyastr/msps
 def _setParent(self, parent):
     self._parent = common.wrapWeakref(parent)
コード例 #31
0
ファイル: volume.py プロジェクト: willingc/music21
 def client(self, client):
     if client is not None:
         if hasattr(client, 'classes') and 'NotRest' in client.classes:
             self._client = common.wrapWeakref(client)
     else:
         self._client = None
コード例 #32
0
ファイル: volume.py プロジェクト: YiqianZh/msps
 def __setstate__(self, state):
     SlottedObject.__setstate__(self, state)
     self._client = common.wrapWeakref(self._client)
コード例 #33
0
ファイル: tinyNotation.py プロジェクト: 00gavin/music21
 def __init__(self, parent, stateInfo):
     self.affectedTokens = []
     self.parent = common.wrapWeakref(parent)
     self.stateInfo = stateInfo
コード例 #34
0
 def _setParent(self, parent):
     self._parent = common.wrapWeakref(parent)
コード例 #35
0
 def client(self, client):
     if client is not None:
         if isinstance(client, note.NotRest):
             self._client = common.wrapWeakref(client)
     else:
         self._client = None
コード例 #36
0
ファイル: tinyNotation.py プロジェクト: 00gavin/music21
 def __init__(self, modifierData, modifierString, parent):
     self.modifierData = modifierData
     self.modifierString = modifierString
     self.parent = common.wrapWeakref(parent)
コード例 #37
0
ファイル: sites.py プロジェクト: pierrebateau/music21
 def _setAndWrapSite(self, site):
     self.siteWeakref = common.wrapWeakref(site)