Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active June 30, 2022 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderofsalvation/b25cebc4f2920ea003d35831968ee79c to your computer and use it in GitHub Desktop.
Save coderofsalvation/b25cebc4f2920ea003d35831968ee79c to your computer and use it in GitHub Desktop.
unix dsp's (UD's) as offline alternative to VST/LV2 plugins)

Unix DSP processors (UDSP's)

Let's face it, non-realtime audio is as important as realtime audio.
UDSP's are a great offline alternative to realtime plugins, which allow for polyglot-scriptable synth & fx-chains.

crossplatform example UD

$ ./myudsp[.exe] [-o out.wav] [-n 60] [in1.wav in2.wav ..] # on unix/mac/linux
                                ^^       
                               midinote   

$ ./myudsp -o out.wav /tmp/in.wav /tmp/clipboard.wav /tmp/envelope.wav

Usecase: an audio application (wave-editor/moduletracker/daw e.g.) can pass a sample in.wav (exported from internal memory, or envelope e.g.) to the UD, and import the processed version (output.wav) after succesful UDSP execution. Optionally it can pass a second input (-2 clipboard.wav) which the UD can use as a second input (to vocode, use as envelope e.g.).

Optionally a midinote can be passed to hint the UDSP (which might indirectly use a vst/ladspa plugin) to play a synthesized sound at a certain pitch.

  • in case mydsp is a synthesizer note-generator, input.wav indicates the length of the output.

UD shebang

Instead of binaries, a script-file can be a UDSP too if:

  • the first 2 (ascii) characters of the file are #!
  • optional: '%s' format-string occurences (to pass the files)

Example flanger UD fx with shebang:

#!ffmpeg -i %s -af flanger %s

Example synth UD with shebang:

#!synth --note %s --samples %s %s

convention v1

  • default output (piping/files): mono 44100hz 16bits signed integers (little endian)
  • default midinote is 60
  • (longest) length of input is assumed as output length
  • mono is assumed, or when inputs are provided: the input with the highest nchannels decide output nchannels)
  • should support min 1 inputs, max 10 inputs (cli args: -0 ... until -9 ...)
  • output and input(s) are RIFF wave-files
  • -n argument for midinote (optional)
  • -r argument for samplerate (optiona)
  • - argument to pipe audio
  • use stderr for info (fprintf(stderr,..) e.g.) o it won't interfere with pipes/chaining

why

  • unix philosophy
  • offline dsp is easy to develop (in contrast to native plugins)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment