Closed andrepxx closed 6 years ago
This looks nice, I haven't used Jack on windows before.
I'll take a closer look later this week, I'm traveling at the moment.
I might use that time in order to tear down my entire build environment, set it up from scratch and document the process. This way, you (and others) could cleanly follow along how to set this all up on Windows, which is really not that obvious and requires quite a bit of manual work (e. g. copying libraries and header files around).
It depends on whether I find time to do that and whether I am willing to take the risk of tearing down a working build environment. :-)
However, I think it might be worth it. The thing I gain is a reproducible process, which is always nice. :-)
You should then have a much easier time testing this. :-)
And I should probably document this anyways, if I plan to regularly build my applications for both platforms.
Ok, I now found time to re-do and document the entire process, so you can possibly recreate it.
I will assume you have an ASIO-capable card in your system and the audio drivers installed and working.
Go to http://jackaudio.org/downloads, download JACK 2 for Windows (64-bit) and install it in the default location.
Default location: C:\Program Files (x86)\Jack\
Open up JACK Control, set the following options.
--- Parameters ---
Driver: portaudio Realtime: yes Sample rate: 96000 Frames/Period: 1024
--- Advanced ---
Output Device: [Your ASIO driver] (For me: "ASIO::UMC ASIO Driver") Input Device: [Your ASIO driver] (For me: "ASIO::UMC ASIO Driver")
Go to https://golang.org/dl/, download latest version of Go for Windows and install it in the default location.
Default location: C:\Go\
Download MinGW-w64 from: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download
Run the installer.
Change the architecture value to x86_64 for a 64-bit system.
By default, MinGW-w64 will install to C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
. Change that! The space will cause problems later on. I'm serious! Install it to C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
instead.
We will call that last path the MinGW-w64 root directory.
Download MSYS-20111123.zip from: https://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/.
Exctract the MSYS archive and it will contain a folder called msys
.
Take everything that's inside that folder and copy it into the MinGW-w64 root directory. (Do not copy the msys
folder itself, but its contents.)
When asked whether folders should be merged, say: "Yes, always."
Run msys.bat
and a /home
directory will be created (inside your MinGW-w64 root directory) and a POSIX shell will be opened.
Create ~/go
directory and directory structure.
$ mkdir go
$ cd go/
$ mkdir src
$ cd src/
$ mkdir github.com
$ cd github.com/
$ mkdir andrepxx
$ cd andrepxx/
$ mkdir go-jack
$ cd go-jack/
Download source of github.com/andrepxx/go-jack as ZIP file and extract the contents of the go-jack-master/
directory (contained within the Archive) to the directory created above (inside MinGW).
(No, you cannot just go get ...
it, since there is no git
in MinGW.)
Set your $GOPATH
. (Replace username with your actual user name. And no, you cannot use the tilde ~
shortcut.)
$ GOPATH="/home/username/go"
Build passthrough example.
First, edit passthrough.go
and midipassthrough.go
to import "github.com/andrepxx/go-jack"
instead of import "github.com/xthexder/go-jack"
, then try to build them.
$ cd example/
$ make
It will complain, that it cannot find the include jack/jack.h
.
Copy the jack
folder from C:\Program Files (x86)\Jack\includes
into /x86_64-w64-mingw32/include
inside your MinGW root directory.
Copy the contents of C:\Program Files (x86)\Jack\lib
into /x86_64-w64-mingw32/lib
inside your MinGW root directory.
Now, run make
again.
$ make
This time, the code should build successfully. Open up Jack Control (from the start menu), "Start" your JACK server, then go back to your MinGW shell.
$ ./passthrough.exe
And it works!
Go Passthrough will appear as a JACK client in the Connection window and pass audio signals through. :-)
Have fun! :-)
(I said it's painful, but it works. :-) )
I confirmed everything still works fine on linux, but didn't have time to go all the way through the windows setup. I'll merge this in now though, since the changes look good.
Thanks for documenting the windows setup! I'll probably add it to a wiki page / readme so it's easy to find for others.
Thanks a lot! :-)
I already tested this on Linux (both x86-64 and ARM).
It works everywhere - at least in principle. JACK itself doesn't really work on ARM currently. jackd just locks up after a while. This has nothing to do with go-jack though. It crashes even when no client is connected.
Linux is my primary platform.
Thanks for merging my last patch so quickly.
I got another set of modifications, which make this library more portable.
This time, I got it to work under Windows (with MSYS/MinGW).
The following changes were made:
Provide a mock "errno.h" header file, as a replacement for <sys/errno.h>, which is not available under Windows.
Use conditional compilation to either include <sys/errno.h> (if we are under a POSIX-compliant OS, such as Linux) or the mocked "errno.h" (if we are under Windows, where no actual "errno.h" header is available).
Use conditional compilation to either link against the library "jack" (if we are under a POSIX-compliant OS, such as Linux), "libjack" (if we are under a 32-bit Windows) or "libjack64" (if we are under a 64-bit Windows).
The user-space libraries for JACK 2 for Windows are called "libjack.lib" (32-bit library) and "libjack64.lib" (64-bit library), respectively.
Contrary to GCC on Linux, the "mingw" linker under Windows does not prefix libraries with "lib". However, the file names of the libraries begin with "lib", even for the Windows versions. Therefore, we have to include this prefix explicitely in the linker directive when building for Windows, but have to omit it when building for Linux (or other POSIX-compliant OS).
Replace the data type "uint", which is not an ANSI-C data type, with the standards-compliant (ANSI-C) data type "unsigned int" in the CGo code.
The non-standard data type "uint" is available under Linux, but not under Windows. Using the standard data type appears to have no negative consequences when building under Linux, but makes the code build (and function) under Windows, hence making it more portable.
One can now install JACK 2 for Windows on top of an ASIO4ALL driver and perform real-time audio processing in Go (with go-jack) on Windows.
Great! :-)
It's still a bit hard to get this to build. To summarize this quickly, one has to ...
CC=x86_64-w64-mingw32-gcc
, but possibly much more.)However, at least then, it actually builds under Windows, and I just got a full-fledged, productive audio application, based upon go-jack (but still unreleased), which was originally developed for Linux, running under Windows with the changes I made to the library.
This library is awesome! Thanks a lot! :-)
... and these modifications make it usable under Windows. :-)