In [1]:
from music21 import *

In [2]:
note


Out[2]:
<module 'music21.note' from '/Users/cuthbert/git/music21base/music21/note.py'>

In [3]:
duration


Out[3]:
<module 'music21.duration' from '/Users/cuthbert/git/music21base/music21/duration.py'>

In [4]:
c = corpus.parse('bach')

In [5]:
c


Out[5]:
<music21.stream.Score 0x106bba6a0>

Note to self: schön isn't printing right in the title.


In [6]:
c.show()


Out[6]:

In [7]:
n = note.Note('C#')

In [8]:
n.name


Out[8]:
'C#'

In [9]:
d = n.duration

In [10]:
d.quarterLength


Out[10]:
1.0

In [11]:
d.type


Out[11]:
'quarter'

In [12]:
d.dots


Out[12]:
0

In [13]:
n.show('midi')



In [14]:
eleven = 11

bedTimes = [9, 10, eleven, 8, 12, eleven]

In [ ]:


In [15]:
print(bedTimes)
print(bedTimes)


[9, 10, 11, 8, 12, 11]
[9, 10, 11, 8, 12, 11]

In [16]:
bedTimeSum = 0
for thisParticularBedTime in bedTimes:
    bedTimeSum = bedTimeSum + thisParticularBedTime

bedTimeSum


Out[16]:
61

In [17]:
len(bedTimes)


Out[17]:
6

In [18]:
print(bedTimeSum / len(bedTimes))


10.166666666666666

In [19]:
n


Out[19]:
<music21.note.Note C#>

In [20]:
help(n)


Help on Note in module music21.note object:

class Note(NotRest)
 |  One of the most important music21 classes, a Note
 |  stores a single note (that is, not a rest or an unpitched element)
 |  that can be represented by one or more notational units -- so
 |  for instance a C quarter-note and a D# eighth-tied-to-32nd are both
 |  a single Note object.
 |  
 |  
 |  A Note knows both its total duration and how to express itself as a set of
 |  tied notes of different lengths. For instance, a note of 2.5 quarters in
 |  length could be half tied to eighth or dotted quarter tied to quarter.
 |  
 |  
 |  The first argument to the Note is the pitch name (with or without
 |  octave, see the introduction to :class:`music21.pitch.Pitch`).
 |  Further arguments can be specified as keywords (such as type, dots, etc.)
 |  and are passed to the underlying :class:`music21.duration.Duration` element.
 |  
 |  
 |  Two notes are considered equal if their most important attributes
 |  (such as pitch, duration,
 |  articulations, and ornaments) are equal.  Attributes
 |  that might change based on the wider context
 |  of a note (such as offset, beams, stem direction)
 |  are not compared. This test presently does not look at lyrics in
 |  establishing equality.  It may in the future.
 |  
 |  Method resolution order:
 |      Note
 |      NotRest
 |      GeneralNote
 |      music21.base.Music21Object
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  __eq__(self, other)
 |      Tests Equality. See docs under Note above
 |      (since __eq__'s docs don't display)
 |      
 |      >>> n1 = note.Note()
 |      >>> n1.pitch.name = 'G#'
 |      >>> n2 = note.Note()
 |      >>> n2.pitch.name = 'A-'
 |      >>> n3 = note.Note()
 |      >>> n3.pitch.name = 'G#'
 |      >>> n1 == n2
 |      False
 |      >>> n1 == n3
 |      True
 |      >>> n3.duration.quarterLength = 3
 |      >>> n1 == n3
 |      False
 |  
 |  __ge__(self, other)
 |  
 |  __gt__(self, other)
 |  
 |  __init__(self, *arguments, **keywords)
 |      # Accepts an argument for pitch
 |  
 |  __le__(self, other)
 |  
 |  __lt__(self, other)
 |      __lt__, __gt__, __le__, __ge__ all use a pitch comparison
 |      
 |      >>> highE = note.Note("E5")
 |      >>> lowF = note.Note("F2")
 |      >>> otherHighE = note.Note("E5")
 |      
 |      >>> highE > lowF
 |      True
 |      >>> highE < lowF
 |      False
 |      >>> highE >= otherHighE
 |      True
 |      >>> highE <= otherHighE
 |      True
 |  
 |  __ne__(self, other)
 |      Inequality.
 |      
 |      >>> n1 = note.Note()
 |      >>> n1.pitch.name = 'G#'
 |      >>> n2 = note.Note()
 |      >>> n2.pitch.name = 'A-'
 |      >>> n3 = note.Note()
 |      >>> n3.pitch.name = 'G#'
 |      >>> n1 != n2
 |      True
 |      >>> n1 != n3
 |      False
 |      >>> n3.duration.quarterLength = 3
 |      >>> n1 != n3
 |      True
 |  
 |  __repr__(self)
 |  
 |  transpose(self, value, inPlace=False)
 |      Transpose the Note by the user-provided 
 |      value. If the value is an integer, the transposition is treated in half steps. 
 |      
 |      If the value is a string, any Interval string specification can be provided.
 |      
 |      >>> a = note.Note('g4')
 |      >>> b = a.transpose('m3')
 |      >>> b
 |      <music21.note.Note B->
 |      >>> aInterval = interval.Interval(-6)
 |      >>> b = a.transpose(aInterval)
 |      >>> b
 |      <music21.note.Note C#>
 |      
 |      >>> c = b.transpose(interval.GenericInterval(2))
 |      >>> c
 |      <music21.note.Note D#>
 |      
 |      >>> a.transpose(aInterval, inPlace=True)
 |      >>> a
 |      <music21.note.Note C#>
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  accidental
 |      Return or set the :class:`~music21.pitch.Accidental` object 
 |      from the :class:`~music21.pitch.Pitch` object.
 |      
 |      DEPRECATED May 2014: use n.pitch.accidental instead
 |  
 |  diatonicNoteNum
 |      Return the diatonic note number from the :class:`~music21.pitch.Pitch` object. 
 |      See :attr:`~music21.pitch.Pitch.diatonicNoteNum`.
 |      
 |      Probably will be deprecated soon...
 |  
 |  frequency
 |      Return or set the frequency from 
 |      the :class:`~music21.pitch.Pitch` object. 
 |      
 |      See :attr:`~music21.pitch.Pitch.frequency`.
 |      
 |      DEPRECATED May 2014: use n.pitch.frequency instead
 |  
 |  fullName
 |      Return the most complete representation of this Note, 
 |      providing duration and pitch information.
 |      
 |      
 |      >>> n = note.Note('A-', quarterLength=1.5)
 |      >>> n.fullName
 |      'A-flat Dotted Quarter Note'
 |      
 |      >>> n = note.Note('E~3', quarterLength=2)
 |      >>> n.fullName
 |      'E-half-sharp in octave 3 Half Note'
 |      
 |      >>> n = note.Note('D', quarterLength=.25)
 |      >>> n.microtone = 25
 |      >>> n.fullName
 |      'D (+25c) 16th Note'
 |  
 |  microtone
 |      Return or set the microtone value from the 
 |      :class:`~music21.pitch.Pitch` object. 
 |      
 |      See :attr:`~music21.pitch.Pitch.microtone`.
 |      
 |      DEPRECATED May 2014: use n.pitch.microtone instead
 |  
 |  midi
 |      Return or set the numerical MIDI pitch 
 |      representation from the 
 |      :class:`~music21.pitch.Pitch` object. 
 |      
 |      See :attr:`~music21.pitch.Pitch.midi`.
 |      
 |      DEPRECATED May 2014: use n.pitch.midi instead
 |  
 |  name
 |      Return or set the pitch name from the :class:`~music21.pitch.Pitch` object.
 |      See `Pitch`'s attribute :attr:`~music21.pitch.Pitch.name`.
 |  
 |  nameWithOctave
 |      Return or set the pitch name with octave from the :class:`~music21.pitch.Pitch` object.
 |      See `Pitch`'s attribute :attr:`~music21.pitch.Pitch.nameWithOctave`.
 |  
 |  octave
 |      Return or set the octave value from the :class:`~music21.pitch.Pitch` object. 
 |      See :attr:`~music21.pitch.Pitch.octave`.
 |  
 |  pitchClass
 |      Return or set the pitch class from the :class:`~music21.pitch.Pitch` object.
 |      See :attr:`music21.pitch.Pitch.pitchClass`.
 |      
 |      DEPRECATED May 2014: use n.pitch.pitchClass instead
 |  
 |  pitchClassString
 |      Return or set the pitch class string 
 |      from the :class:`~music21.pitch.Pitch` 
 |      object. 
 |      
 |      See :attr:`~music21.pitch.Pitch.pitchClassString`.
 |      
 |      DEPRECATED May 2014: use n.pitch.pitchClassString instead
 |  
 |  pitches
 |      Return the :class:`~music21.pitch.Pitch` object in a list.
 |      This property is designed to provide an interface analogous to
 |      that found on :class:`~music21.chord.Chord`.
 |      
 |      >>> n = note.Note('g#')
 |      >>> n.nameWithOctave
 |      'G#'
 |      >>> n.pitches
 |      [<music21.pitch.Pitch G#>]
 |      >>> n.pitches = [pitch.Pitch('c2'), pitch.Pitch('g2')]
 |      >>> n.nameWithOctave
 |      'C2'
 |      >>> n.pitches
 |      [<music21.pitch.Pitch C2>]
 |  
 |  ps
 |      Return or set the numerical pitch space 
 |      representation from the 
 |      :class:`music21.pitch.Pitch` object. 
 |      
 |      See :attr:`music21.pitch.Pitch.ps`.
 |      
 |      DEPRECATED May 2014: use n.pitch.ps instead
 |  
 |  step
 |      Return or set the pitch step from the :class:`~music21.pitch.Pitch` object. 
 |      See :attr:`~music21.pitch.Pitch.step`.
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __hash__ = None
 |  
 |  isNote = True
 |  
 |  isRest = False
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from NotRest:
 |  
 |  __deepcopy__(self, memo=None)
 |      As NotRest objects have a Volume, objects, and Volume objects
 |      store weak refs to the to client object, need to specialize deep copy handling
 |      
 |      >>> import copy
 |      >>> n = note.NotRest()
 |      >>> n.volume = volume.Volume(50)
 |      >>> m = copy.deepcopy(n)
 |      >>> m.volume.client is m
 |      True
 |  
 |  __getstate__(self)
 |  
 |  __setstate__(self, state)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from NotRest:
 |  
 |  notehead
 |      Get or set the notehead type of this NotRest object.
 |      Valid notehead type names are found in note.noteheadTypeNames (see below):
 |      
 |      
 |      >>> note.noteheadTypeNames
 |      ['arrow down', 'arrow up', 'back slashed', 'circle dot', 'circle-x', 'cluster', 
 |       'cross', 'diamond', 'do', 'fa', 'inverted triangle', 'la', 'left triangle', 
 |       'mi', 'none', 'normal', 're', 'rectangle', 'slash', 'slashed', 'so', 
 |       'square', 'ti', 'triangle', 'x']
 |      >>> n = note.Note()
 |      >>> n.notehead = 'diamond'
 |      >>> n.notehead
 |      'diamond'
 |      
 |      >>> n.notehead = 'junk'
 |      Traceback (most recent call last):
 |      NotRestException: not a valid notehead type name: 'junk'
 |  
 |  noteheadFill
 |      Get or set the note head fill status of this NotRest. Valid note head fill values are 
 |      True, False, or None (meaning default).
 |      
 |      >>> n = note.Note()
 |      >>> n.noteheadFill = 'no'
 |      >>> n.noteheadFill
 |      False
 |      >>> n.noteheadFill = 'filled'
 |      >>> n.noteheadFill
 |      True
 |      
 |      >>> n.noteheadFill = 'junk'
 |      Traceback (most recent call last):
 |      NotRestException: not a valid notehead fill value: junk
 |  
 |  noteheadParenthesis
 |      Get or set the note head parentheses for this Note/Unpitched/Chord object.
 |      
 |      >>> n = note.Note()
 |      >>> n.noteheadParenthesis
 |      False
 |      >>> n.noteheadParenthesis = True
 |      >>> n.noteheadParenthesis
 |      True
 |      
 |      'yes' or 1 equate to True; 'no' or 0 to False
 |      
 |      >>> n.noteheadParenthesis = 'no'
 |      >>> n.noteheadParenthesis
 |      False
 |      
 |      Anything else raises an exception:
 |      
 |      >>> n.noteheadParenthesis = 'blah'
 |      Traceback (most recent call last):
 |      NotRestException: notehead parentheses must be True or False, not 'blah'
 |  
 |  stemDirection
 |      Get or set the stem direction of this NotRest object. 
 |      Valid stem direction names are found in note.stemDirectionNames (see below).
 |      
 |      >>> note.stemDirectionNames
 |      ['double', 'down', 'noStem', 'none', 'unspecified', 'up']
 |      >>> n = note.Note()
 |      >>> n.stemDirection = 'noStem'
 |      >>> n.stemDirection
 |      'noStem'
 |      >>> n.stemDirection = 'junk'
 |      Traceback (most recent call last):
 |      NotRestException: not a valid stem direction name: junk
 |  
 |  volume
 |      Get and set the :class:`~music21.volume.Volume` object of this object. 
 |      Volume objects are created on demand.
 |      
 |      
 |      >>> n1 = note.Note()
 |      >>> n1.volume.velocity = 120
 |      >>> n2 = note.Note()
 |      >>> n2.volume = 80 # can directly set a velocity value
 |      >>> s = stream.Stream()
 |      >>> s.append([n1, n2])
 |      >>> [n.volume.velocity for n in s.notes]
 |      [120, 80]
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from GeneralNote:
 |  
 |  addLyric(self, text, lyricNumber=None, applyRaw=False, lyricIdentifier=None)
 |      Adds a lyric, or an additional lyric, to a Note, Chord, or Rest's lyric list. 
 |      If `lyricNumber` is not None, a specific line of lyric text can be set. The lyricIdentifier
 |      can also be set.
 |      
 |      >>> n1 = note.Note()
 |      >>> n1.addLyric("hello")
 |      >>> n1.lyrics[0].text
 |      'hello'
 |      >>> n1.lyrics[0].number
 |      1
 |      
 |      
 |      An added option gives the lyric number, not the list position
 |      
 |      
 |      >>> n1.addLyric("bye", 3)
 |      >>> n1.lyrics[1].text
 |      'bye'
 |      >>> n1.lyrics[1].number
 |      3
 |      >>> for lyr in n1.lyrics: print(lyr.text)
 |      hello
 |      bye
 |      
 |      
 |      Replace an existing lyric by specifying the same number:
 |      
 |      
 |      >>> n1.addLyric("ciao", 3)
 |      >>> n1.lyrics[1].text
 |      'ciao'
 |      >>> n1.lyrics[1].number
 |      3
 |      
 |      
 |      Giving a lyric with a hyphen at either end will set whether it
 |      is part of a multisyllable word:
 |      
 |      
 |      >>> n1.addLyric("good-")
 |      >>> n1.lyrics[2].text
 |      'good'
 |      >>> n1.lyrics[2].syllabic
 |      'begin'
 |      
 |      
 |      This feature can be overridden by specifying "applyRaw = True":
 |      
 |      
 |      >>> n1.addLyric("-5", applyRaw = True)
 |      >>> n1.lyrics[3].text
 |      '-5'
 |      >>> n1.lyrics[3].syllabic
 |      'single'
 |  
 |  augmentOrDiminish(self, scalar, inPlace=True)
 |      Given a scalar greater than zero, return a Note with a scaled Duration. 
 |      If `inPlace` is True, this is done in-place and the method returns None. 
 |      If `inPlace` is False, this returns a modified deepcopy.
 |      
 |      
 |      >>> n = note.Note('g#')
 |      >>> n.quarterLength = 3
 |      >>> n.augmentOrDiminish(2)
 |      >>> n.quarterLength
 |      6.0
 |      
 |      >>> c = chord.Chord(['g#','A#','d'])
 |      >>> n.quarterLength = 2
 |      >>> n.augmentOrDiminish(.25)
 |      >>> n.quarterLength
 |      0.5
 |      
 |      >>> n = note.Note('g#')
 |      >>> n.augmentOrDiminish(-1)
 |      Traceback (most recent call last):
 |      NoteException: scalar must be greater than zero
 |  
 |  getGrace(self, appogiatura=False, inPlace=False)
 |      Return a grace version of this GeneralNote
 |      
 |      >>> n = note.Note('G4', quarterLength=2)
 |      >>> n.duration.quarterLength
 |      2.0
 |      >>> n.duration.isGrace
 |      False
 |      >>> n.duration
 |      <music21.duration.Duration 2.0>
 |      >>> n.duration.type
 |      'half'
 |      >>> n.duration.components
 |      (DurationTuple(type='half', dots=0, quarterLength=2.0),)
 |      
 |      >>> ng = n.getGrace()
 |      >>> ng.duration.quarterLength
 |      0.0
 |      >>> ng.duration.isGrace
 |      True
 |      >>> ng.duration
 |      <music21.duration.GraceDuration unlinked type:zero quarterLength:0.0>
 |      >>> ng.duration.type
 |      'zero'
 |      >>> ng.duration.components
 |      (DurationTuple(type='half', dots=0, quarterLength=0.0),)
 |      
 |      Appogiaturas are still a work in progress...
 |      
 |      >>> ng2 = n.getGrace(appogiatura=True)
 |      >>> ng2.duration
 |      <music21.duration.AppogiaturaDuration unlinked type:zero quarterLength:0.0>
 |      >>> ng2.duration.slash
 |      False
 |      
 |      Set inPlace to True to change the duration element on the Note.  This can have
 |      negative consequences if the Note is in a stream.
 |      
 |      >>> r = note.Rest(quarterLength = .5)
 |      >>> r.getGrace(inPlace=True)
 |      >>> r.duration
 |      <music21.duration.GraceDuration unlinked type:zero quarterLength:0.0>
 |  
 |  hasLyrics(self)
 |      Return True if this object has any lyrics defined
 |      
 |      TODO: Delete: just do: ``if self.lyrics``...
 |  
 |  insertLyric(self, text, index=0, applyRaw=False, identifier=None)
 |      Inserts a lyric into the Note, Chord, or Rest's lyric list in front of
 |      the index specified (0 by default), using index + 1 as the inserted lyric's
 |      line number. shifts line numbers of all following lyrics in list
 |      
 |      
 |      >>> n1 = note.Note()
 |      >>> n1.addLyric("second")
 |      >>> n1.lyrics
 |      [<music21.note.Lyric number=1 syllabic=single text="second">]
 |      >>> n1.insertLyric("first", 0)
 |      >>> n1.lyrics
 |      [<music21.note.Lyric number=1 syllabic=single text="first">, 
 |       <music21.note.Lyric number=2 syllabic=single text="second">]
 |      
 |      OMIT_FROM_DOCS
 |      
 |      test inserting in the middle.
 |      
 |      >>> n1.insertLyric("newSecond", 1)
 |      >>> n1.lyrics
 |      [<music21.note.Lyric number=1 syllabic=single text="first">, 
 |       <music21.note.Lyric number=2 syllabic=single text="newSecond">, 
 |       <music21.note.Lyric number=3 syllabic=single text="second">]
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from GeneralNote:
 |  
 |  color
 |      Return the Note color.
 |      
 |      >>> a = note.GeneralNote()
 |      >>> a.duration.type = 'whole'
 |      >>> a.color is None
 |      True
 |      >>> a.color = '#235409'
 |      >>> a.color
 |      '#235409'
 |      >>> a.editorial.color
 |      '#235409'
 |  
 |  editorial
 |      a :class:`~music21.editorial.NoteEditorial` object that stores editorial information
 |      (comments, harmonic information, ficta) and 
 |      certain display information (color, hidden-state).
 |      
 |      Created automatically as needed:
 |      
 |      >>> n = note.Note("C4")
 |      >>> n.editorial
 |      <music21.editorial.NoteEditorial object at 0x...>
 |      >>> n.editorial.ficta = pitch.Accidental('sharp')
 |      >>> n.editorial.ficta
 |      <accidental sharp>
 |      
 |      OMIT_FROM_DOCS
 |      >>> n2 = note.Note("D4")
 |      >>> n2._editorial is None
 |      True
 |      >>> n2.editorial
 |      <music21.editorial.NoteEditorial object at 0x...>
 |      >>> n2._editorial is None
 |      False
 |  
 |  lyric
 |      The lyric property can
 |      be used to get and set a lyric for this
 |      Note, Chord, or Rest. This is a simplified version of the more general
 |      :meth:`~music21.note.GeneralNote.addLyric` method.
 |      
 |      >>> a = note.Note('A4')
 |      >>> a.lyrics
 |      []
 |      >>> a.lyric = 'hel-'
 |      >>> a.lyric
 |      'hel'
 |      >>> a.lyrics
 |      [<music21.note.Lyric number=1 syllabic=begin text="hel">]
 |      
 |      Eliminate Lyrics by setting a.lyric to None
 |      
 |      >>> a.lyric = None
 |      >>> a.lyric
 |      >>> a.lyrics
 |      []
 |      
 |      TODO: should check data here
 |      should split \n separated lyrics into different lyrics
 |      
 |      presently only creates one lyric, and destroys any existing
 |      lyrics
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from GeneralNote:
 |  
 |  isChord = False
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from music21.base.Music21Object:
 |  
 |  containerHierarchy(self, followDerivation=True, includeNonStreamDerivations=False)
 |      Return a list of Stream subclasses that this object
 |      is contained within or (if followDerivation is set) is derived from. 
 |      
 |      This gives access to the hierarchy that contained or
 |      created this object.
 |      
 |      >>> s = corpus.parse('bach/bwv66.6')
 |      >>> noteE = s[1][2][3]
 |      >>> noteE
 |      <music21.note.Note E>
 |      >>> [e for e in noteE.containerHierarchy()]
 |      [<music21.stream.Measure 1 offset=1.0>, 
 |       <music21.stream.Part Soprano>, 
 |       <music21.stream.Score 0x1049a5668>]
 |       
 |      
 |      Note that derived objects also can follow the container hierarchy:
 |      
 |      >>> import copy
 |      >>> n2 = copy.deepcopy(noteE)
 |      >>> [e for e in n2.containerHierarchy()]
 |      [<music21.stream.Measure 1 offset=1.0>, 
 |       <music21.stream.Part Soprano>, 
 |       <music21.stream.Score 0x1049a5668>]
 |       
 |      Unless followDerivation is False:
 |      
 |      >>> [e for e in n2.containerHierarchy(followDerivation=False)]
 |      []
 |      
 |      if includeNonStreamDerivations is True then n2's containerHierarchy will include
 |      n even though it's not a container.  It gives a good idea of how the hierarchy is being
 |      constructed.
 |      
 |      >>> [e for e in n2.containerHierarchy(includeNonStreamDerivations=True)]
 |      [<music21.note.Note E>,
 |       <music21.stream.Measure 1 offset=1.0>, 
 |       <music21.stream.Part Soprano>, 
 |       <music21.stream.Score 0x1049a5668>]
 |      
 |      
 |      
 |      The method follows activeSites, so set the activeSite as necessary.
 |      
 |      >>> p = stream.Part(id="newPart")
 |      >>> m = stream.Measure(number=20)
 |      >>> p.insert(0, m)
 |      >>> m.insert(0, noteE)
 |      >>> noteE.activeSite
 |      <music21.stream.Measure 20 offset=0.0>
 |      >>> noteE.containerHierarchy()
 |      [<music21.stream.Measure 20 offset=0.0>, 
 |       <music21.stream.Part newPart>]
 |  
 |  contextSites(self, callerFirst=None, memo=None, offsetAppend=0.0, sortByCreationTime=False, priorityTarget=None, followDerivation=True)
 |      A generator that returns a list of tuples of sites to search for a context...
 |      
 |      Each tuple contains a Stream object, the offset of this element in that Stream, and
 |      the method of searching that should be applied to search for a context.  
 |      These methods are:
 |      
 |          * 'flatten' -- flatten the stream and then look from this offset backwards.
 |          
 |          * 'elementsOnly' -- only search the stream's personal 
 |             elements from this offset backwards
 |          
 |          * 'elementsFirst' -- search this stream backwards, 
 |             and then flatten and search backwards
 |          
 |      >>> c = corpus.parse('bwv66.6')
 |      >>> c.id = 'bach'
 |      >>> n = c[2][4][2]
 |      >>> n
 |      <music21.note.Note G#>
 |      
 |      >>> for y in n.contextSites():
 |      ...      print(y)
 |      (<music21.stream.Measure 3 offset=9.0>, 0.5, 'elementsFirst')
 |      (<music21.stream.Part Alto>, 9.5, 'flatten')
 |      (<music21.stream.Score bach>, 9.5, 'elementsOnly')
 |      >>> m = c[2][4]
 |      >>> m
 |      <music21.stream.Measure 3 offset=9.0>
 |      >>> for y in m.contextSites():
 |      ...      print(y)
 |      (<music21.stream.Measure 3 offset=9.0>, 0.0, 'elementsFirst')
 |      (<music21.stream.Part Alto>, 9.0, 'flatten')
 |      (<music21.stream.Score bach>, 9.0, 'elementsOnly')
 |      
 |      >>> import copy
 |      >>> m2 = copy.deepcopy(m)
 |      >>> m2.number = 3333
 |      >>> for y in m2.contextSites():
 |      ...      print(y)
 |      (<music21.stream.Measure 3333 offset=0.0>, 0.0, 'elementsFirst')
 |      (<music21.stream.Part Alto>, 9.0, 'flatten')
 |      (<music21.stream.Score bach>, 9.0, 'elementsOnly')
 |      
 |      >>> tempPartStream = c.parts
 |      >>> tempPartStream.id = 'partStream' # for identificationBelow
 |      >>> m3 = tempPartStream[1].measure(3)
 |      >>> for y in m3.contextSites():
 |      ...      print(y)
 |      (<music21.stream.Measure 3 offset=9.0>, 0.0, 'elementsFirst')
 |      (<music21.stream.Part Alto>, 9.0, 'flatten')
 |      (<music21.stream.Score partStream>, 9.0, 'elementsOnly')
 |      (<music21.stream.Score bach>, 9.0, 'elementsOnly')
 |      
 |      
 |      
 |      Sorting order:
 |      
 |      >>> p1 = stream.Part()
 |      >>> p1.id = 'p1'
 |      >>> m1 = stream.Measure()
 |      >>> m1.number = 1
 |      >>> n = note.Note()
 |      >>> m1.append(n)
 |      >>> p1.append(m1)
 |      >>> for y in n.contextSites():
 |      ...     print(y[0])
 |      <music21.stream.Measure 1 offset=0.0>
 |      <music21.stream.Part p1>
 |      
 |      >>> p2 = stream.Part()
 |      >>> p2.id = 'p2'
 |      >>> m2 = stream.Measure()
 |      >>> m2.number = 2
 |      >>> m2.append(n)
 |      >>> p2.append(m2)
 |      
 |      
 |      The keys could have appeared in any order, but by default
 |      we set set priorityTarget to activeSite.  So this is the same as omitting.
 |      
 |      >>> for y in n.contextSites(priorityTarget=n.activeSite):
 |      ...     print(y[0])
 |      <music21.stream.Measure 2 offset=0.0>
 |      <music21.stream.Part p2>
 |      <music21.stream.Measure 1 offset=0.0>
 |      <music21.stream.Part p1>
 |      
 |      
 |      Or sort by creationTime...
 |      
 |      
 |      >>> for y in n.contextSites(sortByCreationTime = True):
 |      ...     print(y[0])
 |      <music21.stream.Measure 2 offset=0.0>
 |      <music21.stream.Part p2>
 |      <music21.stream.Measure 1 offset=0.0>
 |      <music21.stream.Part p1>
 |      
 |      oldest first...
 |      
 |      >>> for y in n.contextSites(sortByCreationTime='reverse'):
 |      ...     print(y[0])
 |      <music21.stream.Measure 1 offset=0.0>
 |      <music21.stream.Part p1>
 |      <music21.stream.Measure 2 offset=0.0>
 |      <music21.stream.Part p2>
 |  
 |  getAllContextsByClass(self, className)
 |      Returns a generator that yields elements found by `.getContextByClass` and
 |      then finds the previous contexts for that element.
 |      
 |      >>> s = stream.Stream()
 |      >>> s.append(meter.TimeSignature('2/4'))
 |      >>> s.append(note.Note('C'))
 |      >>> s.append(meter.TimeSignature('3/4'))
 |      >>> n = note.Note('D')
 |      >>> s.append(n)
 |      >>> for ts in n.getAllContextsByClass('TimeSignature'):
 |      ...     print(ts, ts.offset)
 |      <music21.meter.TimeSignature 3/4> 1.0
 |      <music21.meter.TimeSignature 2/4> 0.0
 |      
 |      
 |      TODO: make it so that it does not skip over multiple matching classes
 |      at the same offset.
 |  
 |  getContextAttr(self, attr)
 |      Given the name of an attribute, search the Sites object for
 |      contexts having this attribute and return
 |      the best match.
 |      
 |      DEPRECATED
 |      
 |      >>> import music21
 |      >>> class Mock(music21.Music21Object):
 |      ...     attr1 = 234
 |      >>> aObj = stream.Stream()
 |      >>> aObj.attr1 = 'test'
 |      >>> a = music21.Music21Object()
 |      >>> aObj.insert(0, a)
 |      >>> a.sites.getAttrByName('attr1')
 |      'test'
 |      
 |      >>> bObj = stream.Stream()
 |      >>> bObj.attr1 = 'came second'
 |      >>> bObj.insert(0, a)
 |      >>> a.sites.getAttrByName('attr1')
 |      'test'
 |  
 |  getContextByClass(self, className, getElementMethod='getElementAtOrBefore', sortByCreationTime=False)
 |      A very powerful method in music21 of fundamental importance: Returns
 |      the element matching the className that is closest to this element in
 |      its current hierarchy.  For instance, take this stream of changing time
 |      signatures:
 |      
 |      >>> s1 = converter.parse('tinynotation: 3/4 C4 D E 2/4 F G A B 1/4 c')
 |      >>> s2 = s1.makeMeasures()
 |      >>> s2
 |      <music21.stream.Part 0x104ce64e0>
 |      
 |      >>> s2.show('t')
 |      {0.0} <music21.stream.Measure 1 offset=0.0>
 |          {0.0} <music21.clef.BassClef>
 |          {0.0} <music21.meter.TimeSignature 3/4>
 |          {0.0} <music21.note.Note C>
 |          {1.0} <music21.note.Note D>
 |          {2.0} <music21.note.Note E>
 |      {3.0} <music21.stream.Measure 2 offset=3.0>
 |          {0.0} <music21.meter.TimeSignature 2/4>
 |          {0.0} <music21.note.Note F>
 |          {1.0} <music21.note.Note G>
 |      {5.0} <music21.stream.Measure 3 offset=5.0>
 |          {0.0} <music21.note.Note A>
 |          {1.0} <music21.note.Note B>
 |      {7.0} <music21.stream.Measure 4 offset=7.0>
 |          {0.0} <music21.meter.TimeSignature 1/4>
 |          {0.0} <music21.note.Note C>
 |          {1.0} <music21.bar.Barline style=final>
 |      
 |      Let's get the last two notes of the piece, the B and high c:
 |      
 |      >>> c = s2.measure(4).notes[0]
 |      >>> c
 |      <music21.note.Note C>
 |      
 |      >>> b = s2.measure(3).notes[-1]
 |      >>> b
 |      <music21.note.Note B>
 |      
 |      Now when we run `getContextByClass('TimeSignature')` on c, we get a
 |      time signature of 1/4.
 |      
 |      >>> c.getContextByClass('TimeSignature')
 |      <music21.meter.TimeSignature 1/4>
 |      
 |      Doing what we just did wouldn't be hard to do with other methods,
 |      though `getContextByClass` makes it easier.  But the time signature
 |      context for b would be much harder to get without this method, since in
 |      order to do it, it searches backwards within the measure, finds that
 |      there's nothing there.  It goes to the previous measure and searches
 |      that one backwards until it gets the proper TimeSignature of 2/4:
 |      
 |      >>> b.getContextByClass('TimeSignature')
 |      <music21.meter.TimeSignature 2/4>
 |      
 |      The method is smart enough to stop when it gets to the beginning of the
 |      part.  This is all you need to know for most uses.  The rest of the
 |      docs are for advanced uses:
 |      
 |      The methods searches both Sites as well as associated objects to find a
 |      matching class. Returns None if not match is found.
 |      
 |      A reference to the caller is required to find the offset of the object
 |      of the caller.
 |      
 |      The caller may be a Sites reference from a lower-level object.  If so,
 |      we can access the location of that lower-level object. However, if we
 |      need a flat representation, the caller needs to be the source Stream,
 |      not its Sites reference.
 |      
 |      The `getElementMethod` is a string that selects which Stream method is
 |      used to get elements for searching. These strings are accepted:
 |      
 |      *    'getElementAtOrBefore'
 |      *    'getElementBeforeOffset'
 |      *    'getElementAtOrAfter'
 |      *    'getElementAfterOffset'
 |      
 |      Use at or before to avoid getting the same element over and over again
 |      in a recursive context search.
 |      
 |      The latter two do forward contexts -- looking ahead.
 |      
 |      
 |      
 |      OMIT_FROM_DOCS
 |      
 |      TODO: these should not be the same objects!
 |      
 |      >>> a = b.getContextByClass('Note', 'getElementBeforeOffset')
 |      >>> a
 |      <music21.note.Note A>
 |      >>> a2 = b.getContextByClass('Note', 'getElementAfterOffset')
 |      >>> a2
 |      <music21.note.Note A>
 |      >>> a is a2
 |      True
 |      
 |      
 |      TODO: these should actually be sort tuples, so that we can avoid the case of 
 |      skipping elements that are at the same offset...
 |      
 |      
 |      
 |      >>> s = corpus.parse('bwv66.6')
 |      >>> noteA = s[1][2][0]
 |      >>> noteA.getContextByClass('TimeSignature')
 |      <music21.meter.TimeSignature 4/4>
 |  
 |  getOffsetBySite(self, site, stringReturns=False)
 |      If this class has been registered in a container such as a Stream,
 |      that container can be provided here, and the offset in that object
 |      can be returned.
 |      
 |      >>> n = note.Note('A-4')  # a Music21Objecct
 |      >>> n.offset = 30
 |      >>> n.getOffsetBySite(None)
 |      30.0
 |      
 |      >>> s1 = stream.Stream()
 |      >>> s1.id = 'containingStream'
 |      >>> s1.insert(20.0/3, n)
 |      >>> n.getOffsetBySite(s1)
 |      Fraction(20, 3)
 |      >>> float(n.getOffsetBySite(s1))
 |      6.6666...
 |      
 |      n.getOffsetBySite(None) should still return 30.0
 |      
 |      >>> n.getOffsetBySite(None)
 |      30.0
 |      
 |      If the Stream does not contain the element then a SitesException is raised:
 |      
 |      >>> s2 = stream.Stream()
 |      >>> s2.id = 'notContainingStream'
 |      >>> n.getOffsetBySite(s2)
 |      Traceback (most recent call last):
 |      SitesException: an entry for this object <music21.note.Note A-> is not 
 |            stored in stream <music21.stream.Stream notContainingStream>
 |      
 |      
 |      If the object is stored at the end of the Stream, then the highest time 
 |      is usually returned:
 |      
 |      >>> s3 = stream.Stream()
 |      >>> n3 = note.Note(type='whole')
 |      >>> s3.append(n3)
 |      >>> rb = bar.Barline()
 |      >>> s3.storeAtEnd(rb)  # s3.rightBarline = rb would do the same...
 |      >>> rb.getOffsetBySite(s3)
 |      4.0
 |      
 |      However, setting stringReturns to True will return 'highestTime'
 |      
 |      >>> s3._endElements
 |      [<music21.bar.Barline style=regular>]
 |      
 |      >>> rb.getOffsetBySite(s3, stringReturns=True)
 |      'highestTime'
 |      
 |      Normal numbers are still returned as a float or Fraction:
 |      
 |      >>> n3.getOffsetBySite(s3, stringReturns=True)
 |      0.0
 |  
 |  getSpannerSites(self, spannerClassList=None)
 |      Return a list of all :class:`~music21.spanner.Spanner` objects
 |      (or Spanner subclasses) that contain
 |      this element. This method provides a way for
 |      objects to be aware of what Spanners they
 |      reside in. Note that Spanners are not Streams
 |      but specialized Music21Objects that use a
 |      Stream subclass, SpannerStorage, internally to keep track
 |      of the elements that are spanned.
 |      
 |      >>> n1 = note.Note('C4')
 |      >>> n2 = note.Note('D4')
 |      >>> sp1 = spanner.Slur(n1, n2)
 |      >>> n1.getSpannerSites() == [sp1]
 |      True
 |      
 |      Note that not all Spanners are in the spanner module. They
 |      tend to reside in modules closer to their musical function:
 |      
 |      >>> sp2 = dynamics.Crescendo(n2, n1)
 |      
 |      The order that Spanners are returned is usually the order they
 |      were created, but on fast computers there can be ties, so use
 |      a set comparison if you expect multiple:
 |      
 |      >>> set(n2.getSpannerSites()) == set([sp1, sp2])
 |      True
 |      
 |      Optionally a class name or list of class names can be
 |      specified and only Spanners of that class will be returned
 |      
 |      >>> sp3 = dynamics.Diminuendo(n1, n2)
 |      >>> n2.getSpannerSites('Diminuendo') == [sp3]
 |      True
 |      
 |      A larger class name can be used to get all subclasses:
 |      
 |      >>> set(n2.getSpannerSites('DynamicWedge')) == set([sp2, sp3])
 |      True
 |      >>> set(n2.getSpannerSites(['Slur','Diminuendo'])) == set([sp1, sp3])
 |      True
 |      
 |      
 |      >>> set(n2.getSpannerSites(['Slur','Diminuendo'])) == set([sp3, sp1])
 |      True
 |      
 |      
 |      Example: see which pairs of notes are in the same slur.
 |      
 |      >>> n3 = note.Note('E4')
 |      >>> sp4 = spanner.Slur(n1, n3)
 |      
 |      >>> for n in [n1, n2, n3]:
 |      ...    for nOther in [n1, n2, n3]:
 |      ...        if n is nOther:
 |      ...            continue
 |      ...        nSlurs = n.getSpannerSites('Slur')
 |      ...        nOtherSlurs = nOther.getSpannerSites('Slur')
 |      ...        for thisSlur in nSlurs:
 |      ...            if thisSlur in nOtherSlurs:
 |      ...               print("%s shares a slur with %s" % (n.name, nOther.name))
 |      C shares a slur with D
 |      C shares a slur with E
 |      D shares a slur with C
 |      E shares a slur with C
 |      
 |      :rtype: list(spanner.Spanner)
 |  
 |  informSites(self, changedInformation=None)
 |      trigger called whenever sites need to be informed of a change
 |      in the parameters of this object.
 |      
 |      `changedInformation` is not used now, but it can be a dictionary
 |      of what has changed.
 |      
 |      subclass this to do very interesting things.
 |  
 |  isClassOrSubclass(self, classFilterList)
 |      Given a class filter list (a list or tuple must be submitted),
 |      which may have strings or class objects, determine
 |      if this class is of the provided classes or a subclasses.
 |      
 |      NOTE: this is a performance critical operation
 |      for performance, only accept lists or tuples
 |      
 |      >>> n = note.Note()
 |      >>> n.isClassOrSubclass(('Note',))
 |      True
 |      >>> n.isClassOrSubclass(('GeneralNote',))
 |      True
 |      >>> n.isClassOrSubclass((note.Note,))
 |      True
 |      >>> n.isClassOrSubclass((note.Rest,))
 |      False
 |      >>> n.isClassOrSubclass((note.Note,note.Rest))
 |      True
 |      >>> n.isClassOrSubclass(('Rest','Note'))
 |      True
 |  
 |  mergeAttributes(self, other)
 |      Merge all elementary, static attributes. Namely,
 |      `id` and `groups` attributes from another music21 object.
 |      Can be useful for copy-like operations.
 |      
 |      >>> m1 = base.Music21Object()
 |      >>> m2 = base.Music21Object()
 |      >>> m1.id = 'music21Object1'
 |      >>> m1.groups.append("group1")
 |      >>> m2.mergeAttributes(m1)
 |      >>> m2.id
 |      'music21Object1'
 |      >>> "group1" in m2.groups
 |      True
 |  
 |  next(self, classFilterList=None, flattenLocalSites=False, beginNearest=True)
 |      Get the next element found in the activeSite (or other Sites)
 |      of this Music21Object.
 |      
 |      The `classFilterList` can be used to specify one or more classes to match.
 |      
 |      The `flattenLocalSites` parameter determines if the sites of this element 
 |      (e.g., a Measure's Part) are flattened on first search. 
 |      When True, elements contained in adjacent containers may be selected first.
 |      
 |      
 |      >>> s = corpus.parse('bwv66.6')
 |      >>> m3 = s.parts[0].measure(3) 
 |      >>> m3.next() is s.parts[0].measure(4)
 |      True
 |      
 |      Note that calling next() repeatedly gives...the same object.  You'll want to
 |      call next on that object...
 |      
 |      >>> m3.next() is s.parts[0].measure(4)
 |      True
 |      >>> m3.next() is s.parts[0].measure(4)
 |      True
 |      
 |      So do this instead:
 |      
 |      >>> o = m3
 |      >>> for i in range(4):
 |      ...     print(o)
 |      ...     o = o.next()
 |      <music21.stream.Measure 3 offset=9.0>
 |      <music21.stream.Measure 4 offset=13.0>
 |      <music21.stream.Measure 5 offset=17.0>
 |      <music21.stream.Measure 6 offset=21.0>        
 |      
 |      
 |      
 |      
 |      
 |      We can find the next element given a certain class with the `classFilterList`:
 |      
 |      >>> n = m3.next('Note')
 |      >>> n
 |      <music21.note.Note A>
 |      >>> n.measureNumber
 |      3
 |      >>> n is m3.notes[0]
 |      True
 |      
 |      
 |      ..note::
 |      
 |          There may be some unusual cases of using obj.next() in Python2 if obj
 |          uses itself as an Iterator, because Py2 assumes that each iterable has
 |          a .next() function.  In Python3 there will be no problem since the
 |          `next()` function is renamed to `__next__()`.
 |      
 |      
 |      
 |      OMIT_FROM_DOCS
 |      
 |      Add this back when it's explained what the difference from the previous is.
 |      
 |      >>> m3.next('Note', flattenLocalSites=True) == s.parts[0].measure(3).notes[0]
 |      True
 |      >>> n2 = m3.next('Note', flattenLocalSites=True)
 |      >>> n2
 |      <music21.note.Note A>
 |      >>> n2 is n
 |      True
 |      
 |      
 |      
 |      THIS IS OMITTED BECAUSE IT SOMETIMES GIVES SEMIFLATs etc.
 |      
 |      Notice though that when we get to the end of the set of measures, something
 |      interesting happens (maybe it shouldn't? don't count on this...): we descend
 |      into the last measure and give its elements instead.
 |      
 |      We'll leave o where it is (m7 now) to demonstrate what happens, and also
 |      print the its Part for more information...
 |      
 |      #>>> while o is not None:
 |      #...     print(o, o.getContextByClass('Part'))
 |      #...     o = o.next()
 |      <music21.stream.Measure 7 offset=25.0> <music21.stream.Part Soprano>
 |      <music21.stream.Measure 8 offset=29.0> <music21.stream.Part Soprano>
 |      <music21.stream.Measure 9 offset=33.0> <music21.stream.Part Soprano>
 |      <music21.note.Note F#> <music21.stream.Part Soprano>
 |      <music21.note.Note F#> <music21.stream.Part Soprano>
 |      <music21.note.Note E#> <music21.stream.Part Soprano>
 |      <music21.note.Note F#> <music21.stream.Part Soprano>
 |      <music21.bar.Barline style=final> <music21.stream.Part Soprano>
 |      <music21.bar.Barline style=final> <music21.stream.Part Alto>
 |      <music21.bar.Barline style=final> <music21.stream.Part Tenor>
 |      <music21.bar.Barline style=final> <music21.stream.Part Bass>       
 |      
 |      So we get through all the measures in Soprano, then with nothing else to do,
 |      it goes into the measure and gets all the notes in the measure and finally
 |      the final barline.  Then, having nothing else to do, it backtracks out of the
 |      Part to the Score object and finds the object that is at the same offset in
 |      the next object, which is the final barline of the Alto part, and so on.
 |      
 |      Not particularly useful here for `next()`, but it'll be very useful for `prev()`.
 |  
 |  previous(self, classFilterList=None, flattenLocalSites=False, beginNearest=True)
 |      Get the previous element found in the activeSite or other .sites of this
 |      Music21Object.
 |      
 |      The `classFilterList` can be used to specify one or more classes to match.
 |      
 |      The `flattenLocalSites` parameter determines if the sites of this element 
 |      (e.g., a Measure's Part) are flattened on first search. When True, elements 
 |      contained in adjacent containers may be selected first.
 |      
 |      >>> s = corpus.parse('bwv66.6')
 |      >>> m2 = s.parts[0].measure(2)
 |      >>> m3 = s.parts[0].measure(3)
 |      >>> m3.previous() is m2
 |      True
 |      >>> m3.previous('Note', flattenLocalSites=True) is m2.notes[-1]
 |      True
 |      
 |      
 |      TODO:  Try:  l = corpus.parse('luca/gloria'); 
 |      for el in l.recurse: print(el, el.previous('Note'))
 |      SLOWEST THING EVER! why????
 |  
 |  purgeLocations(self, rescanIsDead=False)
 |      Remove references to all locations in objects that no longer exist.
 |  
 |  purgeOrphans(self, excludeStorageStreams=True)
 |      A Music21Object may, due to deep copying or other reasons,
 |      have contain a site (with an offset); yet, that site may
 |      no longer contain the Music21Object. These lingering sites
 |      are called orphans. This methods gets rid of them.
 |      
 |      The `excludeStorageStreams` are SpannerStorage and VariantStorage.
 |  
 |  removeLocationBySite(self, site)
 |      DEPRECATED Jan 2016: use self.sites.remove() instead and set activeSite
 |      manually.
 |      
 |      Remove a location in the :class:`~music21.base.Sites` object.
 |      
 |      This is only for advanced location method and
 |      is not a complete or sufficient way to remove an object from a Stream.
 |  
 |  setContextAttr(self, attrName, value)
 |      Given the name of an attribute, search Contexts and return
 |      the best match.
 |      
 |      >>> import music21
 |      >>> class Mock(music21.Music21Object):
 |      ...     attr1 = 234
 |      >>> aObj = Mock()
 |      >>> aObj.attr1 = 'test'
 |      >>> a = music21.Music21Object()
 |      >>> a.sites.add(aObj)
 |      >>> a.sites.getAttrByName('attr1')
 |      'test'
 |      >>> a.sites.setAttrByName('attr1', 3000)
 |      >>> a.sites.getAttrByName('attr1')
 |      3000
 |  
 |  setOffsetBySite(self, site, value)
 |      Change the offset for a site.  These are equivalent:
 |      
 |          n1.setOffsetBySite(stream1, 20)
 |          
 |      and
 |      
 |          stream1.setElementOffset(n1, 20)
 |      
 |      >>> import music21
 |      >>> aSite = stream.Stream()
 |      >>> a = music21.Music21Object()
 |      >>> a.sites.add(aSite)
 |      >>> aSite.setElementOffset(a, 20)
 |      >>> a.setOffsetBySite(aSite, 30)
 |      >>> a.getOffsetBySite(aSite)
 |      30.0
 |      
 |      And if it isn't there? Nothing changes.
 |      
 |      >>> b = note.Note()
 |      >>> b.setOffsetBySite(aSite, 40)
 |      >>> b.offset
 |      0.0
 |  
 |  show(self, fmt=None, app=None, **keywords)
 |      Displays an object in a format provided by the
 |      fmt argument or, if not provided, the format set in the user's Environment
 |      
 |      Valid formats include (but are not limited to)::
 |          musicxml
 |          text
 |          midi
 |          lily (or lilypond)
 |          lily.png
 |          lily.pdf
 |          lily.svg
 |          braille
 |          vexflow
 |          musicxml.png
 |      
 |      N.B. score.write('lily') returns a bare lilypond file,
 |      score.show('lily') runs it through lilypond and displays it as a png.
 |  
 |  sortTuple(self, useSite=False)
 |      Returns a collections.namedtuple called SortTuple(atEnd, offset, priority, classSortOrder,
 |      isNotGrace, insertIndex)
 |      which contains the six elements necessary to determine the sort order of any set of
 |      objects in a Stream.
 |      
 |      1) atEnd = {0, 1}; Elements specified to always stay at 
 |      the end of a stream (``stream.storeAtEnd``)
 |      sort after normal elements.
 |      
 |      2) offset = float; Offset (with respect to the active site) is the next and most
 |      important parameter in determining the order of elements in a stream (the note on beat 1
 |      has offset 0.0, while the note on beat 2 might have offset 1.0).
 |      
 |      3) priority = int; Priority is a
 |      user-specified property (default 0) that can set the order of 
 |      elements which have the same
 |      offset (for instance, two Parts both at offset 0.0).
 |      
 |      4) classSortOrder = int or float; ClassSortOrder
 |      is the third level of comparison that gives an ordering to elements with different classes,
 |      ensuring, for instance that Clefs (classSortOrder = 0) sort before Notes 
 |      (classSortOrder = 20).
 |      
 |      5) isNotGrace = {0, 1}; 0 = grace, 1 = normal. Grace notes sort before normal notes
 |      
 |      6) The last tie breaker is the creation time (insertIndex) of the site object
 |      represented by the activeSite.
 |      
 |      >>> n = note.Note()
 |      >>> n.offset = 4.0
 |      >>> n.priority = -3
 |      >>> n.sortTuple()
 |      SortTuple(atEnd=0, offset=4.0, priority=-3, classSortOrder=20, 
 |                  isNotGrace=1, insertIndex=0)
 |      >>> st = n.sortTuple()
 |      
 |      Check that all these values are the same as above...
 |      
 |      >>> st.offset == n.offset
 |      True
 |      >>> st.priority == n.priority
 |      True
 |      
 |      An object's classSortOrder comes from the Class object itself:
 |      
 |      >>> st.classSortOrder == note.Note.classSortOrder
 |      True
 |      
 |      Inserting the note into the Stream will set the insertIndex.  Most implementations of
 |      music21 will use a global counter rather than an actual timer.  Note that this is a
 |      last resort, but useful for things such as mutiple Parts inserted in order.  It changes
 |      with each run, so we can't display it here...
 |      
 |      >>> s = stream.Stream()
 |      >>> s.insert(n)
 |      >>> n.sortTuple()
 |      SortTuple(atEnd=0, offset=4.0, priority=-3, classSortOrder=20,
 |                   isNotGrace=1, insertIndex=...)
 |      >>> nInsertIndex = n.sortTuple().insertIndex
 |      
 |      If we create another nearly identical note, the insertIndex will be different:
 |      
 |      >>> n2 = note.Note()
 |      >>> n2.offset = 4.0
 |      >>> n2.priority = -3
 |      >>> s.insert(n2)
 |      >>> n2InsertIndex = n2.sortTuple().insertIndex
 |      >>> n2InsertIndex > nInsertIndex
 |      True
 |      
 |      >>> rb = bar.Barline()
 |      >>> s.storeAtEnd(rb)
 |      >>> rb.sortTuple()
 |      SortTuple(atEnd=1, offset=0.0, priority=0, classSortOrder=-5, 
 |                  isNotGrace=1, insertIndex=...)
 |  
 |  splitAtDurations(self)
 |      Takes a Music21Object (e.g., a note.Note) and returns a list of similar
 |      objects with only a single duration.DurationTuple in each.
 |      Ties are added if the object supports ties.
 |      
 |      Articulations only appear on the first note.  Same with lyrics.
 |      
 |      Fermatas should be on last note, but not done yet.
 |      
 |      >>> a = note.Note()
 |      >>> a.duration.clear() # remove defaults
 |      >>> a.duration.addDurationTuple(duration.durationTupleFromTypeDots('half', 0))
 |      >>> a.duration.quarterLength
 |      2.0
 |      >>> a.duration.addDurationTuple(duration.durationTupleFromTypeDots('whole', 0))
 |      >>> a.duration.quarterLength
 |      6.0
 |      >>> b = a.splitAtDurations()
 |      >>> b
 |      (<music21.note.Note C>, <music21.note.Note C>)
 |      >>> b[0].pitch == b[1].pitch
 |      True
 |      >>> b[0].duration
 |      <music21.duration.Duration 2.0>
 |      >>> b[0].duration.type
 |      'half'
 |      >>> b[1].duration.type
 |      'whole'
 |      >>> b[0].quarterLength, b[1].quarterLength
 |      (2.0, 4.0)
 |      
 |      >>> c = note.Note()
 |      >>> c.quarterLength = 2.5
 |      >>> d, e = c.splitAtDurations()
 |      >>> d.duration.type
 |      'half'
 |      >>> e.duration.type
 |      'eighth'
 |      >>> d.tie.type
 |      'start'
 |      >>> print(e.tie)
 |      <music21.tie.Tie stop>
 |      
 |      Assume c is tied to the next note.  Then the last split note should also be tied
 |      
 |      >>> c.tie = tie.Tie('start')
 |      >>> d, e = c.splitAtDurations()
 |      >>> d.tie.type
 |      'start'
 |      >>> e.tie.type
 |      'continue'
 |      
 |      Rests have no ties:
 |      
 |      >>> f = note.Rest()
 |      >>> f.quarterLength = 2.5
 |      >>> g, h = f.splitAtDurations()
 |      >>> (g.duration.type, h.duration.type)
 |      ('half', 'eighth')
 |      >>> f.tie is None
 |      True
 |      >>> g.tie is None
 |      True
 |      
 |      TODO: unit into a "split" function -- document obscure uses.
 |  
 |  splitAtQuarterLength(self, quarterLength, retainOrigin=True, addTies=True, displayTiedAccidentals=False)
 |      Split an Element into two Elements at a provided
 |      `quarterLength` (offset) into the Element.
 |      
 |      Returns a specialized tuple called a SplitTuple that also has
 |      a .spannerList element which is a list of spanners
 |      that were created during the split, such as by 
 |      
 |      
 |      TODO: unit into a "split" function -- document obscure uses.
 |      
 |      >>> a = note.Note('C#5')
 |      >>> a.duration.type = 'whole'
 |      >>> a.articulations = [articulations.Staccato()]
 |      >>> a.lyric = 'hi'
 |      >>> a.expressions = [expressions.Mordent(), expressions.Trill(), expressions.Fermata()]
 |      >>> st = a.splitAtQuarterLength(3)
 |      >>> b, c = st
 |      >>> b.duration.type
 |      'half'
 |      >>> b.duration.dots
 |      1
 |      >>> b.duration.quarterLength
 |      3.0
 |      >>> b.articulations
 |      []
 |      >>> b.lyric
 |      'hi'
 |      >>> b.expressions
 |      [<music21.expressions.Mordent>, <music21.expressions.Trill>]
 |      >>> c.duration.type
 |      'quarter'
 |      >>> c.duration.dots
 |      0
 |      >>> c.duration.quarterLength
 |      1.0
 |      >>> c.articulations
 |      [<music21.articulations.Staccato>]
 |      >>> c.lyric
 |      >>> c.expressions
 |      [<music21.expressions.Fermata>]
 |      >>> c.getSpannerSites()
 |      [<music21.expressions.TrillExtension <music21.note.Note C#><music21.note.Note C#>>]
 |      
 |      st is a _SplitTuple which can get the spanners from it for inserting into a Stream.
 |      
 |      >>> st.spannerList
 |      [<music21.expressions.TrillExtension <music21.note.Note C#><music21.note.Note C#>>]
 |      
 |      
 |      
 |      Make sure that ties remain as they should be:
 |      
 |      >>> d = note.Note('D#4')
 |      >>> d.duration.quarterLength = 3.0
 |      >>> d.tie = tie.Tie('start')
 |      >>> e, f = d.splitAtQuarterLength(2.0)
 |      >>> e.tie, f.tie
 |      (<music21.tie.Tie start>, <music21.tie.Tie continue>)
 |      
 |      Should be the same for chords...
 |      
 |      >>> g = chord.Chord(['C4', 'E4', 'G4'])
 |      >>> g.duration.quarterLength = 3.0
 |      >>> g._notes[1].tie = tie.Tie('start')
 |      >>> h, i = g.splitAtQuarterLength(2.0)
 |      >>> for j in range(0,3):
 |      ...   h._notes[j].tie, i._notes[j].tie
 |      (<music21.tie.Tie start>, <music21.tie.Tie stop>)
 |      (<music21.tie.Tie start>, <music21.tie.Tie continue>)
 |      (<music21.tie.Tie start>, <music21.tie.Tie stop>)
 |      
 |      
 |      If quarterLength == self.quarterLength then the second element will be None.
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = 0.5
 |      >>> a, b = n.splitAtQuarterLength(0.5)
 |      >>> b is None
 |      True
 |      >>> a is n
 |      True
 |      
 |      (same with retainOrigin off)
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = 0.5
 |      >>> a, b = n.splitAtQuarterLength(0.5, retainOrigin=False)
 |      >>> a is n
 |      False
 |      
 |      
 |      If quarterLength > self.quarterLength then a DurationException will be raised:
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = 0.5
 |      >>> a, b = n.splitAtQuarterLength(0.7)
 |      Traceback (most recent call last):
 |      DurationException: cannot split a duration (0.5) at this quarterLength (7/10)
 |  
 |  splitByQuarterLengths(self, quarterLengthList, addTies=True, displayTiedAccidentals=False)
 |      Given a list of quarter lengths, return a list of
 |      Music21Object objects, copied from this Music21Object,
 |      that are partitioned and tied with the specified quarter
 |      length list durations.
 |      
 |      TODO: unit into a "split" function -- document obscure uses.
 |      
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = 3
 |      >>> post = n.splitByQuarterLengths([1,1,1])
 |      >>> [n.quarterLength for n in post]
 |      [1.0, 1.0, 1.0]
 |  
 |  write(self, fmt=None, fp=None, **keywords)
 |      Write out a file of music notation (or an image, etc.) in a given format.  If
 |      fp is specified as a file path then the file will be placed there.  If it is not
 |      given then a temporary file will be created.
 |      
 |      If fmt is not given then the default of your Environment's 'writeFormat' will
 |      be used.  For most people that is musicxml.
 |      
 |      Returns the full path to the file.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from music21.base.Music21Object:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  activeSite
 |      A reference to the most-recent object used to
 |      contain this object. In most cases, this will be a
 |      Stream or Stream sub-class. In most cases, an object's
 |      activeSite attribute is automatically set when an the
 |      object is attached to a Stream.
 |      
 |      
 |      >>> n = note.Note("C#4")
 |      >>> p = stream.Part()
 |      >>> p.insert(20.0, n)
 |      >>> n.activeSite is p
 |      True
 |      >>> n.offset
 |      20.0
 |      
 |      >>> m = stream.Measure()
 |      >>> m.insert(10.0, n)
 |      >>> n.activeSite is m
 |      True
 |      >>> n.offset
 |      10.0
 |      >>> n.activeSite = p
 |      >>> n.offset
 |      20.0
 |  
 |  beat
 |      Return the beat of this object as found in the most
 |      recently positioned Measure. Beat values count from 1 and
 |      contain a floating-point designation between 0 and 1 to
 |      show proportional progress through the beat.
 |      
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = .5
 |      >>> m = stream.Measure()
 |      >>> m.timeSignature = meter.TimeSignature('3/4')
 |      >>> m.repeatAppend(n, 6)
 |      >>> [m.notes[i].beat for i in range(6)]
 |      [1.0, 1.5, 2.0, 2.5, 3.0, 3.5]
 |      
 |      >>> m.timeSignature = meter.TimeSignature('6/8')
 |      >>> [m.notes[i].beat for i in range(6)]
 |      [1.0, Fraction(4, 3), Fraction(5, 3), 2.0, Fraction(7, 3), Fraction(8, 3)]
 |      
 |      >>> s = stream.Stream()
 |      >>> s.insert(0, meter.TimeSignature('3/4'))
 |      >>> s.repeatAppend(note.Note(), 8)
 |      >>> [n.beat for n in s.notes]
 |      [1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0]
 |      
 |      
 |      >>> s = stream.Stream()
 |      >>> ts = meter.TimeSignature('4/4')
 |      >>> s.insert(0, ts)
 |      >>> n = note.Note(type='eighth')
 |      >>> s.repeatAppend(n, 8)
 |      >>> s.makeMeasures(inPlace = True)
 |      >>> [n.beat for n in s.flat.notes]
 |      [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
 |  
 |  beatDuration
 |      Return a :class:`~music21.duration.Duration` of the beat active 
 |      for this object as found in the most recently positioned Measure.
 |      
 |      If extending beyond the Measure, or in a Stream with a TimeSignature, 
 |      the meter modulus value will be returned.
 |      
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = .5
 |      >>> m = stream.Measure()
 |      >>> m.timeSignature = meter.TimeSignature('3/4')
 |      >>> m.repeatAppend(n, 6)
 |      >>> [m.notes[i].beatDuration.quarterLength for i in range(6)]
 |      [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
 |      
 |      >>> m.timeSignature = meter.TimeSignature('6/8')
 |      >>> [m.notes[i].beatDuration.quarterLength for i in range(6)]
 |      [1.5, 1.5, 1.5, 1.5, 1.5, 1.5]
 |      
 |      >>> s = stream.Stream()
 |      >>> s.insert(0, meter.TimeSignature('2/4+3/4'))
 |      >>> s.repeatAppend(note.Note(), 8)
 |      >>> [n.beatDuration.quarterLength for n in s.notes]
 |      [2.0, 2.0, 3.0, 3.0, 3.0, 2.0, 2.0, 3.0]
 |  
 |  beatStr
 |      Return a string representation of the beat of
 |      this object as found in the most recently positioned
 |      Measure. Beat values count from 1 and contain a
 |      fractional designation to show progress through the beat.
 |      
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = .5
 |      >>> m = stream.Measure()
 |      >>> m.timeSignature = meter.TimeSignature('3/4')
 |      >>> m.repeatAppend(n, 6)
 |      >>> [m.notes[i].beatStr for i in range(6)]
 |      ['1', '1 1/2', '2', '2 1/2', '3', '3 1/2']
 |      >>> m.timeSignature = meter.TimeSignature('6/8')
 |      >>> [m.notes[i].beatStr for i in range(6)]
 |      ['1', '1 1/3', '1 2/3', '2', '2 1/3', '2 2/3']
 |      
 |      >>> s = stream.Stream()
 |      >>> s.insert(0, meter.TimeSignature('3/4'))
 |      >>> s.repeatAppend(note.Note(), 8)
 |      >>> [n.beatStr for n in s.notes]
 |      ['1', '2', '3', '1', '2', '3', '1', '2']
 |  
 |  beatStrength
 |      Return the metrical accent of this object
 |      in the most recently positioned Measure. Accent values
 |      are between zero and one, and are derived from the local
 |      TimeSignature's accent MeterSequence weights. If the offset
 |      of this object does not match a defined accent weight, a
 |      minimum accent weight will be returned.
 |      
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = .5
 |      >>> m = stream.Measure()
 |      >>> m.timeSignature = meter.TimeSignature('3/4')
 |      >>> m.repeatAppend(n, 6)
 |      >>> [m.notes[i].beatStrength for i in range(6)]
 |      [1.0, 0.25, 0.5, 0.25, 0.5, 0.25]
 |      
 |      >>> m.timeSignature = meter.TimeSignature('6/8')
 |      >>> [m.notes[i].beatStrength for i in range(6)]
 |      [1.0, 0.25, 0.25, 0.5, 0.25, 0.25]
 |      
 |      
 |      We can also get the beatStrength for elements not in
 |      a measure, if the enclosing stream has a :class:`~music21.meter.TimeSignature`.
 |      We just assume that the time signature carries through to
 |      hypothetical following measures:
 |      
 |      
 |      >>> n = note.Note('E--3', type='quarter')
 |      >>> s = stream.Stream()
 |      >>> s.insert(0.0, meter.TimeSignature('2/2'))
 |      >>> s.repeatAppend(n, 12)
 |      >>> [s.notes[i].beatStrength for i in range(12)]
 |      [1.0, 0.25, 0.5, 0.25, 1.0, 0.25, 0.5, 0.25, 1.0, 0.25, 0.5, 0.25]
 |      
 |      
 |      Changing the meter changes the output, of course:
 |      
 |      >>> s.insert(4.0, meter.TimeSignature('3/4'))
 |      >>> [s.notes[i].beatStrength for i in range(12)]
 |      [1.0, 0.25, 0.5, 0.25, 1.0, 0.5, 0.5, 1.0, 0.5, 0.5, 1.0, 0.5]
 |      
 |      
 |      Test not using measures
 |      
 |      >>> n = note.Note("E--3")
 |      >>> n.quarterLength = 2
 |      >>> s = stream.Stream()
 |      >>> s.isMeasure
 |      False
 |      >>> s.insert(0, meter.TimeSignature('2/2'))
 |      >>> s.repeatAppend(n, 16)
 |      >>> s.notes[0].beatStrength
 |      1.0
 |      >>> s.notes[1].beatStrength
 |      0.5
 |      >>> s.notes[4].beatStrength
 |      1.0
 |      >>> s.notes[5].beatStrength
 |      0.5
 |  
 |  classSet
 |      Returns a set (that is, unordered, but indexed) of all of the classes that
 |      this class belongs to, including
 |      string names, fullyQualified string names, and objects themselves.
 |      
 |      It's cached on a per class basis, so makes for a really fast way of checking to 
 |      see if something belongs
 |      to a particular class when you don't know if the user has given a string,
 |      a fully qualified string name, or an object.
 |      
 |      Did I mention it's fast?  It's a drop in substitute for the deprecated
 |      `.isClassOrSubClass`.  It's not as fast as x in n.classes or isinstance(n, x)
 |      if you know whether it's a string or class, but this is good and safe.
 |      
 |      >>> n = note.Note()
 |      >>> 'Note' in n.classSet
 |      True
 |      >>> 'music21.note.Note' in n.classSet
 |      True
 |      >>> note.Note in n.classSet
 |      True
 |      
 |      >>> 'Rest' in n.classSet
 |      False
 |      >>> note.Rest in n.classSet
 |      False
 |      
 |      >>> object in n.classSet
 |      True
 |      
 |      >>> sorted([s for s in n.classSet if isinstance(s, str)])
 |      ['GeneralNote', 'Music21Object', 'NotRest', 'Note', '....object', 
 |       'music21.base.Music21Object', 'music21.note.GeneralNote', 'music21.note.NotRest', 
 |       'music21.note.Note', 'object']
 |       
 |      >>> sorted([s for s in n.classSet if not isinstance(s, str)], key=lambda x: x.__name__)
 |      [<class 'music21.note.GeneralNote'>, 
 |       <class 'music21.base.Music21Object'>, 
 |       <class 'music21.note.NotRest'>, 
 |       <class 'music21.note.Note'>, 
 |       <... 'object'>]
 |  
 |  classes
 |      Returns a tuple containing the names (strings, not objects) of classes that this
 |      object belongs to -- starting with the object's class name and going up the mro()
 |      for the object.  Very similar to Perl's @ISA array:
 |      
 |      
 |      >>> q = note.Note()
 |      >>> q.classes
 |      ('Note', 'NotRest', 'GeneralNote', 'Music21Object', 'object')
 |      
 |      Having quick access to these things as strings makes it easier to do comparisons:
 |      
 |      Example: find GClefs that are not Treble clefs (or treble 8vb, etc.):
 |      
 |      >>> s = stream.Stream()
 |      >>> s.insert(10, clef.GClef())
 |      >>> s.insert(20, clef.TrebleClef())
 |      >>> s.insert(30, clef.FrenchViolinClef())
 |      >>> s.insert(40, clef.Treble8vbClef())
 |      >>> s.insert(50, clef.BassClef())
 |      >>> s2 = stream.Stream()
 |      >>> for t in s:
 |      ...    if 'GClef' in t.classes and 'TrebleClef' not in t.classes:
 |      ...        s2.insert(t)
 |      >>> s2.show('text')
 |      {10.0} <music21.clef.GClef>
 |      {30.0} <music21.clef.FrenchViolinClef>
 |      
 |      `Changed 2015 Sep`: returns a tuple, not a list.
 |  
 |  derivation
 |      Return the :class:`~music21.derivation.Derivation` object for this element.
 |      
 |      Or create one if none exists:
 |      
 |      >>> n = note.Note()
 |      >>> n.derivation
 |      <Derivation of <music21.note.Note C> from None via "None">
 |      >>> import copy
 |      >>> n2 = copy.deepcopy(n)
 |      >>> n2.pitch.step = 'D' # for seeing easier...
 |      >>> n2.derivation
 |      <Derivation of <music21.note.Note D> from <music21.note.Note C> via "__deepcopy__">
 |      >>> n2.derivation.origin is n
 |      True
 |      
 |      Note that (for now at least) derivation.origin is NOT a weakref:
 |      
 |      >>> del n
 |      >>> n2.derivation
 |      <Derivation of <music21.note.Note D> from <music21.note.Note C> via "__deepcopy__">
 |      >>> n2.derivation.origin
 |      <music21.note.Note C>
 |  
 |  duration
 |      Get and set the duration of this object as a Duration object.
 |  
 |  measureNumber
 |      Return the measure number of a :class:`~music21.stream.Measure` that contains this
 |      object if the object is in a measure.
 |      
 |      Returns None if the object is not in a measure.  Also note that by 
 |      default Measure objects
 |      have measure number 0.
 |      
 |      If an object belongs to multiple measures (not in the same hierarchy...) 
 |      then it returns the
 |      measure number of the :meth:`~music21.base.Music21Object.activeSite` if that is a
 |      :class:`~music21.stream.Measure` object.  Otherwise it will use 
 |      :meth:`~music21.base.Music21Object.getContextByClass`
 |      to find the number of the measure it was most recently added to.
 |      
 |      
 |      >>> m = stream.Measure()
 |      >>> m.number = 12
 |      >>> n = note.Note()
 |      >>> m.append(n)
 |      >>> n.measureNumber
 |      12
 |      
 |      >>> n2 = note.Note()
 |      >>> n2.measureNumber is None
 |      True
 |      >>> m2 = stream.Measure()
 |      >>> m2.append(n2)
 |      >>> n2.measureNumber
 |      0
 |      
 |      This updates live if the measure number changes:
 |      
 |      >>> m2.number = 11
 |      >>> n2.measureNumber
 |      11
 |      
 |      
 |      The most recent measure added to is used unless activeSite is a measure:
 |      
 |      >>> m.append(n2)
 |      >>> n2.measureNumber
 |      12
 |      >>> n2.activeSite = m2
 |      >>> n2.measureNumber
 |      11
 |      
 |      Copies can retain measure numbers until set themselves:
 |      
 |      >>> import copy
 |      >>> nCopy = copy.deepcopy(n2)
 |      >>> nCopy.measureNumber
 |      12
 |      >>> m3 = stream.Measure()
 |      >>> m3.number = 4
 |      >>> m3.append(nCopy)
 |      >>> nCopy.measureNumber
 |      4
 |  
 |  offset
 |      The offset property sets or returns the position of this object
 |      as a float or fractions.Fraction value
 |      (generally in `quarterLengths`), depending on what is representable. 
 |      
 |      Offsets are measured from the start of the object's `activeSite`,
 |      that is, the most recently referenced `Stream` or `Stream` subclass such
 |      as `Part`, `Measure`, or `Voice`.  It is a simpler
 |      way of calling `o.getOffsetBySite(o.activeSite, returnType='rational')`.
 |      
 |      If we put a `Note` into a `Stream`, we will see the activeSite changes.
 |      
 |      >>> import fractions
 |      >>> n1 = note.Note("D#3")
 |      >>> n1.activeSite is None
 |      True
 |      
 |      >>> m1 = stream.Measure()
 |      >>> m1.number = 4
 |      >>> m1.insert(10.0, n1)
 |      >>> n1.offset
 |      10.0
 |      >>> n1.activeSite
 |      <music21.stream.Measure 4 offset=0.0>
 |      
 |      >>> n1.activeSite is m1
 |      True
 |      
 |      The most recently referenced `Stream` becomes an object's `activeSite` and
 |      thus the place where `.offset` looks to find its number.
 |      
 |      >>> m2 = stream.Measure()
 |      >>> m2.insert(3.0/5, n1)
 |      >>> m2.number = 5
 |      >>> n1.offset
 |      Fraction(3, 5)
 |      >>> n1.activeSite is m2
 |      True
 |      
 |      Notice though that `.offset` depends on the `.activeSite` which is the most
 |      recently accessed/referenced Stream.
 |      
 |      Here we will iterate over the `elements` in `m1` and we
 |      will see that the `.offset` of `n1` now is its offset in
 |      `m1` even though we haven't done anything directly to `n1`.
 |      Simply iterating over a site is enough to change the `.activeSite`
 |      of its elements:
 |      
 |      >>> for element in m1:
 |      ...     pass
 |      >>> n1.offset
 |      10.0
 |      
 |      
 |      The property can also set the offset for the object if no
 |      container has been set:
 |      
 |      
 |      >>> n1 = note.Note()
 |      >>> n1.id = 'hi'
 |      >>> n1.offset = 20/3.
 |      >>> n1.offset
 |      Fraction(20, 3)
 |      >>> float(n1.offset)
 |      6.666...
 |      
 |      
 |      >>> s1 = stream.Stream()
 |      >>> s1.append(n1)
 |      >>> n1.offset
 |      0.0
 |      >>> s2 = stream.Stream()
 |      >>> s2.insert(30.5, n1)
 |      >>> n1.offset
 |      30.5
 |      
 |      After calling `getElementById` on `s1`, the
 |      returned element's `offset` will be its offset in `s1`.
 |      
 |      >>> n2 = s1.getElementById('hi')
 |      >>> n2 is n1
 |      True
 |      >>> n2.offset
 |      0.0
 |      
 |      Iterating over the elements in a Stream will
 |      make its `offset` be the offset in iterated
 |      Stream.
 |      
 |      >>> for thisElement in s2:
 |      ...     thisElement.offset
 |      30.5
 |      
 |      When in doubt, use `.getOffsetBySite(streamObj)`
 |      which is safer.
 |  
 |  priority
 |      Get and set the priority integer value.
 |      
 |      Priority specifies the order of processing from left (lowest number)
 |      to right (highest number) of objects at the same offset.  For
 |      instance, if you want a key change and a clef change to happen at
 |      the same time but the key change to appear first, then set:
 |      keySigElement.priority = 1; clefElement.priority = 2 this might be
 |      a slightly counterintuitive numbering of priority, but it does
 |      mean, for instance, if you had two elements at the same offset,
 |      an allegro tempo change and an andante tempo change, then the
 |      tempo change with the higher priority number would apply to the
 |      following notes (by being processed second).
 |      
 |      Default priority is 0; thus negative priorities are encouraged
 |      to have Elements that appear before non-priority set elements.
 |      
 |      In case of tie, there are defined class sort orders defined in
 |      `music21.base.classSortOrder`.  For instance, a key signature
 |      change appears before a time signature change before a
 |      note at the same offset.  This produces the familiar order of
 |      materials at the start of a musical score.
 |      
 |      >>> import music21
 |      >>> a = music21.Music21Object()
 |      >>> a.priority = 3
 |      >>> a.priority = 'high'
 |      Traceback (most recent call last):
 |      ElementException: priority values must be integers.
 |  
 |  quarterLength
 |      Set or Return the Duration as represented in Quarter Length, possibly as a fraction
 |      
 |      >>> n = note.Note()
 |      >>> n.quarterLength = 2.0
 |      >>> n.quarterLength
 |      2.0
 |      >>> n.quarterLength = 1.0/3
 |      >>> n.quarterLength
 |      Fraction(1, 3)
 |  
 |  seconds
 |      Get or set the duration of this object in seconds, assuming
 |      that this object has a :class:`~music21.tempo.MetronomeMark` 
 |      or :class:`~music21.tempo.MetricModulation` in its past context.
 |      
 |      >>> s = stream.Stream()
 |      >>> s.repeatAppend(note.Note(), 12)
 |      >>> s.insert(0, tempo.MetronomeMark(number=120))
 |      >>> s.insert(6, tempo.MetronomeMark(number=240))
 |      >>> [n.seconds for n in s.notes]
 |      [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25]
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from music21.base.Music21Object:
 |  
 |  classSortOrder = 20
 |  
 |  isStream = False


In [21]:
bedTimes


Out[21]:
[9, 10, 11, 8, 12, 11]

In [22]:
bedTimes[0]


Out[22]:
9

In [ ]: