Skip to content

Commit

Permalink
linking pending
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Oct 12, 2024
1 parent 18cf731 commit be87bbd
Show file tree
Hide file tree
Showing 38 changed files with 142 additions and 28 deletions.
Binary file added FileWriter.o
Binary file not shown.
Binary file added LockFreeQueue.o
Binary file not shown.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ LV2=`pkg-config --cflags lilv-0 --libs`
JACK=`pkg-config jack --libs --cflags`
SNDFILE=`pkg-config --libs sndfile --cflags`
OPUS=`pkg-config libopusenc opus --libs --cflags`
LAME=`pkg-config lame --libs --cflags`
LAME=`pkg-config lame --libs --cflags` -l:libmp3lame.a
X11=`pkg-config x11 --libs --cflags`
OPTIMIZE=#-Ofast -mtune=cortex-a72 -mcpu=cortex-a72
CC=cc
CPP=c++
else ifeq ($(TARGET),win32)
GTK=`x86_64-w64-mingw32-pkg-config --cflags --libs gtk4`
LV2=`pkg-config --cflags lilv-0 --libs`
JACK=`pkg-config jack --libs --cflags`
SNDFILE=`pkg-config --libs sndfile --cflags`
OPUS=`pkg-config libopusenc opus --libs --cflags`
LAME=`pkg-config lame --libs --cflags`
X11=`pkg-config x11 --libs --cflags`
OPTIMIZE=#-Ofast -mtune=cortex-a72 -mcpu=cortex-a72
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=
SNDFILE=
OPUS=
LAME=
X11=
OPTIMIZE=
CC=x86_64-w64-mingw32-gcc
CPP=x86_64-w64-mingw32-g++
CPP=x86_64-w64-mingw32-g++ -std=c++17
endif
all: amprack

amprack: version.o FileWriter.o main.o rack.o presets.o SharedLibrary.o engine.o jack.o process.o util.o snd.o knob.o
$(CPP) *.o -o amprack $(GTK) $(LV2) $(JACK) $(OPTIMIZE) $(SNDFILE) $(OPUS) -l:libmp3lame.a $(LAME)
$(CPP) *.o -o amprack $(GTK) $(LV2) $(JACK) $(OPTIMIZE) $(SNDFILE) $(OPUS) $(LAME) $(LAME)

main.o: main.cc main.h rack.o presets.o
$(CPP) main.cc -c $(GTK) $(LV2) $(OPTIMIZE) -Wno-deprecated-declarations
Expand Down Expand Up @@ -76,7 +76,7 @@ snd.o: snd.cc snd.h

knob.o: knob.cpp cairo.cpp objects.cpp dictionary.cpp mem.cpp pango.cpp
#~ cc -c `pkg-config gtk4 --libs --cflags` GxRegler.cpp GxControlParameter.cpp -w -lm drawingutils.cpp GxKnob.cpp GxBigKnob.cpp
$(CPP) `pkg-config gtk4 --libs --cflags` -w -lm knob.cpp cairo.cpp objects.cpp dictionary.cpp mem.cpp pango.cpp -c
$(CPP) $(GTK) -w -lm knob.cpp cairo.cpp objects.cpp dictionary.cpp mem.cpp pango.cpp -c

version.o:
echo \#define VERSION `git rev-list --count HEAD` > version.h
Expand Down
Binary file added Plugin.o
Binary file not shown.
Binary file added PluginControl.o
Binary file not shown.
Binary file added SharedLibrary.o
Binary file not shown.
Binary file added cairo.o
Binary file not shown.
Binary file added dictionary.o
Binary file not shown.
26 changes: 22 additions & 4 deletions engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,32 @@ bool Engine::openAudio () {
}

Engine::Engine () {
#ifdef __linux__
struct utsname name;
if (uname (&name) == -1)
wtf ("cannot get system name!\n") ;
#endif

home = std::string (getenv("HOME")).append ("/amprack/recordings");
g_mkdir_with_parents (home.c_str (), 0777);

std::string _p_ = std::string ("libs/linux/").append (name.machine).append ("/") ;
# ifdef __linux__
std::string _p_ = std::string ("libs/linux/").append (name.machine).append ("/") ;
# else
std::string _p_ = std::string ("libs/win32/") ;
# endif

libraryPath = strdup (_p_.c_str ());
wtf ("trying %s ...\n", libraryPath);
if (! std::filesystem::exists (libraryPath)) {
free(libraryPath);

# ifdef __linux__
std::string _p_ = std::string ("/usr/share/amprack/libs/linux/").append (name.machine).append ("/") ;
# else
std::string _p_ = std::string ("C:\\Program Files\\Amp Rack\\Libs") ;
# endif

std::string _p_ = std::string ("/usr/share/amprack/libs/linux/").append (name.machine).append ("/") ;
libraryPath = strdup (_p_.c_str ());
wtf ("trying %s ...\n", libraryPath);
}
Expand Down Expand Up @@ -241,6 +253,7 @@ bool Engine::load_preset (json j) {

void Engine::set_plugin_audio_file (int index, char * filename) {
IN
# ifdef __linux__
SoundFile * sf = snd_read (filename) ;
if (sf == NULL) {
LOGD ("file read failed!\n");
Expand All @@ -250,6 +263,7 @@ void Engine::set_plugin_audio_file (int index, char * filename) {
}

LOGD ("file read ok! set plugin: %d [%d bytes]\n", index, * sf -> len);
# endif

//~ for (int i = 0 ; i < * sf -> len; i ++)
//~ LOGD ("[frame: %f]\n", sf -> data [i]);
Expand All @@ -260,13 +274,17 @@ void Engine::set_plugin_audio_file (int index, char * filename) {
//~ *sf -> len = * sf -> len / 2 ;

processor->bypass = true ;

# ifdef __linux__
activePlugins->at (index)->setBuffer (sf ->data, * sf -> len);
delete (sf) ;
# endif

processor->bypass = false ;

activePlugins->at (index)->loadedFileName = std::string (filename) ;
activePlugins->at (index)->loadedFileType = 0 ;
delete (sf) ;


std::string path = std::string (filename) ;

std::string dir = std::string (getenv ("HOME")).append ("/amprack/models/").append (activePlugins->at (index)->lv2_name).append ("/");
Expand Down
12 changes: 9 additions & 3 deletions engine.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#ifndef ENGINE_H
#define ENGINE_H

#ifdef __linux__
#include <lilv/lilv.h>
#include <sys/utsname.h>
#include "snd.h"
#include "jack.h"
#else
#include "pa.h"
#endif

#include <iostream>
#include <filesystem>
#include <sys/utsname.h>

#include <unistd.h>

#include "SharedLibrary.h"
#include "Plugin.h"
#include "jack.h"
#include "process.h"
#include "util.h"
#include "snd.h"
#include "LockFreeQueue.h"
#include "FileWriter.h"

Expand Down
Binary file added engine.o
Binary file not shown.
8 changes: 6 additions & 2 deletions gtk_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
// SPDX-License-Identifier: CC0-1.0

#include <gtk/gtk.h>

#ifndef __linux__
#define _WIN32
#undef HAVE_X11
#else
#define HAVE_X11
#endif

#ifdef HAVE_X11
/* hack to drop dumb typedefs and macros defined by X11 */
# define Region RegionForX11
Expand All @@ -12,7 +17,6 @@
# undef Region
# undef None
#endif

#ifdef _WIN32
# include <gdk/win32/gdkwin32.h>
#endif
3 changes: 3 additions & 0 deletions jack.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __linux__
#include "jack.h"

int
Expand Down Expand Up @@ -139,3 +140,5 @@ int AudioDriver::get_sample_rate () {
int AudioDriver::get_buffer_size () {
return jack_get_buffer_size (client);
}

#endif
Binary file added jack.o
Binary file not shown.
Binary file added knob.o
Binary file not shown.
Binary file added lv2_ext.o
Binary file not shown.
Binary file added main.o
Binary file not shown.
Binary file added mem.o
Binary file not shown.
Binary file added objects.o
Binary file not shown.
46 changes: 46 additions & 0 deletions pa.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "pa.h"

int
process (int nframes, void *arg)
{
AudioDriver * driver = (AudioDriver *) arg ;
float *in, *out;

driver -> processor -> process (nframes, in, out);
return 0;
}

bool AudioDriver::activate () {

/* Connect the ports. You can't do this before the client is
* activated, because we can't make connections to clients
* that aren't running. Note the confusing (but necessary)
* orientation of the driver backend ports: playback ports are
* "input" to the backend, and capture ports are "output" from
* it.
*/

return true ;
}

bool AudioDriver::deactivate () {

return true ;

}

bool AudioDriver::open () {
return activate () ;
}

void AudioDriver::close () {

}

int AudioDriver::get_sample_rate () {
return 48000;
}

int AudioDriver::get_buffer_size () {
return 192 ;
}
26 changes: 26 additions & 0 deletions pa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef PA_H
#define PA_H

#include <cstdlib>
#include <cstdio>
#include <cstring>

#include "log.h"
#include "process.h"

class AudioDriver {
public:
Processor * processor = nullptr;
AudioDriver (Processor * e) {
processor = e ;
}

bool open ();
void close ();
int get_sample_rate () ;
bool activate () ;
bool deactivate () ;
int get_buffer_size ();
} ;

#endif
Binary file added pango.o
Binary file not shown.
7 changes: 7 additions & 0 deletions pluginui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,16 @@ PluginUI::PluginUI (Engine * _engine, Plugin * _plugin, GtkBox * _parent, std::s
int y = 0 ;
while (bypassContains [y] != nullptr) {
//~ wtf ("%s > %s = %d\n", bypassContains [y], control -> name, strcasestr (bypassContains [y], control -> name));
#ifdef __linux__
if (strcasestr (control -> name, bypassContains [y]) != NULL) {
bypassBtn = (GtkToggleButton *) gtk_toggle_button_new_with_label (control->name);
}
#else
if (stricmp (control -> name, bypassContains [y]) == 0) {
bypassBtn = (GtkToggleButton *) gtk_toggle_button_new_with_label (control->name);
}

#endif

y ++ ;
}
Expand Down
Binary file added pluginui.o
Binary file not shown.
4 changes: 2 additions & 2 deletions presets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void Presets::load_user (bool isFav) {
for (const auto & entry : std::filesystem::directory_iterator(where)) {
//~ std::cout << entry.path() << std::endl;

json j = filename_to_json (entry.path ());
json j = filename_to_json (entry.path ().string ());
if (! isFav)
add_preset (j, 1);
else
Expand Down Expand Up @@ -521,7 +521,7 @@ void Presets::save_presets_to_json (std::string filename) {
int i = 0 ;
for (const auto & entry : std::filesystem::directory_iterator(*presets_dir)) {
//~ std::cout << entry.path() << std::endl;
json j = filename_to_json (entry.path ());
json j = filename_to_json (entry.path ().string ());
ex [std::to_string (i++)] = j ;
}

Expand Down
Binary file added presets.o
Binary file not shown.
Binary file added process.o
Binary file not shown.
2 changes: 1 addition & 1 deletion rack.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Rack {
GtkSwitch * onoff ;
GtkToggleButton * toggle_presets ;

bool bnobs = true ;
bool bnobs = false ;
int patch = 0;

std::vector <PluginUI> plugins ;
Expand Down
Binary file added rack.o
Binary file not shown.
Binary file added settings.o
Binary file not shown.
2 changes: 2 additions & 0 deletions snd.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __linux__
#include "snd.h"

SoundFile * snd_read (char * filename) {
Expand Down Expand Up @@ -25,3 +26,4 @@ SoundFile * snd_read (char * filename) {
OUT
return soundFile ;
}
#endif
Binary file added snd.o
Binary file not shown.
3 changes: 2 additions & 1 deletion types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#define __UTILS_TYPES_H__

#include <cstdint>

#ifdef __linux__
#include "gtk_wrapper.h"
#endif
#include <cinttypes>

#pragma GCC diagnostic push
Expand Down
Binary file added upwaker.o
Binary file not shown.
5 changes: 3 additions & 2 deletions util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,16 @@ char ** list_directory (std::string dir) {
return entries ;
}

std::vector <std::string> files ;
std::vector <std::filesystem::path> files ;
for (const auto & entry : std::filesystem::directory_iterator(dir)) {
wtf ("[file] %s\n", entry.path ());
files.push_back (entry.path ());
}

char ** entries = (char **)malloc (files.size () + 1);
for (int i = 0 ; i < files.size (); i ++) {
std::string path = std::string (files.at (i)) ;
//~ std::string path = std::string (files.at (i)) ;
std::string path {files.at (i).string ()} ;
wtf ("[before] %s\n", path);
path = path.substr(path.find_last_of("/") + 1).c_str () ;
wtf ("[after] %s\n", path);
Expand Down
Binary file added 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 135
#define VERSION 136
Binary file added vringbuffer.o
Binary file not shown.

0 comments on commit be87bbd

Please sign in to comment.