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) ⇒ 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



38
39
40
41
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
# File 'lib/vizcore/config.rb', line 38

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_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
end

Instance Attribute Details

#audio_deviceObject (readonly)

Returns the value of attribute audio_device.



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

def audio_device
  @audio_device
end

#audio_fileObject (readonly)

Returns the value of attribute audio_file.



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

def audio_file
  @audio_file
end

#audio_sourceObject (readonly)

Returns the value of attribute audio_source.



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

def audio_source
  @audio_source
end

#bpmObject (readonly)

Returns the value of attribute bpm.



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

def bpm
  @bpm
end

#control_presetObject (readonly)

Returns the value of attribute control_preset.



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

def control_preset
  @control_preset
end

#feature_fileObject (readonly)

Returns the value of attribute feature_file.



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

def feature_file
  @feature_file
end

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#noise_gateObject (readonly)

Returns the value of attribute noise_gate.



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

def noise_gate
  @noise_gate
end

#osc_portObject (readonly)

Returns the value of attribute osc_port.



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

def osc_port
  @osc_port
end

#plugin_assetsObject (readonly)

Returns the value of attribute plugin_assets.



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

def plugin_assets
  @plugin_assets
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#projector_modeObject (readonly)

Returns the value of attribute projector_mode.



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

def projector_mode
  @projector_mode
end

#scene_fileObject (readonly)

Returns the value of attribute scene_file.



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

def scene_file
  @scene_file
end

Instance Method Details

#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.



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

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.



78
79
80
# File 'lib/vizcore/config.rb', line 78

def projector?
  projector_mode
end

#reload?Boolean

Returns true when scene hot reload is enabled.

Returns:

  • (Boolean)

    true when scene hot reload is enabled.



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

def reload?
  @reload
end

#scene_exists?Boolean

Returns true when the configured scene file exists.

Returns:

  • (Boolean)

    true when the configured scene file exists.



73
74
75
# File 'lib/vizcore/config.rb', line 73

def scene_exists?
  scene_file && scene_file.file?
end