### Install Project Dependencies Source: https://github.com/demberto/pyflp/blob/master/docs/contributing.rst Install all necessary development, user, and documentation dependencies, including upgrading pip. This command installs packages from both requirements files. ```console python -m pip install --upgrade pip pip install -r requirements.txt -r docs/requirements.txt tox ``` -------------------------------- ### Install PyFLP Source: https://github.com/demberto/pyflp/blob/master/README.md Install the PyFLP library using pip. Ensure you have Python 3.8+ or PyPy 3.8+ installed. ```none python -m pip install -U pyflp ``` -------------------------------- ### Python Code Example Source: https://github.com/demberto/pyflp/blob/master/_autodocs/MANIFEST.txt Illustrates the standard Python code block formatting used within the documentation. ```python # Python code with syntax highlighting ``` -------------------------------- ### Access Plugin Information Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/channel.md Provides an example of how to access the loaded plugin on a channel and retrieve its name and VST path if applicable. Checks if the plugin is an instance of VSTPlugin. ```python if channel.plugin: print(f"Plugin: {channel.plugin.name}") if isinstance(channel.plugin, VSTPlugin): print(f"VST Path: {channel.plugin.plugin_path}") ``` -------------------------------- ### Set and Get Project Tempo Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Sets or gets the project's tempo in BPM. Supports float values for fine-tuned tempo. Be aware of version-specific limitations and potential errors. ```python project.tempo = 120.5 # 120.5 BPM print(f"Current tempo: {project.tempo} BPM") ``` -------------------------------- ### Iterate Through Pattern Notes Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Access and iterate over the MIDI notes within a pattern. Each note object provides properties like `key` and `position`. The example also shows how to get all notes as a list. ```python for note in pattern.notes: print(f"{note.key} at position {note.position}") # Get all notes as list all_notes = list(pattern.notes) print(f"Total notes: {len(all_notes)}") ``` -------------------------------- ### url Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Sets or gets the web link associated with the project. ```APIDOC ## url ### Description Web link associated with the project. ### Menu location Options > Project info > Web link ### Example ```python project.url = "https://example.com" ``` ``` -------------------------------- ### Format Project Creation Date Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Get the local date and time when the project was created. Format the datetime object for display. Returns None if not available. ```python if project.created_on: print(f"Created: {project.created_on.strftime('%Y-%m-%d %H:%M:%S')}") ``` -------------------------------- ### Get VST Plugin Vendor Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md Print the vendor or manufacturer name of the VST plugin. ```python print(f"Vendor: {channel.plugin.vendor}") ``` -------------------------------- ### title Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Sets or gets the name of the song or project. ```APIDOC ## title ### Description Name of the song or project. ### Menu location Options > Project info > Title ### Example ```python project.title = "My Epic Track" ``` ``` -------------------------------- ### Get Pattern Length in Steps Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Retrieve the pattern's length in PPQ (Pulses Per Quarter note) units. This property returns `None` if the pattern is in Auto mode (looped == False). The example shows how to convert PPQ units to steps. ```python # Get length in PPQ units length = pattern.length if project.ppq: steps = length // project.ppq print(f"Pattern length: {steps} steps") ``` -------------------------------- ### Get and Set Playlist Item Offsets Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Retrieve or modify the start and end offsets for a playlist item's playback window. Offsets are provided as a tuple of two floats. ```python start, end = item.offsets item.offsets = (0.5, -0.2) # Offset playback window ``` -------------------------------- ### Get VST Plugin Path Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md Print the file system path of the loaded VST plugin if the plugin_path property is available. ```python if channel.plugin.plugin_path: print(f"Loaded from: {channel.plugin.plugin_path}") ``` -------------------------------- ### Get Project Timebase (PPQ) Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Retrieves the project's timebase, measured in pulses per quarter (PPQ). ```python print(f"Project timebase: {project.ppq} PPQ") ``` -------------------------------- ### Check Project PPQ Validity Source: https://github.com/demberto/pyflp/blob/master/_autodocs/types.md Example of how to check if a project's current PPQ setting is within the supported range defined by VALID_PPQS. Ensure pyflp.project is imported. ```python from pyflp.project import VALID_PPQS if project.ppq in VALID_PPQS: print(f"Valid PPQ: {project.ppq}") ``` -------------------------------- ### Get Project Licensee Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Get the username of the license holder who last saved the project. Returns an empty string if saved with a trial version. Available in FL Studio v1.3.9+. ```python if project.licensee: print(f"Licensed to: {project.licensee}") ``` -------------------------------- ### Set and Get Channel Color Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/channel.md Demonstrates how to set a channel's color to red using the RGBA type and how to retrieve color components. Requires importing RGBA from pyflp.types. ```python from pyflp.types import RGBA channel.color = RGBA(1.0, 0.0, 0.0, 1.0) ``` ```python if channel.color: print(f"Red: {channel.color.red}, Alpha: {channel.color.alpha}") ``` -------------------------------- ### Get Project Channel Count Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Print the total number of channels in the rack. For Patcher presets, this represents the total number of plugins used inside it. Raises ValueError if a negative value is set. ```python print(f"Total channels: {project.channel_count}") ``` -------------------------------- ### Get FL Studio Version Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Retrieves the FL Studio version used to save the project. Allows comparison with specific versions. ```python print(f"Saved with FL Studio v{project.version}") if project.version >= FLVersion(20, 0, 0): print("Project uses FL Studio v20+") ``` -------------------------------- ### tempo Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Gets or sets the tempo at the current playhead position in BPM. ```APIDOC ## tempo ### Description Tempo at the current playhead position in BPM. ### Raises - `TypeError` — When setting a float on FL Studio v3.4.0 or earlier - `PropertyCannotBeSet` — If underlying event not found - `ValueError` — When tempo outside allowed range ### Range 10.0 to 522.0 BPM (or 999.0 on v1.4.2 to v11) ### Changed - v1.4.2: Max tempo increased to 999 - v3.4.0: Fine-tuned tempo (float) support added - v11: Max tempo limited to 522.0 ### Example ```python project.tempo = 120.5 # 120.5 BPM print(f"Current tempo: {project.tempo} BPM") ``` ``` -------------------------------- ### Set Playlist Item Length Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Define the duration of a playlist item in PPQ units. This example sets the length to one bar, assuming a PPQ of 96. ```python # 1 bar long item.length = 96 * 4 ``` -------------------------------- ### Accessing and Modifying Plucked Plugin Properties Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md This example demonstrates how to verify if an instrument's plugin is of the Plucked type and subsequently alter its decay and color properties. Suitable for string instrument synthesis. ```python if isinstance(instrument.plugin, Plucked): instrument.plugin.decay = 75 instrument.plugin.color = 100 ``` -------------------------------- ### Iterate Through Project Channels Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Provides an iterator over channels and channel rack properties. Access channels by index or iterate through them to get their name and IID. ```python for channel in project.channels: print(f"{channel.name} (IID: {channel.iid})") # Access by index first_channel = project.channels[0] ``` -------------------------------- ### Export Project Samples to ZIP Source: https://github.com/demberto/pyflp/blob/master/docs/handbook.rst Use this to create a ZIP archive containing the FLP project file and all its associated audio samples. Ensure all sample paths are valid and accessible. ```python from zipfile import ZipFile import pyflp project = pyflp.parse("MyGreatSong.flp") with ZipFile("MyGreatSong.zip", "x") as zp: zp.write("MyGreatSong.flp") for sampler in project.channels.samplers: if sampler.sample_path is not None: zp.write(sampler.sample_path) ``` -------------------------------- ### FLVersion Dataclass and Usage Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md An immutable dataclass for comparing FL Studio versions. It supports major, minor, patch, and optional build numbers. Examples show instantiation, string representation, comparison, and parsing from project versions. ```python @dataclass(frozen=True, order=True) class FLVersion: major: int minor: int = 0 patch: int = 0 build: int | None = None def __str__(self) -> str # Returns "major.minor.patch" or "major.minor.patch.build" ``` ```python from pyflp.types import FLVersion v1 = FLVersion(20, 5, 1) v2 = FLVersion(21, 0, 0) print(f"v1: {v1}") # "20.5.1" print(v1 < v2) # True # Parse from project if project.version >= FLVersion(20, 0, 0): print("Modern FL Studio") ``` -------------------------------- ### Iterate All Effects in Project Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Loop through all inserts and slots in the mixer to access enabled plugins. ```python for insert in project.mixer: for slot in insert: if slot.enabled and slot.plugin: print(f"{insert.name} > {slot.name}: {slot.plugin.name}") ``` -------------------------------- ### Note Key - Set by Name and Integer Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Demonstrates setting the note's key by its string name (e.g., 'C5') or by its integer MIDI value (0-131). ```python # Set by name note.key = "C5" print(note.key) # "C5" # Set by integer (0-131) note.key = 60 print(note.key) # "C4" ``` -------------------------------- ### Accessing Instrument Polyphony Settings Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/channel.md Demonstrates how to access and print the polyphony settings (max voices and stacking mode) of an instrument if polyphony is configured. ```python if instrument.polyphony: print(f"Max voices: {instrument.polyphony.max_voices}") print(f"Stacking mode: {instrument.polyphony.stacking}") ``` -------------------------------- ### Get Number of Items on a Track Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Get the total number of playlist items currently on a track. ```python num_items = len(track) ``` -------------------------------- ### Load and Access Project Properties Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Demonstrates how to load an FLP file and access basic project properties like title and tempo. ```APIDOC ## Load and Access Project Properties ### Description Loads an FL Studio project file and provides access to its core properties. ### Method `pyflp.parse(filepath: str) -> Project` ### Parameters #### Path Parameters - **filepath** (str) - Required - The path to the .flp file to load. ### Response #### Success Response (Project Object) - **title** (str) - The title of the project. - **tempo** (float) - The tempo of the project in BPM. ### Request Example ```python import pyflp project = pyflp.parse("song.flp") print(f"Title: {project.title}") print(f"Tempo: {project.tempo} BPM") ``` ``` -------------------------------- ### Instantiate Project Class Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Represents an FL Studio project with full access to all project properties, channels, patterns, arrangements, and mixer settings. Users typically instantiate Project via `parse()` rather than directly. ```python class Project(EventModel) ``` -------------------------------- ### Create and Compare FLVersion Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Instantiate FLVersion objects to represent FL Studio versions and perform comparisons. Useful for conditional logic based on FL Studio version. ```python from pyflp.types import FLVersion version = FLVersion(20, 5, 1) version.major # 20 version.minor # 5 version.patch # 1 str(version) # "20.5.1" if version >= FLVersion(20, 0): # Modern FL Studio ``` -------------------------------- ### ppq Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Sets or gets the pulses per quarter (timebase) for the project. ```APIDOC ## ppq ### Description Pulses per quarter (timebase). Valid values: 24, 48, 72, 96, 120, 144, 168, 192, 384, 768, 960. ### Menu location Options > Project general settings > Timebase (PPQ) ### Note All length, position, and offset calculations use PPQ as a multiplier. ### Danger Changing this affects all timing calculations. FL Studio recalculates when changed in the UI, but PyFLP does not. ### Changed Default changed to 96 in FL Studio v2.1.1 ### Raises `ValueError` — When a value not in `VALID_PPQS` is set. ### Example ```python print(f"Project timebase: {project.ppq} PPQ") ``` ``` -------------------------------- ### Create Pattern Reference Sheet Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Generates a summary for each pattern in the project, including its ID, name, and counts of notes and controllers. Prints the information to the console. ```python print("Patterns in Project") print("-" * 50) for pattern in project.patterns: note_count = sum(1 for _ in pattern.notes) ctrl_count = sum(1 for _ in pattern.controllers) print(f"Pattern {pattern.iid:2d}: {pattern.name:20s} | {note_count:3d} notes, {ctrl_count:2d} controllers") ``` -------------------------------- ### Iterate Channels with Plugins Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Loops through all channels in a project and prints the name of the channel and its associated plugin if one exists. ```python for channel in project.channels: if channel.plugin: print(f"{channel.name}: {channel.plugin.name}") ``` -------------------------------- ### Get Total Number of Patterns Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Returns the total count of patterns present in the project. ```APIDOC ## Get Total Number of Patterns Returns the total number of patterns available in the project. ### Method `__len__(self) -> int` ### Raises - `NoModelsFound` — No patterns exist ### Example ```python num_patterns = len(project.patterns) ``` ``` -------------------------------- ### Load Project Source: https://github.com/demberto/pyflp/blob/master/_autodocs/INDEX.md Loads a project from a specified file path. ```APIDOC ## `parse(file)` ### Description Loads a project from a specified file path. ### Parameters #### Path Parameters - **file** (string) - Required - The path to the project file to load. ### Returns - **Project** - The loaded project object. ``` -------------------------------- ### Get Number of Effect Slots Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Returns the total count of effect slots within a mixer insert. ```APIDOC ## Get Number of Effect Slots Determine the number of effect slots available in an insert. ### Method `__len__()` ### Example ```python num_slots = len(insert) print(f"This insert has {num_slots} effect slots.") ``` ``` -------------------------------- ### show_info Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Determines whether to display a banner when loading the project in FL Studio. ```APIDOC ## show_info ### Description Whether to display a banner when loading the project in FL Studio. ### Menu location Options > Project info > Show info on opening ### Note Banner displays title, artists, genre, comments, and URL. ### Example ```python project.show_info = True ``` ``` -------------------------------- ### Accessing Plugin Information Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Illustrates how to check if a plugin is loaded in a slot and access its properties, such as name and vendor for VST plugins. ```python if slot.plugin: print(f"Effect: {slot.plugin.name}") if isinstance(slot.plugin, VSTPlugin): print(f"Vendor: {slot.plugin.vendor}") ``` -------------------------------- ### Accessing Channels Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/channel.md Provides methods to get a specific channel by its index or name, or to iterate over all channels in the rack. ```APIDOC ## Accessing Channels via ChannelRack ### Description The `ChannelRack` class, accessible via `project.channels`, allows users to retrieve individual channels by their zero-based index or unique name. It also supports slicing to get a range of channels and provides an iterator for looping through all channels. ### Methods #### `__getitem__` (Get Channel by Index or Name) ##### Description Retrieves a `Channel` object using either its integer index or its string name. ##### Parameters * **i** (`int` or `str`) - Required - The zero-based index or the name of the channel to retrieve. ##### Raises * `ChannelNotFound` - If no channel matches the provided index or name. ##### Example ```python # Get channel by index channel_by_index = project.channels[0] # Get channel by name lead_synth_channel = project.channels["Lead Synth"] # Get a slice of channels first_five_channels = project.channels[0:5] ``` #### `__iter__` (Iterate Over Channels) ##### Description Allows iteration over all `Channel` objects within the `ChannelRack`. ##### Example ```python for channel in project.channels: print(f"Channel Name: {channel.name}, IID: {channel.iid}") ``` #### `__len__` (Get Number of Channels) ##### Description Returns the total number of channels present in the `ChannelRack`. ##### Example ```python number_of_channels = len(project.channels) print(f"Total channels: {number_of_channels}") ``` ``` -------------------------------- ### Load and Inspect an FLP Project Source: https://github.com/demberto/pyflp/blob/master/_autodocs/INDEX.md Parses an FLP file and prints basic project information like title, tempo, and version. Requires the 'pyflp' library to be imported. ```python import pyflp project = pyflp.parse("song.flp") print(f"Title: {project.title}") print(f"Tempo: {project.tempo} BPM") print(f"Version: {project.version}") ``` -------------------------------- ### Set Track Queued State Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Set whether a track starts in a queued state. Defaults to False. ```python track.queued = False ``` -------------------------------- ### Access Project Properties Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Instantiate a Project object by parsing an FLP file and access its top-level properties like title, tempo, version, and main components. ```python project = pyflp.parse("song.flp") project.title # Project name project.tempo # BPM project.version # FL Studio version project.channels # ChannelRack project.patterns # Patterns project.arrangements # Arrangements project.mixer # Mixer ``` -------------------------------- ### Activate the Virtual Environment Source: https://github.com/demberto/pyflp/blob/master/docs/contributing.rst Activate the created virtual environment. The command differs based on your operating system. ```console ./venv/Scripts/activate ``` -------------------------------- ### Get Controller Channel Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Retrieves the channel associated with the controller event. This corresponds to the containing channel's IID. ```python channel_obj = project.channels[controller.channel - 1] ``` -------------------------------- ### Set Project Title Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Sets the title or name of the project. ```python project.title = "My Epic Track" ``` -------------------------------- ### Create and Checkout a New Branch Source: https://github.com/demberto/pyflp/blob/master/docs/contributing.rst Follow these commands to create a new branch for your feature or bugfix and switch to it. ```console git branch my_new_feature git checkout my_new_feature ``` -------------------------------- ### Get Total Number of Channels Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/channel.md Determine the total count of channels present in the ChannelRack. This can be used for validation or setting up loops. ```python num_channels = len(project.channels) ``` -------------------------------- ### Project Object Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md The main entry point for accessing all data within an FLP file. ```APIDOC ## Project Object ### Description The `Project` object is the root of the FLP file structure, containing all other components. ### Attributes - **title** (str) - The name of the project. - **tempo** (float) - The project's tempo in beats per minute (BPM). - **version** (str) - The version of FL Studio used to create the project. - **channels** (ChannelRack) - Access to the channel rack. - **patterns** (Patterns) - Access to the patterns. - **arrangements** (Arrangements) - Access to the arrangements. - **mixer** (Mixer) - Access to the mixer. ### Example ```python project = pyflp.parse("song.flp") print(f"Project Title: {project.title}") print(f"Tempo: {project.tempo}") ``` ``` -------------------------------- ### Get Pattern by Index, Name, or Slice Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Retrieve a specific `Pattern` object from the `Patterns` collection using its index, name, or a slice. ```APIDOC ## Get Pattern by Index, Name, or Slice Allows retrieval of a `Pattern` object using various methods. ### Method `__getitem__(self, i: int | str | slice) -> Pattern` ### Parameters #### Path Parameters - **i** (`int`, `str`, or `slice`) - Required - Zero-based index, pattern name, or slice ### Raises - `ModelNotFound` — Pattern not found ### Example ```python # By index pattern = project.patterns[0] # By name drum_pattern = project.patterns["Drums"] # By slice patterns_0_to_5 = project.patterns[0:5] ``` ``` -------------------------------- ### Set Project URL Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Associates a web link with the project. ```python project.url = "https://example.com" ``` -------------------------------- ### Get Effect Slot by Index or Name Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Retrieve a specific effect slot within an insert using its numerical index or its assigned name. ```APIDOC ## Get Effect Slot by Index or Name Access individual effect slots within an insert using their index or name. ### Method `insert[i: int | str]` ### Parameters - **i** (int or str) - Required - The index (0-based) or name of the slot. ### Raises - `ModelNotFound` - If the slot with the specified index or name does not exist. ### Example ```python # Get the first effect slot (index 0) first_effect_slot = insert[0] # Get the slot named 'EQ' eq_slot = insert["EQ"] ``` ``` -------------------------------- ### Iterate Through Patterns Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Demonstrates how to access and iterate through patterns and their notes within a project. ```APIDOC ## Iterate Through Patterns and Notes ### Description Accesses patterns within a project and iterates through the notes contained within each pattern. ### Method `project.patterns` (property of Project object) `pattern.notes` (property of Pattern object) ### Parameters `project.patterns` is an iterable property of the `Project` object. `pattern.notes` is an iterable property of each `Pattern` object. ### Response Each item in `project.patterns` is a `Pattern` object. Each item in `pattern.notes` is a `Note` object with the following properties: - **key** (int) - The MIDI key number of the note. - **position** (float) - The position of the note on the timeline. ### Request Example ```python # Assuming 'project' is a loaded Project object for pattern in project.patterns: for note in pattern.notes: print(f"Note {note.key} at {note.position}") ``` ``` -------------------------------- ### Get Total Number of Arrangements Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Obtain the total count of arrangements present in the project. This can be used to determine the scope of operations or for display purposes. ```python num_arrangements = len(project.arrangements) ``` -------------------------------- ### Iterate Through Channels Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Shows how to iterate through the channels within a loaded FLP project. ```APIDOC ## Iterate Through Channels ### Description Iterates over all channels defined in the FL Studio project. ### Method `project.channels` (property of Project object) ### Parameters This is an iterable property of the `Project` object returned by `pyflp.parse()`. ### Response Each item in the `project.channels` iterable is a `Channel` object with the following properties: - **iid** (int) - The internal ID of the channel. - **name** (str) - The name of the channel. ### Request Example ```python # Assuming 'project' is a loaded Project object for channel in project.channels: print(f"Channel {channel.iid}: {channel.name}") ``` ``` -------------------------------- ### List All Channels in a Project Source: https://github.com/demberto/pyflp/blob/master/_autodocs/INDEX.md Iterates through all channels in a loaded FLP project and prints their internal ID (iid) and name. Assumes a 'project' object has already been loaded. ```python for channel in project.channels: print(f"{channel.iid}: {channel.name}") ``` -------------------------------- ### Check Project File Format Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Use the FileFormat enumeration to identify the type of FL Studio project file. This is essential for handling different project types correctly. ```python from pyflp.project import FileFormat if project.format == FileFormat.Project: print("Standard FLP") ``` -------------------------------- ### Get Total Number of Mixer Inserts Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Determine the total count of inserts available in the mixer. This can be used for setting up loops or validating insert indices. ```python num_inserts = len(project.mixer) ``` -------------------------------- ### Get Currently Selected Pattern Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Retrieve the pattern that is currently selected in the project. This is useful for context-aware operations or for identifying the active pattern the user is working with. ```python if project.patterns.current: print(f"Selected: {project.patterns.current.name}") ``` -------------------------------- ### Create Plugin Data Model Source: https://github.com/demberto/pyflp/blob/master/docs/guides/plugin.rst Create a data model for the plugin event. This maps the binary structure to accessible Python properties. ```python class FruityBalance(_PluginBase[FruityBalanceEvent]): pan = _PluginDataProp[int]() volume = _PluginDataProp[int]() ``` -------------------------------- ### Project Class Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Represents the main FL Studio project object. ```APIDOC ## Project ### Description The main object representing an FL Studio project. It contains all other project elements like channels, patterns, and arrangements. ### Usage This class is typically instantiated when a project is loaded using the `parse()` function. ``` -------------------------------- ### Get Total Number of Patterns Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Obtain the total count of patterns available in the project. This can be used to understand the scale of the project or for setting up loops and data structures. ```python num_patterns = len(project.patterns) ``` -------------------------------- ### Clone the PyFLP Repository Source: https://github.com/demberto/pyflp/blob/master/docs/contributing.rst Use this command to clone the PyFLP repository from GitHub to your local machine. ```console git clone https://github.com/demberto/PyFLP ``` -------------------------------- ### Import Modulation and Arpeggiator Settings Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Import enumerations for LFO shape and arpeggiator direction. These are used to configure channel modulation and arpeggiation patterns. ```python from pyflp.channel import LFOShape, ArpDirection ``` -------------------------------- ### Get Track Item by Index or Slice Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Retrieve a playlist item from a track using its index or a slice. Ensure the track is converted to a list if direct indexing is needed. ```python track = list(arrangement.tracks)[0] first_item = track[0] items_0_to_5 = track[0:5] ``` -------------------------------- ### File Operations Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Functions for loading and saving FL Studio projects. ```APIDOC ## parse() ### Description Loads an FL Studio project from a file. ### Method ``` parse(filepath: str) ``` ### Parameters #### Path Parameters - **filepath** (str) - Required - The path to the FL Studio project file. ### Response #### Success Response (Project Object) - Returns a Project object representing the loaded project. ### Request Example ```python project = pyflp.parse("path/to/your/project.flp") ``` ``` ```APIDOC ## save() ### Description Saves the current project to a file. ### Method ``` save(project, filepath: str) ``` ### Parameters #### Path Parameters - **project** (Project) - Required - The Project object to save. - **filepath** (str) - Required - The path where the FL Studio project file will be saved. ### Request Example ```python pyflp.save(project, "path/to/save/project.flp") ``` ``` -------------------------------- ### Load, Access, and Save FLP Project Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Load an FLP project, access its properties like title and tempo, iterate through channels and patterns, and save modifications. Requires the 'pyflp' library. ```python import pyflp # Load a project project = pyflp.parse("song.flp") # Access properties print(f"Title: {project.title}") print(f"Tempo: {project.tempo} BPM") # Iterate channels for channel in project.channels: print(f"Channel {channel.iid}: {channel.name}") # Iterate patterns for pattern in project.patterns: for note in pattern.notes: print(f"Note {note.key} at {note.position}") # Save changes pyflp.save(project, "modified.flp") ``` -------------------------------- ### Iterate Through Patterns Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Access the Patterns collection from a Project object and iterate through individual Pattern objects to get their name, ID, length, loop mode, and access their notes and controllers. ```python for pattern in project.patterns: pattern.name # Pattern name pattern.iid # Pattern ID pattern.length # Duration pattern.looped # Loop mode pattern.notes # Iterator of Note objects pattern.controllers # Iterator of Controller objects ``` -------------------------------- ### Keyboard Class Source: https://github.com/demberto/pyflp/blob/master/docs/reference/channel/shared.rst Implements Keyboard functionality for channels. ```APIDOC ## Keyboard Class ### Description Implements Keyboard functionality for channels. ### Members This class has members that can be invoked by users. ``` -------------------------------- ### Get Effect Slot by Index or Name Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Retrieve an effect slot within a mixer insert using either its numerical index or its string name. Raises ModelNotFound if the slot does not exist. ```python first_effect = insert[0] ``` ```python eq_slot = insert["EQ"] ``` -------------------------------- ### Note Rack Channel - Get Containing Channel Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Retrieves the internal ID (IID) of the containing channel for the note. This can be used to access the channel object from the project's channels list. ```python channel = project.channels[note.rack_channel - 1] ``` -------------------------------- ### List VST Plugins Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Identifies and collects all channels and mixer slots that contain a VSTPlugin. Requires importing VSTPlugin from pyflp.plugin. ```python from pyflp.plugin import VSTPlugin vstplugins = [] for channel in project.channels: if isinstance(channel.plugin, VSTPlugin): vstplugins.append(channel) for insert in project.mixer: for slot in insert: if isinstance(slot.plugin, VSTPlugin): vstplugins.append(slot) ``` -------------------------------- ### Iterate Over All Arrangements Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Loop through all available arrangements in the project to perform actions on each one, such as printing their names and the number of tracks they contain. This is useful for batch processing or analysis. ```python for arrangement in project.arrangements: print(f"{arrangement.name}: {len(list(arrangement.tracks))} tracks") ``` -------------------------------- ### Parse FLP and Get Plugin Data Event Source: https://github.com/demberto/pyflp/blob/master/docs/guides/plugin.rst Use this snippet to parse an FLP file and extract the first plugin data event, which typically corresponds to the first loaded plugin. ```python import pyflp from pyflp.plugin import PluginID # Parse the FLP file into a project project = pyflp.parse("fruity-balance.flp") # Collect all the events as a dict of ID to event events = project.events_asdict() # Get the first plugin data event - the Fruity Balance one itself plugin_data_event = events[PluginID.Data][0] ``` -------------------------------- ### Iterate Through Tracks within an Arrangement Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Access the tracks of an Arrangement object and iterate through individual Track objects to get their name, ID, playback mode, color, and access the items (clips) they contain. ```python for track in arrangement.tracks: track.name # Track name track.iid # Track ID track.motion # Playback mode track.color # RGBA # Items can be ChannelPLItem or PatternPLItem for item in track: item.position # Position on timeline item.length # Duration ``` -------------------------------- ### Find Notes by Key Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Searches through all patterns and notes in a project to find notes matching a specific musical key. Returns a list of tuples, each containing a pattern and a matching note. ```python def find_notes_by_key(project, target_key): notes = [] for pattern in project.patterns: for note in pattern.notes: if note.key == target_key: notes.append((pattern, note)) return notes # Usage notes = find_notes_by_key(project, "C5") for pattern, note in notes: print(f"{pattern.name}: {note.key}") ``` -------------------------------- ### Access Project Patterns Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Returns a collection of all patterns in the project. Access patterns by index or name. ```python for pattern in project.patterns: print(f"Pattern {pattern.iid}: {pattern.name}") # Access by index or name pattern = project.patterns[0] pattern_by_name = project.patterns["MyPattern"] ``` -------------------------------- ### Set Channel Name Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/channel.md Illustrates how to change the display name of a channel in the FL Studio rack. ```python channel.name = "Main Lead Synth" ``` -------------------------------- ### FLVersion Type Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Represents the FL Studio version. ```APIDOC ## FLVersion ### Description An object representing the version of FL Studio. Contains information about major, minor, and patch versions. ``` -------------------------------- ### Iterate Through Patterns and Notes Source: https://github.com/demberto/pyflp/blob/master/_autodocs/INDEX.md Loops through all patterns in a project and then iterates over the notes within each pattern, printing the note's key and position. Requires a loaded 'project' object. ```python for pattern in project.patterns: print(f"Pattern: {pattern.name}") for note in pattern.notes: print(f" {note.key} @ {note.position}") ``` -------------------------------- ### Set Project Info Banner Visibility Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Controls whether a banner is displayed when loading the project in FL Studio. Set to True to show, False to hide. ```python project.show_info = True ``` -------------------------------- ### Set Project Comments Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Set the project description, comments, or summary text. PyFLP stores comments as plain text, even if older FL versions stored them in RTF. ```python project.comments = "Work in progress - 80% complete" ``` -------------------------------- ### version Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Retrieves the version of FL Studio used to save the file. ```APIDOC ## version ### Description Version of FL Studio used to save the file. Returned as a `FLVersion` object with major, minor, patch, and optional build fields. ### Caution Changing this to a lower version will not make newer events/plugins magically work. ### Raises - `PropertyCannotBeSet` — Should never occur; indicates possible corruption - `ValueError` — Invalid version format ### Example ```python print(f"Saved with FL Studio v{project.version}") if project.version >= FLVersion(20, 0, 0): print("Project uses FL Studio v20+") ``` ``` -------------------------------- ### Note Key - Iterate and Extract Octave Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Shows how to iterate through notes in a pattern and extract the octave from the note's key string. ```python # Iterate notes for note in pattern.notes: octave = note.key.lstrip('ACDFG#') print(f"Note: {note.key}") ``` -------------------------------- ### Access Arrangement by Index Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Access a specific arrangement within a project using its index. ```python project.arrangements[index] ``` -------------------------------- ### VSTPlugin Class Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Represents a VST/AU plugin. ```APIDOC ## VSTPlugin ### Description Represents a VST or AU plugin loaded into an effect slot. ### Inheritance Likely inherits from a base plugin class. ``` -------------------------------- ### List All Effects in Mixer Chain Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md Iterates through the mixer inserts and lists all enabled effects within each insert's slots. Displays slot information and the plugin name if an effect is present. ```python def list_mixer_effects(project): for insert in project.mixer: print(f"Insert {insert.iid}: {insert.name}") for slot in insert: if slot.enabled and slot.plugin: print(f" Slot {slot.iid}: {slot.plugin.name}") elif not slot.enabled: print(f" Slot {slot.iid}: (disabled)") list_mixer_effects(project) ``` -------------------------------- ### Insert Class Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Represents a mixer track. ```APIDOC ## Insert ### Description Represents a single mixer track (insert) in FL Studio. Allows control over volume, panning, and effects. ``` -------------------------------- ### Create a Virtual Environment Source: https://github.com/demberto/pyflp/blob/master/docs/contributing.rst This command creates a Python virtual environment named 'venv' in the current directory. It's recommended for isolating project dependencies. ```console python -m venv venv ``` -------------------------------- ### Set Project Main Pitch Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Set the master pitch in cents. The range is -1200 to +1200, with a default of 0. ```python project.main_pitch = 100 # Pitch up by 100 cents (1 semitone) ``` -------------------------------- ### Set Project Main Volume Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Set the master volume level. Can be up to 125% (+5.6dB). ```python project.main_volume = 100 ``` -------------------------------- ### Iterate Through Mixer Inserts Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Access the Mixer from a Project object and iterate through individual Insert objects to retrieve properties like name, ID, volume, color, and access their EQ settings and effect slots. ```python for insert in project.mixer: insert.name # Insert name insert.iid # Insert ID insert.volume # Volume level insert.color # RGBA insert.eq # InsertEQ for slot in insert: slot.plugin # Effect plugin slot.enabled # Slot active slot.mix # Dry/wet mix ``` -------------------------------- ### VersionNotDetected Exception Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Exception raised when the FL Studio version cannot be detected. ```APIDOC ## VersionNotDetected ### Description Exception raised when the version of the FL Studio project file cannot be determined. ### Inheritance Inherits from `Error`. ``` -------------------------------- ### Set Track Note Press Behavior Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Configure how notes are handled when triggered on a track. Options include 'Retrigger', 'HoldStop', 'HoldMotion', and 'Latch'. ```python track.press = TrackPress.Retrigger ``` -------------------------------- ### Set VST Plugin Wrapper Page Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md Change the active wrapper page/tab for the VST plugin. Requires importing WrapperPage. ```python from pyflp.plugin import WrapperPage channel.plugin.page = WrapperPage.Settings ``` -------------------------------- ### patterns Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Returns a collection of all patterns in the project with their related properties. ```APIDOC ## patterns ### Description Returns a collection of all patterns in the project with related properties. ### Returns `Patterns` — Collection of patterns ### Example ```python for pattern in project.patterns: print(f"Pattern {pattern.iid}: {pattern.name}") # Access by index or name pattern = project.patterns[0] pattern_by_name = project.patterns["MyPattern"] ``` ### See Also [Patterns Documentation](pattern.md) ``` -------------------------------- ### Save Project Source: https://github.com/demberto/pyflp/blob/master/_autodocs/INDEX.md Saves the given project to a specified file path. ```APIDOC ## `save(project, file)` ### Description Saves the given project to a specified file path. ### Parameters #### Path Parameters - **project** (Project) - Required - The project object to save. - **file** (string) - Required - The path to save the project file to. ### Returns - **None** ``` -------------------------------- ### parse Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/main.md Parses an FL Studio project file (.flp) and returns a Project object. Handles file paths as strings or pathlib.Path objects. Raises HeaderCorrupted or VersionNotDetected on errors. ```APIDOC ## parse ### Description Parses an FL Studio project file and returns a parsed `Project` object. ### Method ```python def parse(file: pathlib.Path | str) -> Project ``` ### Parameters #### Path Parameters - **file** (pathlib.Path | str) - Required - Path to the .flp file to parse ### Returns - **Project** - The parsed project object ### Raises - **HeaderCorrupted** - When an invalid value is found in the file header - **VersionNotDetected** - A correct string type couldn't be determined ### Example ```python import pyflp # Load a project project = pyflp.parse("/path/to/song.flp") # Access project properties print(f"Title: {project.title}") print(f"Tempo: {project.tempo} BPM") print(f"Version: {project.version}") ``` ``` -------------------------------- ### Check for Missing VSTs Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md Identifies VST plugins within project channels that do not have a specified plugin path. This is useful for troubleshooting missing plugin issues. ```python def find_missing_vsts(project): missing = [] for channel in project.channels: if isinstance(channel.plugin, VSTPlugin): if not channel.plugin.plugin_path: missing.append((channel, channel.plugin)) return missing for channel, vst in find_missing_vsts(project): print(f"Missing VST on {channel.name}: {vst.name}") ``` -------------------------------- ### FruityNotebook2 Class Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Represents the Fruity Notebook 2 plugin. ```APIDOC ## FruityNotebook2 ### Description Represents the Fruity Notebook 2 plugin, likely for managing notes or lyrics. ### Inheritance Inherits from `VSTPlugin`. ``` -------------------------------- ### VSTPlugin Object Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Represents a VST/AU plugin instance loaded in the project. ```APIDOC ## VSTPlugin Object ### Description Represents a VST or AU plugin instance loaded onto a channel or mixer insert. ### Attributes - **name** (str) - The name of the plugin. - **vendor** (str) - The manufacturer of the plugin. - **plugin_path** (str) - The file path to the plugin. - **generator** (bool) - Indicates if the plugin is an instrument. - **page** (int) - The currently displayed plugin page. - **state** (bytes) - The plugin's preset data. ### Example ```python if isinstance(channel.plugin, VSTPlugin): print(f"Plugin Name: {channel.plugin.name}, Vendor: {channel.plugin.vendor}") ``` ``` -------------------------------- ### Set Track Motion Mode Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/arrangement.md Configure the performance motion/playback mode for a track. Options include 'Stay', 'OneShot', 'MarchWrap', 'MarchStay', 'MarchStop', 'Random', and 'ExclusiveRandom'. ```python track.motion = TrackMotion.Stay ``` -------------------------------- ### Iterate Over Mixer Inserts and Their Slots Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/mixer.md Loop through all inserts in the mixer and their respective effect slots. This is useful for inspecting or modifying insert and slot properties. ```python for insert in project.mixer: print(f"Insert {insert.iid}: {insert.name}") for slot in insert: print(f" Slot {slot.iid}: {slot.name}") ``` -------------------------------- ### Tracking Class Source: https://github.com/demberto/pyflp/blob/master/docs/reference/channel/shared.rst Implements Tracking functionality for channels. ```APIDOC ## Tracking Class ### Description Implements Tracking functionality for channels. ### Members This class has members that can be invoked by users. ``` -------------------------------- ### Access Mixer Effects Slots Source: https://github.com/demberto/pyflp/blob/master/_autodocs/INDEX.md Traverses the mixer inserts and slots to print the names of plugins present in each slot. This code assumes a 'project' object is loaded and iterates through its mixer structure. ```python for insert in project.mixer: for slot in insert: if slot.plugin: print(f"{insert.name} > {slot.name}: {slot.plugin.name}") ``` -------------------------------- ### Convert Position to Musical Time Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/pattern.md Converts a pattern's note position (in PPQ units) into musical time, displaying the result in bars and beats. Requires the project's PPQ value for accurate calculation. ```python # Convert position to musical time position = pattern.notes[0].position bars = position // (project.ppq * 4) beats = (position % (project.ppq * 4)) // project.ppq print(f"Position: {bars} bars, {beats} beats") ``` -------------------------------- ### Find All VST Plugins Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/plugin.md Locates all VST plugins present in both project channels and mixer inserts. Returns a list of tuples containing the location (channel or mixer slot) and the plugin object. ```python def find_vst_plugins(project): vstplugins = [] for channel in project.channels: if isinstance(channel.plugin, VSTPlugin): vstplugins.append((channel, channel.plugin)) for insert in project.mixer: for slot in insert: if isinstance(slot.plugin, VSTPlugin): vstplugins.append((slot, slot.plugin)) return vstplugins for location, vst in find_vst_plugins(project): print(f"VST: {vst.name} by {vst.vendor}") ``` -------------------------------- ### Parse FLP File Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/main.md Use this function to load an FL Studio project file into a `Project` object for further manipulation. Ensure the file path is correct. ```python import pyflp # Load a project project = pyflp.parse("/path/to/song.flp") # Access project properties print(f"Title: {project.title}") print(f"Tempo: {project.tempo} BPM") print(f"Version: {project.version}") ``` -------------------------------- ### Configure Track Behavior Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Set playlist track behavior settings like motion, press, and trigger synchronization using the respective enumerations. This controls how tracks interact and respond. ```python from pyflp.arrangement import TrackMotion, TrackPress, TrackSync track.motion = TrackMotion.Random track.press = TrackPress.Retrigger track.trigger_sync = TrackSync.FourBeats ``` -------------------------------- ### WrapperPage Enumeration Source: https://github.com/demberto/pyflp/blob/master/_autodocs/types.md Represents the different pages or tabs available in a VST plugin wrapper. ```APIDOC ## WrapperPage ### Description Represents the different pages or tabs available in a VST plugin wrapper. ### Values - **Editor** (0): Plugin editor - **Settings** (1): VST wrapper settings - **Sample** (3): Sample settings - **Envelope** (4): Envelope/instrument - **Miscellaneous** (5): Miscellaneous ### Example ```python from pyflp.plugin import WrapperPage if hasattr(channel.plugin, 'page'): channel.plugin.page = WrapperPage.Settings ``` ``` -------------------------------- ### FileFormat Enumeration Source: https://github.com/demberto/pyflp/blob/master/_autodocs/types.md Represents FL Studio file format types. Use this to check or set the format of a project file. ```python class FileFormat(enum.IntEnum) ``` ```python from pyflp.project import FileFormat if project.format == FileFormat.Project: print("Standard FLP project") elif project.format == FileFormat.ChannelState: print("Channel preset file") ``` -------------------------------- ### Select VST Wrapper Page Source: https://github.com/demberto/pyflp/blob/master/_autodocs/README.md Use the WrapperPage enumeration to select specific pages within a VST plugin's wrapper interface. This allows programmatic control over plugin settings. ```python from pyflp.plugin import WrapperPage plugin.page = WrapperPage.Settings ``` -------------------------------- ### Set Project Licensed Status Source: https://github.com/demberto/pyflp/blob/master/_autodocs/api-reference/project.md Set whether the project was last saved with a licensed copy of FL Studio. Setting this to True and saving may allow the project to load in trial versions. ```python project.licensed = True ```