added osc ports to the settings interface, bumped the version num

This commit is contained in:
Dave Griffiths 2022-10-14 19:23:07 +01:00
parent 5e347f7f13
commit b5fd6dd3e0
8 changed files with 224 additions and 29 deletions

View File

@ -27,7 +27,7 @@
using namespace std; using namespace std;
MainWindow::MainWindow(const string &port, const string &audio_port, const string &process_port) : MainWindow::MainWindow(const string &port, const string &audio_port, const string &process_port, QSettings *settings) :
m_last_file("."), m_last_file("."),
m_feedback(port), m_feedback(port),
m_audio_port(audio_port), m_audio_port(audio_port),
@ -51,7 +51,7 @@ MainWindow::MainWindow(const string &port, const string &audio_port, const strin
m_Ui.brain_contents->setSpacing(0); m_Ui.brain_contents->setSpacing(0);
m_Ui.brain_contents->setContentsMargins(0,0,0,0); m_Ui.brain_contents->setContentsMargins(0,0,0,0);
m_settings_dialog = new SettingsDialog(this); m_settings_dialog = new SettingsDialog(this,settings);
// add default local dest // add default local dest
// turn on first one // turn on first one

View File

@ -33,13 +33,15 @@
using namespace std; using namespace std;
using namespace spiralcore; using namespace spiralcore;
class QSettings;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWindow(const string &port, const string &audio_port, const string &process_port); MainWindow(const string &port, const string &audio_port, const string &process_port, QSettings *settings);
void message(const string &msg) { void message(const string &msg) {
QMessageBox::information(this,"problem",msg.c_str(), QMessageBox::Ok); QMessageBox::information(this,"problem",msg.c_str(), QMessageBox::Ok);
} }
@ -453,4 +455,5 @@ private:
string m_audio_port; string m_audio_port;
string m_process_port; string m_process_port;
}; };

View File

@ -24,12 +24,16 @@
using namespace std; using namespace std;
SettingsDialog::SettingsDialog(MainWindow *parent): SettingsDialog::SettingsDialog(MainWindow *parent, QSettings *settings):
m_device(""), m_device(""),
m_parent(parent), m_parent(parent),
m_buffersize(2048), m_buffersize(2048),
m_samplerate(44100) { m_samplerate(44100),
m_settings(settings) {
m_Ui.setupUi(this); m_Ui.setupUi(this);
m_Ui.guiOSCLineEdit->setText(settings->value("gui_port").toByteArray().constData());
m_Ui.processOSCLineEdit->setText(settings->value("process_port").toByteArray().constData());
m_Ui.audioOSCLineEdit->setText(settings->value("audio_port").toByteArray().constData());
} }
void SettingsDialog::connect() { void SettingsDialog::connect() {

View File

@ -20,6 +20,7 @@
#include <QtGui> #include <QtGui>
#include <QDialog> #include <QDialog>
#include <QLineEdit> #include <QLineEdit>
#include <QSettings>
#include "ui_settings.h" #include "ui_settings.h"
#include <iostream> #include <iostream>
@ -36,7 +37,7 @@ class SettingsDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SettingsDialog(MainWindow *parent); SettingsDialog(MainWindow *parent, QSettings *settings);
Ui_SettingsDialog m_Ui; Ui_SettingsDialog m_Ui;
string m_device; string m_device;
@ -61,15 +62,28 @@ class SettingsDialog : public QDialog
void accept() { connect(); hide(); } void accept() { connect(); hide(); }
void reject() { hide(); } void reject() { hide(); }
void apply() { connect(); } void apply() { connect(); }
void gui_port(QString str) {
m_settings->setValue("gui_port",str);
}
void process_port(QString str) {
m_settings->setValue("process_port",str);
}
void audio_port(QString str) {
m_settings->setValue("audio_port",str);
}
private: private:
void connect(); void connect();
MainWindow *m_parent; MainWindow *m_parent;
unsigned int m_buffersize; unsigned int m_buffersize;
unsigned int m_samplerate; unsigned int m_samplerate;
QSettings *m_settings;
}; };
#endif #endif

View File

@ -50,7 +50,7 @@ int main( int argc , char *argv[] ){
status::set_port(gui_port); status::set_port(gui_port);
MainWindow mainWin(gui_port,audio_port,process_port); MainWindow mainWin(gui_port,audio_port,process_port,&settings);
mainWin.show(); mainWin.show();
process_thread pt(process_port); process_thread pt(process_port);
audio_thread at(audio_port,pt); audio_thread at(audio_port,pt);

View File

@ -34,11 +34,12 @@ OSC_server::OSC_server(const string &port) :
m_port(port), m_port(port),
m_exit(false), m_exit(false),
m_command_ring_buffer(262144) { m_command_ring_buffer(262144) {
//cerr<<"using port: ["<<port<<"]"<<endl; cerr<<"OSC using port: ["<<port<<"]"<<endl;
m_server = lo_server_thread_new(port.c_str(), error_handler); m_server = lo_server_thread_new(port.c_str(), error_handler);
if (m_server) { if (m_server) {
cerr<<m_server<<endl;
lo_server_thread_add_method(m_server, NULL, NULL, default_handler, this); lo_server_thread_add_method(m_server, NULL, NULL, default_handler, this);
} else {
cerr<<"error opening OSC port"<<endl;
} }
} }

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>samplebrain 0.18.4</string> <string>samplebrain 0.18.5</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>438</width>
<height>522</height> <height>656</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -31,7 +31,13 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="deviceComboBox"/> <widget class="QComboBox" name="deviceComboBox">
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -57,6 +63,11 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="text"> <property name="text">
<string>44100</string> <string>44100</string>
</property> </property>
@ -73,7 +84,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>(note: this currently should probably match your sample file's input rate as no conversion is run on them - yet)</string> <string>note: this currently should probably match your sample file's input rate as no conversion is run on them - yet</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@ -98,6 +109,11 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="buffersizeComboBox"> <widget class="QComboBox" name="buffersizeComboBox">
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>5</number> <number>5</number>
</property> </property>
@ -180,6 +196,112 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<family>Comic Sans MS</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>restart needed for the ports below to update</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="text">
<string>gui osc port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="guiOSCLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="text">
<string>process osc port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="processOSCLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="text">
<string>audio osc port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="audioOSCLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QPushButton" name="applyPushButton"> <widget class="QPushButton" name="applyPushButton">
<property name="font"> <property name="font">
@ -218,8 +340,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>231</x> <x>244</x>
<y>358</y> <y>642</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>157</x> <x>157</x>
@ -234,8 +356,8 @@
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>299</x> <x>312</x>
<y>364</y> <y>642</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>286</x> <x>286</x>
@ -266,8 +388,8 @@
<slot>apply()</slot> <slot>apply()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>112</x> <x>125</x>
<y>321</y> <y>592</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>4</x> <x>4</x>
@ -298,8 +420,8 @@
<slot>buffersize(QString)</slot> <slot>buffersize(QString)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>326</x> <x>390</x>
<y>131</y> <y>215</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>395</x> <x>395</x>
@ -307,11 +429,62 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>guiOSCLineEdit</sender>
<signal>textChanged(QString)</signal>
<receiver>SettingsDialog</receiver>
<slot>gui_port(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>346</x>
<y>432</y>
</hint>
<hint type="destinationlabel">
<x>401</x>
<y>419</y>
</hint>
</hints>
</connection>
<connection>
<sender>processOSCLineEdit</sender>
<signal>textChanged(QString)</signal>
<receiver>SettingsDialog</receiver>
<slot>process_port(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>356</x>
<y>482</y>
</hint>
<hint type="destinationlabel">
<x>398</x>
<y>479</y>
</hint>
</hints>
</connection>
<connection>
<sender>audioOSCLineEdit</sender>
<signal>textChanged(QString)</signal>
<receiver>SettingsDialog</receiver>
<slot>audio_port(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>374</x>
<y>511</y>
</hint>
<hint type="destinationlabel">
<x>398</x>
<y>517</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>output_device(QString)</slot> <slot>output_device(QString)</slot>
<slot>samplerate(QString)</slot> <slot>samplerate(QString)</slot>
<slot>buffersize(QString)</slot> <slot>buffersize(QString)</slot>
<slot>apply()</slot> <slot>apply()</slot>
<slot>gui_port(QString)</slot>
<slot>audio_port(QString)</slot>
<slot>process_port(QString)</slot>
</slots> </slots>
</ui> </ui>