Skip to content

Commit

Permalink
Boot - enable separate input/output audio cards to be specified in co…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
samaaron committed Jun 3, 2024
1 parent 714d333 commit 81962bd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/config/user-examples/audio-settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@
# num_inputs = 16
# num_outputs = 16

## ===========================================
## Advanced - separate input/output soundcards
## ===========================================
#
# Note that these will override the sound_card_name option above.
# Also, these sound cards must be set to the same sample rate and
# the name must exactly match the full name of the sound card.

# input_sound_card_name = ""
# output_sound_card_name = ""

## ====================
## Server Audio options
Expand Down
24 changes: 22 additions & 2 deletions app/server/ruby/bin/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,8 @@ class ScsynthBooter < ProcessBooter

OPTS_TOML_KEY_CONVERSION = {
sound_card_name: "-H",
input_sound_card_name: "__HI__",
output_sound_card_name: "__HO__",
sound_card_sample_rate: "-S",
sound_card_buffer_size: "-Z",
num_inputs: "-i",
Expand Down Expand Up @@ -1147,11 +1149,29 @@ def initialize(ports, no_scsynth_inputs=false)
Util.log "Unified Audio Settings toml hash: #{opts.inspect}"
opts = scsynth_inputs_hash.merge(opts)
Util.log "Combined Audio Settings toml hash with GUI scsynth inputs hash: #{opts.inspect}"
opts = merge_opts(toml_opts_hash, opts)
opts = merge_scsynth_opts(toml_opts_hash, opts)
Util.log "Merged Audio Settings toml hash: #{opts.inspect}"
@num_inputs = opts["-i"].to_i
@num_outputs = opts["-o"].to_i

sound_card_name = opts.delete("-H")
input_sound_card_name = opts.delete("__HI__")
output_sound_card_name = opts.delete("__HO__")
args = opts.to_a.flatten

# handle multiargs for soundcard input/output
if input_sound_card_name && output_sound_card_name
args << "-H" << input_sound_card_name << output_sound_card_name
elsif input_sound_card_name && sound_card_name
args << "-H" << input_sound_card_name << sound_card_name
elsif input_sound_card_name
args << "-H" << input_sound_card_name
elsif output_sound_card_output_name
args << "-H" << output_sound_card_name
elsif sound_card_name
args << "-H" << sound_card_name
end

cmd = Paths.scsynth_path

case Util.os
Expand Down Expand Up @@ -1344,7 +1364,7 @@ def unify_toml_opts_hash(toml_opts_hash)
opts
end

def merge_opts(toml_opts_hash, opts)
def merge_scsynth_opts(toml_opts_hash, opts)
# extract scsynth opts override
begin
clobber_opts_a = Shellwords.split(toml_opts_hash.fetch(:scsynth_opts_override, ""))
Expand Down

0 comments on commit 81962bd

Please sign in to comment.