Class: Vizcore::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/config.rb

Overview

Runtime configuration for CLI/server startup.

Constant Summary collapse

DEFAULT_HOST =

Default host used by ‘vizcore start`.

"127.0.0.1"
DEFAULT_PORT =

Default HTTP/WebSocket port.

4567
DEFAULT_AUDIO_SOURCE =

Default audio source.

:mic
DEFAULT_NOISE_GATE =

Default RMS noise gate for live audio.

0.01
DEFAULT_RELOAD =

Default scene file hot reload behavior.

true
SUPPORTED_AUDIO_SOURCES =

Supported CLI audio source values.

%i[mic file dummy].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scene_file:, host: DEFAULT_HOST, port: DEFAULT_PORT, audio_source: DEFAULT_AUDIO_SOURCE, audio_file: nil, audio_device: nil, feature_file: nil, control_preset: nil, plugin_assets: [], noise_gate: DEFAULT_NOISE_GATE, bpm: nil, bpm_lock: false, osc_port: nil, reload: DEFAULT_RELOAD, projector_mode: false, scene_switch_effect: nil, scene_switch_effect_duration: nil, allow_public_control: false) ⇒ Config

Returns a new instance of Config.

Parameters:

  • scene_file (String, Pathname)

    scene DSL file path

  • host (String) (defaults to: DEFAULT_HOST)

    bind host

  • port (Integer) (defaults to: DEFAULT_PORT)

    bind port

  • audio_source (Symbol, String) (defaults to: DEFAULT_AUDIO_SOURCE)

    one of ‘:mic`, `:file`, `:dummy`

  • audio_file (String, Pathname, nil) (defaults to: nil)

    file path used with ‘audio_source=:file`

  • audio_device (String, Integer, nil) (defaults to: nil)

    input device index/name used with ‘audio_source=:mic`

  • feature_file (String, Pathname, nil) (defaults to: nil)

    recorded feature JSON used instead of live analysis

  • control_preset (String, Pathname, nil) (defaults to: nil)

    browser control preset JSON

  • plugin_assets (Array<String, Pathname>) (defaults to: [])

    browser plugin renderer files to serve

  • noise_gate (Numeric) (defaults to: DEFAULT_NOISE_GATE)

    RMS threshold below which live input is treated as silence

  • bpm (Numeric, nil) (defaults to: nil)

    fixed BPM value used when BPM lock is enabled

  • bpm_lock (Boolean) (defaults to: false)

    true when the analysis output BPM should stay fixed

  • osc_port (Integer, nil) (defaults to: nil)

    UDP port for OSC control sync

  • reload (Boolean) (defaults to: DEFAULT_RELOAD)

    true when scene file changes should be reloaded while running

  • projector_mode (Boolean) (defaults to: false)

    true when the browser should hide operator UI by default

  • scene_switch_effect (Hash, nil) (defaults to: nil)

    transition metadata applied to manual scene switches

  • allow_public_control (Boolean) (defaults to: false)

    true when binding operator control routes on a public host is intentional



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vizcore/config.rb', line 42

def initialize(
  scene_file:,
  host: DEFAULT_HOST,
  port: DEFAULT_PORT,
  audio_source: DEFAULT_AUDIO_SOURCE,
  audio_file: nil,
  audio_device: nil,
  feature_file: nil,
  control_preset: nil,
  plugin_assets: [],
  noise_gate: DEFAULT_NOISE_GATE,
  bpm: nil,
  bpm_lock: false,
  osc_port: nil,
  reload: DEFAULT_RELOAD,
  projector_mode: false,
  scene_switch_effect: nil,
  scene_switch_effect_duration: nil,
  allow_public_control: false
)
  @scene_file = Pathname.new(scene_file).expand_path if scene_file
  @host = host
  @port = Integer(port)
  @audio_source = normalize_audio_source(audio_source)
  @audio_file = audio_file ? Pathname.new(audio_file).expand_path : nil
  @audio_device = normalize_audio_device(audio_device)
  @feature_file = feature_file ? Pathname.new(feature_file).expand_path : nil
  @control_preset = control_preset ? Pathname.new(control_preset).expand_path : nil
  @plugin_assets = normalize_plugin_assets(plugin_assets)
  @noise_gate = normalize_noise_gate(noise_gate)
  @bpm = normalize_bpm(bpm)
  @bpm_lock = !!bpm_lock
  @osc_port = normalize_optional_port(osc_port)
  @reload = !!reload
  @projector_mode = !!projector_mode
  @scene_switch_effect = normalize_scene_switch_effect(scene_switch_effect, scene_switch_effect_duration)
  @allow_public_control = !!allow_public_control
end

Instance Attribute Details

#audio_deviceObject (readonly)

Returns the value of attribute audio_device.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def audio_device
  @audio_device
end

#audio_fileObject (readonly)

Returns the value of attribute audio_file.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def audio_file
  @audio_file
end

#audio_sourceObject (readonly)

Returns the value of attribute audio_source.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def audio_source
  @audio_source
end

#bpmObject (readonly)

Returns the value of attribute bpm.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def bpm
  @bpm
end

#control_presetObject (readonly)

Returns the value of attribute control_preset.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def control_preset
  @control_preset
end

#feature_fileObject (readonly)

Returns the value of attribute feature_file.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def feature_file
  @feature_file
end

#hostObject (readonly)

Returns the value of attribute host.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def host
  @host
end

#noise_gateObject (readonly)

Returns the value of attribute noise_gate.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def noise_gate
  @noise_gate
end

#osc_portObject (readonly)

Returns the value of attribute osc_port.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def osc_port
  @osc_port
end

#plugin_assetsObject (readonly)

Returns the value of attribute plugin_assets.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def plugin_assets
  @plugin_assets
end

#portObject (readonly)

Returns the value of attribute port.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def port
  @port
end

#projector_modeObject (readonly)

Returns the value of attribute projector_mode.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def projector_mode
  @projector_mode
end

#scene_fileObject (readonly)

Returns the value of attribute scene_file.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def scene_file
  @scene_file
end

#scene_switch_effectObject (readonly)

Returns the value of attribute scene_switch_effect.



22
23
24
# File 'lib/vizcore/config.rb', line 22

def scene_switch_effect
  @scene_switch_effect
end

Instance Method Details

#allow_public_control?Boolean

Returns true when public host binding is allowed.

Returns:

  • (Boolean)

    true when public host binding is allowed.



102
103
104
# File 'lib/vizcore/config.rb', line 102

def allow_public_control?
  @allow_public_control
end

#bpm_lock?Boolean

Returns true when BPM output should use the fixed BPM value.

Returns:

  • (Boolean)

    true when BPM output should use the fixed BPM value.



97
98
99
# File 'lib/vizcore/config.rb', line 97

def bpm_lock?
  @bpm_lock
end

#projector?Boolean

Returns true when browser output should start without operator UI.

Returns:

  • (Boolean)

    true when browser output should start without operator UI.



87
88
89
# File 'lib/vizcore/config.rb', line 87

def projector?
  projector_mode
end

#reload?Boolean

Returns true when scene hot reload is enabled.

Returns:

  • (Boolean)

    true when scene hot reload is enabled.



92
93
94
# File 'lib/vizcore/config.rb', line 92

def reload?
  @reload
end

#scene_exists?Boolean

Returns true when the configured scene file exists.

Returns:

  • (Boolean)

    true when the configured scene file exists.



82
83
84
# File 'lib/vizcore/config.rb', line 82

def scene_exists?
  scene_file && scene_file.file?
end