Python プロジェクト編集 API
アレンジを変更する Project のメンバーを載せています。ソース、トラック、クリップ、ワープ、オートメーション、パート、取り消し履歴です。MIDI のメンバーは Python プロジェクト MIDI API、Project のライフサイクルとその他のメンバーは Python プロジェクト API にあります。作業手順は プロジェクト & アレンジ編集 を参照してください。
ソース、トラック、クリップ、履歴
set_source_audio(source_id, channels, sample_rate) は、デコード済みのプレーナー PCM(長さが等しいチャンネルバッファ、またはチャンネル先行の配列)を受け取ります。sample_rate は 3 番目の引数です。set_clip_fade の長さは引き続き位置引数で渡せますが、キーワード名は fade_in_ppq と fade_out_ppq です。set_max_undo_depth(depth) は [1, 500000000] の整数を受け取り、範囲外の値ではクランプせず SonareValueError を送出します。
python
# Set the project sample rate in Hz.
def set_sample_rate(self, sample_rate: int) -> None: ...
# Return the ``uint32`` ids of audio sources that need PCM after deserialization.
def unresolved_audio_source_ids(self) -> np.ndarray: ...
# Return descriptors of audio sources that need PCM, with the full URI.
def unresolved_audio_sources(self) -> list[ProjectSource]: ...
# Register decoded, channels-first PCM for an existing audio source.
def set_source_audio(
self,
source_id: int,
channels: Sequence[Sequence[float] | np.ndarray] | np.ndarray,
sample_rate: int,
) -> None: ...
# Replace an audio source's metadata strings as one undoable edit.
def set_audio_source_metadata(
self,
source_id: int,
content_hash: str | None,
external_stem_role: str | None,
) -> None: ...
# Add a track and return its allocated stable id.
def add_track(self, kind: ProjectTrackKind = 'audio', name: str | None = None) -> int: ...
# Add an audio or MIDI clip and return its allocated clip id.
def add_clip(
self,
track_id: int,
start_ppq: float,
length_ppq: float,
*,
is_midi: bool = False,
source_offset_ppq: float = 0.0,
gain: float = 1.0,
audio: Sequence[float] | np.ndarray | None = None,
audio_channels: int | None = None,
audio_sample_rate: int | None = None,
source_uri: str | None = None,
) -> int: ...
# Import host-separated planar PCM as normal audio tracks and clips.
def import_external_stems(
self,
sample_rate: int,
stems: Sequence[Mapping[str, object]],
) -> ExternalSeparatedStemImportResult: ...
# Split a captured loop recording into takes and add one clip.
def add_loop_recording_takes(
self,
track_id: int,
start_ppq: float,
loop_length_ppq: float,
audio: Sequence[float] | Sequence[Sequence[float]] | np.ndarray,
*,
audio_channels: int | None = None,
audio_sample_rate: int,
partial_tail: str = 'keep',
) -> ProjectLoopRecordingResult: ...
# Create a MIDI track + clip; return a :class:`ProjectMidiClipResult`.
def add_midi_clip(self, start_ppq: float, length_ppq: float) -> ProjectMidiClipResult: ...
# Split a clip at ``split_ppq`` (absolute PPQ); return the new clip id.
def split_clip(self, clip_id: int, split_ppq: float) -> int: ...
# Trim a clip's start / length (PPQ).
def trim_clip(self, clip_id: int, new_start_ppq: float, new_length_ppq: float) -> None: ...
# Move a clip to ``new_start_ppq``, onto ``new_track_id`` when given.
def move_clip(
self,
clip_id: int,
new_start_ppq: float,
new_track_id: int | None = None,
) -> None: ...
# Change a track kind via an undoable edit command.
def set_track_kind(self, track_id: int, kind: ProjectTrackKind) -> None: ...
# Set a clip's warp reference id (``0`` clears it).
def set_clip_warp_ref(self, clip_id: int, warp_ref_id: int) -> None: ...
# Set a clip's warp playback mode.
def set_clip_warp_mode(self, clip_id: int, mode: ProjectWarpMode) -> None: ...
# Replace a clip's take list and active take via an undoable edit; ``[]`` clears it.
def set_clip_takes(
self,
clip_id: int,
takes: Sequence[Mapping[str, object]],
active_take_id: int | None = None,
) -> None: ...
# Replace a clip's comp lane via an undoable edit; ``[]`` clears it.
def set_clip_comp_segments(
self,
clip_id: int,
segments: Sequence[Mapping[str, object]],
) -> None: ...
# Add or replace a first-class project warp map.
def set_warp_map(
self,
warp_ref_id: int,
anchors: Sequence[tuple[float, float]],
name: str | None = None,
) -> None: ...
# Remove a first-class project warp map by id.
def remove_warp_map(self, warp_ref_id: int) -> None: ...
# Route a track's MIDI to host-instrument ``destination_id``.
def set_track_midi_destination(self, track_id: int, destination_id: int) -> None: ...
# Pick the rig for one part of a destination's instrument via an undoable edit.
def set_part_rig(
self,
destination_id: int,
part: int,
*,
mode: PartRigMode,
inserts: Sequence[Mapping[str, object]] | None = None,
) -> None: ...
# Read back :meth:`set_part_rig` as a :class:`PartRigEntry`, or ``None`` if unset.
def part_rig(self, destination_id: int, part: int) -> PartRigEntry | None: ...
# Remove one part-rig entry via an undoable edit (absent entries are a no-op).
def clear_part_rig(self, destination_id: int, part: int) -> None: ...
# Set a track's linear playback gain (1.0 = unity; >= 0) via an undoable edit.
def set_track_gain(self, track_id: int, gain: float) -> None: ...
# Set a track's mute flag via an undoable edit (a muted track is silent).
def set_track_mute(self, track_id: int, mute: bool) -> None: ...
# Set a track's solo flag via an undoable edit.
def set_track_solo(self, track_id: int, solo: bool) -> None: ...
# Set a track's stereo balance in [-1, +1] (0 = center) via an undoable edit.
def set_track_pan(self, track_id: int, pan: float) -> None: ...
# Remove a clip via an undoable edit command (undo restores it).
def remove_clip(self, clip_id: int) -> None: ...
# Set a clip's linear playback gain (at least 0; 0 = muted) via an undoable edit.
def set_clip_gain(self, clip_id: int, gain: float) -> None: ...
# Set a clip's fade-in and fade-out regions via an undoable edit.
def set_clip_fade(
self,
clip_id: int,
fade_in_ppq: float = 0.0,
fade_out_ppq: float = 0.0,
*,
fade_in_curve: ProjectFadeCurve = 'linear',
fade_out_curve: ProjectFadeCurve = 'linear',
) -> None: ...
# Set a clip's loop mode + loop length (PPQ) via an undoable edit.
def set_clip_loop(
self,
clip_id: int,
loop_mode: ProjectLoopMode = 'off',
loop_length_ppq: float | None = None,
loop_crossfade_ppq: float = 0.0,
) -> None: ...
# Rebind a clip to a different (already-registered) source via an undoable edit.
def set_clip_source(self, clip_id: int, source_id: int) -> None: ...
# Duplicate a clip at ``new_start_ppq`` (same track); return the new clip id.
def duplicate_clip(self, clip_id: int, new_start_ppq: float) -> int: ...
# Remove a track (and its clips) via an undoable edit command.
def remove_track(self, track_id: int) -> None: ...
# Rename a track via an undoable edit command (``None`` = empty name).
def rename_track(self, track_id: int, name: str | None = None) -> None: ...
# Set a track's mixer-strip binding + output target via an undoable edit.
def set_track_route(
self,
track_id: int,
channel_strip_ref: str | None = None,
output_target: str | None = None,
) -> None: ...
# Append a project-owned automation lane and return its lane id.
def add_automation_lane(
self,
track_id: int,
points: Sequence[AutomationPoint] | None = None,
*,
target_kind: ProjectAutomationTargetKind | None = None,
target_param_id: int | None = None,
send_id: str | None = None,
insert_index: int | None = None,
processor: str | None = None,
param_name: str | None = None,
) -> int: ...
# Replace a lane by its project-owned id via an undoable edit.
def edit_automation_lane(
self,
track_id: int,
lane_id: int,
points: Sequence[AutomationPoint] | None = None,
*,
target_kind: ProjectAutomationTargetKind | None = None,
target_param_id: int | None = None,
send_id: str | None = None,
insert_index: int | None = None,
processor: str | None = None,
param_name: str | None = None,
) -> None: ...
# Remove the lane identified by ``lane_id`` via an undoable edit.
def remove_automation_lane(self, track_id: int, lane_id: int) -> None: ...
# Undo the most recent edit (raises when the undo stack is empty).
def undo(self) -> None: ...
# Redo the most recently undone edit (raises when the redo stack is empty).
def redo(self) -> None: ...
# Empty the undo and redo stacks without altering project state.
def clear_history(self) -> None: ...
# Set undo depth in [1, 500000000] and evict the oldest excess entries.
def set_max_undo_depth(self, depth: int) -> None: ...
# Set the combined retained undo/redo history byte cap.
def set_max_history_bytes(self, bytes: int) -> None: ...