Skip to content

Add .properties config support and audio device selection#17

Open
monsterwendy wants to merge 6 commits intoprojectM-visualizer:masterfrom
monsterwendy:feature/properties-config
Open

Add .properties config support and audio device selection#17
monsterwendy wants to merge 6 commits intoprojectM-visualizer:masterfrom
monsterwendy:feature/properties-config

Conversation

@monsterwendy
Copy link
Copy Markdown

Summary

This PR adds support for loading .properties config files — the format used by the C++ SDL frontend (projectMSDL) — so users can migrate from the C++ frontend without rewriting their config.

What's new

.properties config file support (src/properties.rs)

  • Auto-detected by file extension when passed via -c config.properties
  • Parses the key: value format used by projectMSDL
  • Two-pass parsing: window.* keys first, then projectM.* / audio.* keys
  • Handles Windows-style backslash paths (normalizes to forward slashes)
  • Spaces in paths work without quoting

Property mappings:

.properties key Setting
projectM.presetPath --preset-path
projectM.shuffleEnabled --shuffle-enabled (new)
projectM.transitionDuration --transition-duration (new)
projectM.displayDuration --preset-duration
audio.device --audio-device (new — see below)
window.width/height/left/top window geometry

Audio device selection (src/app/audio.rs)

  • New --audio-device CLI flag / PM_AUDIO_INPUT env var
  • Finds device by name at startup (case-insensitive, falls back to substring match)
  • If not found, falls back to default device with a warning

Preset path fix

  • After loading the user's preset path, immediately calls playlist_play_next() so presets from the configured folder start playing right away instead of waiting for the first transition timer

Window config (src/app.rs)

  • Window size (width/height) now read from config

New CLI flags added to Settings:

  • --audio-device / PM_AUDIO_INPUT
  • --shuffle-enabled / PM_SHUFFLE
  • --transition-duration / PM_TRANSITION_DURATION

README updates

  • Added .properties format usage example
  • Added macOS note: terminal app needs Microphone permission in System Settings → Privacy & Security, or audio capture will silently return no data

Example config

A Windows projectMSDL config file can be used directly:

audio.device: BlackHole 2ch
projectM.presetPath: /Users/delta/presets
projectM.shuffleEnabled: true
projectM.transitionDuration: 10
projectM.displayDuration: 60
window.width: 1280
window.height: 720
./projectm -c projectMSDL.properties

Test plan

  • .properties file loads correctly (unit tests in src/properties.rs)
  • cargo test passes
  • Audio device selection works on macOS and Linux
  • Preset path loads immediately on startup
  • Existing .toml/.json/.yaml config still works

Wendy and others added 6 commits April 30, 2026 02:39
Adds support for loading projectMSDL .properties config files used by
the C++ SDL frontend, making migration to the Rust frontend seamless.

Changes:
- New properties.rs module: parses .properties format in two passes
  (window.* keys first, then projectM.*/audio.* keys)
- Settings struct: added audio_device, shuffle_enabled, transition_duration fields
- Config struct: added shuffle, transition, audio device, window geometry fields
- Audio: implemented device selection by name (exact match, then substring)
- App: window size/position from config, audio device name passthrough
- Auto-detect .properties extension via -c flag alongside .toml/.json/.yaml

Property mappings:
  projectM.presetPath -> preset_path
  projectM.shuffleEnabled -> shuffle_enabled
  projectM.transitionDuration -> transition_duration
  projectM.displayDuration -> preset_duration
  audio.device -> audio_device (SDL device enumeration + name match)
  window.* -> window geometry config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t_duration

Three related fixes:

1. Remove default_value = "10" from --preset-duration CLI arg (and "1.0" from
   --beat-sensitivity). These defaults caused Settings::apply() to always
   overwrite file-loaded values with CLI defaults, ignoring .properties config.
   projectM's library defaults apply when neither CLI nor file specifies a value.

2. Reorder apply_config: call set_preset_duration (and set_soft_cut_duration)
   BEFORE play_next, so the correct durations are in effect when the first
   preset's timer starts.

3. Map projectM.transitionDuration to set_soft_cut_duration (crossfade blend
   time), not set_preset_duration. Rename Config::transition_duration to
   Config::soft_cut_duration to match the projectM API semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant