Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kmatheussen/radium
Browse files Browse the repository at this point in the history
  • Loading branch information
kmatheussen committed Jan 28, 2024
2 parents 87b6ca5 + 6d4c96a commit 19809f2
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 82 deletions.
21 changes: 17 additions & 4 deletions Makefile.Qt
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,21 @@ ifeq ($(RADIUM_QT_VERSION),5)
# QT_LDFLAGS ?= `$(PKGqt) --libs Qt5Gui --libs Qt5OpenGL --libs Qt5Network --libs Qt5Widgets --libs Qt5WebEngineWidgets`

# If using QtWebKit:
QT_CFLAGS ?= `$(PKGqt) --cflags Qt5Gui --cflags Qt5Network --cflags Qt5OpenGL --cflags Qt5Widgets --cflags Qt5WebKitWidgets --cflags Qt5WebKit --cflags Qt5Concurrent` -I$(QHTTPSERVER_PATH)/src -I$(QSCINTILLA_PATH) -DQHTTPSERVER_EXPORT $(QT_SYSTEM_CFLAGS) $(FPIC)
QT_LDFLAGS ?= $(QT_UI_LDFLAGS) $(QT_SVG_LDFLAGS) `$(PKGqt) --libs Qt5Gui --libs Qt5OpenGL --libs Qt5Widgets --libs Qt5Network ` `$(PKGqt) --libs Qt5WebKitWidgets --libs Qt5WebKit` $(FPIC)
QT_CFLAGS ?= `$(PKGqt) --cflags Qt5Gui --cflags Qt5Network --cflags Qt5OpenGL --cflags Qt5Widgets --cflags Qt5Concurrent` -I$(QHTTPSERVER_PATH)/src -I$(QSCINTILLA_PATH) -DQHTTPSERVER_EXPORT $(QT_SYSTEM_CFLAGS) $(FPIC)
QT_LDFLAGS ?= $(QT_UI_LDFLAGS) $(QT_SVG_LDFLAGS) `$(PKGqt) --libs Qt5Gui --libs Qt5OpenGL --libs Qt5Widgets --libs Qt5Network ` $(FPIC)

ifeq ($(USE_QWEBENGINE),1)
USE_QWEBENGINE_CFLAGS = -D USE_QWEBENGINE=1
QT_CFLAGS += `$(PKGqt) --cflags Qt5WebEngine --cflags Qt5WebEngineCore --cflags Qt5WebEngineWidgets`
QT_LDFLAGS += `$(PKGqt) --libs Qt5WebEngine --libs Qt5WebEngineCore --libs Qt5WebEngineWidgets`
else
USE_QWEBENGINE_CFLAGS = -D USE_QWEBENGINE=0
QT_CFLAGS += `$(PKGqt) --cflags Qt5WebKitWidgets --cflags Qt5WebKit`
QT_LDFLAGS += `$(PKGqt) --libs Qt5WebKitWidgets --libs Qt5WebKit`
endif

QT_CFLAGS += $(USE_QWEBENGINE_CFLAGS)

endif

WNO_DEPRECATED_COPY=
Expand Down Expand Up @@ -248,7 +261,7 @@ ifeq ($(GCC_MAJOR),11)
else ifeq ($(GCC_MAJOR),10)
UNDEFINED_SANITIZE_OPTS= -fsanitize=undefined # -fno-sanitize-recover
NO_SANITIZE_SIGNED_INTEGER_OVERFLOW=-fno-sanitize=signed-integer-overflow
WNO_DEPRECATED_DECLARATIONS=-Wno-deprecated-declarationswQtWebKitWidgets/
WNO_DEPRECATED_DECLARATIONS=-Wno-deprecated-declarations
# UNDEFINED_SANITIZE_OPTS=
else ifeq ($(GCC_MAJOR),9)
UNDEFINED_SANITIZE_OPTS= -fsanitize=undefined -fno-sanitize-recover
Expand Down Expand Up @@ -1991,7 +2004,7 @@ $(T)api_midi.o: $(BUILD_DEPENDENCIES) $(API)api_midi.cpp
$(CCC2) $(API)api_midi.cpp $(QTOPT) $(BOOST_INCLUDE)

$(T)api_gui.o: $(BUILD_DEPENDENCIES) $(API)api_gui.cpp Qt/ScrollArea.hpp Qt/helpers.h Qt/lzqlineedit.h Qt/Rational.h Qt/Qt_MyQCheckBox.h embedded_scheme/s7extra_proc.h Qt/Qt_MyQScrollBar.hpp Qt/FileRequester.hpp Qt/Timer.hpp Qt/HashVector.hpp Qt/Qt_MyQCheckBox.h Qt/FocusSniffers.h Qt/Editor.hpp
$(MOC) $(API)api_gui.cpp > $(API)mapi_gui.cpp
$(MOC) $(USE_QWEBENGINE_CFLAGS) $(API)api_gui.cpp > $(API)mapi_gui.cpp
$(CCC2) $(API)api_gui.cpp $(QTOPT) $(QT_UI_CFLAGS) $(QT_SVG_CFLAGS) $(FPIC) -Wno-null-dereference $(NO_ANALYZER) $(WNO_DEPRECATED_DECLARATIONS)


Expand Down
11 changes: 9 additions & 2 deletions Qt/Qt_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#endif
#include <boost/lockfree/queue.hpp>

#ifndef USE_QWEBENGINE
#error error
#endif


#include <signal.h>
Expand All @@ -41,7 +44,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <QPluginLoader>
#endif

#if !USE_QWEBENGINE
#include <QtWebKitWidgets/QWebView>
#endif

#define TEST_CRASHREPORTER 0

Expand Down Expand Up @@ -4835,9 +4840,11 @@ int main(int argc, char **argv){

qapplication->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); // Fix splitter handlers on OSX. Seems like a good flag to set in general. Seems like a hack qt has added to workaround bugs in qt. https://bugreports.qt.io/browse/QTBUG-33479

#if !USE_QWEBENGINE
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, false);
#if !defined(RELEASE)
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#if !defined(RELEASE)
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#endif
#endif

init_weak_jack();
Expand Down
7 changes: 2 additions & 5 deletions Qt/Qt_faust_plugin_widget_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

#include <QScrollArea>

#if USE_QT5
#define USE_QWEBENGINE 0
#else
#define USE_QWEBENGINE 0 // Can not be 1.
#ifndef USE_QWEBENGINE
#error error
#endif


#if USE_QWEBENGINE

#include <QWebEngineView>
Expand Down
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ IF YOU ARE DEVELOPING RADIUM

export INCLUDE_FAUSTDEV_BUT_NOT_LLVM="jadda"

If you don't want to bother with installing qt-webkit, but instead use the lesser supported qt-webengine (which is included with Qt),
run this line first:

export USE_QWEBENGINE=1

Then run these lines:

# Debug build. Lots of assertions. Very slow. Don't build this version if you are just testing the program.
Expand Down
70 changes: 60 additions & 10 deletions api/api_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <QMouseEvent>

#include <QDesktopServices>
#include <QtWebKitWidgets/QWebView>
#include <QtWebKitWidgets/QWebFrame>

#ifndef USE_QWEBENGINE
#error error
#endif

#if USE_QWEBENGINE
#include <QWebEngineView>
#include <QWebEnginePage>
#else
#include <QtWebKitWidgets/QWebView>
#include <QtWebKitWidgets/QWebFrame>
#endif

#include "../common/nsmtracker.h"
#include "../common/patch_proc.h"
Expand Down Expand Up @@ -3857,7 +3866,11 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
};


#if USE_QWEBENGINE
//MakeFocusSnifferClass(QWebEngineView);
#else
MakeFocusSnifferClass(QWebView);
#endif

static std::tuple<QString,QString, bool> getAbsoluteUrl(QString stringurl){
if (stringurl.startsWith("http:") || stringurl.startsWith("https:") || stringurl.startsWith("file:")) {
Expand All @@ -3884,7 +3897,8 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
return {ret, query, true};
}
}


#if !USE_QWEBENGINE
static QUrl getUrl(QString stringurl){
auto [absoluteurl, query, is_local_file] = getAbsoluteUrl(stringurl);

Expand All @@ -3902,15 +3916,26 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one

}
}

struct Web : FocusSnifferQWebView, Gui, public radium::MouseCycleFix {
#endif

struct Web :
#if USE_QWEBENGINE

//FocusSnifferQWebEngineView,
QWidget,
Gui
#else
FocusSnifferQWebView, Gui
#endif
, public radium::MouseCycleFix {
Q_OBJECT;

public:

Web(QString url)
: Gui(this)
{
#if !USE_QWEBENGINE
//QWebView::settings()->setAttribute(QWebSettings::PluginsEnabled, false);

//setWindowTitle(url);
Expand All @@ -3919,8 +3944,13 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
connect(this,SIGNAL(urlChanged(const QUrl &)),this,SLOT(urlChanged(const QUrl &)));

mySetZoomFactor(1.0);
#else
R_ASSERT(false);
#endif
}

#if !USE_QWEBENGINE

/*
QSize sizeHint() const override {
return QSize(-1,-1);
Expand All @@ -3933,6 +3963,7 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
}
#endif

#if !USE_QWEBENGINE
// https://forum.qt.io/topic/23736/qwebview-qwebpage-need-help-with-context-menu/4
void contextMenuEvent(QContextMenuEvent * ev) override {
ScopedEventHandlerTracker event_handler_tracker;
Expand All @@ -3943,10 +3974,14 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
auto hit_url = hit_test.linkUrl();
if(hit_url.isEmpty()){
//printf("NOT LINK URL\n");
#if USE_QWEBENGINE
FocusSnifferQWebEngineView::contextMenuEvent(ev);
#else
FocusSnifferQWebView::contextMenuEvent(ev);
#endif
return;
}

int64_t parentgui = -1;
QWidget *parent_widget = parentWidget();
if (parent_widget!=NULL)
Expand All @@ -3967,10 +4002,11 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
//printf("Evaling -%s-\n", code);
evalScheme(code);
}
#endif

QString _last_search_text;

void searchForward(void){
void searchForward(void){
if(_last_search_text != "")
findText(_last_search_text, QWebPage::FindWrapsAroundDocument);
}
Expand Down Expand Up @@ -4110,15 +4146,19 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
}
}

#if !USE_QWEBENGINE
// Implement "Open link in new window"
QWebView *createWindow(QWebPage::WebWindowType type) override{
auto *ret = new Web("");
ret->show();
return ret;
}
#endif

OVERRIDERS_WITHOUT_KEY_AND_MOUSE_WHEEL(FocusSnifferQWebView);

#endif

public slots:

void urlChanged(const QUrl &url){
Expand All @@ -4130,10 +4170,9 @@ static QQueue<Gui*> g_delayed_resized_guis; // ~Gui removes itself from this one
void download(const QNetworkRequest &request){
qDebug()<<"Download Requested: "<<request.url();
}
*/
*/
};


struct FileRequester : radium::FileRequester, Gui, public radium::MouseCycleFix {
Q_OBJECT;

Expand Down Expand Up @@ -5488,10 +5527,15 @@ int64_t gui_floatText(double min, double curr, double max, int num_decimals, dou
}

int64_t gui_web(const_char* stringurl){
#if !USE_QWEBENGINE
return (new Web(stringurl))->get_gui_num();
#else
return -1;
#endif
}

void gui_setUrl(int64_t guinum, const_char* url){
#if !USE_QWEBENGINE
Gui *web_gui = get_gui(guinum);
if (web_gui==NULL)
return;
Expand All @@ -5504,14 +5548,20 @@ void gui_setUrl(int64_t guinum, const_char* url){
if (web->url() != dasurl)
web->setUrl(dasurl);
}
#endif
}

bool gui_webCanShowManual(void){
#if USE_QWEBENGINE
return false;
#else
int major = qWebKitVersion().split(".")[0].toInt();

//printf("Version: %s. Major: %d\n", qWebKitVersion().toUtf8().constData(), major);

//getchar();

return major >= 600;
#endif
}

void openExternalWebBrowser(const_char *charstringurl){
Expand Down
13 changes: 13 additions & 0 deletions audio/Faust_plugins_template1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ static float linear2db(float val){
}
#endif

#define MIN_LINEAR_VELOCITY 0.1
static float g_min_linear_gain = 0.001995; // = powf(10, R_SCALE(MIN_LINEAR_VELOCITY, 0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f;

// input is between 0 and 1.
// output is between 0 and 1.
static float velocity2gain(float val){
#if 0
g_min_linear_gain = powf(10, R_SCALE(MIN_LINEAR_VELOCITY, 0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f;
printf("%f\n",g_min_linear_gain);
getchar();
#endif

if(val<=0.0f)
return 0.0f;
else if(val>=1.0f)
return 1.0f;
else if (val < MIN_LINEAR_VELOCITY)
return scale(val,
0, MIN_LINEAR_VELOCITY,
0, g_min_linear_gain);
else
return powf(10, scale(val,0.0, 1.0 ,-40, 20) / 20.0f) / 10.0f;
}
Expand Down
4 changes: 2 additions & 2 deletions audio/MultiCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ static void process_soundproducer(int cpunum, SoundProducer *sp, int64_t time, i

for(int ch=0;ch<sp->_num_outputs;ch++)
if (false == sp->_curr_output_is_silent[ch]){
R_ASSERT_NON_RELEASE(false);
sp->_curr_output_is_silent[ch] = true;
R_ASSERT_NON_RELEASE(false);
sp->_curr_output_is_silent[ch] = true;
}

/*
Expand Down
11 changes: 11 additions & 0 deletions audio/Presets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,17 @@ void PRESET_save(const vector_t *patches, bool save_button_pressed, int64_t pare
if(filename=="")
return;

QFileInfo fileInfo(filename);
QString extension = fileInfo.suffix();

if (is_multipreset) {
if (extension != "mrec")
filename += ".mrec";
} else {
if (extension != "rec")
filename += ".rec";
}

disk_t *file = DISK_open_for_writing(filename);

if(file==NULL){
Expand Down
3 changes: 2 additions & 1 deletion audio/SoundPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ extern "C"{
#define MAX_DB_GAIN 56.23413251903491 // = powf(10, MAX_DB/20.0f);
#define THRESHOLD_GAIN 0.01778279410038923 // = powf(10, MIN_DB_THRESHOLD / 20.0f);

//#define MIN_AUTOSUSPEND_PEAK 0.00001
#define MIN_AUTOSUSPEND_PEAK 0.00035565046709962195 // = db2gain(MIN_DB_A_LITTLE_BIT_ABOVE)

#define MIN_NONSILENT_PEAK (1000000.0f * 0.000000000000000000000000000000000000012207031820f) // I.e. 1000000 times size of largest denormal.


#if !defined(RELEASE)
Expand Down
Loading

0 comments on commit 19809f2

Please sign in to comment.