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

Conditionally set play flags for wsl2/wslg on win11 #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tj64
Copy link
Contributor

@tj64 tj64 commented Mar 13, 2022

Hi, with current versions of WSL2 (Windows Subsystem for Linux) graphics and audio are possible, the latter due to a running Pulse Server on WSLg, linked to the users linux distro via env var $PULSE_SERVER.

I added some code that

  • detects if on modern WSL2 (from Win11 on ...)
  • sets the csound play flags such that csound-play works out of the box on WSL2/WSLg.

Cheers
Thorsten

PS
sorry for the accidental formatting noise in the PR.
And something similar needs to be done for csound-repl, but I'm not yet there, maybe another PR soon

@hlolli
Copy link
Owner

hlolli commented Mar 13, 2022

Looks legit issue and legit solution.

I'll review tomorrow (and look into the midi-sco issue as well)

But we need to take into accout that

  1. defvar is user variable, so we can't punish the user for defining csound options within csound-mode. Example: the user defines "-m0", and the check string-empty-p sees that csound-play-flags are defined (as opposed to undefined) and doesn't apply the rtaudio options, and the user loses audio for defining message level options.
  2. .csound6rc (.coundrc or soon to be .csound7rc) are defined by the user, the user defined rtaudio there, but it unable to understand why their dotfiles don't work on rtaudio options. So we need to make sure where order of precedence lies here. We need to respect user's intentions, but if csound-mode in emacs has precedence over .csound6rc I'm not so convinced about.

@tj64
Copy link
Contributor Author

tj64 commented Mar 13, 2022

I had this in my doom emacs config.el, but first I had to figure out the problem with csound-mode on wsl2 (and how audio works in wsl2 now). The idea of this PR is to set defaults on wsl2 so everything works out-of-the box without each user having to analyse the situation again.

I understand the conflict between avoiding error messages for starters and not messing up csound configs of seasoned users.

Not sure if a new variable like "csound-wsl-flags" would help.
Maybe just add another check for a .csoundrc (must be empty or non-existing)?

@hlolli
Copy link
Owner

hlolli commented Mar 14, 2022

We could rethink the configuration variable, and set csound options on individual argument basis. So that rtaudio vars would be their own emacs var, within that, we could set them to defaults depending on the system configuration.

@tj64
Copy link
Contributor Author

tj64 commented Mar 14, 2022

Sounds good to me. Maybe we could have a defvar (not defcustom) like csound-os-wslg-p, and set that once with this code or something similar:

` (and 
   (string-match "linux" (format "%s" system-type)) 
   (string-match "WSL2" operating-system-release)
   (not (string-empty-p (getenv "PULSE_SERVER") ) ) )`

Then have defcustoms like csound-rtaudio-flag, csound-server-flag (maybe more, but thats all I need for WSL2). And we set them conditional on csound-os-wslg-p as default.

But then they need to be used for csound-play and csound-repl--start-server.

How to proceed now? Reject/Delete the current PR, then either you implement this, or I try to create a new cleaner PR?

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.

2 participants