Skip to content

Commit

Permalink
ladies and gentlemen,
Browse files Browse the repository at this point in the history
it works on win32
ᕕ( ᐛ )ᕗ
  • Loading branch information
Shaji Khan committed Oct 18, 2024
1 parent 45147da commit 76a57ea
Show file tree
Hide file tree
Showing 38 changed files with 102 additions and 44 deletions.
Binary file modified FileWriter.o
Binary file not shown.
Binary file modified LockFreeQueue.o
Binary file not shown.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#~ GTKMM=`pkg-config --cflags --libs gtkmm-4.0`

TARGET=linux
#TARGET=win32
TARGET=win32

ifeq ($(TARGET),linux)
GTK=`pkg-config --cflags --libs gtk4`
Expand All @@ -19,15 +19,15 @@ CPP=c++
else ifeq ($(TARGET),win32)
GTK=`x86_64-w64-mingw32-pkg-config --cflags --libs gtk4 gtk4-win32` -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/gtk-4.0/
LV2=
JACK=`mingw64-pkg-config portaudio-2.0 --libs --cflags`
JACK=-ljack64 -L.
SNDFILE=
OPUS=`x86_64-w64-mingw32-pkg-config --cflags --libs opus opusfile`
LAME=
LAME=-llibmp3lame
X11=
GLIB=`mingw64-pkg-config glib-2.0 --libs --cflags`
OPTIMIZE=
CC=x86_64-w64-mingw32-gcc -g -mwindows
CPP=x86_64-w64-mingw32-g++ -std=c++17 -g -mwindows
CC=x86_64-w64-mingw32-gcc -g -mwindows -mconsole
CPP=x86_64-w64-mingw32-g++ -std=c++17 -g -mwindows -mconsole
DLFCN=-llibdl
endif
all: amprack
Expand Down Expand Up @@ -69,13 +69,13 @@ test: lv2_test.c
$(CC) lv2_test.c $(LV2) -I/usr/include/lv2 -o lv2_test

# DEV
ifeq ($(TARGET),linux1)
#~ ifeq ($(TARGET),linux1)
jack.o: jack.cc jack.h
$(CC) jack.cc -c $(JACK) $(GTK)
else
jack.o: pa.cc pa.h
$(CPP) pa.cc -c $(GTK) $(JACK) -o jack.o $(GLIB)
endif
#~ else
#~ jack.o: pa.cc pa.h
#~ $(CPP) pa.cc -c $(GTK) $(JACK) -o jack.o $(GLIB)
#~ endif

process.o: process.cc process.h
$(CC) process.cc -c $(GTK)
Expand Down
Binary file modified Plugin.o
Binary file not shown.
Binary file modified PluginControl.o
Binary file not shown.
Binary file modified SharedLibrary.o
Binary file not shown.
Binary file removed amprack
Binary file not shown.
Binary file modified amprack.exe
Binary file not shown.
Binary file modified cairo.o
Binary file not shown.
Binary file modified dictionary.o
Binary file not shown.
6 changes: 6 additions & 0 deletions engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Engine::Engine () {
std::string _p_ = std::string ("libs/linux/").append (name.machine).append ("/") ;
# else
std::string _p_ = std::string ("libs/win32/") ;
LOGD ("[engine] %d\n", GetCurrentThreadId());
# endif

libraryPath = strdup (_p_.c_str ());
Expand Down Expand Up @@ -113,6 +114,9 @@ Engine::Engine () {

processor = new Processor () ;
openAudio () ;

HERE LOGD ("processor status %d\n", processor->bypass);
//~ processor -> bypass = false ;

ladspaPlugins = new std::vector <std::string> ();
lv2Plugins = new std::vector <std::string> ();
Expand All @@ -129,6 +133,8 @@ Engine::Engine () {
fileWriter = new FileWriter ();
queueManager.add_function (fileWriter->disk_write);
processor->lockFreeQueueManager = & queueManager ;
HERE LOGD ("processor status %d\n", processor->bypass);
//~ processor -> bypass = false ;
OUT
}

Expand Down
Binary file modified engine.o
Binary file not shown.
42 changes: 24 additions & 18 deletions jack.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef __linux__
#include "jack.h"

int
Expand Down Expand Up @@ -26,8 +25,9 @@ jack_shutdown (void *arg)
}

bool AudioDriver::activate () {
IN
if (jack_activate (client)) {
fprintf (stderr, "cannot activate client");
LOGD ( "cannot activate client");
return false ;
}

Expand All @@ -42,36 +42,38 @@ bool AudioDriver::activate () {
i_ports = jack_get_ports (client, NULL, NULL,
JackPortIsPhysical|JackPortIsOutput);
if (i_ports == NULL) {
fprintf(stderr, "no physical capture ports\n");
LOGD ("no physical capture ports\n");
return false ;
}

if (jack_connect (client, i_ports[0], jack_port_name (input_port))) {
fprintf (stderr, "cannot connect input ports\n");
LOGD ( "cannot connect input ports\n");
}

o_ports = jack_get_ports (client, NULL, NULL,
JackPortIsPhysical|JackPortIsInput);
if (o_ports == NULL) {
fprintf(stderr, "no physical playback ports\n");
LOGD ("no physical playback ports\n");
return false ;
}

if (jack_connect (client, jack_port_name (output_port), o_ports[0])) {
fprintf (stderr, "cannot connect output ports\n");
return false ;
LOGD ( "cannot connect output ports\n");
return false ;
}

LOGD ("[audio engine ok]");
free (i_ports);
free (o_ports);

//~ free (i_ports);
//~ free (o_ports);

LOGD ("[processor %d] great success!\n", processor -> bypass);
OUT
return true ;
}

bool AudioDriver::deactivate () {
if (jack_deactivate (client)) {
fprintf (stderr, "cannot deactivate client");
LOGD ( "cannot deactivate client");
return false ;
}

Expand All @@ -80,32 +82,36 @@ bool AudioDriver::deactivate () {
}

bool AudioDriver::open () {
IN
client_name = strdup ("Amp Rack\0");
LOGD ("client name: %s\n", client_name);
client = jack_client_open (client_name, options, &status, server_name);
if (client == NULL) {
fprintf (stderr, "jack_client_open() failed, "
LOGD ("jack_client_open() failed, "
"status = 0x%2.0x\n", status);
//~ abort ();
return false ;
}

if (status & JackServerFailed) {
fprintf (stderr, "Unable to connect to JACK server\n");
LOGD ("Unable to connect to JACK server\n");
return false ;
}


if (status & JackServerStarted) {
fprintf (stderr, "JACK server started\n");
LOGD ("JACK server started\n");
}

if (status & JackNameNotUnique) {
client_name = jack_get_client_name(client);
fprintf (stderr, "unique name `%s' assigned\n", client_name);
LOGD ("unique name `%s' assigned\n", client_name);
}

jack_set_process_callback (client, process, this);
jack_on_shutdown (client, jack_shutdown, 0);

printf ("engine sample rate: %" PRIu32 "\n",
LOGD ("engine sample rate: %" PRIu32 "\n",
jack_get_sample_rate (client));

/* create two ports */
Expand All @@ -118,14 +124,15 @@ bool AudioDriver::open () {
JackPortIsOutput, 0);

if ((input_port == NULL) || (output_port == NULL)) {
fprintf(stderr, "no more JACK ports available\n");
LOGD ("no more JACK ports available\n");
exit (1);
}

/* Tell the JACK server that we are ready to roll. Our
* process() callback will start running now. */


OUT
return activate () ;
}

Expand All @@ -141,4 +148,3 @@ int AudioDriver::get_buffer_size () {
return jack_get_buffer_size (client);
}

#endif
Binary file modified jack.o
Binary file not shown.
Binary file modified knob.o
Binary file not shown.
Binary file added libjack64.dll.a
Binary file not shown.
Binary file added libmp3lame.dll.a
Binary file not shown.
2 changes: 2 additions & 0 deletions log.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ int printf_windows (const char* format, ...) ;
#define ASSERT(cond, ...)
#define LOGV(arg) printf_windows("!! [%s: %d] %s\n", __FILE__, __LINE__, arg) ;
#define HERE printf_windows("!! %s: %d\n", __FILE__, __LINE__) ;
#define IN printf_windows(">> %s\n", __PRETTY_FUNCTION__);
#define OUT printf_windows("<< %s \n", __PRETTY_FUNCTION__);

#endif

Expand Down
Binary file modified log.o
Binary file not shown.
Binary file modified lv2_ext.o
Binary file not shown.
4 changes: 4 additions & 0 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ void activate (GApplication * app, void * v) {

if (std::filesystem::exists (user_css))
gtk_css_provider_load_from_path(cssProvider2, user_css.c_str());

gtk_style_context_add_provider_for_display (gdk_display_get_default (), (GtkStyleProvider *)cssProvider2, GTK_STYLE_PROVIDER_PRIORITY_USER);

window.rack -> engine -> processor -> bypass = false ;

gtk_window_present ((GtkWindow *)window.window);
LOGD ("we are live and rocking\n");
OUT
}

Expand Down
Binary file modified main.o
Binary file not shown.
Binary file modified mem.o
Binary file not shown.
Binary file modified objects.o
Binary file not shown.
3 changes: 3 additions & 0 deletions pa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ bool AudioDriver::open () {
return false;
}

LOGD( "PortAudio version number = %d\nPortAudio version text = '%s'\n",
Pa_GetVersion(), Pa_GetVersionText() );

OUT
return activate () ;
}
Expand Down
Binary file modified pango.o
Binary file not shown.
Binary file modified pluginui.o
Binary file not shown.
Binary file modified presets.o
Binary file not shown.
38 changes: 35 additions & 3 deletions process.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
#include "process.h"

bool Processor::recording = false ;
bool Processor::bypass = false ;
int Processor::activePlugins = 0;
int Processor::inputPorts [MAX_PLUGINS];
int Processor::inputPorts2 [MAX_PLUGINS];
int Processor::outputPorts [MAX_PLUGINS];
int Processor::outputPorts2 [MAX_PLUGINS];
void * Processor::handle [MAX_PLUGINS] ;

void (*Processor::connect_port [MAX_PLUGINS])(LADSPA_Handle Instance,
unsigned long Port,
LADSPA_Data * DataLocation);
void (*Processor::run [MAX_PLUGINS])(LADSPA_Handle Instance,
unsigned long SampleCount);
void (*Processor::run_adding [MAX_PLUGINS])(LADSPA_Handle Instance,
unsigned long SampleCount);
void (*Processor::set_run_adding_gain [MAX_PLUGINS])(LADSPA_Handle Instance,
LADSPA_Data Gain);



void Processor::process (int n_samples, float * in, float * data) {
memcpy (data, in, sizeof (float) * n_samples);
if (bypass)
//~ LOGD ("[process] %d\n", GetCurrentThreadId());
if (bypass) {
//~ LOGD ("[status: %d] WARNING: audio driver process bypass\n", bypass);
return ;

}

//~ LOGD ("active plugins: %d", activePlugins);

for (int i = 0 ; i < activePlugins ; i ++) {
//~ LOGD ("[process plugin] %d", i);
if (inputPorts [i] != -1)
connect_port [i] (handle [i], inputPorts [i], (LADSPA_Data *) data);
if (outputPorts [i] != -1)
Expand All @@ -17,7 +44,7 @@ void Processor::process (int n_samples, float * in, float * data) {
connect_port [i] (handle [i], outputPorts2 [i], (LADSPA_Data *) data);

if (run [i] == NULL)
LOGF ("run %d is null", i);
LOGD ("run %d is null", i);
else
run [i] (handle [i], n_samples);
/*
Expand All @@ -33,3 +60,8 @@ void Processor::process (int n_samples, float * in, float * data) {
lockFreeQueueManager->process(in, data, n_samples) ;
}

Processor::Processor () {
bypass = false ;
recording = false ;
LOGD ("bypass: %d\n", bypass);
}
29 changes: 17 additions & 12 deletions process.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,37 @@
#include "logging_macros.h"
#include "LockFreeQueue.h"

# ifndef __linux__
# include <windows.h>
# endif

#define MAX_PLUGINS 10 // aaarrrrghhhhhh

class Processor {
public:
void (*connect_port [MAX_PLUGINS])(LADSPA_Handle Instance,
static void (*connect_port [MAX_PLUGINS])(LADSPA_Handle Instance,
unsigned long Port,
LADSPA_Data * DataLocation);
void (*run [MAX_PLUGINS])(LADSPA_Handle Instance,
static void (*run [MAX_PLUGINS])(LADSPA_Handle Instance,
unsigned long SampleCount);
void (*run_adding [MAX_PLUGINS])(LADSPA_Handle Instance,
static void (*run_adding [MAX_PLUGINS])(LADSPA_Handle Instance,
unsigned long SampleCount);
void (*set_run_adding_gain [MAX_PLUGINS])(LADSPA_Handle Instance,
static void (*set_run_adding_gain [MAX_PLUGINS])(LADSPA_Handle Instance,
LADSPA_Data Gain);

void * handle [MAX_PLUGINS] ;
static void * handle [MAX_PLUGINS] ;
LADSPA_Data run_adding_gain [MAX_PLUGINS] ;
const LADSPA_Descriptor * descriptor [MAX_PLUGINS] ;
int inputPorts [MAX_PLUGINS] ;
int inputPorts2 [MAX_PLUGINS] ;
int outputPorts [MAX_PLUGINS] ;
int outputPorts2 [MAX_PLUGINS] ;
static int inputPorts [MAX_PLUGINS] ;
static int inputPorts2 [MAX_PLUGINS] ;
static int outputPorts [MAX_PLUGINS] ;
static int outputPorts2 [MAX_PLUGINS] ;

int activePlugins = 0;
static int activePlugins;
void process (int, float *, float *);
bool bypass = false, recording = false ;
static bool bypass, recording;
LockFreeQueueManager * lockFreeQueueManager;


Processor () ;
};
#endif
Binary file modified process.o
Binary file not shown.
Binary file modified rack.o
Binary file not shown.
Binary file modified settings.o
Binary file not shown.
Binary file modified snd.o
Binary file not shown.
Binary file modified upwaker.o
Binary file not shown.
Binary file modified util.o
Binary file not shown.
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION 141
#define VERSION 142
Binary file modified vringbuffer.o
Binary file not shown.

0 comments on commit 76a57ea

Please sign in to comment.