generative-music-composer
Creates algorithmic music composition systems using procedural generation, Markov chains, L-systems, and neural approaches for ambient, adaptive, and experimental music.
What this skill does
# Generative Music Composer
This skill provides guidance for creating algorithmic and procedural music systems that generate compositions autonomously or semi-autonomously.
## Core Competencies
- **Algorithmic Composition**: Rule-based music generation
- **Stochastic Methods**: Markov chains, probability distributions
- **Formal Grammars**: L-systems, generative grammars for music
- **Adaptive Systems**: Music that responds to input/context
- **Neural Approaches**: ML-based generation techniques
## Generative Music Fundamentals
### Generation Paradigms
| Approach | Description | Best For |
|----------|-------------|----------|
| Rule-based | Explicit compositional rules | Traditional styles, controlled output |
| Stochastic | Probability-driven selection | Natural variation, surprise |
| Grammar-based | Recursive structure generation | Complex forms, self-similarity |
| Constraint-based | Satisfy musical constraints | Harmony, voice leading |
| Learning-based | Train on corpus | Style imitation, novelty |
### Musical Elements to Generate
```
┌─────────────────────────────────────────────────────────┐
│ Music Generation Layers │
├─────────────────────────────────────────────────────────┤
│ │
│ Macro Structure │ Form, sections, key areas │
│ ──────────────────────────────────────────────────────│
│ Harmony │ Chord progressions, voice leading │
│ ──────────────────────────────────────────────────────│
│ Melody │ Pitch sequences, contour, rhythm │
│ ──────────────────────────────────────────────────────│
│ Rhythm │ Duration patterns, meter, groove │
│ ──────────────────────────────────────────────────────│
│ Timbre/Texture │ Instrumentation, dynamics │
│ ──────────────────────────────────────────────────────│
│ Micro Variation │ Ornaments, expression, humanize │
│ │
└─────────────────────────────────────────────────────────┘
```
## Stochastic Generation
### Markov Chain Melody
```python
import random
from collections import defaultdict
class MarkovMelodyGenerator:
"""Generate melodies using Markov chains"""
def __init__(self, order=2):
self.order = order
self.transitions = defaultdict(list)
def train(self, melodies):
"""Learn from existing melodies (lists of MIDI notes)"""
for melody in melodies:
for i in range(len(melody) - self.order):
state = tuple(melody[i:i + self.order])
next_note = melody[i + self.order]
self.transitions[state].append(next_note)
def generate(self, length, seed=None):
"""Generate a new melody"""
if seed is None:
seed = random.choice(list(self.transitions.keys()))
melody = list(seed)
for _ in range(length - self.order):
state = tuple(melody[-self.order:])
if state in self.transitions:
next_note = random.choice(self.transitions[state])
else:
# Fallback: random from all possible next notes
next_note = random.choice(
[n for notes in self.transitions.values() for n in notes]
)
melody.append(next_note)
return melody
```
### Weighted Random Selection
```python
def weighted_choice(options, weights):
"""Select with custom probability distribution"""
total = sum(weights)
r = random.uniform(0, total)
cumulative = 0
for option, weight in zip(options, weights):
cumulative += weight
if r <= cumulative:
return option
return options[-1]
# Scale degree probabilities (tendency tones)
scale_weights = {
1: 0.20, # Tonic - stable, common
2: 0.10, # Supertonic - passing
3: 0.15, # Mediant - stable
4: 0.10, # Subdominant - tendency to 3
5: 0.20, # Dominant - stable
6: 0.10, # Submediant - relative major/minor
7: 0.05, # Leading tone - strong tendency
8: 0.10 # Octave
}
def generate_scale_melody(length, key='C', scale='major'):
degrees = list(scale_weights.keys())
weights = list(scale_weights.values())
melody = [weighted_choice(degrees, weights) for _ in range(length)]
return [degree_to_midi(d, key, scale) for d in melody]
```
## Grammar-Based Generation
### L-System for Musical Structure
```python
class MusicalLSystem:
"""L-system for generating musical phrases"""
def __init__(self):
self.rules = {
'A': 'AB', # Antecedent expands to Antecedent + Bridge
'B': 'CA', # Bridge expands to Consequent + Antecedent
'C': 'DC', # Consequent expands to Development + Consequent
'D': 'A' # Development returns to Antecedent
}
self.interpretations = {
'A': self._phrase_a,
'B': self._phrase_b,
'C': self._phrase_c,
'D': self._phrase_d
}
def generate_structure(self, axiom='A', iterations=4):
"""Generate formal structure"""
result = axiom
for _ in range(iterations):
result = ''.join(self.rules.get(c, c) for c in result)
return result
def realize(self, structure):
"""Convert structure to musical phrases"""
phrases = []
for symbol in structure:
if symbol in self.interpretations:
phrases.append(self.interpretations[symbol]())
return phrases
def _phrase_a(self):
# Antecedent: tension-building phrase
return generate_phrase(contour='ascending', cadence='half')
def _phrase_b(self):
# Bridge: transitional material
return generate_phrase(contour='static', cadence='deceptive')
def _phrase_c(self):
# Consequent: resolution phrase
return generate_phrase(contour='descending', cadence='authentic')
def _phrase_d(self):
# Development: variation material
return generate_phrase(contour='varied', cadence='half')
```
### Generative Grammar for Rhythm
```python
class RhythmGrammar:
"""Context-free grammar for rhythm generation"""
def __init__(self):
# Non-terminal symbols with production rules
self.rules = {
'MEASURE': [
['HALF', 'HALF'],
['QUARTER', 'QUARTER', 'QUARTER', 'QUARTER'],
['DOTTED_HALF', 'QUARTER'],
['BEAT', 'BEAT', 'BEAT', 'BEAT']
],
'HALF': [
['QUARTER', 'QUARTER'],
['half']
],
'QUARTER': [
['EIGHTH', 'EIGHTH'],
['quarter'],
['SIXTEENTH', 'SIXTEENTH', 'EIGHTH']
],
'BEAT': [
['quarter'],
['EIGHTH', 'EIGHTH'],
['TRIPLET']
],
'EIGHTH': [
['eighth'],
['SIXTEENTH', 'SIXTEENTH']
],
'TRIPLET': [
['triplet', 'triplet', 'triplet']
],
'SIXTEENTH': [
['sixteenth']
]
}
def generate(self, symbol='MEASURE'):
"""Recursively expand grammar"""
if symbol not in self.rules:
return [symbol] # Terminal symbol
# Choose random production rule
production = random.choice(self.rules[symbol])
result = []
for s in production:
result.extend(self.generate(s))
return result
```
## Constraint-Based Harmony
### Voice Leading Rules
```python
class HarmonyGenerator:
"""Generate chord progressions with voice leading constraints"""
def __init__(self, key='C', mode='major'):
self.key = key
self.mode = mode
self.chord_vocabulary = self._build_chords()
def generatRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.