### Install and Configure Reapy Next Source: https://context7.com/wiccy46/reapy-next/llms.txt Commands for installing the package and initializing the REAPER distant API configuration. ```bash # Install the package pip install reapy-next # For local development pip install -e . # Configure REAPER (run with REAPER open) python -c "import reapy; reapy.configure_reaper()" # Test the installation python -c "import reapy; reapy.print('Hello from reapy!')" ``` -------------------------------- ### Install reapy using pip Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/install_guide.md Use this command to install the reapy library via pip. Ensure you have Python and pip installed. ```bash pip install reapy ``` -------------------------------- ### Test Reapy Installation Source: https://github.com/wiccy46/reapy-next/blob/main/README.md Verify your Reapy installation by printing a message to the Reaper console. ```python import reapy; reapy.print('a message') ``` -------------------------------- ### Check Python Installation (MacOS/Linux) Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/install_guide.md Verify if Python is installed on your MacOS or Linux system by running this command in the terminal. ```bash python --version ``` -------------------------------- ### Navigate Project Timeline Source: https://context7.com/wiccy46/reapy-next/llms.txt Move the project cursor to the start or end of the timeline using surface control methods. These simulate button presses. ```python project.current_surface_go_start() project.current_surface_go_end() ``` -------------------------------- ### Check Python Installation (Windows) Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/install_guide.md Verify if Python is installed on your Windows system by running this command in the terminal. ```bash py --version ``` -------------------------------- ### Configure REAPER with reapy (Windows) Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/install_guide.md Run this command in the terminal after installing reapy to configure REAPER. This command is for Windows users. ```python py -c "import reapy; reapy.configure_reaper()" ``` -------------------------------- ### Get Audio Samples Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Retrieve audio samples from an accessor. Use slicing to separate channels if multiple channels are requested. ```python >>> samples = audio_accessor.get_samples(0, 1024, 2) >>> first_channel = samples[::2] >>> second_channel = samples[1::2] ``` -------------------------------- ### GET /beat_to_ppq Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Converts beat number to MIDI ticks. ```APIDOC ## GET /beat_to_ppq ### Description Convert beat number (from project start) to MIDI ticks (of the take). ### Parameters #### Query Parameters - **beat** (float) - Required - Beat time to convert in beats. ### Response #### Success Response (200) - **ppq** (float) - Converted time in MIDI ticks of current take. ``` -------------------------------- ### Basic reapy Functions Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_guide.md Demonstrates fundamental reapy operations like printing to the console, clearing it, getting the REAPER version, and adding/getting command names. Use these for general REAPER interaction. ```pycon >>> import reapy >>> reapy.print("Hello world!") >>> reapy.clear_console() >>> reapy.get_reaper_version() '5.965/x64' >>> command_id = reapy.add_reascript(r"C:\path\to\my\reascript.py") >>> command_id 53007 >>> reapy.get_command_name(command_id) '_RSbcbf8f64cb92ff8062457098ee1194c7742e6431' ``` -------------------------------- ### Access FX Parameter by Index or Name Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Shows how to retrieve an FX parameter using its index or its string name. The example also demonstrates setting a parameter's value. ```python >>> params_list = fx.params >>> params_list[0] # Say this is "Dry Gain" parameter 0.5 >>> params_list["Dry Gain"] 0.5 >>> params_list["Dry Gain"] = 0.1 >>> params_list[0] 0.1 ``` -------------------------------- ### Get REAPER Project Instance Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_guide.md Instantiate a Project object to represent the current or a specific REAPER project. Use `index=-1` or no arguments for the current project, and `index` for other projects. ```python >>> reapy.Project() # Current project Project("(ReaProject*)0x0000000006D3AFF0") ``` ```python >>> reapy.Project(index=1) # Project in REAPER's second tab Project("(ReaProject*)0x000000000440A2D0") ``` ```python >>> reapy.Project(index=-1) # Current project Project("(ReaProject*)0x0000000006D3AFF0") ``` -------------------------------- ### Configure REAPER with reapy (MacOS/Linux) Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/install_guide.md Run this command in the terminal after installing reapy to configure REAPER. This command is for MacOS and Linux users. ```python python -c "import reapy; reapy.configure_reaper()" ``` -------------------------------- ### Set Project Time Selection Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Set the project's time selection using a tuple of start and end times in seconds. Can also be deleted. ```python project.time_selection = 3, 8 # seconds ``` ```python del project.time_selection ``` -------------------------------- ### Add Project Regions Source: https://context7.com/wiccy46/reapy-next/llms.txt Define new regions with start and end times, names, and colors. Regions are useful for segmenting the project. ```python # Add regions region = project.add_region( start=20.0, end=40.0, name="Chorus", color=(0, 255, 0) # Green ) ``` -------------------------------- ### Perform Reaper Action by ID Source: https://github.com/wiccy46/reapy-next/blob/main/README.md This example shows how to select the first track in a project and then perform a specific Reaper action using its ID. The action ID '40701' corresponds to 'Item: delete selected items'. ```python import reapy project = reapy.Project() track = project.tracks[0].select() project.perform_action(40701) ``` -------------------------------- ### Set Project Info String Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Set various project information strings, such as render paths, patterns, and formats. Refer to the documentation for specific parameter names. ```python project.set_info_string("RENDER_PATH", "/path/to/render") project.set_info_string("RENDER_FORMAT", "wave") ``` -------------------------------- ### Instantiate and access Tracks Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Shows how to access tracks via a project object or by direct instantiation using index or name. ```pycon >>> project = reapy.Project() >>> project.tracks[0] Track("(MediaTrack*)0x00000000110A1AD0") >>> project.tracks["PIANO"] # This is actually the same track Track("(MediaTrack*)0x00000000110A1AD0") ``` ```pycon >>> reapy.Track(0, project) Track("(MediaTrack*)0x00000000110A1AD0") ``` ```pycon >>> reapy.Track("PIANO", project) Track("(MediaTrack*)0x00000000110A1AD0") ``` -------------------------------- ### Build Project with Python Build Source: https://github.com/wiccy46/reapy-next/blob/main/dev/publish_guide.md Use the python -m build command to create distribution packages for the project. ```bash python -m build ``` -------------------------------- ### Enable FX Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Enables the FX, making it active. ```python enable() ``` -------------------------------- ### Get Normalized FX Parameter Value Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Illustrates how to get and set the normalized value of an FX parameter. It highlights that modifying the parameter directly can invalidate the existing FXParam object, requiring re-fetching. ```python >>> param = fx.params[0] >>> param 10.0 >>> param.normalized 0.5 >>> param.normalized = 1 >>> param, param.normalized 10.0, 0.5 >>> param = fx.params[0] >>> param, param.normalized 20.0, 1.0 ``` -------------------------------- ### Project Opening and Selection API Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Functions to open a project and select a project instance. ```APIDOC ## POST /api/project/open ### Description Opens a specified project. ### Method POST ### Endpoint /api/project/open ### Parameters #### Request Body - **project_path** (string) - Required - The file path to the project to open. ## POST /api/project/make_current ### Description Sets the specified project instance as the current project. ### Method POST ### Endpoint /api/project/make_current ### Parameters #### Request Body - **project_instance** (object) - Required - The project instance to make current. (Details depend on reapy implementation) ``` -------------------------------- ### GET /window/refresh Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Refreshes the specified window. ```APIDOC ## GET /window/refresh ### Description Triggers a refresh operation for the window instance. ``` -------------------------------- ### Commands Module Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.md Lists available commands for interacting with the DAW, such as automation, file operations, and options. ```APIDOC ## Commands Module ### Description Lists available commands for interacting with the DAW, such as automation, file operations, and options. ### Available Commands - **AUTOMATION_SET_SELECTED_TRACKS_LATCH** - **AUTOMATION_SET_SELECTED_TRACKS_READ** - **AUTOMATION_SET_SELECTED_TRACKS_TOUCH** - **AUTOMATION_SET_SELECTED_TRACKS_TRIM_READ** - **AUTOMATION_SET_SELECTED_TRACKS_WRITE** - **FILE_RENDER_DIALOG** - **ITEM_RENDER_TO_TAKE** - **OPTIONS_OPEN_PREFERENCES** - **OPTIONS_SHOW_METRONOME_SETTINGS** - **OPTIONS_TOGGLE_METRONOME** - **RENDER** - **RENDER_RECENT_SETTINGS** - **RENDER_RECENT_SETTINGS_AND_CLOSE_DIALOG** ``` -------------------------------- ### MIDI Time Conversion Utilities Source: https://context7.com/wiccy46/reapy-next/llms.txt Convert between seconds, beats, and MIDI ticks (PPQ) using take's utility methods. These are essential for precise timing. ```python ppq = take.time_to_ppq(1.0) # Seconds to MIDI ticks time = take.ppq_to_time(ppq) # MIDI ticks to seconds beat = take.ppq_to_beat(ppq) # MIDI ticks to beats ``` -------------------------------- ### Track Properties Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Properties for accessing the unique identifier (GUID) of a Track. ```APIDOC ## *property* GUID ### Description Track’s GUID. 16-byte GUID, can query or update. If using a `_String()` function, GUID is a string {xyz-…}. ### Type str ``` -------------------------------- ### Cursor Positioning API Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Functions for getting and setting the edit cursor position. ```APIDOC ## Cursor Position ### Description Gets or sets the current edit cursor position in seconds. ### Method Multiple (corresponds to SetEditCurPos, SetEditCurPos2 in REAPER SDK) ### Endpoint N/A (Scripting API) ### Parameters #### Request Body (for setting) - **position** (float) - Required - The desired cursor position in seconds. ### Request Example ```python # Example using reapy to set cursor position project.cursor_position = 10.5 # Example using reapy to get cursor position current_pos = project.cursor_position ``` ### Response (for getting) - **position** (float) - The current cursor position in seconds. ``` -------------------------------- ### POST /reapy.core.reaper.reaper.open_project Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.reaper.md Opens a REAPER project file from the specified path. ```APIDOC ## POST reapy.core.reaper.reaper.open_project ### Description Open project and return it. ### Parameters #### Request Body - **filepath** (str) - Required - Path to the project file. - **in_new_tab** (bool) - Optional - Whether to open project in new tab (default=False). - **make_current_project** (bool) - Optional - Whether to make opened project current project (default=True). ### Response #### Success Response (200) - **project** (Project) - Opened project object. ``` -------------------------------- ### Project Playback State Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Functions to get and set the playback state of a project. ```APIDOC ## CSurf_SetPlayState ### Description Sets the playback state for the current project. ### Method Not specified (likely a function call within REAPER's API). ### Endpoint N/A ### Parameters None explicitly defined in the provided text. ### Request Example N/A ### Response N/A ``` ```APIDOC ## CSurf_SetRepeatState ### Description Sets the repeat state for the current project. ### Method Not specified (likely a function call within REAPER's API). ### Endpoint N/A ### Parameters None explicitly defined in the provided text. ### Request Example N/A ### Response N/A ``` ```APIDOC ## GetAllProjectPlayStates ### Description Retrieves the play states for all projects. ### Method Not specified (likely a function call within REAPER's API). ### Endpoint N/A ### Parameters None explicitly defined in the provided text. ### Request Example N/A ### Response N/A ``` ```APIDOC ## GetPlayState ### Description Gets the current playback state (playing, paused, stopped, recording) of the project. ### Method Not specified (likely a function call within REAPER's API). ### Endpoint N/A ### Parameters None explicitly defined in the provided text. ### Request Example N/A ### Response N/A ``` ```APIDOC ## GetPlayStateEx ### Description Gets the playback state of the project. ### Method Not specified (likely a function call within REAPER's API). ### Endpoint N/A ### Parameters None explicitly defined in the provided text. ### Request Example N/A ### Response N/A ``` -------------------------------- ### Media Item Manipulation Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Functions for getting, setting, and manipulating media items. ```APIDOC ## GET /api/mediaitems/{itemId}/track ### Description Retrieves the track associated with a given media item. ### Method GET ### Endpoint /api/mediaitems/{itemId}/track ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. ### Response #### Success Response (200) - **trackId** (string) - The ID of the track the media item belongs to. #### Response Example { "trackId": "track_123" } ## GET /api/mediaitems/{itemId}/is_selected ### Description Checks if a media item is currently selected. ### Method GET ### Endpoint /api/mediaitems/{itemId}/is_selected ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. ### Response #### Success Response (200) - **selected** (boolean) - True if the item is selected, false otherwise. #### Response Example { "selected": true } ## GET /api/mediaitems/{itemId}/length ### Description Retrieves the length of a media item. ### Method GET ### Endpoint /api/mediaitems/{itemId}/length ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. ### Response #### Success Response (200) - **length** (number) - The length of the media item. #### Response Example { "length": 10.5 } ## GET /api/mediaitems/{itemId}/position ### Description Retrieves the position of a media item. ### Method GET ### Endpoint /api/mediaitems/{itemId}/position ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. ### Response #### Success Response (200) - **position** (number) - The position of the media item. #### Response Example { "position": 5.0 } ## POST /api/mediaitems/{itemId}/set_length ### Description Sets the length of a media item. ### Method POST ### Endpoint /api/mediaitems/{itemId}/set_length ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. #### Request Body - **length** (number) - Required - The new length for the media item. ### Request Example { "length": 12.0 } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item length updated successfully." } ## POST /api/mediaitems/{itemId}/set_position ### Description Sets the position of a media item. ### Method POST ### Endpoint /api/mediaitems/{itemId}/set_position ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. #### Request Body - **position** (number) - Required - The new position for the media item. ### Request Example { "position": 7.5 } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item position updated successfully." } ## POST /api/mediaitems/{itemId}/split ### Description Splits a media item at a specified position. ### Method POST ### Endpoint /api/mediaitems/{itemId}/split ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item to split. #### Request Body - **position** (number) - Required - The position at which to split the item. ### Request Example { "position": 8.0 } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item split successfully." } ## POST /api/mediaitems/{itemId}/update ### Description Updates a media item in the project. ### Method POST ### Endpoint /api/mediaitems/{itemId}/update ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item to update. ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item updated successfully." } ## POST /api/mediaitems/{itemId}/set_state_chunk ### Description Sets the state chunk of a media item. ### Method POST ### Endpoint /api/mediaitems/{itemId}/set_state_chunk ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. #### Request Body - **stateChunk** (string) - Required - The new state chunk for the media item. ### Request Example { "stateChunk": "" } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item state chunk updated successfully." } ## POST /api/mediaitems/{itemId}/set_value ### Description Sets a value for a media item. ### Method POST ### Endpoint /api/mediaitems/{itemId}/set_value ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. #### Request Body - **parameter** (string) - Required - The name of the parameter to set. - **value** (any) - Required - The new value for the parameter. ### Request Example { "parameter": "volume", "value": -3.0 } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item value updated successfully." } ## POST /api/mediaitems/{itemId}/set_take_value ### Description Sets a value for a take within a media item. ### Method POST ### Endpoint /api/mediaitems/{itemId}/set_take_value ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. #### Request Body - **takeIndex** (integer) - Required - The index of the take. - **parameter** (string) - Required - The name of the parameter to set. - **value** (any) - Required - The new value for the parameter. ### Request Example { "takeIndex": 0, "parameter": "gain", "value": 2.0 } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item take value updated successfully." } ## POST /api/mediaitems/{itemId}/set_take_source ### Description Sets the source for a take within a media item. ### Method POST ### Endpoint /api/mediaitems/{itemId}/set_take_source ### Parameters #### Path Parameters - **itemId** (string) - Required - The ID of the media item. #### Request Body - **takeIndex** (integer) - Required - The index of the take. - **sourceGuid** (string) - Required - The GUID of the source media. ### Request Example { "takeIndex": 0, "sourceGuid": "{some-guid-string}" } ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example { "message": "Media item take source updated successfully." } ``` -------------------------------- ### Window Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.md Methods for interacting with the REAPER window. ```APIDOC ## Window Methods ### Description Provides methods for interacting with the REAPER window. ### Methods - `Window.refresh()`: Refreshes the REAPER window. ``` -------------------------------- ### Managing project context Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Sets a project as the current project, optionally using a context manager to revert to the previous state automatically. ```pycon >>> p1 = reapy.Project() # current project >>> p2 = reapy.Project(1) # other project >>> p2.make_current_project() # now p2 is current project >>> with p1.make_current_project(): ... do_something() # current project is temporarily p1 >>> # and p2 is current project again ``` -------------------------------- ### GET /reapy.core.reaper.reaper.get_ini_file Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.reaper.md Retrieves the file system path to the REAPER.ini configuration file. ```APIDOC ## GET reapy.core.reaper.reaper.get_ini_file() ### Description Return path to REAPER.ini file. ### Response - **path** (str) - Path to REAPER.ini file. ``` -------------------------------- ### TimeSelection Properties Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Properties for accessing the start, end, and length of a time selection. ```APIDOC ## *property* end ### Description Return time selection end in seconds. ### Returns - **end** (float) - Time selection end in seconds. ## *property* is_looping ### Description Return whether looping is enabled. ### Returns - **looping** (bool) - Whether looping is enabled. ## *property* length ### Description Return time selection length in seconds. ### Returns - **length** (float) - Time selection length in seconds. ## *property* start ### Description Return time selection start in seconds. ### Returns - **start** (float) - Time selection start in seconds. ``` -------------------------------- ### Add Multiple MIDI Notes Efficiently Source: https://context7.com/wiccy46/reapy-next/llms.txt Add multiple MIDI notes in a loop and then sort them using `take.sort_events()`. Setting `sort=False` during batch insertion improves performance. ```python for i in range(8): take.add_note( start=i * 0.5, end=(i + 1) * 0.5 - 0.1, pitch=60 + (i % 12), velocity=80, sort=False # Don't sort until done ) take.sort_events() # Sort after batch insert ``` -------------------------------- ### Project Information API Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Functions to get and set project information, including string-based values. ```APIDOC ## GET /api/project/info ### Description Retrieves information about the current project. ### Method GET ### Endpoint /api/project/info ### Parameters #### Query Parameters - **key** (string) - Required - The key of the project info to retrieve. ### Response #### Success Response (200) - **value** (string) - The value associated with the project info key. ## POST /api/project/info ### Description Sets information for the current project. ### Method POST ### Endpoint /api/project/info ### Parameters #### Request Body - **key** (string) - Required - The key of the project info to set. - **value** (string) - Required - The value to set for the project info. ## GET /api/project/info/string ### Description Retrieves string-based information about the current project. ### Method GET ### Endpoint /api/project/info/string ### Parameters #### Query Parameters - **key** (string) - Required - The key of the project info string to retrieve. ### Response #### Success Response (200) - **value** (string) - The string value associated with the project info key. ## POST /api/project/info/string ### Description Sets string-based information for the current project. ### Method POST ### Endpoint /api/project/info/string ### Parameters #### Request Body - **key** (string) - Required - The key of the project info string to set. - **value** (string) - Required - The string value to set for the project info. ## GET /api/project/notes ### Description Retrieves the notes for the current project. ### Method GET ### Endpoint /api/project/notes ### Response #### Success Response (200) - **notes** (string) - The notes of the project. ## POST /api/project/notes ### Description Sets the notes for the current project. ### Method POST ### Endpoint /api/project/notes ### Parameters #### Request Body - **notes** (string) - Required - The notes to set for the project. ``` -------------------------------- ### Media Item Info Functions Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Functions for getting specific values from media item properties. ```APIDOC ## GET /api/media/item/{item_id}/info_value ### Description Retrieves a specific info value for a media item. ### Method GET ### Endpoint /api/media/item/{item_id}/info_value ### Parameters #### Path Parameters - **item_id** (integer) - Required - The ID of the media item. #### Query Parameters - **info_key** (string) - Required - The key for the info value to retrieve (e.g., 'DUR', 'POS'). ### Response #### Success Response (200) - **value** (float) - The requested info value. #### Response Example ```json { "value": 1.5 } ``` ``` -------------------------------- ### Compare ReaScript and reapy API usage Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/index.md Demonstrates the difference between using the native ReaScript Python API and the reapy wrapper for printing to the console. ```default >>> from reaper_python import * >>> RPR_ShowConsoleMsg("Hello world!") ``` ```default >>> import reapy >>> reapy.print("Hello world!") ``` -------------------------------- ### Get Envelope Derivatives Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Retrieve the first, second, and third order derivatives of an envelope at a specific time. ```pycon >>> envelope = track.envelopes["Pan"] >>> envelope.get_derivatives(10, raw=True) (0.10635556358181712, 0.2127113398749741, 0.21271155258652666) >>> envelope.get_value(10) # human-readable ('10%L', '21%L', '21%L') ``` -------------------------------- ### Audio Accessor Properties Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Retrieves properties of an audio accessor, such as its start time, end time, and hash. ```APIDOC ## Audio Accessor Properties ### Description Provides access to various properties of an audio accessor, including timing information and data integrity checks. ### Methods #### `AudioAccessor.end_time` ##### Description Gets the end time of the audio accessor. ##### ReaScript Equivalent `GetAudioAccessorEndTime` #### `AudioAccessor.hash` ##### Description Gets the hash of the audio accessor's data. ##### ReaScript Equivalent `GetAudioAccessorHash` #### `AudioAccessor.get_samples` ##### Description Retrieves audio samples from the accessor. ##### ReaScript Equivalent `GetAudioAccessorSamples` #### `AudioAccessor.start_time` ##### Description Gets the start time of the audio accessor. ##### ReaScript Equivalent `GetAudioAccessorStartTime` ``` -------------------------------- ### Source Object Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Methods and properties for interacting with media sources. ```APIDOC ## Source Class ### Description Represents a media source in REAPER. ### Properties - **filename** (str) - Source file name. - **has_valid_id** (bool) - Whether ReaScript ID is still valid. - **n_channels** (int) - Number of channels in source media. - **sample_rate** (int) - Source sample rate. - **type** (str) - Source type (e.g., WAV, MIDI). ### Methods - **delete()** - Delete source. - **length(unit: str)** - Return source length in 'seconds' or 'beats'. ``` -------------------------------- ### Get Envelope Value Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Retrieve the value of an envelope at a specific time, optionally returning the human-readable string format. ```pycon >>> envelope = track.envelopes["Pan"] >>> envelope.get_value(10, raw=True) -0.5145481809245827 >>> envelope.get_value(10) # human-readable '51%R' ``` -------------------------------- ### Get Visible FX Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Retrieves the visible FX in the track's FX chain. Returns None if there are no visible FX. ```python visible_fx ``` -------------------------------- ### Project Control Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Methods for controlling project playback, undo blocks, and track FX states. ```APIDOC ## Project Control Methods ### Description Methods to manipulate project playback, undo history, and track FX settings. ### Methods - **bypass_fx_on_all_tracks(bypass=True)**: Bypass or un-bypass FX on all tracks. - **close()**: Close project and its corresponding tab. - **disarm_rec_on_all_tracks()**: Disarm record on all tracks. - **end_undo_block(description='')**: End an undo block. ### Parameters - **bypass** (bool) - Whether to bypass FX. - **description** (str) - Undo block description. ``` -------------------------------- ### Item Methods and Properties Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Methods and properties for interacting with media items. ```APIDOC ## Item Methods and Properties ### add_take() Create and return a new take in item. * **Returns:** **take** – New take in item. * **Return type:** [Take](#reapy.core.Take) ### delete() Delete item. ### get_info_value(param_name) ### get_take(index) Return index-th take of item. * **Parameters:** **index** (*int*) – Take index. * **Returns:** **take** – index-th take of media item. * **Return type:** [Take](#reapy.core.Take) ### *property* has_valid_id Whether ReaScript ID is still valid. For instance, if item has been deleted, ID will not be valid anymore. * **Type:** bool ### *property* is_selected Return whether item is selected. * **Returns:** **is_selected** – Whether item is selected. * **Return type:** bool ### *property* length Return item length in seconds. * **Returns:** **length** – Item length in seconds. * **Return type:** float ### *property* n_takes Return the number of takes of media item. * **Returns:** **n_takes** – Number of takes of media item. * **Return type:** int ### *property* position Return item position in seconds. * **Returns:** **position** – Item position in seconds. * **Return type:** float ### *property* project Item parent project. * **Type:** reapy.Project ### set_info_value(param_name, value) ### split(position) Split item and return left and right parts. * **Parameters:** **position** (*float*) – Split position in seconds. * **Returns:** **left, right** – Left and right parts of the split. * **Return type:** [Item](#reapy.core.Item) ### *property* takes Return list of all takes of media item. * **Returns:** **takes** – List of all takes of media item. * **Return type:** list of [Take](#reapy.core.Take) ### *property* track Parent track of item. Set it by passing a track, or a track index. * **Type:** [Track](#reapy.core.Track) ### update() Update item in REAPER interface. ``` -------------------------------- ### Get Track Instrument in Reaper Source: https://context7.com/wiccy46/reapy-next/llms.txt Retrieve the instrument associated with a track. This property returns the instrument object if one is present. ```python instrument = track.instrument ``` -------------------------------- ### Publish to Test PyPI Source: https://github.com/wiccy46/reapy-next/blob/main/dev/publish_guide.md Upload distribution packages to TestPyPI for pre-release testing using twine. ```bash twine upload --repository-url https://test.pypi.org/legacy/ dist/* ``` -------------------------------- ### Access MIDI Notes and CC Events Source: https://context7.com/wiccy46/reapy-next/llms.txt Retrieve lists of notes and CC events from a take. Use `take.n_notes` and `take.n_cc` to get the count. ```python notes = take.notes print(f"Number of notes: {take.n_notes}") for note in notes: print(f"Pitch: {note.pitch}, Start: {note.start}, End: {note.end}") cc_events = take.cc_events print(f"Number of CC events: {take.n_cc}") ``` -------------------------------- ### Set Project Info Value Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Set project information values, typically numerical flags or settings for rendering. Use bitwise OR for multiple flags. ```python project.set_info_value("RENDER_SETTINGS", 64) project.set_info_value("RENDER_BOUNDSFLAG", 2) ``` -------------------------------- ### Project Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.md Provides methods for interacting with the current project. ```APIDOC ## Project Methods ### Description Methods for interacting with the current project. ### Methods - **add_marker(position, name, id)**: Adds a marker to the project. - **position** (float) - The position of the marker in beats. - **name** (str) - The name of the marker. - **id** (int) - The ID of the marker. - **add_region(start, end, name, id)**: Adds a region to the project. - **start** (float) - The start position of the region in beats. - **end** (float) - The end position of the region in beats. - **name** (str) - The name of the region. - **id** (int) - The ID of the region. - **add_track()**: Adds a new track to the project. - **any_track_solo** (bool) - Returns true if any track is soloed. - **beats_to_time(beats)**: Converts beats to time in seconds. - **beats** (float) - The number of beats to convert. ``` -------------------------------- ### Add Project Markers Source: https://context7.com/wiccy46/reapy-next/llms.txt Create new markers at specific positions in the project. Markers can be named and assigned a color using RGB values. ```python import reapy project = reapy.Project() # Add markers marker = project.add_marker( position=10.0, # Position in seconds name="Verse 1", color=(255, 128, 0) # Orange RGB color ) ``` -------------------------------- ### Control Recording Transport Source: https://context7.com/wiccy46/reapy-next/llms.txt Start and stop recording using surface controls or transport methods. `time.sleep` can be used to control recording duration. ```python # Start recording using surface controls project.current_surface_record() time.sleep(5) # Record for 5 seconds project.current_surface_stop() # Alternative: use transport controls project.record() # Hit record button time.sleep(5) project.stop() ``` -------------------------------- ### Get Track Envelope Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_guide.md Retrieve a track's envelope by its index, name, or chunk name. Envelopes represent parameters like Volume or Pan. ```python >>> envelope = track.get_envelope(index=0) >>> envelope.name 'Volume' ``` ```python >>> track.get_envelope(name="Volume") == envelope True ``` -------------------------------- ### Take Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Methods for manipulating MIDI events and properties within a Take object. ```APIDOC ## select_all_midi_events(select=True) ### Description Select or unselect all MIDI events. ### Method N/A (Method of Take object) ### Parameters #### Query Parameters - **select** (bool) - Optional - Whether to select or unselect events. ## sort_events() ### Description Sort MIDI events on take. This is only needed if `Take.add_note` was called with `sort=False`. ### Method N/A (Method of Take object) ### Parameters None ### Request Example ```python take.sort_events() ``` ## time_to_ppq(time) ### Description Convert time in seconds to MIDI ticks. ### Method N/A (Method of Take object) ### Parameters #### Query Parameters - **time** (float) - Required - Time to convert in seconds. ### Returns - **ppq** (float) - Converted time in MIDI ticks. ## unselect_all_midi_events() ### Description Unselect all MIDI events. ### Method N/A (Method of Take object) ### Parameters None ``` -------------------------------- ### Configure Track for Recording Source: https://context7.com/wiccy46/reapy-next/llms.txt Arm a track for recording and set its input channel. Use `recarm_change(1)` to arm and `set_info_value` for input selection. ```python import reapy import time project = reapy.Project() # Add and configure track for recording track = project.add_track(name="Recording Track") track.recarm_change(1) # Arm for recording track.set_info_value("I_RECINPUT", 0) # Input channel (0-based) ``` -------------------------------- ### Project Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Perform actions and modify settings within the Reaper project. ```APIDOC ## Project Methods ### Description Perform actions and modify settings within the Reaper project. ### Methods - **set_ext_state(section, key, value, pickled=False)** Sets the external state of the project. * **Parameters**: * **section** (str) - The section of the state. * **key** (str) - The key for the state. * **value** (Any or str) - The state value. Will be converted to string using pickle or JSON. * **pickled** (bool, optional) - If True, data will be pickled. * **Raises**: * **ValueError** - If the dumped value's length exceeds 2**31 - 2. - **set_info_string(param_name, param_string)** Sets an informational string parameter for the project. * **Parameters**: * **param_name** (str) - The name of the parameter (e.g., MARKER_GUID, RECORD_PATH, RENDER_FILE). * **param_string** (str) - The string value for the parameter. - **set_info_value(param_name, param_value)** Sets an informational float value parameter for the project. * **Parameters**: * **param_name** (str) - The name of the parameter (e.g., RENDER_SETTINGS, RENDER_BOUNDSFLAG, RENDER_CHANNELS). * **param_value** (float) - The float value for the parameter. - **solo_all_tracks()** Solos all tracks in the project. - **stop()** Simulates hitting the stop button in the transport. - **time_to_beats(time)** Converts a time value in seconds to beats. * **Parameters**: * **time** (float) - Time in seconds. * **Returns**: * **beats** (float) - Time in beats. - **undo()** Undoes the last action performed in the project. * **Raises**: * **UndoError** - If the action cannot be undone. - **unmute_all_tracks()** Unmutes all tracks in the project. - **unselect_all_tracks()** Deselects all tracks in the project. - **unsolo_all_tracks()** Unsolos all tracks in the project. ``` -------------------------------- ### Get MIDI Hash for Change Detection Source: https://context7.com/wiccy46/reapy-next/llms.txt Generate a hash value for the MIDI data in a take, useful for detecting changes. Set `notes_only` to `True` to exclude CC and other events. ```python hash_value = take.midi_hash(notes_only=False) ``` -------------------------------- ### Solo All Tracks Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Solos all tracks in the project. Use `unsolo_all_tracks` to revert. ```python project.solo_all_tracks() ``` -------------------------------- ### Project Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_guide.md Utilize methods of the Project class to perform actions within REAPER, such as making a project current, adding tracks, or playing the project. ```default >>> project.make_current_project() ``` ```default >>> track = project.add_track() ``` ```default >>> project.play() # Hit the play button ``` -------------------------------- ### Custom JSON Default Serialization Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.tools.md Implement the `default` method in a subclass of `ReapyEncoder` to handle custom object serialization. This example shows how to serialize arbitrary iterators by converting them to lists. ```default def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o) ``` -------------------------------- ### Get Current Project Name using ReaScript API Source: https://github.com/wiccy46/reapy-next/blob/main/README.md This snippet demonstrates how to access the Reaper ReaScript API to retrieve the name of the current project. Ensure 'reapy.reascript_api' is imported as 'RPR'. ```python from reapy import reascript_api as RPR print(RPR.GetProjectName()) ``` -------------------------------- ### Publish to Public PyPI Source: https://github.com/wiccy46/reapy-next/blob/main/dev/publish_guide.md Upload distribution packages to the public PyPI repository using twine. ```bash twine upload dist/* ``` -------------------------------- ### ToolTip Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Methods for controlling the visibility and refresh of ToolTip windows. ```APIDOC ## hide() ### Description Hide tooltip. ### Method N/A (Method of ToolTip object) ### Parameters None ## refresh() ### Description Refresh window. ### Method N/A (Method of ToolTip object) ### Parameters None ## show() ### Description Show tooltip. ### Method N/A (Method of ToolTip object) ### Parameters None ``` -------------------------------- ### Take Class Methods Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.md Methods for manipulating takes within media items, including FX and MIDI event management. ```APIDOC ## Take Methods ### Description Methods for adding content and effects to media takes. ### Methods - **add_fx(fx_name)**: Adds an FX to the take. - **add_note(start, end, pitch, velocity)**: Adds a MIDI note to the take. - **add_event(event)**: Adds a generic MIDI event to the take. ``` -------------------------------- ### Manage REAPER Projects Source: https://context7.com/wiccy46/reapy-next/llms.txt Access project properties, transport controls, and time selection using the Project class. ```python import reapy # Get current project project = reapy.Project() # Get project by tab index project_in_tab_2 = reapy.Project(index=1) # Project properties print(f"Project name: {project.name}") print(f"BPM: {project.bpm}") print(f"Length: {project.length} seconds") print(f"Number of tracks: {project.n_tracks}") # Set project tempo project.bpm = 140 # Transport controls project.play() project.pause() project.stop() project.record() # Cursor position management print(f"Cursor at: {project.cursor_position}") project.cursor_position = 10.0 # Move cursor to 10 seconds # Time selection project.time_selection = (5.0, 15.0) # Select 5-15 seconds # Save project project.save() ``` -------------------------------- ### POST /add_note Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Adds a MIDI note to the take. ```APIDOC ## POST /add_note ### Description Add MIDI note to take. ### Parameters #### Request Body - **start** (float) - Required - Note start. Unit depends on unit. - **end** (float) - Required - Note end. Unit depends on unit. - **pitch** (int) - Required - Note pitch between 0 and 127. - **velocity** (int) - Optional - Note velocity between 0 and 127 (default=100). - **channel** (int) - Optional - MIDI channel between 0 and 15. - **selected** (bool) - Optional - Whether to select new note (default=False). - **muted** (bool) - Required - Whether to mute new note (default=False). - **unit** (string) - Optional - Time unit for start and end (default="seconds"). - **sort** (bool) - Optional - Whether to resort notes after creating new note (default=True). ``` -------------------------------- ### Commands Class Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md A collection of command IDs for various REAPER actions. ```APIDOC ## Commands Class ### Description Provides a collection of command IDs for REAPER actions. ### Command IDs - **AUTOMATION_SET_SELECTED_TRACKS_LATCH** - **AUTOMATION_SET_SELECTED_TRACKS_READ** - **AUTOMATION_SET_SELECTED_TRACKS_TOUCH** - **AUTOMATION_SET_SELECTED_TRACKS_TRIM_READ** - **AUTOMATION_SET_SELECTED_TRACKS_WRITE** - **FILE_RENDER_DIALOG** - **ITEM_RENDER_TO_TAKE** - **OPTIONS_OPEN_PREFERENCES** - **OPTIONS_SHOW_METRONOME_SETTINGS** - **OPTIONS_TOGGLE_METRONOME** - **RENDER** - **RENDER_RECENT_SETTINGS** - **RENDER_RECENT_SETTINGS_AND_CLOSE_DIALOG** ``` -------------------------------- ### MIDI Time and Beat Conversion Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/api_table.md Methods for converting between PPQ positions, project beats, and project time. ```APIDOC ## Take.beat_to_ppq ### Description Converts a project beat position to a PPQ position. ## Take.time_to_ppq ### Description Converts a project time to a PPQ position. ## Take.ppq_to_beat ### Description Converts a PPQ position to a project beat position. ## Take.ppq_to_time ### Description Converts a PPQ position to a project time. ``` -------------------------------- ### Create and Manipulate MIDI Items Source: https://context7.com/wiccy46/reapy-next/llms.txt Add new MIDI items to tracks and access their active takes for further manipulation. Use `add_midi_item` to create items. ```python import reapy project = reapy.Project() track = project.tracks[0] # Create MIDI item midi_item = track.add_midi_item(start=0, end=4, quantize=False) take = midi_item.active_take ``` -------------------------------- ### Iterate and Print Track Names Source: https://github.com/wiccy46/reapy-next/blob/main/docs/source/reapy.core.md Demonstrates iterating through a project's tracks and printing their names. This is useful for accessing and manipulating individual tracks. ```python tracks = project.tracks len(tracks) tracks[0].name for track in tracks: print(track.name) ```