Developer Reference#
This page documents PyFLP’s internals which consists of pyflp._events
,
pyflp._descriptors
and pyflp._models
.
The content below assumes you have fairly good knowledge of the following:
OOP and descriptors, especially
Type annotations
Binary data types and streams
Events#
Source code: pyflp/_events.py
Contains implementations for various types of event data and its container.
These types serve as the backbone for model creation and simplify marshalling and unmarshalling.
If you have read Part I, you know how events use a TLV encoding scheme.
Type#
The type
represents the event ID. A custom enum class (and a metaclass)
supporting unknown IDs and member check using Python’s ... in ...
syntax is
used.
- class pyflp._events._EventEnumMeta(cls, bases, classdict, *, boundary=None, _simple=False, **kwds)[source]#
- class pyflp._events.EventEnum[source]#
IDs used by events.
Event values are stored as a tuple of event ID and its designated type. The types are used to serialise/deserialise events by the parser.
All event names prefixed with an underscore (_) are deprecated w.r.t to the latest version of FL Studio, to the best of my knowledge.
Length#
The length
is a field prefixed for IDs in the range of 192-255. It is the
size of value
and is encoded as a VLQ128 (variable length quantity base-128).
Value#
Below are the list of classes PyFLP has, grouped w.r.t the ID range.
0-63
- class pyflp._events.ByteEventBase(id: EventEnum, data: bytes)[source]#
Base class of events used for storing 1 byte data.
- class pyflp._events.U8Event(id: EventEnum, data: bytes)[source]#
An event used for storing a 1 byte unsigned integer.
64-127
128-191
- class pyflp._events.DWordEventBase(id: EventEnum, data: bytes)[source]#
Base class of events used for storing 4 byte data.
- class pyflp._events.U32Event(id: EventEnum, data: bytes)[source]#
An event used for storing a 4 byte unsigned integer.
- class pyflp._events.I32Event(id: EventEnum, data: bytes)[source]#
An event used for storing a 4 byte signed integer.
192-255
- class pyflp._events.StrEventBase(id: EventEnum, data: bytes)[source]#
Base class of events used for storing strings.
- class pyflp._events.StructEventBase(id: EventEnum, data: bytes)[source]#
Base class for events used for storing fixed size structured data.
Consists of a collection of POD types like int, bool, float, but not strings. Its size is determined by the event as well as FL version.
EventTree#
- class pyflp._events.EventTree(parent: EventTree | None = None, init: Iterable[IndexedEvent] | None = None)[source]#
Provides mutable “views” which propagate changes back to parents.
This tree is analogous to the hierarchy used by models.
- parent#
Immediate ancestor / parent. Defaults to self.
- root#
Parent of all parent trees.
- children#
- List of children.
- append(event: EventBase[Any]) None [source]#
Appends an event at its corresponding key’s list’s end.
- first(id: EventEnum) EventBase[Any] [source]#
Returns the first event with
id
.- Raises:
KeyError – An event with
id
isn’t found.
- property ids: frozenset[pyflp._events.EventEnum]#
- pop(id: EventEnum, pos: int = 0) EventBase[Any] [source]#
Pops the event with
id
atpos
inself
and all parents.
- remove(id: EventEnum, pos: int = 0) None [source]#
Removes the event with
id
atpos
inself
and all parents.
Models#
Source code: pyflp/_models.py
Contains the ABCs used by model classes and some shared classes.
Implementing a model#
A look at the source code will definitely help, although these are a few points that must be kept in mind when Implementing a model:
Does the model mimic the hierarchy exposed by FL Studio’s GUI?
Tip
Browse through the hierarchies of
pyflp.channel.Channel
subclasses to get a very good idea of this.Are
__dunder__
methods provided by Python used whenever possible?Is either
ModelReprMixin
subclassed or__repr__
implemented?
Descriptors#
Source code: pyflp/_descriptors.py
Contains the descriptor and adaptor classes used by models and events.
Adapters#
Source code: pyflp/_adapters.py