data_structures

midi.py

class MIDIEvent

Bases: object

MIDIEvent(channel: ‘int’, value: ‘float’, time: ‘float’)

__init__(channel: int, value: float, time: float) -> (channel: int, value: float, time: float)
channel: int
time: float
value: 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

Parameters

name (str) – The name of the track to be returned

Return list

The track with the specified name

getMIDITracks()
listTrackNames()
mergeTracks(track1: midi.MIDITrack, track2: midi.MIDITrack, name=None)
class MIDINote

Bases: object

MIDINote(channel: ‘int’, noteNumber: ‘int’, velocity: ‘int’, timeOn: ‘float’, timeOff: ‘float’)

__init__(channel: int, noteNumber: int, velocity: int, timeOn: float, timeOff: float) -> (channel: int, noteNumber: int, velocity: int, timeOn: float, timeOff: float)
channel: int
noteNumber: int
timeOff: float
timeOn: float
velocity: int
class MIDITrack

Bases: object

__init__(name: str)

initialize a MIDITrack

Parameters

name (str) – name of track

addAftertouch(channel: int, value: float, time: float) -> (channel: int, value: float, time: float)

add a aftertouch event

Parameters
  • channel (int) – the MIDI channel number

  • value (float) – value of the aftertouch, TODO range

  • time (float) – time value (in seconds)

addControlChange(control_number: int, channel: int, value: int, time: float)

add a control change value automatically checks if number has been added

Parameters
  • control_number (int) – the control change number

  • channel (int) – MIDI channel number

  • value (int) – value of the control change

  • time (float) – time value (in seconds)

addNoteOff(channel: int, noteNumber: int, velocity: int, timeOff: float) -> (channel: int, noteNumber: int, velocity: int, timeOff: float)

adds a Note Off event

Parameters
  • channel (int) – MIDI channel

  • noteNumber (int) – the note number, TODO range

  • velocity (int) – the note velocity, TODO range

  • timeOff (float) – the note time off, in seconds

addNoteOn(channel: int, noteNumber: int, velocity: int, timeOn: float) -> (channel: int, noteNumber: int, velocity: int, timeOn: float)

adds a Note Event

Parameters
  • channel (int) – the MIDI Channel the note is on

  • noteNumber (int) – the note number, range from 0-127

  • velocity (int) – the note velocity, range 0-127

  • timeOn (float) – the note time on, in seconds

addPitchwheel(channel: int, value: float, time: float) -> (channel: int, value: float, time: float)

add a pitchwheel event

Parameters
  • channel (int) – the MIDI channel number

  • value (float) – value of the pitch wheel TODO range

  • time (float) – time value (in seconds)

aftertouch: List[MIDIAnimator.data_structures.midi.MIDIEvent]
allUsedNotes()

Returns a list of all used notes in a MIDI Track.

Return list

a list of all used notes

controlChange: Dict[int, List[MIDIAnimator.data_structures.midi.MIDIEvent]]
name: str
pitchwheel: List[MIDIAnimator.data_structures.midi.MIDIEvent]

Module contents

class BlenderObject

Bases: object

BlenderObject(obj: ‘bpy.types.Object’, noteNumbers: ‘tuple’, noteOnCurves: ‘ObjectFCurves’, noteOffCurves: ‘ObjectFCurves’)

__init__(obj: bpy.types.Object, noteNumbers: tuple, noteOnCurves: ObjectFCurves, noteOffCurves: ObjectFCurves)
noteNumbers: tuple
noteOffCurves: MIDIAnimator.data_structures.ObjectFCurves
noteOnCurves: MIDIAnimator.data_structures.ObjectFCurves
obj: bpy.types.Object
rangeOff()
Returns

start and end offsets for playing the note off curve

rangeOn()
Returns

start and end offsets for playing the note on curve

class CacheInstance

Bases: object

CacheInstance(objs: ‘List[bpy.types.Object]’) -> ‘None’

__init__(objs: typing.List[bpy.types.Object]) -> (objs: typing.List[bpy.types.Object])

initializes a type List[bpy.types.Object] to the cache instance.

getObject()

takes out a bpy.types.Object from the cache. This is the method to use when you want to take an object out

Returns

the reusable bpy.types.Object

returnObject(obj: bpy.types.Object) -> (obj: bpy.types.Object)

returns a bpy.types.Object back to the cache. This is the method to use when you are done with the object

class FCurveProcessor

Bases: object

__init__(obj: bpy.types.Object, fCurves: ObjectFCurves, locationObject: Optional[bpy.types.Object] = None)
applyFCurve(delta: int)
customProperties: Dict[str, Union[int, float]]
fCurves: MIDIAnimator.data_structures.ObjectFCurves
insertKeyFrames(frame: int)
location: Optional[mathutils.Vector]
locationObject: Optional[bpy.types.Object]
obj: bpy.types.Object
rotation: Optional[mathutils.Euler]
shapeKeys: Dict[str, float]
class FrameRange

Bases: object

this stores an object that will be moving from startFrame to endFrame

__init__(startFrame: int, endFrame: int, bObj: BlenderObject, type: str = 'note_on') -> (startFrame: int, endFrame: int, bObj: BlenderObject, type: str = 'note_on')
bObj: MIDIAnimator.data_structures.BlenderObject
endFrame: int
startFrame: int
type: str = 'note_on'
class ObjectFCurves

Bases: object

ObjectFCurves(location: ‘Tuple[bpy.types.FCurve]’ = (), rotation: ‘Tuple[bpy.types.FCurve]’ = (), customProperties: ‘Tuple[bpy.types.FCurve]’ = (), shapeKeysDict: ‘Dict[str, List[bpy.types.FCurve, bpy.types.ShapeKey]]’ = (), shapeKeys: ‘Tuple[bpy.types.FCurve]’ = (), origLoc: ‘Vector’ = <mathutils.Vector object at 0x7f41d7b227d0>, origRot: ‘Euler’ = <mathutils.Euler object at 0x7f41d312f310>)

__init__(location: Tuple[bpy.types.FCurve] = (), rotation: Tuple[bpy.types.FCurve] = (), customProperties: Tuple[bpy.types.FCurve] = (), shapeKeysDict: Dict[str, List[bpy.types.FCurve, bpy.types.ShapeKey]] = (), shapeKeys: Tuple[bpy.types.FCurve] = (), origLoc: Vector = <mathutils.Vector object>, origRot: Euler = <mathutils.Euler object>) -> (location: Tuple[bpy.types.FCurve] = (), rotation: Tuple[bpy.types.FCurve] = (), customProperties: Tuple[bpy.types.FCurve] = (), shapeKeysDict: Dict[str, List[bpy.types.FCurve, bpy.types.ShapeKey]] = (), shapeKeys: Tuple[bpy.types.FCurve] = (), origLoc: Vector = <mathutils.Vector object>, origRot: Euler = <mathutils.Euler object>)
customProperties: Tuple[bpy.types.FCurve] = ()
location: Tuple[bpy.types.FCurve] = ()
origLoc: Vector = <mathutils.Vector object>
origRot: Euler = <mathutils.Euler object>
rotation: Tuple[bpy.types.FCurve] = ()
shapeKeys: Tuple[bpy.types.FCurve] = ()
shapeKeysDict: Dict[str, List[bpy.types.FCurve, bpy.types.ShapeKey]] = ()