# AI MusiMuse

# 013_COMPOSITION_SEARCH.md

Version 1.0

---

# Purpose

The Composer should never generate the first possible continuation.

Instead it should explore multiple possible futures and choose the one that best matches the author's musical style.

Composition therefore becomes a search problem.

---

# Philosophy

Traditional music generators operate as

Current Context

↓

Next Token

↓

Next Token

↓

Next Token

AI MusiMuse operates as

Current State

↓

Possible Decisions

↓

Future Simulation

↓

Evaluation

↓

Best Decision

Generation is therefore planning rather than prediction.

---

# Search Loop

```
Current State

↓

Generate Candidates

↓

Simulate Futures

↓

Evaluate

↓

Select Best

↓

Update State

↓

Repeat
```

---

# Current State

At every generation step the Composer knows

Current section

Current energy

Current density

Current harmony

Current texture

Current motifs

Elapsed time

Remaining duration

User constraints

Style probabilities

---

# Candidate Generation

The Composer generates multiple possible decisions.

Example

```
Add Bass

Increase Energy

Return Theme

Create Break

Introduce Variation

Change Harmony

Do Nothing
```

Typically

```
5–20 candidates
```

per step.

---

# Future Simulation

Each candidate is expanded into a hypothetical future.

Example

```
Decision

↓

New State

↓

Next Decisions

↓

Future Composition
```

The simulation depth is configurable.

---

# Evaluation

Every simulated future receives a score.

Example

```
Style Score

0.91

Coherence

0.84

Novelty

0.73

Constraint Satisfaction

1.00

Overall

0.89
```

---

# Evaluation Components

Overall score consists of weighted terms.

```
Style Match

Structural Consistency

Energy Continuity

Density Continuity

Harmony Consistency

Motif Development

Novelty

Constraint Satisfaction
```

Weights are configurable.

---

# Style Score

Questions

```
Would the author probably do this

Has this transition occurred before

Does it resemble learned habits

Does it violate the Style Model
```

---

# Novelty Score

Novelty prevents copying.

Examples

```
Exact repetition

↓

Penalty

Small variation

↓

Preferred

Completely random

↓

Penalty
```

The highest score belongs to balanced originality.

---

# Constraint Score

Examples

```
Ambient only

No percussion

Long intro

Minor mode

Low energy
```

Constraint violations reduce the score.

---

# Beam Search

The default search algorithm is Beam Search.

Example

```
Width = 8

Depth = 5
```

Only the strongest candidates survive each expansion.

---

# Alternative Algorithms

The architecture supports

Beam Search

Monte Carlo Tree Search

A

Best First Search

Sampling

Hybrid Search

The Composer is independent of the search strategy.

---

# Search Tree

```
State

├── Decision A

│   ├── Future A1

│   └── Future A2

├── Decision B

│   ├── Future B1

│   └── Future B2

└── Decision C
```

Only the best path is selected.

---

# Decision Memory

During one generation the Composer stores

Visited states

Repeated motifs

Previous decisions

Current plan

This prevents loops.

---

# Replanning

The Composer may reconsider.

Example

```
Initial Plan

↓

Unexpected evaluation

↓

Choose different branch
```

Generation is adaptive.

---

# Randomness

Random Seed influences

candidate ordering

tie breaking

creative variation

The same seed always produces identical output.

---

# Determinism

Given

Style Model

Seed

Constraints

the Composer always produces the same composition.

---

# Future Neural Integration

In future versions

Candidate Generation

may be neural.

Evaluation

may be neural.

Search

remains explicit.

This keeps generation explainable.

---

# Explainability

Every generated decision can be explained.

Example

```
Decision

Return Theme

Reason

Occurs in 82% of similar compositions

Energy curve predicts thematic return

Matches user constraints
```

Generation should never be a black box.

---

# Design Principles

Planning before generation.

Multiple futures explored.

Search independent of AI model.

Evaluation independent of renderer.

Deterministic generation.

Explainable decisions.

---

# Long-Term Goal

The Composer should behave like a human composer,

who mentally explores several possible continuations,

rejects weaker ideas,

and develops the strongest one into a finished composition.