Coder Social home page Coder Social logo

andrepxx / go-dsp-guitar Goto Github PK

View Code? Open in Web Editor NEW
183.0 11.0 29.0 21.12 MB

A cross-platform multichannel multi-effects processor for electric guitars and other instruments.

License: Apache License 2.0

Makefile 0.68% Go 65.05% CSS 0.90% HTML 15.78% JavaScript 17.60%
audio dsp guitar effects effects-modeling jack-audio-connection-kit simulation guitar-amp amplifier-modeling

go-dsp-guitar's Introduction

go-dsp-guitar

This project implements a cross-platform multichannel multi-effects processor for electric guitars and other instruments, based upon concepts and algorithms originating from the field of circuit simulation.

The software takes the signals from N audio input channels, processes them and provides N + 3 audio output channels. The user may, for example, connect the signal from individual instruments to separate input channels of his / her sound card / audio interface. The input signals are then taken and put through dedicated signal chains for processing. The software provides one dedicated signal chain for each input. The output from the last processing element in each chain is then sent to one of the output channels, providing one output channel for each of the input channels. The remaining three output channels include a dedicated metronome, which creates a monophonic click track, as well as a pair of "master output" channels providing a stereo mixdown of all processed signals, say for monitoring purposes.

To manipulate the signal, the user may choose from a variety of highly customizable signal processing units, including the following.

  • signal / function generator
  • noise gate
  • bandpass filter
  • auto-wah (envelope-following bandpass filter)
  • auto-yoy (envelope-following comb filter)
  • compressor / limiter
  • (multi-)octaver
  • excess (distortion by phase-modulation)
  • fuzz (asymmetric hard or soft saturation)
  • overdrive (symmetric soft saturation)
  • distortion (symmetric hard saturation)
  • tone stack (four-band equalizer)
  • (multi-)chorus
  • flanger (simple LFO-driven comb filter)
  • phaser (complex LFO-driven comb filter)
  • tremolo (amplitude modulation)
  • ring modulator
  • delay (echo)
  • reverb (ambience)
  • power amplifier simulation
  • cabinet simulation

In addition, the software provides ...

  • a means to dynamically control the latency of the audio hardware / JACK server
  • a highly sensitive, fully chromatic instrument tuner based on the auto-correlation function
  • a room simulation (spatializer) to create a stereo mixdown from all (processed) instrument signals
  • a metronome to generate a click track for the performing musician for synchronization
  • sampled peak programme meters (SPPMs) for controlling the signal level of each input and output channel

... and much more.

The software itself runs in headless mode and is entirely controlled via a modern, web-based user interface, accessible either from the same machine or remotely over the network. It may operate either in real-time mode (default), where it takes signals from either the computer's audio hardware or other applications (e. g. a software synth) and delivers signals to either the computer's audio hardware or other applications (e. g. a DAW), via JACK, or in batch processing mode, where it reads signals from and writes generated output to audio files in either RIFF WAVE or RF64 format. It currently supports files in 8-bit, 16-bit, 24-bit and 32-bit linear PCM (LPCM), as well as 32-bit and 64-bit IEEE 754 floating-point format. Supported sample rates include 22.05 kHz, 32 kHz, 44.1 kHz, 48 kHz, 88.2 kHz, 96 kHz and 192 kHz. The simulation engine will adjust its internal time discretization to the selected sample rate. It will also use the highest precision available from the processor's floating-point implementation for all intermediate results. Only when the results are written to file or handed back to the JACK audio server, the (amplitude) resolution of the audio signal may be reduced, if required.

Screenshots

Screenshot 01

View full resolution image

Running the software (from a binary package)

Just download the binary (non-src) tarball from our Releases page, extract it somewhere, start JACK (e. g. via qjackctl), cd into the directory where you extracted go-dsp-guitar and run the ./dsp-* executable which matches your target architecture. For example, on an x86-64 system running Linux, you may do the following.

cd go-dsp-guitar/
./dsp-linux-amd64

If you want to run the software in batch processing mode (without JACK) instead, replace the last line with the following.

./dsp-linux-amd64 -channels 1

Replace the number 1 with the actual number of input channels you want to process, then enter the sample rate (time discretization) you want the simulation engine to operate at.

No matter if you run the software in real-time (JACK-aware) or batch processing mode, you should finally get the following message in your terminal emulator / console.

Web interface ready: https://localhost:8443/

Point your browser to the following URL to fire up the web interface: https://localhost:8443/

You will find more documentation inside the web interface.

Building the software from source locally

To download and build the software from source for your system, run the following commands in a shell (assuming that ~/go is your $GOPATH).

cd ~/go/src/
go get -d github.com/andrepxx/go-dsp-guitar
cd github.com/andrepxx/go-dsp-guitar/
make keys
make

(If you build using the v1.0.0 source code package from the Releases page, instead of obtaining the source via go get from version control, you will have to mkdir keys before running make keys. In all other cases, do not run mkdir keys before make keys.)

This will create an RSA key pair for the TLS connection between the user-interface and the actual signal processing service (make keys) and then build the software for your system (make). The executable is called dsp, but you may re-name it to match your architecture. For example, on an x86-64 system running on Linux, you may rename the executable as follows.

mv dsp dsp-linux-amd64

Building the software from source for other architectures (cross-compilation)

In addition, you may cross-compile the software from source for other architectures. Currently, the following targets are supported for cross-compilation.

make dsp-linux-aarch64
make dsp-linux-amd64
make dsp-linux-arm
make dsp-win-amd64.exe
make dsp-win-i686.exe

In order to cross-compile the software, you will need a cross-compilation toolchain and a populated sysroot for your target architecture. You may find it by invoking your cross-compiler with the -v option. For example, the sysroot may be one of the following.

/usr/aarch64-linux-gnu/sys-root/
/usr/arm-linux-gnu/sys-root/
/usr/x86_64-linux-gnu/sys-root/
/usr/x86_64-w64-mingw32/sys-root/
/usr/i686-w64-mingw32/sys-root/

The sysroot for the Windows cross-compilation builds is set to ~/win-sysroot from v1.3.1 onwards.

Packaging the software for distribution

After you build either a binary for your system or cross-compiled binaries for different systems (or both), you can bundle your binaries, along with scripts and auxiliary data, into packages for distribution.

make dist

This will create a binary package under dist/bin/go-dsp-guitar-vX.X.X.tar.gz, as well as a source package under dist/src/go-dsp-guitar-src-vX.X.X.tar.gz. Rename these for proper semantic versioning.

Other build targets

There are other build targets in the Makefile.

  • make clean: Removes the dist/ directory and the dsp executable built for your local system.
  • make clean-all: Removes the dist/ directory, as well as all dsp executables built for your local system and cross-compiled for other systems.
  • make fmt: Format the source code. Run this build target immediately before committing source code to version control.
  • make test: Run automated tests to ensure the software functions correctly on your system. You should also run this before committing source code to version control to ensure that there are no regressions.

Build requirements

You may need the following packages in order to build the software on your system.

  • gcc-aarch64-linux-gnu
  • gcc-arm-linux-gnu
  • gcc-mingw-w64-i686 (Debian / Ubuntu)
  • gcc-mingw-w64-x86-64 (Debian / Ubuntu)
  • gcc-x86_64-linux
  • git
  • glibc-arm-linux-gnu
  • glibc-devel.i686
  • glibc-devel.x86_64
  • glibc-headers.i686
  • glibc-headers.x86_64
  • golang-bin (Fedora / RHEL)
  • golang-go (Debian / Ubuntu)
  • jack-audio-connection-kit (Fedora / RHEL)
  • jack-audio-connection-kit-devel (Fedora / RHEL)
  • libjack-jackd2-dev (Debian / Ubuntu)
  • mingw32-gcc (Fedora / RHEL)
  • mingw32-gcc-c++ (Fedora / RHEL)
  • mingw32-pkg-config (Fedora / RHEL)
  • mingw64-gcc (Fedora / RHEL)
  • mingw64-gcc-c++ (Fedora / RHEL)
  • mingw64-pkg-config (Fedora / RHEL)
  • openssl
  • rsync

Q and A

Q: To the project initiator: Why the hell did you create this software?

A (short): I created this software because I wanted to do things that I was unable to do without it.

A (long): I'm a fanatic music lover and concert-goer. Learning to play electric guitar was one of my greatest dreams back in the day when I was like thirteen years old and has remained it ever since. I always wanted to establish a band, stand on a stage, play my instrument in front of a large audience, you get the idea. I've seen hundreds of bands live, and I'm very passionate about audio engineering in general since back in the day when I went to school. However, for a long time, electric guitar required a lot of expensive and large and heavy and especially LOUD equipment, stuff that one simply could not justify to operate inside the parents' home or later inside a small flat in the city. While this became less of an issue since decently-sounding (mostly solid-state) pre-amplifier pedals (and rack units) are available, I always felt the desire to create my own audio equipment, which would sound and behave exactly like I wanted. Being a computer scientist, not an electrical engineer, it was clear that, instead of designing and building an actual circuit for, say, a guitar effects pedal, I had to create a piece of software that would behave LIKE such a circuit. While we currently reach a point where we begin to see some decent computer-based audio effects on the horizon, they simply weren't there back in the day when I started creating this software. Also, most of these effects are still not designed with precision as a priority - at least not the kind of precision you'd expect if you have experience with (scientific) simulation software, like I did. They therefore lack the ultimate "realism", so to speak. Also, these effects are normally not THAT customizable that you could ever hope to recreate, say, the sound of a very specific and rare pedal, which was one of the things I always wanted to be able to do, but until now simply couldn't.

Q: How long did it take you to build this thing?

A (short): Overall it took about five years from the first concept to the first release. Our actual implementation in Golang took about three years until the first release.

A (long): The project started in October 2013 as a small tool, written in Python, which could perform some simple processing (especially non-linear distortion and filtering) on RIFF WAVE files. At this point, our vision was born, to take concepts and algorithms originating from the field of circuit simulation and create an effects processor based upon them. We weren't certain if we could ever hope to achieve sufficient performance for real-time processing with this approach, but if we couldn't, at least we could fall back to file-based processing. We first tried to combine Python (for control) with C (for the actual processing) in order to achieve the performance necessary to perform any kind of real-time processing. We tried several audio APIs and libraries, first "raw" ALSA, then PortAudio, and (very briefly) also rtAudio, but with each of these APIs, there was always a point where we hit a roadblock, so development began to stagnate. Almost two years later, in summer 2015, we found that Golang was finally mature enough and we might give this language a chance and try to implement our algorithms in it instead. In addition, we were also at some sort of tipping point, where we could hope that hardware, which is fast enough to run our algorithms in real-time at an acceptable latency, would begin to become commonplace. We also chose to transition to JACK as our audio API. All of these changes finally gave us the required performance and, after countless nights of coding, countless cups of coffee, a lot of (original) research including measurements on actual audio equipment and analysis, as well as countless chords strummed on the guitar for testing, we finally arrived at what we released in December 2018 as go-dsp-guitar. So all in all, it took us slightly more than five years from the first prototype to what we finally considered stable and "polished" enough to be released.

Q: Which platforms can I run this software on?

A: We currently provide binaries for Linux on x86-64 / amd64 (typically PCs), Linux on ARM or AArch64 (typically embedded devices, like a Raspberry Pi), Windows on x86-64 / amd64 (64-bit CPUs, basically all current machines) and Windows on i686 (32-bit CPUs, PCs from pre-2004 or very ressource-limited devices like netbooks from pre-2010). Note that even though the 32-bit variant of the software will typically run on a 64-bit CPU (but not the other way round), using the native (64-bit) variant on a 64-bit machine will be both faster and able to process larger files due to the larger address space of the process. We highly recommend Linux on x86-64 / amd64 for real-time use with JACK. Based upon our own testing, current ARM-based devices will not nearly be fast enough for real-time processing, and Linux currently performs better on x86-64 / amd64 for real-time use than Windows does. We still chose to support Windows as well due to its high market share on the desktop. When running this software on Windows, use the x86-64 / amd64 binary if possible. (It should run, unless your're on a very old machine.) And, of course, you can always use the file-based batch processing mode on slower machines.

Q: Why do I run out of memory when batch-processing files?

A: The batch processing mode currently requires a lot of (virtual) memory, especially when processing large files and / or many channels, since it has to load the entire files into memory, resample all audio material to the target sampling rate and, finally, extend (zero-pad) it to the same length. During this entire process, the entire high-resolution audio data has to reside in (virtual) memory. This is a technical limitation of how go-dsp-guitar currently operates when in this particular mode. If you want to process large files, but are unable to provide a lot of (virtual) memory, you might consider running go-dsp-guitar in real-time mode with a very high latency setting instead, then feed audio streams from a DAW through go-dsp-guitar and back into the DAW, where the result gets recorded. Real-time operation of go-dsp-guitar requires a certain amount of processing power from the CPU though.

Q: Why don't you support macOS?

A: We're well aware of the fact that macOS has a high market share among the creative folks. However, we currently neither have a device for building and testing nor do we know, which changes we'd have to make to our software so that it builds for macOS. Feel free to fork our project and try to port it to macOS though. When you're done, submit a pull request and we might merge your changes into mainline. (We still won't be able to provide binaries though.) Keep in mind that we will only accept changes which do not break functionality on our currently supported platforms.

Q: You implement real-time audio processing in a garbage-collected language and use mutex locks for synchronization. Won't that be detrimental to the performance?

A: A performance discussion / analysis is available here.

Q: How do I set this app up on Windows?

A: You have to setup JACK Audio Connection Kit as a sound server first. A short documentation is available here.

go-dsp-guitar's People

Contributors

andrepxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-dsp-guitar's Issues

Support for control by expression pedals

I'm pretty to new all this so sorry if this is a 'bad' question: Is there any chance that control by expression pedals might be made possible?

Best I can tell, the 'most proper' way to do this would be MIDI control messages.

There are numerous gaps...

  1. Expression pedal to MIDI control messages. This is solved by things like "beat bars" EX2M Adapter. It could also be solved by a little DIY project using Arduino Leonardo.
  2. Connecting MIDI control messages between apps, good reading here: https://www.donyaquick.com/midi-on-windows/#x1-150004.4
  3. Utilizing MIDI in your app... I don't program in Go and it looks like Greek to me. If your server supported an automation API (eg: receive a unit ID, parameter ID, and the updated value) then people like me might jump on that easy opportunity to link external data to your application.

Would love to know your thoughts,
Thanks for this very cool tool!

make error: reference not defined in jack.go

Running make fails:

meister@HP-II:~/.go/src/github.com/andrepxx/go-dsp-guitar$ make
GOPATH=`pwd`/../../../.. go build -o dsp -ldflags 'all=-w -s'
go: downloading github.com/andrepxx/go-jack v0.0.0-20220929171107-71a712d2f786
# github.com/andrepxx/go-dsp-guitar
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-156518109/000003.o: In Funktion `jack_set_port_rename_callback_go':
/home/meister/.go/pkg/mod/github.com/andrepxx/[email protected]/jack.go:49: Nicht definierter Verweis auf `jack_set_port_rename_callback'
collect2: error: ld returned 1 exit status

Makefile:29: die Regel für Ziel „dsp“ scheiterte
make: *** [dsp] Fehler 1

The error text translates to

/home/meister/.go/pkg/mod/github.com/andrepxx/[email protected]/jack.go:49: Undefined reference to `jack_set_port_rename_callback'
...
Makefile:29: the rule for target "dsp" failed

Tried to install as proposed in https://github.com/andrepxx/go-dsp-guitar#building-the-software-from-source-locally

All commands except make ran successfully.

meister@HP-II:~/.go/src/github.com/andrepxx/go-dsp-guitar$ uname -a
Linux HP-II 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

meister@HP-II:~/.go/src/github.com/andrepxx/go-dsp-guitar$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/meister/.cache/go-build"
GOENV="/home/meister/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/meister/.go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/meister/.go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/meister/.go/src/github.com/andrepxx/go-dsp-guitar/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3210947670=/tmp/go-build -gno-record-gcc-switches"

meister@HP-II:~/.go/src/github.com/andrepxx/go-dsp-guitar$ echo $PATH
/home/meister:/home/meister/bin:/home/meister/.bin:/home/meister/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/brlcad/bin:/usr/local/go/bin:/home/meister/.go/bin

What I've tried so far:

  • installed libjack0 as it was required to install libjack-dev:
meister@HP-II:~/.go/src/github.com/andrepxx/go-dsp-guitar$ sudo apt-get install libjack-dev
...
The following packages have unfulfilled dependencies:
 libjack-dev : Depends on: libjack0 (= 1:0.124.1+20140122git5013bed0-3build2) but should not be installed.
  • installed libjack-dev, as it was required for make

alternative way to use persistence.

I wonder if there is an alternative way to upload a patch file for persistence, instead of the drag and drop, that currently in my setup, does not work, because I am running dsp in a headless machine, connecting with my phone.

Literature about nonlinear audio processing (distortion and amp modeling)

Hi,

First of all, great work !!! All the stuff that you did is pretty impressive!!! For quite some time I have in my mind pretty similary thing that you did but I want to run all the algorithems in real-time with dedicated, custom HW. However, first I want to write more algorythms by myself for learning and better undestanding. I know how to do all the stuff with FFT, filters, delay-based effect, tremolo, wah-wah e.g. but I have some problem because I don't know how to write decent distortion or even how to start with amp modeling. Of course I can make reverse engineering of your code but I would rather prefer to read some articles/books to undestand this problem better. Can you recommend me some literature or whatever that you based on your work? Or maybe give me some different tips how to start.

Thank you in advance,
Rino Reyns

[SUGGESTION] ....possible collaborations ?

1st of all, thanks for your coding !

Some time ago we "dumped" ayeMux sources from their Google code (rip) page.

We don't have any embedded dev actually, so we don't know if can help you in any way, but - since it's GPLd - take it in consideration if you need.

In the past we also have "contributed" to ScorchCrafter' (wich is - unfortunally - in deadlock stage, even if @osxmidi have made a JUCE "port") source openness, so we of course encourage any kind of possible collaborations.

Hope that helps/inspires.

Application does not run on fully updated Windows 10

go-dsp-guitar claims to be a cross-platform application, but currently fails to run on a fully updated Windows 10 machine with the latest version of JACK 2 installed.

When started from within the Windows PowerShell, with the JACK audio server running, the application just returns to the command prompt without any error message.

I suspect that the sysroot which we use for our cross-platform build (which is already several years old) has to be updated with libraries extracted from a current Windows 10 release, since it seems like there were unfortunately binary-incompatible changes at some point. Afterwards, go-dsp-guitar shall be built against the updated sysroot and tested again.

Applying effects to audio file

First thing first, awesome job you did here.

I was wondering, I have an audio sample from a file. Uncompressed 16-bit signed little-endian samples (Linear PCM). Audio content returned as LINEAR16 also contains a WAV header.

Is it possible to use your components to apply certain effects to the audio?

stuck on startup, Web interface ready, https localhost 8443

I'm stuck on start go-dsp-guitar.
Downloaded binary package and decompress, Have started the Jack with cadence.
then excute in terminal:

$ ./dsp-linux-amd64
Web interface ready: https://localhost:8443/

Then stuck on this, Had to ctrl+c to cancel the program.

Please help! Thx.

Error on Windows 10

I'm trying to run on windows 10 home edition. The program says "libjack64.dll" now found. How can I setup that dependency?

I'm very curious to test this code! Nice job!! Congrats

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.