Package jazzparser :: Package data :: Package input :: Class SegmentedMidiInput
[hide private]
[frames] | no frames]

Class SegmentedMidiInput

source code

 object --+        
          |        
InputReader --+    
              |    
          Input --+
                  |
                 SegmentedMidiInput

Input wrapper for MIDI files with extra information about segmentation, in the form it's needed for the Raphael and Stoddard model and midi supertagging models: that is, offset (start of first bar) and bar length.

Each segment is a midi midi.EventStream. It also has the additional attribute segment_start, giving the tick time at which the segment begins in the original midi stream.

Optionally also stores a gold standard analysis in the form of a db annotated chord sequence: see AnnotatedDbInput.

Instance Methods [hide private]
 
__init__(self, inputs, time_unit=4, tick_offset=0, stream=None, gold=None, sequence_index=None, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__len__(self) source code
 
__getitem__(self, item) source code
 
__str__(self)
str(x)
source code
 
slice(self, start=None, end=None)
Subclasses should provide a way of slicing (taking a subsequence of) the input that returns an input of the original type.
source code
 
get_gold_analysis(self)
If the input includes a gold-standard analysis, this should return it.
source code

Inherited from Input (private): _get_string_name

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from InputReader: process_option_dict

Static Methods [hide private]
 
from_file(filename, options={}, gold=None, sequence_index=None) source code
 
from_stream(stream, time_unit=4, tick_offset=0, name=None, only_notes=True, truncate=None, gold=None, sequence_index=None)
Creates a SegmentedMidiInput from a midi event stream.
source code
Class Variables [hide private]
  FILE_INPUT_OPTIONS = [ModuleOption('time_unit', filter= float,...
  SHELL_TOOLS = Input.SHELL_TOOLS+ [tools.PlayMidiChunksTool(), ...
Properties [hide private]

Inherited from Input: string_name

Inherited from object: __class__

Method Details [hide private]

__init__(self, inputs, time_unit=4, tick_offset=0, stream=None, gold=None, sequence_index=None, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • stream - the midi data segments
  • time_unit (int or float) - number of beats to take as the basic unit of time for observations
  • tick_offset (int) - number of ticks after which the first bar begins
  • inputs (list of midi.EventStreams)
Overrides: object.__init__

__len__(self)
(Length operator)

source code 
Overrides: Input.__len__

__getitem__(self, item)
(Indexing operator)

source code 
Overrides: Input.__getitem__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

slice(self, start=None, end=None)

source code 

Subclasses should provide a way of slicing (taking a subsequence of) the input that returns an input of the original type.

Overrides: Input.slice
(inherited documentation)

get_gold_analysis(self)

source code 

If the input includes a gold-standard analysis, this should return it. Otherwise, it will return None.

Overrides: Input.get_gold_analysis
(inherited documentation)

from_file(filename, options={}, gold=None, sequence_index=None)
Static Method

source code 
Overrides: InputReader.from_file

from_stream(stream, time_unit=4, tick_offset=0, name=None, only_notes=True, truncate=None, gold=None, sequence_index=None)
Static Method

source code 

Creates a SegmentedMidiInput from a midi event stream.

Parameters:
  • only_notes (bool) - if True, only includes note-on/note-off events in the segments. If False, the stream will be sliced so that each segment repeats things like program change events at the beginning. Including only notes, however, makes the preprocessing very much faster

Class Variable Details [hide private]

FILE_INPUT_OPTIONS

Value:
[ModuleOption('time_unit', filter= float, help_text= "number of beats \
(by the MIDI file resolution) " "to take to be one time unit", usage= \
"time_unit=X, where X is an int or float", required= False, default= 4\
), ModuleOption('tick_offset', filter= int, help_text= "time in MIDI t\
icks at which the first time " "unit begins", usage= "tick_offset=X, w\
here X is an int", required= False, default= 0), ModuleOption('truncat\
e', filter= int, help_text= "truncate the input to this length.", usag\
e= "truncate=L, where L is an integer"),]

SHELL_TOOLS

Value:
Input.SHELL_TOOLS+ [tools.PlayMidiChunksTool(), tools.PrintMidiChunksT\
ool()]