snd-selectric-mode v0.0.1 released

I fixed the performance issues from selectric-mode that I wrote about in my article about ipc for sounds in emacs. Code is here: https://codeberg.org/MegaJ/snd-selectric-mode.

Demo (turn sound on!):

To briefly recap, last time I experimented with

  • selectric-mode without changes
  • thread spawning for each sound played
  • mpv as a daemon, emacs sending commands through a socket

My last option was the most performant but suffered from limitations like mixing not being very practical. Now, I found an option to mix that I've tested only on linux. It relies on a binary called snd, which may be packaged by your package manager.

When you have snd, here's a use-package incantation to get my emacs package if you use straight.el:

(use-package snd-selectric-mode
  :straight (:type git :host codeberg
                   :repo "megaj/snd-selectric-mode"
                   :files ("*.el" "*.wav"))
  ;; I recommend leaving the verbosity setting on in case you run into bugs
  ;; the first time you use it.
  ;; You can check the *snd-selectric-scheme* buffer for output.
  ;; :custom (snd-selectric-verbose-process-p nil)
  )

How it works

Ultimately, it's just emacs sending scheme commands through a comint buffer. There's nothing fancy here1. All the heavy lifting is done by snd.

snd

snd is an audio editor, but it handles realtime audio playback and mixes it all down. It accepts commands through a repl directly, or even through a socket. It's what makes this all possible. And it runs scheme!

Not only does it run scheme, but it's the emacs of sound editing–it seems most things about the currently running program can be changed while it's running.

It was not made for my use case, but it's flexible. I've already thought about my next project with it. I want to use it like how people use fmod for games.

It does come with some drawbacks though. It lacks a really good debugger as admitted by the author of snd. It also doesn't have a community outside of a mailing list.

Performance

This is comparable to using mpv. Maybe slightly more CPU usage, but I get mixing and a bunch more functionality.

2025-01-09_20-07-46_screenshot.png
Figure 1: 20% cpu using snd

Enjoy!

This package hasn't had users other than myself yet. Please raise issues you find on https://codeberg.org/MegaJ/snd-selectric-mode/issues.

And if you have any tips on writing s7 scheme or know a lot about snd, send me word at jwow [at] 17070415 [dot] xyz.

Lastly if you enjoy my articles or any software I wrote, please consider supporting my work.


1

the only contrived thing was to suppress the output since the comint buffer acts like a repl. There is no way to suppress the output, but I've made it possible for users to (setq snd-selectric-command "snd -b > /dev/null") which eliminates all terminal output.

I believe I can write some scheme to change how the repl prints, but I'm not sure. I actually don't know how scheme works, only that it's a compartively much smaller language spec than common lisp.