Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When booting the server, output_device should appear after -H in serialized Options and not before #409

Closed
rubencart opened this issue Dec 20, 2024 · 4 comments · Fixed by #411
Assignees
Labels

Comments

@rubencart
Copy link

rubencart commented Dec 20, 2024

Describe the bug
The command with which the server is booted is /Applications/SuperCollider.app/Contents/Resources/scsynth 'GIGAPort HD+' -H 'MacBook Pro Microphone' -R 0 -S 44100 -i 2 -l 1 -u 57110, if I set output_device = 'GIGAPort HD+'. This is an error, it should be /Applications/SuperCollider.app/Contents/Resources/scsynth -H 'MacBook Pro Microphone' 'GIGAPort HD+' -R 0 -S 44100 -i 2 -l 1 -u 57110.

The mistake is in supriya.scsynth.Options.serialize:

    def serialize(self) -> List[str]:
        result = [str(find(self.executable))]
        pairs: Dict[str, Optional[str]] = {}
        if self.realtime:
            ...
            if self.input_device:
                pairs["-H"] = str(self.input_device)
                if self.output_device != self.input_device:
                    result.append(str(self.output_device))  # should be appended to pairs["-H"]

Additionally, this means one cannot set the output device without setting the input device, I don't know whether that is intended or not.

To Reproduce

import supriya
options = supriya.Options(
    input_bus_channel_count=2,
    output_bus_channel_count=8,
    sample_rate=44100,
    executable='/Applications/SuperCollider.app/Contents/Resources/scsynth',
    output_device="GIGAPort HD+",
    input_device="MacBook Pro Microphone",
)
server = supriya.Server().boot(options=options)

Results in

---------------------------------------------------------------------------
ServerCannotBoot                          Traceback (most recent call last)
Cell In[68], [line 10](vscode-notebook-cell:?execution_count=68&line=10)
      [1](vscode-notebook-cell:?execution_count=68&line=1) import supriya
      [2](vscode-notebook-cell:?execution_count=68&line=2) options = Options(
      [3](vscode-notebook-cell:?execution_count=68&line=3)     input_bus_channel_count=2,
      [4](vscode-notebook-cell:?execution_count=68&line=4)     output_bus_channel_count=8,
   (...)
      [8](vscode-notebook-cell:?execution_count=68&line=8)     input_device="MacBook Pro Microphone",
      [9](vscode-notebook-cell:?execution_count=68&line=9) )
---> [10](vscode-notebook-cell:?execution_count=68&line=10) server = Server().boot(options=options)

File ~/Documents/miniconda3/envs/gharieni_env/lib/python3.11/site-packages/supriya/contexts/realtime.py:603, in Server.boot(self, options, **kwargs)
    [601](https://file+.vscode-resource.vscode-cdn.net/Users/rubenc/Documents/rapps/manu/~/Documents/miniconda3/envs/gharieni_env/lib/python3.11/site-packages/supriya/contexts/realtime.py:601) if not (self._boot_future.result()):
    [602](https://file+.vscode-resource.vscode-cdn.net/Users/rubenc/Documents/rapps/manu/~/Documents/miniconda3/envs/gharieni_env/lib/python3.11/site-packages/supriya/contexts/realtime.py:602)     if (self._shutdown_future.result()) == ServerShutdownEvent.PROCESS_PANIC:
--> [603](https://file+.vscode-resource.vscode-cdn.net/Users/rubenc/Documents/rapps/manu/~/Documents/miniconda3/envs/gharieni_env/lib/python3.11/site-packages/supriya/contexts/realtime.py:603)         raise ServerCannotBoot
    [604](https://file+.vscode-resource.vscode-cdn.net/Users/rubenc/Documents/rapps/manu/~/Documents/miniconda3/envs/gharieni_env/lib/python3.11/site-packages/supriya/contexts/realtime.py:604) return self
ServerCannotBoot:

With supernova instead of scsynth I don't get an error but the output device is not correctly set.

import supriya
options = supriya.Options(
    input_bus_channel_count=2,
    output_bus_channel_count=8,
    sample_rate=44100,
    executable='/Applications/SuperCollider.app/Contents/Resources/supernova',
    output_device="GIGAPort HD+",
    input_device="MacBook Pro Microphone",
)
server = supriya.Server().boot(options=options)
server

Prints <Server ONLINE [/Applications/SuperCollider.app/Contents/Resources/supernova 'GIGAPort HD+' -H 'MacBook Pro Microphone' -R 0 -S 44100 -i 2 -l 1 -u 57110]>. Note the ... supernova 'GIGAPort HD+' -H 'MacBook Pro Microphone' ... . When I play a sound, it plays through the default output (MacBook Pro Speakers), and not through GIGAPort HD+.

Expected behavior
I expect the serialized output command to be /Applications/SuperCollider.app/Contents/Resources/scsynth -H 'MacBook Pro Microphone' 'GIGAPort HD+' -R 0 -S 44100 -i 2 -l 1 -u 57110. Running this command in my terminal gives:

Number of Devices: 7
   0 : "PHL 245E1"
   1 : "GIGAPort HD+"
   2 : "USB2.0 MIC"
   3 : "MacBook Pro Microphone"
   4 : "MacBook Pro Speakers"
   5 : "Microsoft Teams Audio"
   6 : "Serato Virtual Audio"

"MacBook Pro Microphone" Input Device
   Streams: 1
      0  channels 1

"GIGAPort HD+" Output Device
   Streams: 1
      0  channels 8

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
SuperCollider 3 server ready.

Running the wrongfully serialized command /Applications/SuperCollider.app/Contents/Resources/scsynth 'GIGAPort HD+' -H 'MacBook Pro Microphone' -R 0 -S 44100 -i 2 -l 1 -u 57110 in my terminal gives: ERROR: Invalid option GIGAPort HD+.

Environment (please complete the following information):

  • OS: Mac OS 13.4.1
  • Python Version 3.11.10
  • SuperCollider Version 3.13.0
  • Supriya Version [what git commit?]: 24.11b0
@josephine-wolf-oberholtzer
Copy link
Member

Thanks for the report. Desired behavior is that server options basically match sclang's. In this case, it's this block: https://github.com/supercollider/supercollider/blob/develop/SCClassLibrary/Common/Control/Server.sc#L189-L198

Will have a PR up shortly that you can play with.

@josephine-wolf-oberholtzer
Copy link
Member

josephine-wolf-oberholtzer commented Dec 20, 2024

@rubencart Take a look at #411 and let me know if this solves your troubles.

@rubencart
Copy link
Author

I had already opened a PR :). But yours looks good, thanks!

@josephine-wolf-oberholtzer
Copy link
Member

Cool. Cutting a release once main goes green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants