Esempio n. 1
0
 def notes(self):
     '''
     >>> s = stream.Stream()
     >>> s.append(note.Note('C'))
     >>> s.append(note.Rest())
     >>> s.append(note.Note('D'))
     >>> for el in s.iter.notes:
     ...     print(el)
     <music21.note.Note C>
     <music21.note.Note D>
     '''
     self.addFilter(filter.ClassFilter('NotRest'))
     return self
Esempio n. 2
0
 def __init__(
         self,
         srcStream,
         filters=None,
         restoreActiveSites=True,
         activeInformation=None,
         streamsOnly=False,  # to be removed
         includeSelf=False,  # to be removed
 ):  #, parentIterator=None):
     super(RecursiveIterator,
           self).__init__(srcStream,
                          filters,
                          restoreActiveSites,
                          activeInformation=activeInformation)
     self.returnSelf = includeSelf
     self.includeSelf = includeSelf
     if streamsOnly is True:
         self.filters.append(filter.ClassFilter('Stream'))
     self.recursiveIterator = None
Esempio n. 3
0
    def getElementsByClass(self, classFilterList):
        '''
        Add a filter to the Iterator to remove all elements
        except those that match one
        or more classes in the `classFilterList`. A single class
        can also used for the `classFilterList` parameter instead of a List.

        >>> s = stream.Stream(id="s1")
        >>> s.append(note.Note('C'))
        >>> r = note.Rest()
        >>> s.append(r)
        >>> s.append(note.Note('D'))
        >>> for el in s.iter.getElementsByClass('Rest'):
        ...     print(el)
        <music21.note.Rest rest>
                
        
        ActiveSite is restored...
        
        >>> s2 = stream.Stream(id="s2")
        >>> s2.insert(0, r)
        >>> r.activeSite.id
        's2'

        >>> for el in s.iter.getElementsByClass('Rest'):
        ...     print(el.activeSite.id)
        s1   
        
        
        Classes work in addition to strings...
        
        >>> for el in s.iter.getElementsByClass(note.Rest):
        ...     print(el)
        <music21.note.Rest rest>
        
        '''
        self.addFilter(filter.ClassFilter(classFilterList))
        return self
Esempio n. 4
0
 def notesAndRests(self):
     '''
     >>> s = stream.Stream()
     >>> s.append(meter.TimeSignature('4/4'))
     >>> s.append(note.Note('C'))
     >>> s.append(note.Rest())
     >>> s.append(note.Note('D'))
     >>> for el in s.iter.notesAndRests:
     ...     print(el)
     <music21.note.Note C>
     <music21.note.Rest rest>
     <music21.note.Note D>
     
     
     chained filters... (this makes no sense since notes is a subset of notesAndRests
     
     
     >>> for el in s.iter.notesAndRests.notes:
     ...     print(el)
     <music21.note.Note C>
     <music21.note.Note D>        
     '''
     self.addFilter(filter.ClassFilter('GeneralNote'))
     return self
Esempio n. 5
0
 def voices(self):
     self.addFilter(filter.ClassFilter('Voice'))
     return self
Esempio n. 6
0
 def variants(self):
     self.addFilter(filter.ClassFilter('Variant'))
     return self
Esempio n. 7
0
 def spanners(self):
     self.addFilter(filter.ClassFilter('Spanner'))
     return self
Esempio n. 8
0
 def parts(self):
     self.addFilter(filter.ClassFilter('Part'))
     return self