- Add DrumLoopAnalyzer: extracts BPM, transients, key, beat grid from drumloops - Rewrite compose.py: drumloop drives everything (BPM, key, rhythm) - Bass tresillo pattern placed in kick-free zones - Chords change on downbeats matching drumloop key - Melody avoids transients, emphasizes chord tones - Vocal chops between transients, clap on dembow (beats 2, 3.5) - Remove COLOR token (not recognized by REAPER) - 90 tests passing, generates drumloop_song.rpp with 10 tracks, 20 plugins
147 lines
4.7 KiB
Python
147 lines
4.7 KiB
Python
"""Tests for section builder — SectionDef, track builders, plugin helpers."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parents[1]))
|
|
|
|
import pytest
|
|
from src.core.schema import SectionDef, PluginDef
|
|
|
|
|
|
class TestSectionDef:
|
|
def test_section_def_instantiation(self):
|
|
section = SectionDef(name="chorus", bars=8, energy=0.9)
|
|
assert section.name == "chorus"
|
|
assert section.bars == 8
|
|
assert section.energy == 0.9
|
|
assert section.velocity_mult == 1.0
|
|
assert section.vol_mult == 1.0
|
|
|
|
def test_section_def_default_energy(self):
|
|
section = SectionDef(name="verse", bars=8)
|
|
assert section.energy == 0.5
|
|
assert section.velocity_mult == 1.0
|
|
assert section.vol_mult == 1.0
|
|
|
|
def test_section_def_custom_mults(self):
|
|
section = SectionDef(
|
|
name="intro", bars=4, energy=0.3,
|
|
velocity_mult=0.4, vol_mult=0.6,
|
|
)
|
|
assert section.velocity_mult == 0.4
|
|
assert section.vol_mult == 0.6
|
|
|
|
|
|
class TestPluginRegistry:
|
|
def test_plugins_in_registry(self):
|
|
from src.reaper_builder import PLUGIN_REGISTRY
|
|
assert "Decapitator" in PLUGIN_REGISTRY
|
|
assert "EchoBoy" in PLUGIN_REGISTRY
|
|
assert "Serum_2" in PLUGIN_REGISTRY
|
|
assert "Omnisphere" in PLUGIN_REGISTRY
|
|
assert "Pro-Q_3" in PLUGIN_REGISTRY
|
|
assert "Pro-C_2" in PLUGIN_REGISTRY
|
|
assert "Pro-L_2" in PLUGIN_REGISTRY
|
|
assert "FabFilter_Pro-R_2" in PLUGIN_REGISTRY
|
|
assert "ValhallaDelay" in PLUGIN_REGISTRY
|
|
assert "PhaseMistress" in PLUGIN_REGISTRY
|
|
assert "Tremolator" in PLUGIN_REGISTRY
|
|
assert "Radiator" in PLUGIN_REGISTRY
|
|
assert "Gullfoss_Master" in PLUGIN_REGISTRY
|
|
assert "VC_76" in PLUGIN_REGISTRY
|
|
|
|
|
|
class TestMakePlugin:
|
|
def test_make_plugin_known_key(self):
|
|
from scripts.compose import make_plugin
|
|
p = make_plugin("Decapitator", 0)
|
|
assert p.name == "Decapitator"
|
|
assert p.index == 0
|
|
|
|
def test_make_plugin_unknown_key(self):
|
|
from scripts.compose import make_plugin
|
|
p = make_plugin("NonExistent", 2)
|
|
assert p.name == "NonExistent"
|
|
assert p.index == 2
|
|
|
|
|
|
class TestBuildFxChain:
|
|
def test_build_fx_chain_returns_list(self):
|
|
from scripts.compose import build_fx_chain
|
|
assert build_fx_chain() == []
|
|
|
|
def test_build_fx_chain_with_args(self):
|
|
from scripts.compose import build_fx_chain
|
|
assert build_fx_chain("drums", {}, []) == []
|
|
|
|
|
|
class TestCreateReturnTracks:
|
|
def test_create_return_tracks_returns_two(self):
|
|
from scripts.compose import create_return_tracks
|
|
tracks = create_return_tracks()
|
|
assert len(tracks) == 2
|
|
assert tracks[0].name == "Reverb"
|
|
assert tracks[1].name == "Delay"
|
|
|
|
def test_reverb_track_has_pro_r2(self):
|
|
from scripts.compose import create_return_tracks
|
|
tracks = create_return_tracks()
|
|
reverb = tracks[0]
|
|
assert len(reverb.plugins) == 1
|
|
assert "Pro-R" in reverb.plugins[0].name
|
|
|
|
def test_delay_track_has_valhalla(self):
|
|
from scripts.compose import create_return_tracks
|
|
tracks = create_return_tracks()
|
|
delay = tracks[1]
|
|
assert len(delay.plugins) == 1
|
|
assert "Valhalla" in delay.plugins[0].name
|
|
|
|
def test_return_tracks_have_volume_0_7(self):
|
|
from scripts.compose import create_return_tracks
|
|
tracks = create_return_tracks()
|
|
for t in tracks:
|
|
assert t.volume == 0.7
|
|
|
|
|
|
class TestMusicTheory:
|
|
def test_parse_key_minor(self):
|
|
from scripts.compose import parse_key
|
|
root, minor = parse_key("Am")
|
|
assert root == "A"
|
|
assert minor is True
|
|
|
|
def test_parse_key_major(self):
|
|
from scripts.compose import parse_key
|
|
root, minor = parse_key("C")
|
|
assert root == "C"
|
|
assert minor is False
|
|
|
|
def test_root_to_midi(self):
|
|
from scripts.compose import root_to_midi
|
|
assert root_to_midi("A", 4) == 69
|
|
assert root_to_midi("C", 4) == 60
|
|
|
|
def test_build_chord_major(self):
|
|
from scripts.compose import build_chord
|
|
chord = build_chord(60, "major")
|
|
assert chord == [60, 64, 67]
|
|
|
|
def test_build_chord_minor(self):
|
|
from scripts.compose import build_chord
|
|
chord = build_chord(60, "minor")
|
|
assert chord == [60, 63, 67]
|
|
|
|
def test_pentatonic_minor(self):
|
|
from scripts.compose import get_pentatonic
|
|
notes = get_pentatonic("A", True, 4)
|
|
assert notes[0] == 69 # A4
|
|
assert len(notes) == 5
|
|
|
|
def test_pentatonic_major(self):
|
|
from scripts.compose import get_pentatonic
|
|
notes = get_pentatonic("C", False, 4)
|
|
assert notes[0] == 60 # C4
|
|
assert len(notes) == 5
|