Skip to content

Commit

Permalink
config renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Oct 23, 2024
1 parent d82d085 commit 4a5f568
Show file tree
Hide file tree
Showing 38 changed files with 119 additions and 37 deletions.
Binary file modified FileWriter.o
Binary file not shown.
Binary file modified LockFreeQueue.o
Binary file not shown.
2 changes: 1 addition & 1 deletion 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 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 added amprack
Binary file not shown.
Binary file modified amprack.exe
Binary file not shown.
12 changes: 6 additions & 6 deletions assets/themes/Analog/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ spinbutton > text, spinbutton > button {
}

#knob3 {
background-image:url("file:///usr/share/amprack/assets/themes/Analog/knobs/5.png");
background-image:url("knobs/5.png");
background-position: center;
background-repeat: no-repeat;
}

#knob2 {
background-image:url("file:///usr/share/amprack/assets/themes/Analog/knobs/4.png");
background-image:url("knobs/4.png");
background-position: center;
background-repeat: no-repeat;
}
#knob1 {
background-image:url("file:///usr/share/amprack/assets/themes/Analog/knobs/3.png");
background-image:url("knobs/3.png");
background-position: center;
background-repeat: no-repeat;
}
#knob0 {
background-image:url("file:///usr/share/amprack/assets/themes/Analog/knobs/2.png");
background-image:url("knobs/2.png");
background-position: center;
background-repeat: no-repeat;
}

/*
#bypass > active {
background-image:url("file:///usr/share/amprack/assets/themes/Analog/on.png");
background-image:url("on.png");
background-position: center;
background-repeat: no-repeat;
}
#bypass {
background-image:url("file:///usr/share/amprack/assets/themes/Analog/off.png");
background-image:url("off.png");
background-position: center;
background-repeat: no-repeat;
}
Expand Down
16 changes: 8 additions & 8 deletions assets/themes/Classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,45 @@ spinbutton > text, spinbutton > button {
}

#plugin, headerbar, notebook > header {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/card/bg.png");
border-image:url("file:///usr/share/amprack/assets/themes/Classic/card/left.png") 10 round;
background-image:url("card/bg.png");
border-image:url("card/left.png") 10 round;
border: 5px solid ;
border-style: solid;
background-repeat: repeat;

}

#knob3 {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/knobs/5.png");
background-image:url("knobs/5.png");
background-position: center;
background-repeat: no-repeat;
}

#knob2 {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/knobs/4.png");
background-image:url("knobs/4.png");
background-position: center;
background-repeat: no-repeat;
}
#knob1 {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/knobs/3.png");
background-image:url("knobs/3.png");
background-position: center;
background-repeat: no-repeat;
}
#knob0 {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/knobs/2.png");
background-image:url("knobs/2.png");
background-position: center;
background-repeat: no-repeat;
}

/*
#bypass > active {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/on.png");
background-image:url("on.png");
background-position: center;
background-repeat: no-repeat;
}
#bypass {
background-image:url("file:///usr/share/amprack/assets/themes/Classic/off.png");
background-image:url("off.png");
background-position: center;
background-repeat: no-repeat;
}
Expand Down
16 changes: 8 additions & 8 deletions assets/themes/Hybrid/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,44 @@ spinbutton > text, spinbutton > button {
}

#plugin, headerbar, notebook > header {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/card/bg.png");
border-image:url("file:///usr/share/amprack/assets/themes/Hybrid/card/left.png") 10 round;
background-image:url("card/bg.png");
border-image:url("card/left.png") 10 round;
border: 5px solid ;
border-style: solid;

}

#knob3 {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/knobs/5.png");
background-image:url("knobs/5.png");
background-position: center;
background-repeat: no-repeat;
}

#knob2 {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/knobs/4.png");
background-image:url("knobs/4.png");
background-position: center;
background-repeat: no-repeat;
}
#knob1 {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/knobs/3.png");
background-image:url("knobs/3.png");
background-position: center;
background-repeat: no-repeat;
}
#knob0 {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/knobs/2.png");
background-image:url("knobs/2.png");
background-position: center;
background-repeat: no-repeat;
}

/*
#bypass > active {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/on.png");
background-image:url("on.png");
background-position: center;
background-repeat: no-repeat;
}
#bypass {
background-image:url("file:///usr/share/amprack/assets/themes/Hybrid/off.png");
background-image:url("off.png");
background-position: center;
background-repeat: no-repeat;
}
Expand Down
16 changes: 8 additions & 8 deletions assets/themes/Modern/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,44 @@ spinbutton > text, spinbutton > button {
}

#plugin, headerbar {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/card/bg.png");
border-image:url("file:///usr/share/amprack/assets/themes/Modern/card/left.png") 10 round;
background-image:url("card/bg.png");
border-image:url("card/left.png") 10 round;
border: 5px solid ;
border-style: solid;

}

#knob3 {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/knobs/5.png");
background-image:url("knobs/5.png");
background-position: center;
background-repeat: no-repeat;
}

#knob2 {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/knobs/4.png");
background-image:url("knobs/4.png");
background-position: center;
background-repeat: no-repeat;
}
#knob1 {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/knobs/3.png");
background-image:url("knobs/3.png");
background-position: center;
background-repeat: no-repeat;
}
#knob0 {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/knobs/2.png");
background-image:url("knobs/2.png");
background-position: center;
background-repeat: no-repeat;
}

/*
#bypass > active {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/on.png");
background-image:url("on.png");
background-position: center;
background-repeat: no-repeat;
}
#bypass {
background-image:url("file:///usr/share/amprack/assets/themes/Modern/off.png");
background-image:url("off.png");
background-position: center;
background-repeat: no-repeat;
}
Expand Down
Binary file modified cairo.o
Binary file not shown.
Binary file modified dictionary.o
Binary file not shown.
Binary file modified engine.o
Binary file not shown.
8 changes: 6 additions & 2 deletions jack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ bool AudioDriver::activate () {
}

bool AudioDriver::deactivate () {
IN
LOGD ("DE activate");
if (jack_deactivate (client)) {
LOGD ( "cannot deactivate client");
return false ;
}

OUT
return true ;

}
Expand Down Expand Up @@ -137,7 +139,9 @@ bool AudioDriver::open () {
}

void AudioDriver::close () {
jack_client_close (client);
IN
jack_client_close (client);
OUT
}

int AudioDriver::get_sample_rate () {
Expand Down
Binary file modified jack.o
Binary file not shown.
Binary file modified knob.o
Binary file not shown.
Binary file modified log.o
Binary file not shown.
Binary file modified lv2_ext.o
Binary file not shown.
26 changes: 25 additions & 1 deletion main.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#include "main.h"
const char * renderers [7] = {
"auto",
"cairo",
"gl",
"ngl",
"vulkan",
nullptr
} ;

void activate (GApplication * app, void * v) {
IN
Expand Down Expand Up @@ -42,7 +50,23 @@ int main(int argc, char* argv[])
{
LOGD ("Rock and roll can never die");
IN
g_setenv ("GSK_RENDERER", "cairo", 1);
# ifdef __linux__
std::string config = std::string (getenv ("HOME")).append ("/.config/amprack/config.json");
# else
std::string config = std::string (getenv ("USERPROFILE")).append ("/.config/amprack/config.json");
# endif

LOGD ("[config] load: %s\n", config.c_str ());
json j = filename_to_json (config);

if (j.contains ("renderer")) {
int renderer = j ["renderer"] . get <int> () ;
if (renderer) {
g_setenv ("GSK_RENDERER", renderers [renderer], 1);
LOGD ("[config] set renderer to %s\n", renderers [renderer]);
}
}

auto app = gtk_application_new ("org.acoustixaudio.amprack", G_APPLICATION_DEFAULT_FLAGS);

//~ window.set_title("Gtk4 Demo");
Expand Down
13 changes: 12 additions & 1 deletion main.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,19 @@ void qquit (void *) {
}

void quit (void * w, void * d) {
IN
MyWindow * window = (MyWindow *) d ;
LOGD ("sss %d\n", window -> rack -> hearts.size ());
LOGD ("Closing audio ...\n");
window -> rack -> engine -> driver -> deactivate ();
window -> rack -> engine -> driver -> close ();
LOGD ("Saving preset ...\n");

window -> rack -> engine -> savePreset (std::string (window -> presets -> dir) .append ("/default").c_str (), "Last saved preset") ;

json favs = {} ;

LOGD ("Saving favorites ...\n");

for (int i = 0 ; i < window -> rack -> hearts.size (); i ++) {
GtkWidget * fav = (GtkWidget *) window -> rack -> hearts.at (i);
if (gtk_toggle_button_get_active ((GtkToggleButton *)fav)) {
Expand All @@ -141,14 +147,19 @@ void quit (void * w, void * d) {
}

json_to_filename (favs, std::string (window -> presets -> dir).append ("/fav.json"));

LOGD ("Saving settings ...\n");
# ifdef __linux__
json_to_filename (window -> rack->config, std::string (getenv ("HOME")).append ("/.config/amprack/config.json"));
# else
json_to_filename (window -> rack->config, std::string (getenv ("USERPROFILE")).append ("/.config/amprack/config.json"));
# endif

LOGD ("Ok done, goodbye xoxo ...\n");

gtk_window_destroy ((GtkWindow *)window -> gobj ());
g_application_quit ((GApplication *)window -> app);
OUT
}

// omg
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.
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.
Binary file modified process.o
Binary file not shown.
Binary file modified rack.o
Binary file not shown.
44 changes: 43 additions & 1 deletion settings.cc
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
#include "settings.h"

void switch_renderer (GtkDropDown * dropdown, int event, Rack * rack) {
rack->config ["renderer"] = gtk_drop_down_get_selected (dropdown);
# ifdef __linux__
json_to_filename (rack->config, std::string (getenv ("HOME")).append ("/.config/amprack/config.json"));
# else
json_to_filename (rack->config, std::string (getenv ("USERPROFILE")).append ("/.config/amprack/config.json"));
# endif

}

void switch_theme (GtkDropDown * dropdown, int event, Rack * rack) {
GtkCssProvider *cssProvider = gtk_css_provider_new();
const char * basename = gtk_string_object_get_string ((GtkStringObject *)gtk_drop_down_get_selected_item ((GtkDropDown *)dropdown));
if (basename == NULL)
return ;

std::string filename = std::string ("/usr/share/amprack/assets/themes/").append (std::string (basename)).append ("/style.css");
std::string filename = std::string ("assets/themes/").append (std::string (basename)).append ("/style.css");
if (! std::filesystem::exists (filename))
return ;

gtk_css_provider_load_from_path(cssProvider, filename.c_str ());
gtk_style_context_add_provider_for_display (gdk_display_get_default (), (GtkStyleProvider *)cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
rack -> config ["theme"] = std::string (basename);
# ifdef __linux__
json_to_filename (rack->config, std::string (getenv ("HOME")).append ("/.config/amprack/config.json"));
# else
json_to_filename (rack->config, std::string (getenv ("USERPROFILE")).append ("/.config/amprack/config.json"));
# endif

}

Settings::Settings (Rack * rack) {
grid = gtk_grid_new () ;
gtk_widget_set_name ((GtkWidget *) grid, "plugin");
GtkLabel * l1 = (GtkLabel *)gtk_label_new ("Theme");
GtkLabel * l2 = (GtkLabel *)gtk_label_new ("Renderer");
const char * themes [5] = {
"TubeAmp",
"Classic",
Expand All @@ -27,11 +44,36 @@ Settings::Settings (Rack * rack) {
nullptr
} ;

const char * renderers [7] = {
"auto",
"cairo",
"gl",
"ngl",
"vulkan",
nullptr
} ;

int current_rend = 0 ;
if (rack -> config.contains ("renderer")) {
current_rend = rack -> config ["renderer"].get <int> () ;
LOGD ("[config] current renderer: %d\n", current_rend);
}

GtkDropDown * theme = (GtkDropDown *)gtk_drop_down_new_from_strings (themes);
gtk_widget_set_margin_end ((GtkWidget *) l1, 10);

g_signal_connect (theme, "notify::selected", (GCallback) switch_theme, rack);

gtk_grid_attach ((GtkGrid *) grid, (GtkWidget *)l1, 0, 0, 1, 1);
gtk_grid_attach ((GtkGrid *) grid, (GtkWidget *)theme, 1, 0, 1, 1);

GtkDropDown * rend = (GtkDropDown *)gtk_drop_down_new_from_strings (renderers);
gtk_widget_set_margin_end ((GtkWidget *) l2, 10);

g_signal_connect (rend, "notify::selected", (GCallback) switch_renderer, rack);

gtk_grid_attach ((GtkGrid *) grid, (GtkWidget *)l2, 0, 2, 1, 1);
gtk_grid_attach ((GtkGrid *) grid, (GtkWidget *)rend, 1, 2, 1, 1);

gtk_drop_down_set_selected (rend, current_rend);
}
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.
Loading

0 comments on commit 4a5f568

Please sign in to comment.