Emacs, scsynth and Microphone Permissions

Hi y’all,

after happily using SuperCollider for sound synthesis in emacs for a few months, today I tried to dabble with SoundIn.

As it turns out, on Mac OS Catalina (10.15.7), you need Microphone Permissions to get sound into SuperCollider. Using the IDE this works as expected, and Emacs has microphone permissions, too:

Still, I don’t get any sound in.

I suspect this has to do with the fact that in emacs mode, SuperCollider launches a standalone scsynth process, which does not have microphone permissions:

$ ps aux | grep scsynth                                                                                                                                                           64|15:41:08
jrubisch         57662   0.4  0.1  5123704  29264   ??  S     3:39PM   0:03.09 /Applications/SuperCollider/SuperCollider.app/Contents/Resources/../Resources/scsynth -u 57110 -a 1024 -i 2 -o 2 -R 0 -l 1
jrubisch         58011   0.0  0.0  4408548    784 s030  S+    3:46PM   0:00.00 grep --color=auto scsynth

has anyone had this problem already, and solved it? thanks!

Hello Julian,

I have not solved the problem (no longer working with MacOS atm), but maybe this tip would help:
Have a look at the emacs code for booting the server:

(defun sclang-perform-server-command (command &rest args)
(sclang-eval-string
    (sclang-format "Server.named.at(%o.asSymbol).performList(\\tryPerform, %o.asSymbol.asArray ++ %o)"
  sclang-current-server command args)

nil))

It is performing the string for localhost obtained from sclang. So that throws the responsibility back to sclang itself. Meaning it runs exactly the same unix command as when booting from IDE. I know of someone working with Catalina who resorted to booting emacs from the terminal in order to have root privileges. Maybe that is something to try.

Cheers,
Iannis

1 Like

Thanks, I’ll give it a try! Very appreciated!

Heyall,

wanted to quickly return back to this and note that this can simply be solved by starting emacs from the terminal.

Then Terminal/iTerm/whatever will ask for mic privileges, problem solved!

I’d say this is still an issue – not with sc though, but with Emacs.

Running GUI Emacs through the Terminal might be an option but I would not say it is optimal.

I had this working on Catalina, but managed to screw it up by reinstalling Emacs. The issue seems to be that Emacs never asks for Microphone permissions.

I am not completely sure, but the issue seems to be that no Emacs distribution I have tried sets the key

	<key>NSMicrophoneUsageDescription</key>

in Info.plist within the macOS app bundle (Emacs.app). Adding the key manually does not seem to work.
Last time I think I got this working by testing different versions of Emacs, but can’t remember which one actually worked…

If anyone has got GUI Emacs asking for Microphone permission on 10.15.+, please get back to me.

That’s interesting! Do you think it would make sense to escalate this to whoever is compiling the Emacs app for MacOS, i.e. file an issue there?

I think it would, but I have no idea where to post the issue. I’ve tried this with different distributions of GUI Emacs (brew, emacs-plus and I can’t really remember all of them). I’d guess microphone usage is an edge case for Emacs.

The frustrating this is that I had it working, but I can not remember how I did fix it last time.

Ok, a solution:
I successfully used this tool

to manually add microphone permissions for GUI Emacs, running like so:

sudo python tccutil.py -p /Applications/Emacs.app/ --micro -e

For this to work I had to disable System Integrity Protection (but re-enabled afterwards), so usual caveats apply. No guarantees about the safety of the code linked above and so on, but so far no issues.

1 Like

Awesome! I‘ll still try to find out that repo and post an issue there or submit a PR. Two solutions would be better than none! I’ll report back

I think I’ve identified the place it needs to go;

Problem is, there’s no issue tracker, only the mailing list

While suboptimal, maybe an idea is to build with the relevant key added and if that works, make a personal fork.

I have little idea how code signatures and such work, but my guess is that editing files such as the .plist after building interferes with some other security system on the mac.

I’ll maybe test this idea later, but right now I want to actually work on some music… :))