mirror of
https://gitlab.com/then-try-this/samplebrain.git
synced 2025-05-12 02:27:21 +00:00
sorted file paths so we have separate ones for each dialog - fixes: #75
This commit is contained in:
parent
c4499ce7c9
commit
f9f3557b79
@ -28,7 +28,11 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
MainWindow::MainWindow(const string &port, const string &audio_port, const string &process_port, QSettings *settings) :
|
MainWindow::MainWindow(const string &port, const string &audio_port, const string &process_port, QSettings *settings) :
|
||||||
m_last_file("."),
|
m_last_sound_file("."),
|
||||||
|
m_last_target_file("."),
|
||||||
|
m_last_brain_file("."),
|
||||||
|
m_last_session_file("."),
|
||||||
|
m_last_recording_file("."),
|
||||||
m_feedback(port),
|
m_feedback(port),
|
||||||
m_audio_port(audio_port),
|
m_audio_port(audio_port),
|
||||||
m_process_port(process_port),
|
m_process_port(process_port),
|
||||||
|
142
app/MainWindow.h
142
app/MainWindow.h
@ -67,7 +67,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_process_osc(const char *name, const char *types) {
|
void send_process_osc(const char *name, const char *types) {
|
||||||
for (auto dest:m_destinations) {
|
for (auto dest:m_destinations) {
|
||||||
if (dest.m_enabled) {
|
if (dest.m_enabled) {
|
||||||
@ -206,12 +206,14 @@ private slots:
|
|||||||
|
|
||||||
void run_slot() {}
|
void run_slot() {}
|
||||||
void load_target() {
|
void load_target() {
|
||||||
m_last_file=QFileDialog::getOpenFileName(this,
|
QString path=QFileDialog::getOpenFileName(this,
|
||||||
QString("Select an audio file"),
|
QString("Select an audio file"),
|
||||||
m_last_file,
|
m_last_target_file,
|
||||||
m_format_string);
|
m_format_string);
|
||||||
|
if (m_last_target_file!="") {
|
||||||
send_process_osc("/load_target","s",m_last_file.toStdString().c_str());
|
m_last_target_file=path;
|
||||||
|
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_size(int s) { send_process_osc("/target_block_size","i",s); }
|
||||||
void target_block_overlap(double s) { send_process_osc("/target_overlap","f",s); }
|
void target_block_overlap(double s) { send_process_osc("/target_overlap","f",s); }
|
||||||
@ -221,14 +223,15 @@ private slots:
|
|||||||
void fft_spectrum_size(int) {}
|
void fft_spectrum_size(int) {}
|
||||||
void generate() { send_process_osc("/generate_brain",""); }
|
void generate() { send_process_osc("/generate_brain",""); }
|
||||||
void load_sound() {
|
void load_sound() {
|
||||||
m_last_file=QFileDialog::getOpenFileName(this,
|
QString path=QFileDialog::getOpenFileName(this,
|
||||||
QString("Select a wav file"),
|
QString("Select a wav file"),
|
||||||
m_last_file,
|
m_last_sound_file,
|
||||||
m_format_string);
|
m_format_string);
|
||||||
|
|
||||||
if (m_last_file!="") {
|
if (path!="") {
|
||||||
send_process_osc("/load_sample","s",m_last_file.toStdString().c_str());
|
m_last_sound_file=path;
|
||||||
sound_items::sound_item &si = m_sound_items.add(m_Ui.brain_contents, m_last_file.toStdString(),true);
|
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()));
|
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);
|
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()));
|
QObject::connect(si.m_del, SIGNAL(clicked()), m_sound_item_delete_mapper, SLOT(map()));
|
||||||
@ -238,25 +241,27 @@ private slots:
|
|||||||
|
|
||||||
|
|
||||||
void load_sounds() {
|
void load_sounds() {
|
||||||
m_last_file=QFileDialog::getExistingDirectory(this,
|
QString path=QFileDialog::getExistingDirectory(this,
|
||||||
QString("Select a directory of wav files"),
|
QString("Select a directory of wav files"),
|
||||||
m_last_file);
|
m_last_directory_file);
|
||||||
|
|
||||||
|
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() &&
|
||||||
|
QFileInfo(dirIt.filePath()).suffix() == "wav") {
|
||||||
|
send_process_osc("/load_sample","s",dirIt.filePath().toStdString().c_str());
|
||||||
|
|
||||||
QDirIterator dirIt(m_last_file,QDirIterator::Subdirectories);
|
sound_items::sound_item &si = m_sound_items.add(m_Ui.brain_contents, dirIt.filePath().toStdString(),true);
|
||||||
while (dirIt.hasNext()) {
|
|
||||||
dirIt.next();
|
|
||||||
if (QFileInfo(dirIt.filePath()).isFile() &&
|
|
||||||
QFileInfo(dirIt.filePath()).suffix() == "wav") {
|
|
||||||
send_process_osc("/load_sample","s",dirIt.filePath().toStdString().c_str());
|
|
||||||
|
|
||||||
sound_items::sound_item &si = m_sound_items.add(m_Ui.brain_contents, dirIt.filePath().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_enable, SIGNAL(clicked()), m_sound_item_enable_mapper, SLOT(map()));
|
QObject::connect(si.m_del, SIGNAL(clicked()), m_sound_item_delete_mapper, SLOT(map()));
|
||||||
m_sound_item_enable_mapper->setMapping(si.m_enable, si.m_id);
|
m_sound_item_delete_mapper->setMapping(si.m_del, 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);
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,12 +318,11 @@ private slots:
|
|||||||
|
|
||||||
void record() {
|
void record() {
|
||||||
if (m_save_wav=="") {
|
if (m_save_wav=="") {
|
||||||
m_last_file=QFileDialog::getSaveFileName(
|
m_last_recording_file=QFileDialog::getSaveFileName(this,
|
||||||
this,
|
QString("Select a wav file"),
|
||||||
QString("Select a wav file"),
|
m_last_recording_file,
|
||||||
m_last_file,
|
QString("Sounds (*.wav);;All files (*.*)"));
|
||||||
QString("Sounds (*.wav);;All files (*.*)"));
|
m_save_wav = m_last_recording_file.toStdString();
|
||||||
m_save_wav = m_last_file.toStdString();
|
|
||||||
// chop off .wav
|
// chop off .wav
|
||||||
size_t pos = m_save_wav.find_last_of(".");
|
size_t pos = m_save_wav.find_last_of(".");
|
||||||
if (pos!=string::npos) {
|
if (pos!=string::npos) {
|
||||||
@ -339,43 +343,48 @@ private slots:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void load_brain() {
|
void load_brain() {
|
||||||
m_last_file=QFileDialog::getOpenFileName(
|
QString path=QFileDialog::getOpenFileName(this,
|
||||||
this,
|
QString("Select a brain file"),
|
||||||
QString("Select a brain file"),
|
m_last_brain_file,
|
||||||
m_last_file,
|
QString("Brains (*.brain);;All files (*.*)"));
|
||||||
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() {
|
void save_brain() {
|
||||||
m_last_file=QFileDialog::getSaveFileName(
|
QString path=QFileDialog::getSaveFileName(this,
|
||||||
this,
|
QString("Select a brain file"),
|
||||||
QString("Select a brain file"),
|
m_last_brain_file,
|
||||||
m_last_file,
|
QString("Brains (*.brain);;All files (*.*)"));
|
||||||
QString("Brains (*.brain);;All files (*.*)"));
|
if (path!="") {
|
||||||
|
m_last_brain_file=path;
|
||||||
send_process_osc("/save_brain","s",m_last_file.toStdString().c_str());
|
send_process_osc("/save_brain","s",m_last_brain_file.toStdString().c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_session() {
|
void load_session() {
|
||||||
m_last_file=QFileDialog::getOpenFileName(
|
QString path=QFileDialog::getOpenFileName(this,
|
||||||
this,
|
QString("Select a session file"),
|
||||||
QString("Select a session file"),
|
m_last_session_file,
|
||||||
m_last_file,
|
QString("Sessions *.samplebrain (*.samplebrain);;All files (*.*)"));
|
||||||
QString("Sessions *.samplebrain (*.samplebrain);;All files (*.*)"));
|
if (path!="") {
|
||||||
|
m_last_session_file=path;
|
||||||
send_process_osc("/load_session","s",m_last_file.toStdString().c_str());
|
send_process_osc("/load_session","s",m_last_session_file.toStdString().c_str());
|
||||||
init_from_session(m_last_file.toStdString());
|
init_from_session(m_last_session_file.toStdString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_session() {
|
void save_session() {
|
||||||
m_last_file=QFileDialog::getSaveFileName(
|
QString path=QFileDialog::getSaveFileName(this,
|
||||||
this,
|
QString("Select a session file"),
|
||||||
QString("Select a session file"),
|
m_last_session_file,
|
||||||
m_last_file,
|
QString("Sessions *.samplebrain (*.samplebrain)"));
|
||||||
QString("Sessions *.samplebrain (*.samplebrain)"));
|
if (path!="") {
|
||||||
|
m_last_session_file=path;
|
||||||
send_process_osc("/save_session","s",m_last_file.toStdString().c_str());
|
send_process_osc("/save_session","s",m_last_session_file.toStdString().c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_status() {
|
void update_status() {
|
||||||
@ -440,7 +449,12 @@ private:
|
|||||||
QSignalMapper* enable_mapper);
|
QSignalMapper* enable_mapper);
|
||||||
|
|
||||||
string m_save_wav;
|
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;
|
unsigned int m_record_id;
|
||||||
Ui_MainWindow m_Ui;
|
Ui_MainWindow m_Ui;
|
||||||
feedback m_feedback;
|
feedback m_feedback;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user