Adapt Synth¶
adapt_synth — Audio synthesis & music generation for G6 agents.
Cluster: Uncategorised | Type: component | MCP Tools: 34
Overview¶
adapt_synth is a useful creative/audio utility, not a launch-critical reliability component. For first-user onboarding, show it only when the user's workflow clearly needs generated tones, short musical patterns, sound effects, or audio analysis. The launch-critical path remains MCP install, clear workflow execution, structured errors, and reliability-oriented harness behavior.
Software synthesiser with 16 core DSP operations — oscillators, FM synthesis, noise generators, musical constructs (notes, chords, arpeggios, scales), ADSR envelopes, LFO modulation, effects (filter, reverb, delay, distortion), and step sequencing. Produces PCM audio as base64-encoded WAV.
The default curated path is bounded and deterministic: optional native backends are disclosed but policy-blocked unless explicitly enabled by the operator.
Advanced backend-native access is exposed only through explicit MCP adapter operations: backend_capabilities, backend_describe_op, backend_call, native_librosa_features, native_signalflow_render, native_nnaudio_transform, and native_audio_dsp_process. These native operations are allowlisted, schema-described, resource-bounded, and do not support arbitrary Python method execution, arbitrary imports, filesystem access, network access, or model/checkpoint loading.
Missing dependencies and policy-blocked backends return loud degradation envelopes with completion_state, warning_card, evidence, request_id, task_id, and run_id. Curated fallback-capable paths return qualified-draft; explicit unavailable native requests return blocked-escalated. Backend recommendation remains advisory and never self-certifies as verified.
When to use:
- Generating sound effects or musical patterns programmatically
- Building audio pipelines for AI creative workflows
- Composing drum patterns or melodic sequences from structured inputs
When not to use:
- As proof of G6's core reliability-layer value proposition
- As part of the default first-run workflow for non-technical users
- For production music mastering or broadcast delivery without downstream audio tooling such as
adapt_audiooradapt_ffmpeg
Example:
from mvp.adapt_synth import AdaptSynthBlock, SynthInput
block = AdaptSynthBlock(name="synth")
result = block.infer(SynthInput(op="chord", note="C4", chord_type="major", duration=2.0))
# result.ok → True; result.value → SynthOutput with audio_base64
Works well with: adapt_audio, adapt_ffmpeg, adapt_voice
Public API¶
BackendWorkloadProfile¶
Bounded workload profile that drives the backend recommendation.
| Field | Type | Default |
|---|---|---|
target_op | str | required |
gpu_available | bool | required |
realtime | bool | required |
spectral_precision | bool | required |
audio_duration_s | float | required |
Methods:
from_input(inp_or_kwargs: Any) -> 'BackendWorkloadProfile'¶
Build a profile from an MCPSynthInput-like object or a dict of kwargs.
BackendRecommendation¶
Decision record for a ranked audio-backend recommendation.
| Field | Type | Default |
|---|---|---|
ranked_backends | tuple[str, ...] | () |
rationale | str | '' |
confidence | float | 0.0 |
completion_state | str | 'qualified-draft' |
degraded | bool | False |
raw_response | str | '' |
metadata | dict[str, Any] | field(default_factory=dict) |
Methods:
choice() -> str¶
Compatibility accessor for the top-ranked backend.
BackendPlanner¶
Runtime-first facade with the real deterministic recommender as fallback.
Constructor:
| Parameter | Type | Default |
|---|---|---|
runtime | BackendRuntime \| None | None |
Methods:
recommend(profile: BackendWorkloadProfile) -> BackendRecommendation¶
SynthBackendPatternRuntime¶
Stateless executable mechanisms for adapt_synth's applied patterns.
Methods:
deconflict(ranked_backends: tuple[str, ...], eligible_backends: tuple[str, ...]) -> SynthBackendPatternReview¶
failover-aware-model-fallback guard (one-way de-risking).
SynthInput(BaseModel)¶
Input for :class:
AdaptSynthBlock— 16 core synthesis operations.
| Field | Type | Default |
|---|---|---|
op | Literal['oscillator', 'fm_synth', 'noise', 'note', 'chord', 'arpeggio', 'scale', 'envelope', 'lfo', 'filter', 'reverb', 'delay', 'distortion', 'sequence', 'drum_pattern', 'analyze'] | 'note' |
waveform | str | 'sine' |
frequency | float | Field(default=440.0, gt=0.0, le=20000.0) |
duration | float | Field(default=1.0, gt=0.0, le=30.0) |
sample_rate | int | Field(default=44100, ge=8000, le=192000) |
volume | float | Field(default=0.8, ge=0.0, le=1.0) |
note | str | 'A4' |
notes | str | '' |
chord_type | str | 'major' |
scale_type | str | 'major' |
octaves | int | Field(default=1, ge=1, le=4) |
attack | float | Field(default=0.01, ge=0.0, le=10.0) |
decay | float | Field(default=0.05, ge=0.0, le=10.0) |
sustain | float | Field(default=0.7, ge=0.0, le=1.0) |
release | float | Field(default=0.1, ge=0.0, le=10.0) |
mod_freq | float | Field(default=0.0, ge=0.0, le=20000.0) |
mod_index | float | Field(default=1.0, ge=0.0, le=100.0) |
filter_type | str | 'lowpass' |
cutoff | float | Field(default=1000.0, gt=0.0) |
cutoff_high | float | Field(default=5000.0, gt=0.0) |
reverb_decay | float | Field(default=0.5, ge=0.0, le=0.99) |
delay_ms | float | Field(default=250.0, ge=0.0, le=5000.0) |
feedback | float | Field(default=0.3, ge=0.0, le=0.95) |
effect_mix | float | Field(default=0.5, ge=0.0, le=1.0) |
distortion_gain | float | Field(default=2.0, ge=0.0, le=100.0) |
lfo_rate | float | Field(default=5.0, ge=0.0, le=100.0) |
lfo_depth | float | Field(default=0.5, ge=0.0, le=1.0) |
bpm | float | Field(default=120.0, gt=0.0, le=1000.0) |
pattern | str | '' |
note_duration | float | Field(default=0.0, ge=0.0, le=10.0) |
noise_type | str | 'white' |
audio_base64 | str | '' |
SynthOutput(BaseModel)¶
Output from :class:
AdaptSynthBlock.
| Field | Type | Default |
|---|---|---|
op | str | required |
audio_base64 | str | '' |
duration_seconds | float | 0.0 |
sample_rate | int | 0 |
channels | int | 0 |
size_bytes | int | 0 |
metadata | dict[str, Any] | Field(default_factory=dict) |
degraded | bool | False |
degradation_reason | str | '' |
selected_backend | str | '' |
preferred_backend | str | '' |
fallback_reason | str | '' |
fallback_backend | str | '' |
capability_missing | bool | False |
BackendSkillCatalog¶
Maps each applied pattern slug to an adapt_synth backend-recommendation skill.
Methods:
list_skills() -> list[BackendSkill]¶
executable_skills() -> list[BackendSkill]¶
get(slug: str) -> BackendSkill | None¶
AdaptSynthBlock(AIBlock[SynthInput, SynthOutput, None])¶
Multi-operation audio synthesis block.
| Field | Type | Default |
|---|---|---|
name | str | 'adapt_synth' |
resource_bounds | ResourceBounds \| None | None |
usage | ResourceUsage | field(default_factory=ResourceUsage) |
Methods:
infer(data: SynthInput) -> Result[SynthOutput]¶
MCPSynthInput(BaseModel)¶
Input for :class:
AdaptSynthMCPBlock— 27 operations.
| Field | Type | Default |
|---|---|---|
op | Literal['oscillator', 'fm_synth', 'noise', 'note', 'chord', 'arpeggio', 'scale', 'envelope', 'lfo', 'filter', 'reverb', 'delay', 'distortion', 'sequence', 'drum_pattern', 'analyze', 'save', 'load', 'list', 'delete', 'save_preset', 'load_preset', 'list_presets', 'stats', 'get_info', 'backend_recommend', 'list_patterns', 'backend_capabilities', 'backend_describe_op', 'backend_call', 'native_librosa_features', 'native_signalflow_render', 'native_nnaudio_transform', 'native_audio_dsp_process'] | 'note' |
waveform | str | 'sine' |
frequency | float | Field(default=440.0, gt=0.0, le=20000.0) |
duration | float | Field(default=1.0, gt=0.0, le=30.0) |
sample_rate | int | Field(default=44100, ge=8000, le=192000) |
volume | float | Field(default=0.8, ge=0.0, le=1.0) |
note | str | 'A4' |
notes | str | '' |
chord_type | str | 'major' |
scale_type | str | 'major' |
octaves | int | Field(default=1, ge=1, le=4) |
attack | float | Field(default=0.01, ge=0.0, le=10.0) |
decay | float | Field(default=0.05, ge=0.0, le=10.0) |
sustain | float | Field(default=0.7, ge=0.0, le=1.0) |
release | float | Field(default=0.1, ge=0.0, le=10.0) |
mod_freq | float | Field(default=0.0, ge=0.0, le=20000.0) |
mod_index | float | Field(default=1.0, ge=0.0, le=100.0) |
filter_type | str | 'lowpass' |
cutoff | float | Field(default=1000.0, gt=0.0) |
cutoff_high | float | Field(default=5000.0, gt=0.0) |
reverb_decay | float | Field(default=0.5, ge=0.0, le=0.99) |
delay_ms | float | Field(default=250.0, ge=0.0, le=5000.0) |
feedback | float | Field(default=0.3, ge=0.0, le=0.95) |
effect_mix | float | Field(default=0.5, ge=0.0, le=1.0) |
distortion_gain | float | Field(default=2.0, ge=0.0, le=100.0) |
lfo_rate | float | Field(default=5.0, ge=0.0, le=100.0) |
lfo_depth | float | Field(default=0.5, ge=0.0, le=1.0) |
bpm | float | Field(default=120.0, gt=0.0, le=1000.0) |
pattern | str | '' |
note_duration | float | Field(default=0.0, ge=0.0, le=10.0) |
noise_type | str | 'white' |
audio_base64 | str | '' |
name | str | '' |
tags_csv | str | '' |
notes_text | str | '' |
limit | int | Field(default=50, ge=1, le=500) |
preset_params | str | '' |
target_op | str | 'analyze' |
gpu_available | bool | False |
realtime | bool | False |
spectral_precision | bool | False |
audio_duration_s | float | 0.0 |
request_id | str | '' |
task_id | str | '' |
run_id | str | '' |
backend_name | str | '' |
native_action | str | '' |
native_params | dict[str, Any] | Field(default_factory=dict) |
max_duration_seconds | float | Field(default=30.0, gt=0.0, le=30.0) |
max_samples | int | Field(default=1323000, ge=1, le=1323000) |
allow_gpu | bool | False |
MCPSynthOutput(BaseModel)¶
Output from :class:
AdaptSynthMCPBlock.
| Field | Type | Default |
|---|---|---|
op | str | required |
audio_base64 | str | '' |
duration_seconds | float | 0.0 |
sample_rate | int | 0 |
channels | int | 0 |
size_bytes | int | 0 |
metadata | dict[str, Any] | Field(default_factory=dict) |
name | str | '' |
found | bool | False |
count | int | 0 |
records | list[dict[str, Any]] | Field(default_factory=list) |
patterns | list[dict[str, Any]] | Field(default_factory=list) |
message | str | '' |
degraded | bool | False |
degradation_reason | str | '' |
selected_backend | str | '' |
preferred_backend | str | '' |
fallback_backend | str | '' |
fallback_reason | str | '' |
capability_missing | bool | False |
completion_state | Literal['verified', 'qualified-draft', 'blocked-escalated'] | 'qualified-draft' |
warning_card | dict[str, Any] \| None | None |
evidence | dict[str, Any] | Field(default_factory=dict) |
request_id | str | '' |
task_id | str | '' |
run_id | str | '' |
SynthStore¶
SQLite store with two tables:
synth_filesandsynth_presets.
Constructor:
| Parameter | Type | Default |
|---|---|---|
db_path | str | ':memory:' |
Methods:
save_file(name: str, audio_base64: str, duration_seconds: float = 0.0, sample_rate: int = 44100, channels: int = 1, size_bytes: int = 0, op: str = '', tags: str = '', notes: str = '', metadata: dict[str, Any] | None = None) -> str¶
load_file(name: str) -> dict[str, Any] | None¶
list_files(tags_csv: str = '', limit: int = 50) -> list[dict[str, Any]]¶
delete_file(name: str) -> bool¶
save_preset(name: str, params: dict[str, Any], tags: str = '', notes: str = '') -> str¶
load_preset(name: str) -> dict[str, Any] | None¶
list_presets(limit: int = 50) -> list[dict[str, Any]]¶
count_files() -> int¶
count_presets() -> int¶
total_size() -> int¶
total_duration() -> float¶
AdaptSynthMCPBlock(AIBlock[MCPSynthInput, MCPSynthOutput, dict])¶
27-op synthesis MCP block with SQLite persistence.
| Field | Type | Default |
|---|---|---|
name | str | 'adapt_synth_mcp' |
state | dict | field(default_factory=dict) |
db_path | str | field(default_factory=lambda: os.environ.get('SYNTH_DB_PATH', _DEFAULT_DB)) |
resource_bounds | ResourceBounds | field(default_factory=ResourceBounds) |
usage | ResourceUsage | field(default_factory=ResourceUsage) |
agentic_planner | BackendPlanner \| None | None |
Methods:
infer(data: MCPSynthInput) -> Result[MCPSynthOutput]¶
Functions¶
summarize_adapt_synth_agentic_evidence(decisions: list[dict[str, Any]]) -> dict[str, Any]¶
Summarise runtime-vs-fallback recommendation decisions with path redaction.
agentic_planner_enabled(default_enabled: bool, llm_backend: str | None = None) -> bool¶
Decide whether the agentic recommendation planner should be used.
validate_backend_recommendation(rec: BackendRecommendation) -> None¶
Reject an unusable recommendation (fail closed on unknown backend names).
eligible_backends(target_op: str) -> tuple[str, ...]¶
FIXED eligible-set ceiling, computed DETERMINISTICALLY (no LLM).
deterministic_backend_recommend(target_op: str) -> BackendRecommendation¶
Demoted-real render-preference ranking, intersected with the eligible ceiling.
applied_agentic_patterns() -> list[dict[str, Any]]¶
Return compact metadata for adapt_synth-applied vendored patterns.
get_skill_catalog() -> BackendSkillCatalog¶
MCP Tools¶
| Operation | Source |
|---|---|
oscillator | synth_mcp |
fm_synth | synth_mcp |
noise | synth_mcp |
note | synth_mcp |
chord | synth_mcp |
arpeggio | synth_mcp |
scale | synth_mcp |
envelope | synth_mcp |
lfo | synth_mcp |
filter | synth_mcp |
reverb | synth_mcp |
delay | synth_mcp |
distortion | synth_mcp |
sequence | synth_mcp |
drum_pattern | synth_mcp |
analyze | synth_mcp |
save | synth_mcp |
load | synth_mcp |
list | synth_mcp |
delete | synth_mcp |
save_preset | synth_mcp |
load_preset | synth_mcp |
list_presets | synth_mcp |
stats | synth_mcp |
get_info | synth_mcp |
backend_recommend | synth_mcp |
list_patterns | synth_mcp |
backend_capabilities | synth_mcp |
backend_describe_op | synth_mcp |
backend_call | synth_mcp |
native_librosa_features | synth_mcp |
native_signalflow_render | synth_mcp |
native_nnaudio_transform | synth_mcp |
native_audio_dsp_process | synth_mcp |