data_structures
midi.py
- class MIDIEvent
Bases:
objectTakes a channel, value, time and creates a MIDIEvent object.
- Parameters
- __init__(channel: int, value: float, time: float) -> (channel: int, value: float, time: float)
- class MIDIFile
Bases:
object- __init__(midiFile: str)
open file and store it as data in lists tracks with channels and track names, timesOn and off information for each track, velocity and MIDI CC info for each track, etc
- Parameters
midiFile (str) – MIDI file path
- findTrack(name)
Finds the track with a specified name
raises ValueError if there is no track with that specified name
- Parameters
name (str) – The name of the track to be returned
- Return list
The track with the specified name
- getMIDITracks()
returns a list of all MIDITrack objects in the MIDIFile
- Return List[MIDITrack]
a list of all MIDITrack objects
- listTrackNames()
gets a list of all MIDITrack names
- Return List[str]
returns a list of MIDITrack names
- mergeTracks(track1: midi.MIDITrack, track2: midi.MIDITrack, name: str = None) -> (track1: midi.MIDITrack, track2: midi.MIDITrack, name: str = None)
merges 2 tracks together. You can also use the + operator.
- class MIDINote
Bases:
objectTakes a channel, noteNumber, velocity, timeOn and timeOff and creates a MIDINote object.
- Parameters
- Returns
None
- __init__(channel: int, noteNumber: int, velocity: int, timeOn: float, timeOff: float) -> (channel: int, noteNumber: int, velocity: int, timeOn: float, timeOff: float)
- class MIDITrack
Bases:
object- addAftertouch(channel: int, value: float, time: float) -> (channel: int, value: float, time: float)
add a aftertouch event
- addControlChange(control_number: int, channel: int, value: int, time: float)
add a control change value automatically checks if number has been added
- addNoteOff(channel: int, noteNumber: int, velocity: int, timeOff: float) -> (channel: int, noteNumber: int, velocity: int, timeOff: float)
adds a Note Off event
- addNoteOn(channel: int, noteNumber: int, velocity: int, timeOn: float) -> (channel: int, noteNumber: int, velocity: int, timeOn: float)
adds a Note Event
- addPitchwheel(channel: int, value: float, time: float) -> (channel: int, value: float, time: float)
add a pitchwheel event
- aftertouch: List[MIDIAnimator.data_structures.midi.MIDIEvent]
- allUsedNotes()
- Return list
a list of all used notes in the MIDITrack
- controlChange: Dict[int, List[MIDIAnimator.data_structures.midi.MIDIEvent]]
- notes: List[MIDIAnimator.data_structures.midi.MIDINote]
- pitchwheel: List[MIDIAnimator.data_structures.midi.MIDIEvent]
Module contents
- class CacheInstance
Bases:
objectCacheInstance handles caching objects by finding avaialbe frame times. If there are not any avaiable frame times, it will create a new object
- __init__()
- addObject(frameRange: FrameRange)
adds FrameRange to the cache.
- findRange(frameRange: FrameRange)
finds a index for the given frameRange
- Parameters
frameRange (FrameRange) – the FrameRange to insert
- Return int
the index key at which the FrameRange will be inserted into self._cache
- getCache()
gets the entire cache
- Return Dict[int, List[FrameRange]]
the cache instance dictionary with all of the indicies and `FrameRange`s
- getStartTime()
gets the first start time in the cache. If there isn’t any data yet, it will be 0.
- Return float
the first start time
- class DummyFCurve
Bases:
objectDummyFCurve(keyframe_points: ‘Tuple[Keyframe]’, array_index: ‘int’, data_path: ‘str’)
- __init__(keyframe_points: typing.Tuple[Keyframe], array_index: int, data_path: str) -> (keyframe_points: typing.Tuple[Keyframe], array_index: int, data_path: str)
- evaluate(frame)
- keyframe_points: Tuple[MIDIAnimator.data_structures.Keyframe]
- static range()
- class FrameRange
Bases:
objectthis stores an object that will be moving from startFrame to endFrame
- __init__(startFrame: int, endFrame: int, wpr: ObjectWrapper) -> (startFrame: int, endFrame: int, wpr: ObjectWrapper)
- class Keyframe
Bases:
objectA simple keyframe data structure. :param float frame: the frame value of the keyframe (x) :param float value: the value of the keyframe (y)
- __init__(frame: float, value: float) -> (frame: float, value: float)
- property co
- class KeyframeSeconds
Bases:
objectA simple keyframe data structure for time in seconds. :param float seconds: the seconds value of the keyframe (x) :param float value: the value of the keyframe (y)
- __init__(seconds: float, value: float) -> (seconds: float, value: float)
- property co
- class ObjectShapeKey
Bases:
objectWrapper for a bpy.types.Object’s Shape Key
- Parameters
name (str) – name of the shape key
referenceCurve (bpy.types.FCurve) – the reference shape key (with the reference/animation curve)
targetKey (bpy.types.ShapeKey) – the target shape key, this will be keyframed
data_path (str) – data path for the shape key (needed for keyframing)
array_index (int) – array index for the shape key (needed for keyframing)
- __init__(name: str = '', referenceCurve: bpy.types.FCurve = None, targetKey: bpy.types.ShapeKey = None, data_path: str = '', array_index: int = 0) -> (name: str = '', referenceCurve: bpy.types.FCurve = None, targetKey: bpy.types.ShapeKey = None, data_path: str = '', array_index: int = 0)
- property keyframe_points
- range()
returns the range (total length) of the reference curve
- Return Tuple[float, float]
start time and end time
- referenceCurve: bpy.types.FCurve = None
- targetKey: bpy.types.ShapeKey = None
- class ObjectWrapper
Bases:
objectObjectWrapper(obj: ‘bpy.types.Object’, noteNumbers: ‘Tuple[int]’, noteOnCurves: ‘List[Union[bpy.types.FCurve, ObjectShapeKey]]’, noteOffCurves: ‘List[Union[bpy.types.FCurve, ObjectShapeKey]]’)
- __init__(obj: bpy.types.Object, noteNumbers: Tuple[int], noteOnCurves: List[Union[bpy.types.FCurve, ObjectShapeKey]], noteOffCurves: List[Union[bpy.types.FCurve, ObjectShapeKey]])
object wrapper for bpy.types.Object objects. this allows us to store data with the blender objects (such as FCurve data, note numbers, MIDI information, etc)
- Parameters
obj (bpy.types.Object) – Blender object
noteNumbers (Tuple[int]) – a tuple of note numbers of type int.
noteOnCurves (List[Union[bpy.types.FCurve, ObjectShapeKey]]) – A list of NoteOn curves dervided from obj.
noteOffCurves (List[Union[bpy.types.FCurve, ObjectShapeKey]]) – A list of NoteOff curves dervided from obj.
- noteOffCurves: List[Union[bpy.types.FCurve, MIDIAnimator.data_structures.ObjectShapeKey]]
- noteOnCurves: List[Union[bpy.types.FCurve, MIDIAnimator.data_structures.ObjectShapeKey]]
- obj: bpy.types.Object