Compare commits

...

15 Commits

Author SHA1 Message Date
dave griffiths
30e290dcbd Merge branch 'production' into 'production'
Fix the parameter type of default_handler

Closes #96

See merge request then-try-this/samplebrain!16
2024-08-12 13:10:08 +00:00
tous
032fd7c039 Fix the parameter type of default_handler 2024-07-17 02:37:38 +00:00
dave griffiths
a8ea957f45 removed reddit link as it's not really used 2023-05-01 16:39:52 +00:00
Dave Griffiths
edf2071467 added reddit 2022-10-29 12:39:18 +01:00
Dave Griffiths
2e517e3bff changelog update 2022-10-29 08:48:13 +01:00
Dave Griffiths
1b766822f6 new version README update 2022-10-29 08:35:34 +01:00
Dave Griffiths
bc8002a9f0 added target filename to GUI - not adding brain session or directory as less need for it/more clutter... partially fixes: #76 2022-10-23 10:06:23 +01:00
Dave Griffiths
f9f3557b79 sorted file paths so we have separate ones for each dialog - fixes: #75 2022-10-23 09:34:46 +01:00
Dave Griffiths
c4499ce7c9 commented out unused and confusing old code - fixes: #28 2022-10-20 21:22:23 +01:00
Dave Griffiths
46ab0a131a optimisation from Claude - fixes: #27 2022-10-20 21:15:27 +01:00
Dave Griffiths
385563e64e forgot to add flac 2022-10-14 21:24:56 +01:00
Dave Griffiths
e1c8e0ea67 added more soundfile formats to the loading dialog and new error report when it can't load 2022-10-14 20:30:12 +01:00
Dave Griffiths
b5fd6dd3e0 added osc ports to the settings interface, bumped the version num 2022-10-14 19:23:07 +01:00
Dave Griffiths
5e347f7f13 made the 3 osc ports configurable via (cross-platform) config scripts and move them outside of well used ranges for UDP 2022-10-14 18:27:59 +01:00
Dave Griffiths
5469a8f253 added build instructions for ubuntu 22.04 fixes: #66 2022-10-07 08:39:45 +01:00
24 changed files with 781 additions and 478 deletions

View File

@ -41,12 +41,16 @@ written to run on a couple of computers!) you will have to bear with
us as we gradually stabilise things based on your feedback. There
might currently be problems running it on 64bit Windows.
* **Windows**: [samplebrain_0.18.4_win.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.4_win.zip)
* **Mac (intel/m1)**: [samplebrain_0.18.4_macintel.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.4_macintel.app.zip)
* **Windows**: [samplebrain_0.18.5_win.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.5_win.zip)
* **Mac (intel/m1)**: [samplebrain_0.18.5_macintel.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.5_macintel.app.zip)
Changes in 0.18.4: New audio device settings window and updated
windows build. Better default block size, tool tip tweaks and fixes
for dark themes by [Claude Heiland-Allen](https://mathr.co.uk/).
Changes in 0.18.5 (relased 28/10/22):
* Target sound filename shown (and tells you if you don't have one)
* More soundfile formats supported (aiff,aifc,au,snd,fasttracker xi,flac)
* New configurable OSC ports in settings
* Warning boxes if the OSC network connection fails
* File path memory per-dialog rather than global
For old versions see the [changelog](changelog.md)

View File

@ -27,9 +27,16 @@
using namespace std;
MainWindow::MainWindow() :
m_last_file("."),
m_feedback("8890")
MainWindow::MainWindow(const string &port, const string &audio_port, const string &process_port, QSettings *settings) :
m_last_sound_file("."),
m_last_target_file("."),
m_last_brain_file("."),
m_last_session_file("."),
m_last_recording_file("."),
m_feedback(port),
m_audio_port(audio_port),
m_process_port(process_port),
m_format_string("Microsoft WAV (*.wav);;SGI/Apple AIFF (*.aiff);;SGI/Apple AIFC (*.aifc);;Sun/DEC/NeXT AU (*.au);;Sun/DEC/NeXT SND (*.snd);;Fasttracker 2 XI (*.xi);;Free Lossless Audio Codec FLAC (*.flac);;All files (*.*)")
{
m_sound_item_enable_mapper = new QSignalMapper(this);
m_sound_item_delete_mapper = new QSignalMapper(this);
@ -49,7 +56,7 @@ MainWindow::MainWindow() :
m_Ui.brain_contents->setSpacing(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
// turn on first one
@ -59,8 +66,8 @@ MainWindow::MainWindow() :
for (int i=0; i<10; i++) {
osc_destination d;
d.m_id=i;
d.m_audio_address = lo_address_new_from_url("osc.udp://localhost:8888");
d.m_process_address = lo_address_new_from_url("osc.udp://localhost:8889");
d.m_audio_address = lo_address_new_from_url(string("osc.udp://localhost:"+m_audio_port).c_str());
d.m_process_address = lo_address_new_from_url(string("osc.udp://localhost:"+m_process_port).c_str());
if (i==0) d.m_enabled=true;
else d.m_enabled=false;
add_gui_address(d,enable_mapper);
@ -154,6 +161,12 @@ void MainWindow::init_from_session(const string &filename) {
m_Ui.spinBoxSlideError->setValue(r.get_slide_error());
// target
if (t.get_samples().size()>0) {
// extract target filename from brain sample
string fn = t.get_samples().begin()->m_filename;
m_Ui.labelTargetSound->setText("loaded: "+QFileInfo(QString::fromStdString(fn)).fileName());
}
m_Ui.spinBoxBlockSizeTarget->setValue(t.get_block_size());
m_Ui.doubleSpinBoxBlockOverlapTarget->setValue(t.get_overlap()/(float)t.get_block_size());

View File

@ -18,6 +18,7 @@
#include <QDirIterator>
#include <QFileDialog>
#include <QLineEdit>
#include <QMessageBox>
#include "ui_samplebrain.h"
#include "SettingsDialog.h"
@ -32,12 +33,22 @@
using namespace std;
using namespace spiralcore;
class QSettings;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
MainWindow(const string &port, const string &audio_port, const string &process_port, QSettings *settings);
void message(const string &msg) {
QMessageBox::information(this,"problem",msg.c_str(), QMessageBox::Ok);
}
bool ok() {
return m_feedback.ok();
}
// all this to work around liblo's use of varargs...
void send_audio_osc(const char *name, const char *types) {
@ -195,13 +206,15 @@ private slots:
void run_slot() {}
void load_target() {
m_last_file=QFileDialog::getOpenFileName(
this,
QString("Select an wav file"),
m_last_file,
QString("Sounds (*.wav)"));
send_process_osc("/load_target","s",m_last_file.toStdString().c_str());
QString path=QFileDialog::getOpenFileName(this,
QString("Select an audio file"),
m_last_target_file,
m_format_string);
if (m_last_target_file!="") {
m_last_target_file=path;
m_Ui.labelTargetSound->setText("loaded: "+QFileInfo(path).fileName());
send_process_osc("/load_target","s",m_last_target_file.toStdString().c_str());
}
}
void target_block_size(int s) { send_process_osc("/target_block_size","i",s); }
void target_block_overlap(double s) { send_process_osc("/target_overlap","f",s); }
@ -211,30 +224,31 @@ private slots:
void fft_spectrum_size(int) {}
void generate() { send_process_osc("/generate_brain",""); }
void load_sound() {
m_last_file=QFileDialog::getOpenFileName(
this,
QString path=QFileDialog::getOpenFileName(this,
QString("Select a wav file"),
m_last_file,
QString("Sounds (*.wav)"));
send_process_osc("/load_sample","s",m_last_file.toStdString().c_str());
sound_items::sound_item &si = m_sound_items.add(m_Ui.brain_contents, m_last_file.toStdString(),true);
m_last_sound_file,
m_format_string);
if (path!="") {
m_last_sound_file=path;
send_process_osc("/load_sample","s",m_last_sound_file.toStdString().c_str());
sound_items::sound_item &si = m_sound_items.add(m_Ui.brain_contents, m_last_sound_file.toStdString(),true);
QObject::connect(si.m_enable, SIGNAL(clicked()), m_sound_item_enable_mapper, SLOT(map()));
m_sound_item_enable_mapper->setMapping(si.m_enable, si.m_id);
QObject::connect(si.m_del, SIGNAL(clicked()), m_sound_item_delete_mapper, SLOT(map()));
m_sound_item_delete_mapper->setMapping(si.m_del, si.m_id);
}
}
void load_sounds() {
m_last_file=QFileDialog::getExistingDirectory(this,
QString("Select a directory"),
m_last_file);
QString path=QFileDialog::getExistingDirectory(this,
QString("Select a directory of wav files"),
m_last_directory_file);
QDirIterator dirIt(m_last_file,QDirIterator::Subdirectories);
if (path!="") {
m_last_directory_file=path;
QDirIterator dirIt(m_last_directory_file,QDirIterator::Subdirectories);
while (dirIt.hasNext()) {
dirIt.next();
if (QFileInfo(dirIt.filePath()).isFile() &&
@ -251,6 +265,7 @@ private slots:
}
}
}
}
void select_all() {
for (auto &si:m_sound_items.m_sound_items) {
@ -304,12 +319,11 @@ private slots:
void record() {
if (m_save_wav=="") {
m_last_file=QFileDialog::getSaveFileName(
this,
m_last_recording_file=QFileDialog::getSaveFileName(this,
QString("Select a wav file"),
m_last_file,
QString("Sounds (*.wav)"));
m_save_wav = m_last_file.toStdString();
m_last_recording_file,
QString("Sounds (*.wav);;All files (*.*)"));
m_save_wav = m_last_recording_file.toStdString();
// chop off .wav
size_t pos = m_save_wav.find_last_of(".");
if (pos!=string::npos) {
@ -330,43 +344,48 @@ private slots:
}
void load_brain() {
m_last_file=QFileDialog::getOpenFileName(
this,
QString path=QFileDialog::getOpenFileName(this,
QString("Select a brain file"),
m_last_file,
QString("Brains (*.brain)"));
m_last_brain_file,
QString("Brains (*.brain);;All files (*.*)"));
send_process_osc("/load_brain","s",m_last_file.toStdString().c_str());
if (path!="") {
m_last_brain_file=path;
send_process_osc("/load_brain","s",m_last_brain_file.toStdString().c_str());
}
}
void save_brain() {
m_last_file=QFileDialog::getSaveFileName(
this,
QString path=QFileDialog::getSaveFileName(this,
QString("Select a brain file"),
m_last_file,
QString("Brains (*.brain)"));
send_process_osc("/save_brain","s",m_last_file.toStdString().c_str());
m_last_brain_file,
QString("Brains (*.brain);;All files (*.*)"));
if (path!="") {
m_last_brain_file=path;
send_process_osc("/save_brain","s",m_last_brain_file.toStdString().c_str());
}
}
void load_session() {
m_last_file=QFileDialog::getOpenFileName(
this,
QString path=QFileDialog::getOpenFileName(this,
QString("Select a session file"),
m_last_file,
QString("Sessions *.samplebrain (*.samplebrain)"));
send_process_osc("/load_session","s",m_last_file.toStdString().c_str());
init_from_session(m_last_file.toStdString());
m_last_session_file,
QString("Sessions *.samplebrain (*.samplebrain);;All files (*.*)"));
if (path!="") {
m_last_session_file=path;
send_process_osc("/load_session","s",m_last_session_file.toStdString().c_str());
init_from_session(m_last_session_file.toStdString());
}
}
void save_session() {
m_last_file=QFileDialog::getSaveFileName(
this,
QString path=QFileDialog::getSaveFileName(this,
QString("Select a session file"),
m_last_file,
m_last_session_file,
QString("Sessions *.samplebrain (*.samplebrain)"));
send_process_osc("/save_session","s",m_last_file.toStdString().c_str());
if (path!="") {
m_last_session_file=path;
send_process_osc("/save_session","s",m_last_session_file.toStdString().c_str());
}
}
void update_status() {
@ -385,8 +404,8 @@ private slots:
string url = d.m_address->text().toUtf8().constData();
lo_address_free(d.m_audio_address);
lo_address_free(d.m_process_address);
d.m_audio_address = lo_address_new_from_url(string(url+":8888").c_str());
d.m_process_address = lo_address_new_from_url(string(url+":8889").c_str());
d.m_audio_address = lo_address_new_from_url(string(url+":"+m_audio_port).c_str());
d.m_process_address = lo_address_new_from_url(string(url+":"+m_process_port).c_str());
// start sending messages here
d.m_enabled=true;
} else {
@ -431,7 +450,12 @@ private:
QSignalMapper* enable_mapper);
string m_save_wav;
QString m_last_file;
QString m_last_sound_file;
QString m_last_target_file;
QString m_last_directory_file;
QString m_last_brain_file;
QString m_last_session_file;
QString m_last_recording_file;
unsigned int m_record_id;
Ui_MainWindow m_Ui;
feedback m_feedback;
@ -442,4 +466,7 @@ private:
SettingsDialog *m_settings_dialog;
audio_thread *m_audio_thread;
string m_audio_port;
string m_process_port;
QString m_format_string;
};

View File

@ -24,12 +24,16 @@
using namespace std;
SettingsDialog::SettingsDialog(MainWindow *parent):
SettingsDialog::SettingsDialog(MainWindow *parent, QSettings *settings):
m_device(""),
m_parent(parent),
m_buffersize(2048),
m_samplerate(44100) {
m_samplerate(44100),
m_settings(settings) {
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() {

View File

@ -20,6 +20,7 @@
#include <QtGui>
#include <QDialog>
#include <QLineEdit>
#include <QSettings>
#include "ui_settings.h"
#include <iostream>
@ -36,7 +37,7 @@ class SettingsDialog : public QDialog
{
Q_OBJECT
public:
SettingsDialog(MainWindow *parent);
SettingsDialog(MainWindow *parent, QSettings *settings);
Ui_SettingsDialog m_Ui;
string m_device;
@ -62,6 +63,18 @@ class SettingsDialog : public QDialog
void reject() { hide(); }
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:
void connect();
@ -70,6 +83,7 @@ class SettingsDialog : public QDialog
unsigned int m_buffersize;
unsigned int m_samplerate;
QSettings *m_settings;
};
#endif

View File

@ -20,26 +20,23 @@
using namespace spiralcore;
using namespace std;
audio_thread::audio_thread(process_thread &p) :
audio_thread::audio_thread(const string &port, process_thread &p) :
m_audio_device(NULL),
m_osc("8888"),
m_osc(port),
m_process_thread(p),
m_brain_mutex(p.m_brain_mutex),
m_stereo_mode(false),
m_mic_mode(false),
m_bufsize(2048),
m_samplerate(44100),
m_device("")
{
// start_audio();
m_device("") {
pthread_mutex_lock(m_brain_mutex);
m_left_renderer = new renderer(p.m_source,p.m_left_target);
m_right_renderer = new renderer(p.m_source,p.m_right_target);
m_block_stream = new block_stream();
pthread_mutex_unlock(m_brain_mutex);
m_osc.run();
// it this threadsafe?
// m_audio_device->report_devices();
}
static bool state = 1;

View File

@ -26,12 +26,12 @@ namespace spiralcore {
class audio_thread {
public:
audio_thread(process_thread &p);
audio_thread(const string &port, process_thread &p);
~audio_thread();
void start_audio();
void restart_audio(const string device, unsigned int samplerate, unsigned int bufsize);
bool ok() { return m_osc.ok(); }
void process(sample &left_in, sample &right_in, sample &left_out, sample &right_out);
static void run_audio(void* c, unsigned int frames);

View File

@ -29,6 +29,7 @@ class feedback {
public:
feedback(std::string address);
void poll(QStatusBar *s, sound_items *sound_items, SettingsDialog *settings);
bool ok() { return m_osc.ok(); }
private:

View File

@ -32,8 +32,8 @@ static void* _process(void *c) {
return NULL;
}
process_thread::process_thread() :
m_osc("8889"),
process_thread::process_thread(const string &port) :
m_osc(port),
m_source_block_size(1000),
m_source_overlap(0.75),
m_target_block_size(1000),

View File

@ -25,9 +25,9 @@
namespace spiralcore {
class process_thread {
public:
process_thread();
class process_thread {
public:
process_thread(const string &port);
~process_thread();
pthread_mutex_t* m_brain_mutex;
@ -47,10 +47,13 @@ public:
void load_session(const std::string &filename);
void save_session(const std::string &filename);
bool ok() { return m_osc.ok(); }
// only for use in mutex
brain m_source, m_left_target, m_right_target;
private:
private:
OSC_server m_osc;
u32 m_source_block_size;
float m_source_overlap;
@ -64,6 +67,6 @@ private:
renderer *m_left_renderer;
renderer *m_right_renderer;
block_stream *m_block_stream;
};
};
}

View File

@ -19,22 +19,54 @@
#include <iostream>
#include <unistd.h>
#include <QtGui>
#include <QSettings>
#include "MainWindow.h"
#include "process_thread.h"
#include "audio_thread.h"
#include "status.h"
using namespace std;
int main( int argc , char *argv[] ){
QApplication app(argc, argv);
MainWindow mainWin;
mainWin.show();
process_thread pt;
audio_thread at(pt);
pt.register_renderer(at.m_left_renderer, at.m_right_renderer, at.m_block_stream);
QApplication app(argc, argv);
QSettings settings("thentrythis", "samplebrain");
// slight over-use of OSC servers here, but the are packaged nicely for
// threadsafe (nonblocking) communication, and it's useful to expose all
// moving parts for external control (i.e. the processing and the audio)
if (!settings.contains("gui_port")) settings.setValue("gui_port", "62345");
if (!settings.contains("audio_port")) settings.setValue("audio_port", "62346");
if (!settings.contains("process_port")) settings.setValue("process_port", "62347");
string gui_port = settings.value("gui_port").toByteArray().constData();
string audio_port = settings.value("audio_port").toByteArray().constData();
string process_port = settings.value("process_port").toByteArray().constData();
status::set_port(gui_port);
MainWindow mainWin(gui_port,audio_port,process_port,&settings);
mainWin.show();
process_thread pt(process_port);
audio_thread at(audio_port,pt);
pt.register_renderer(at.m_left_renderer, at.m_right_renderer, at.m_block_stream);
mainWin.set_audio_thread(&at);
if (!at.ok()) {
mainWin.message("problem starting audio thread on port "+audio_port);
}
if (!pt.ok()) {
mainWin.message("problem starting process thread on port "+process_port);
}
if (!mainWin.ok()) {
mainWin.message("problem starting gui thread on port "+gui_port);
}
return app.exec();
}

View File

@ -112,6 +112,7 @@ void block::process(const sample &pcm, sample &fft, sample &mfcc, float &freq) {
// calculate fft
std::vector<std::complex<double> > mfspec;
mfspec.reserve(m_block_size);
for (u32 i=0; i<m_block_size; ++i) {
mfspec.push_back(std::complex<double>(m_fftw->m_spectrum[i][0],
m_fftw->m_spectrum[i][1]));

View File

@ -79,6 +79,7 @@ void block_stream::init(u32 block_size, u32 overlap, window::type t, bool ditchp
m_window.set_current_type(t);
m_blocks.clear();
m_blocks.reserve(MAX_BLOCKS);
sample dummy(block_size);
for (u32 i=0; i<MAX_BLOCKS; i++) {
m_blocks.push_back(block(0,"dummy",dummy,44100,m_window));

View File

@ -69,6 +69,8 @@ void brain::load_sound(std::string filename, stereo_mode mode) {
delete[] temp;
m_samples.push_back(sound(filename,s));
status::update("loaded %s",filename.c_str());
} else {
status::update("problem loading %s",filename.c_str());
}
}
@ -226,6 +228,7 @@ u32 brain::rev_search(const block &target, const search_params &params) {
return furthest_index;
}
/*
// really slow - every to every comparison of blocks calculating average distance
double brain::calc_average_diff(search_params &params) {
double diff=0;
@ -259,6 +262,7 @@ void brain::build_synapses_thresh(search_params &params, double thresh) {
++outer_index;
}
}
*/
void brain::build_synapses_fixed(search_params &params) {
//m_average_error = calc_average_diff(params)*thresh;

View File

@ -62,8 +62,8 @@ public:
u32 rev_search(const block &target, const search_params &params);
// synaptic search
double calc_average_diff(search_params &params);
void build_synapses_thresh(search_params &params, double threshold);
// double calc_average_diff(search_params &params);
// void build_synapses_thresh(search_params &params, double threshold);
void build_synapses_fixed(search_params &params);
u32 search_synapses(const block &target, search_params &params);
double get_current_error() { return m_current_error; }

View File

@ -31,41 +31,41 @@ extern "C" {
#endif
OSC_server::OSC_server(const string &port) :
m_port(port),
m_exit(false),
m_command_ring_buffer(262144)
{
//cerr<<"using port: ["<<port<<"]"<<endl;
m_port(port),
m_exit(false),
m_command_ring_buffer(262144) {
cerr<<"OSC using port: ["<<port<<"]"<<endl;
m_server = lo_server_thread_new(port.c_str(), error_handler);
if (m_server) {
lo_server_thread_add_method(m_server, NULL, NULL, default_handler, this);
} else {
cerr<<"error opening OSC port"<<endl;
}
}
OSC_server::~OSC_server()
{
OSC_server::~OSC_server() {
m_exit=true;
lo_server_thread_stop(m_server);
}
void OSC_server::run()
{
void OSC_server::run() {
if (!m_server) return;
lo_server_thread_start(m_server);
// while (!m_exit) usleep(1000);
// while (!m_exit) usleep(1000);
}
void OSC_server::error_handler(int num, const char *msg, const char *path)
{
void OSC_server::error_handler(int num, const char *msg, const char *path) {
//cerr<<"liblo server error "<<num<<" in path "<<path<<": "<<msg<<endl;
cerr<<"liblo server error "<<num<<endl;
}
int OSC_server::default_handler(const char *path, const char *types, lo_arg **argv,
int argc, void *data, void *user_data)
{
int argc, lo_message data, void *user_data) {
OSC_server *server = (OSC_server*)user_data;
if (!server) return -1;
unsigned int size = 0;
for (int i=0; i<argc; i++)
{
for (int i=0; i<argc; i++) {
size+=lo_arg_size((lo_type)types[i],argv[i]);
// add one for the null terminator
if (types[i]=='s') size++;
@ -73,14 +73,10 @@ int OSC_server::default_handler(const char *path, const char *types, lo_arg **ar
char *newdata=new char[size];
unsigned int pos=0;
for (int i=0; i<argc; i++)
{
switch (types[i])
{
case LO_INT32:
{
if (pos+4>COMMAND_DATA_SIZE)
{
for (int i=0; i<argc; i++) {
switch (types[i]) {
case LO_INT32: {
if (pos+4>COMMAND_DATA_SIZE) {
cerr<<"osc data too big for ringbuffer command"<<endl;
delete[] newdata;
return 1;
@ -90,10 +86,8 @@ int OSC_server::default_handler(const char *path, const char *types, lo_arg **ar
pos+=4;
}
break;
case LO_FLOAT:
{
if (pos+4>COMMAND_DATA_SIZE)
{
case LO_FLOAT: {
if (pos+4>COMMAND_DATA_SIZE) {
cerr<<"osc data too big for ringbuffer command"<<endl;
delete[] newdata;
return 1;
@ -103,12 +97,10 @@ int OSC_server::default_handler(const char *path, const char *types, lo_arg **ar
pos+=4;
}
break;
case LO_STRING:
{
case LO_STRING: {
int size=strlen(&argv[i]->s);
if (pos+size+1>COMMAND_DATA_SIZE)
{
if (pos+size+1>COMMAND_DATA_SIZE) {
cerr<<"osc data too big for ringbuffer command"<<endl;
delete[] newdata;
return 1;
@ -119,8 +111,7 @@ int OSC_server::default_handler(const char *path, const char *types, lo_arg **ar
pos+=size+1;
}
break;
default:
{
default: {
cerr<<"unsupported type: "<<types[i]<<endl;
delete[] newdata;
return 1;
@ -129,16 +120,14 @@ int OSC_server::default_handler(const char *path, const char *types, lo_arg **ar
}
}
if (1)//pos==size) hmm
{
if (1) { //pos==size) hmm
command_ring_buffer::command command(path,types,newdata,pos);
if (!server->m_command_ring_buffer.send(command))
{
if (!server->m_command_ring_buffer.send(command)) {
//cerr<<"OSC_server - ringbuffer full!"<<endl;
}
}
else
{
else {
cerr<<"OSC_server::default_handler: size mismatch ["<<pos<<":"<<size<<"], not sending message"<<endl;
}

View File

@ -29,9 +29,10 @@ public:
void run();
bool get(command_ring_buffer::command& command) { return m_command_ring_buffer.get(command);}
bool ok() { return m_server!=NULL; }
private:
static int default_handler(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
static int default_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data);
static void error_handler(int num, const char *m, const char *path);
lo_server_thread m_server;

View File

@ -22,6 +22,10 @@ using namespace std;
lo_address status::m_address = lo_address_new_from_url("osc.udp://localhost:8890");
void status::set_port(const std::string &port) {
status::m_address = lo_address_new_from_url(string("osc.udp://localhost:"+port).c_str());
}
void status::_update(const std::string &msg) {
lo_send(m_address,"/report","s",msg.c_str());
}

View File

@ -24,6 +24,7 @@ namespace spiralcore {
class status {
public:
static void set_port(const std::string &port);
static void _update(const std::string &msg);
static void update(const char *msg, ...);
static void sound_item(const std::string &name, const std::string &colour);

View File

@ -8,6 +8,10 @@ Install dependencies for the interface:
$ sudo apt install build-essential qtcreator qt5-default
On ubuntu 22.04 it's:
$ apt install build-essential qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
Build & run it:
$ mkdir build
@ -57,3 +61,12 @@ Then edit Info.plist to add samplebrain.icns to CFBundleIconFile. Key `CFBundleI
You might also need to resign the app bundle after making any changes
$ codesign --force --deep --sign - samplebrain.app
# Windows (Work in progress)
* Install [MSYS2](https://www.msys2.org/)
* Install dependances via pacman
* Build with qmake as usual
* Run `windeployqt` and copy missing .dll files into release directory

View File

@ -1,5 +1,14 @@
# Changlog
0.18.4
* **Windows**: [samplebrain_0.18.4_win.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.4_win.zip)
* **Mac (intel/m1)**: [samplebrain_0.18.4_macintel.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.4_macintel.app.zip)
Changes in 0.18.4: New audio device settings window and updated
windows build. Better default block size, tool tip tweaks and fixes
for dark themes by [Claude Heiland-Allen](https://mathr.co.uk/).
0.18.3
* **Windows**: [samplebrain_0.18.3_win.zip](https://static.thentrythis.org/samplebrain/samplebrain_0.18.3_win.zip)

11
debian/changelog vendored
View File

@ -1,6 +1,11 @@
samplebrain (0.18rc2-1ubuntu0~bionic4) bionic; urgency=medium
samplebrain (0.18.5rc1-1ubuntu0~bionic1) bionic; urgency=medium
* Initial release
* Target sound filename shown (and tells you if you don't have one)
* More soundfile formats supported (aiff,aifc,au,snd,fasttracker xi,flac)
* New configurable OSC ports in settings
* Warning boxes if the OSC network connection fails
* File path memory per-dialog rather than global
-- Dave Griffiths <dave@thentrythis.org> Thu, 29 Oct 2022 08:47:10 +0100
-- Dave Griffiths <dave@thentrythis.org> Thu, 08 Sep 2022 13:08:26 +0100

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>samplebrain 0.18.4</string>
<string>samplebrain 0.18.5</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -728,6 +728,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTargetSound">
<property name="text">
<string>no target sound loaded</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonLoadTarget">
<property name="font">
@ -1112,8 +1119,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>17</width>
<height>13</height>
</size>
</property>
</spacer>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>522</height>
<width>438</width>
<height>656</height>
</rect>
</property>
<property name="windowTitle">
@ -31,7 +31,13 @@
</widget>
</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>
</layout>
</item>
@ -57,6 +63,11 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="text">
<string>44100</string>
</property>
@ -73,7 +84,7 @@
</font>
</property>
<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 name="wordWrap">
<bool>true</bool>
@ -98,6 +109,11 @@
</item>
<item>
<widget class="QComboBox" name="buffersizeComboBox">
<property name="font">
<font>
<family>Comic Sans MS</family>
</font>
</property>
<property name="currentIndex">
<number>5</number>
</property>
@ -180,6 +196,112 @@
</property>
</widget>
</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>
<widget class="QPushButton" name="applyPushButton">
<property name="font">
@ -218,8 +340,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>231</x>
<y>358</y>
<x>244</x>
<y>642</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
@ -234,8 +356,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>299</x>
<y>364</y>
<x>312</x>
<y>642</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
@ -266,8 +388,8 @@
<slot>apply()</slot>
<hints>
<hint type="sourcelabel">
<x>112</x>
<y>321</y>
<x>125</x>
<y>592</y>
</hint>
<hint type="destinationlabel">
<x>4</x>
@ -298,8 +420,8 @@
<slot>buffersize(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>326</x>
<y>131</y>
<x>390</x>
<y>215</y>
</hint>
<hint type="destinationlabel">
<x>395</x>
@ -307,11 +429,62 @@
</hint>
</hints>
</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>
<slots>
<slot>output_device(QString)</slot>
<slot>samplerate(QString)</slot>
<slot>buffersize(QString)</slot>
<slot>apply()</slot>
<slot>gui_port(QString)</slot>
<slot>audio_port(QString)</slot>
<slot>process_port(QString)</slot>
</slots>
</ui>