mirror of
https://gitlab.com/then-try-this/samplebrain.git
synced 2025-07-04 03:03:34 +00:00
Compare commits
2 Commits
main
...
developmen
Author | SHA1 | Date | |
---|---|---|---|
6a89c19d24 | |||
13ee3ed817 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,7 +1,3 @@
|
|||||||
*.rej
|
|
||||||
*.orig
|
|
||||||
.DS_Store
|
|
||||||
*.ini
|
|
||||||
build
|
|
||||||
*.*~
|
*.*~
|
||||||
*.o
|
*.o
|
||||||
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
build-ubuntu:
|
|
||||||
stage: build
|
|
||||||
image: ubuntu:22.04
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get install -y git cmake g++ freeglut3-dev qtbase5-dev qt5-qmake qtbase5-dev-tools
|
|
||||||
- mkdir -p build
|
|
||||||
- cd build
|
|
||||||
- cmake ..
|
|
||||||
- cmake --build . --target samplebrain
|
|
||||||
|
|
||||||
build-win64:
|
|
||||||
tags:
|
|
||||||
- "windows"
|
|
||||||
before_script:
|
|
||||||
- choco install -y cmake python qt5-default
|
|
||||||
- $env:Path += ';C:\Program Files\CMake\bin'
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- set CMAKE_PREFIX_PATH=C:\Qt\5.15.2\mingw81_64
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake ..
|
|
||||||
- cmake --build . --target samplebrain
|
|
@ -1,81 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
project(samplebrain VERSION 1.0 LANGUAGES C CXX)
|
|
||||||
|
|
||||||
include(Dependencies.cmake)
|
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
|
|
||||||
# Set up AUTOMOC and some sensible defaults for runtime execution
|
|
||||||
# When using Qt 6.3, you can replace the code block below with
|
|
||||||
# qt_standard_project_setup()
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
set(CMAKE_AUTORCC ON)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core)
|
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui Widgets)
|
|
||||||
find_package(OpenMP)
|
|
||||||
|
|
||||||
add_executable(samplebrain WIN32 MACOSX_BUNDLE
|
|
||||||
app/MainWindow.cpp app/MainWindow.h
|
|
||||||
app/SettingsDialog.cpp app/SettingsDialog.h
|
|
||||||
app/audio_thread.cpp
|
|
||||||
app/feedback.cpp
|
|
||||||
app/process_thread.cpp
|
|
||||||
app/qtmain.cpp
|
|
||||||
app/samplebrain.qrc
|
|
||||||
app/sound_items.cpp
|
|
||||||
brain/src/aquila/filter/MelFilter.cpp
|
|
||||||
brain/src/aquila/filter/MelFilterBank.cpp
|
|
||||||
brain/src/aquila/transform/Dct.cpp
|
|
||||||
brain/src/block.cpp
|
|
||||||
brain/src/block_stream.cpp
|
|
||||||
brain/src/brain.cpp
|
|
||||||
brain/src/fft.cpp
|
|
||||||
brain/src/mfcc.cpp
|
|
||||||
brain/src/renderer.cpp
|
|
||||||
brain/src/search_params.cpp
|
|
||||||
brain/src/spiralcore/OSC_server.cpp
|
|
||||||
brain/src/spiralcore/allocator.cpp
|
|
||||||
brain/src/spiralcore/audio.cpp
|
|
||||||
brain/src/spiralcore/command_ring_buffer.cpp
|
|
||||||
brain/src/spiralcore/portaudio_client.cpp
|
|
||||||
brain/src/spiralcore/ring_buffer.cpp
|
|
||||||
brain/src/spiralcore/sample.cpp
|
|
||||||
brain/src/spiralcore/stream.cpp
|
|
||||||
brain/src/status.cpp
|
|
||||||
brain/src/window.cpp
|
|
||||||
app/gui/samplebrain.ui
|
|
||||||
app/gui/settings.ui
|
|
||||||
)
|
|
||||||
target_include_directories(samplebrain PRIVATE
|
|
||||||
.
|
|
||||||
brain/src
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(samplebrain PRIVATE
|
|
||||||
Qt5::Core
|
|
||||||
Qt5::Gui
|
|
||||||
Qt5::Widgets
|
|
||||||
fftw3
|
|
||||||
lo_shared
|
|
||||||
portaudio
|
|
||||||
sndfile
|
|
||||||
)
|
|
||||||
|
|
||||||
if(OpenMP_CXX_FOUND)
|
|
||||||
target_link_libraries(samplebrain PUBLIC OpenMP::OpenMP_CXX)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS samplebrain
|
|
||||||
BUNDLE DESTINATION .
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Consider using qt_generate_deploy_app_script() for app deployment if
|
|
||||||
# the project can use Qt 6.3. In that case rerun qmake2cmake with
|
|
||||||
# --min-qt-version=6.3.
|
|
@ -1,49 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
# FetchContent
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# fftw3
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
fftw3
|
|
||||||
URL http://fftw.org/fftw-3.3.10.tar.gz
|
|
||||||
URL_HASH MD5=8ccbf6a5ea78a16dbc3e1306e234cc5c)
|
|
||||||
FetchContent_MakeAvailable(fftw3)
|
|
||||||
|
|
||||||
include_directories(${fftw3_SOURCE_DIR}/api)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# liblo
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
liblo
|
|
||||||
URL http://downloads.sourceforge.net/liblo/liblo-0.31.tar.gz
|
|
||||||
URL_HASH MD5=14378c1e74c58e777fbb4fcf33ac5315)
|
|
||||||
FetchContent_MakeAvailable(liblo)
|
|
||||||
|
|
||||||
add_subdirectory(${liblo_SOURCE_DIR}/cmake)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# PortAudio
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
portaudio
|
|
||||||
URL http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz
|
|
||||||
URL_HASH MD5=ad319249932c6794b551d954b8844402)
|
|
||||||
FetchContent_MakeAvailable(portaudio)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# libsndfile
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
libsndfile
|
|
||||||
GIT_REPOSITORY https://github.com/libsndfile/libsndfile
|
|
||||||
GIT_TAG 1.1.0)
|
|
||||||
FetchContent_MakeAvailable(libsndfile)
|
|
@ -113,8 +113,8 @@ void MainWindow::init_from_session(const string &filename) {
|
|||||||
ifstream ifs(filename.c_str(),ios::binary);
|
ifstream ifs(filename.c_str(),ios::binary);
|
||||||
if (!ifs) return;
|
if (!ifs) return;
|
||||||
|
|
||||||
brain s,t;
|
brain s,t,lt;
|
||||||
u32 version=0;
|
u32 version=1;
|
||||||
ifs||version;
|
ifs||version;
|
||||||
renderer r(s,t);
|
renderer r(s,t);
|
||||||
ifs||r;
|
ifs||r;
|
||||||
@ -133,7 +133,14 @@ void MainWindow::init_from_session(const string &filename) {
|
|||||||
ifs||source_window||target_window;
|
ifs||source_window||target_window;
|
||||||
// todo: probably don't need to load all the sample data too :/
|
// todo: probably don't need to load all the sample data too :/
|
||||||
ifs||s;
|
ifs||s;
|
||||||
ifs||t;
|
ifs||t; // left
|
||||||
|
ifs||lt; // right
|
||||||
|
|
||||||
|
if (version>0) {
|
||||||
|
ifs||m_stereo;
|
||||||
|
m_Ui.checkBoxStereo->setChecked(m_stereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// brain tweaks
|
// brain tweaks
|
||||||
search_params * p = r.get_params();
|
search_params * p = r.get_params();
|
||||||
@ -198,8 +205,6 @@ void MainWindow::init_from_session(const string &filename) {
|
|||||||
m_Ui.sliderAutotune->setValue(r.get_autotune()*100);
|
m_Ui.sliderAutotune->setValue(r.get_autotune()*100);
|
||||||
m_Ui.doubleSpinBoxAutotune->setValue(r.get_autotune());
|
m_Ui.doubleSpinBoxAutotune->setValue(r.get_autotune());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "gui/ui_samplebrain.h"
|
#include "ui_samplebrain.h"
|
||||||
#include "SettingsDialog.h"
|
#include "SettingsDialog.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -393,7 +393,11 @@ private slots:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void stereo_mode(bool s) {
|
void stereo_mode(bool s) {
|
||||||
|
m_stereo=s;
|
||||||
send_audio_osc("/stereo","i",s);
|
send_audio_osc("/stereo","i",s);
|
||||||
|
// irritating but need to tell process thread about stereo state
|
||||||
|
// just to it can save it to the session file
|
||||||
|
send_process_osc("/stereo","i",s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void net_enable(int id) {
|
void net_enable(int id) {
|
||||||
@ -469,4 +473,5 @@ private:
|
|||||||
string m_audio_port;
|
string m_audio_port;
|
||||||
string m_process_port;
|
string m_process_port;
|
||||||
QString m_format_string;
|
QString m_format_string;
|
||||||
|
bool m_stereo;
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include "gui/ui_settings.h"
|
#include "ui_settings.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <lo/lo.h>
|
#include <lo/lo.h>
|
||||||
|
@ -140,6 +140,10 @@ void process_thread::process() {
|
|||||||
if (name=="/save_session") {
|
if (name=="/save_session") {
|
||||||
save_session(cmd.get_string(0));
|
save_session(cmd.get_string(0));
|
||||||
}
|
}
|
||||||
|
if (name=="/stereo") {
|
||||||
|
// only for session file save
|
||||||
|
m_stereo=cmd.get_int(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
@ -174,16 +178,7 @@ void process_thread::load_session(const std::string &filename) {
|
|||||||
m_left_target.clear();
|
m_left_target.clear();
|
||||||
m_right_target.clear();
|
m_right_target.clear();
|
||||||
ifstream ifs(filename.c_str(),ios::binary);
|
ifstream ifs(filename.c_str(),ios::binary);
|
||||||
u32 version=0;
|
stream_session(ifs);
|
||||||
ifs||version;
|
|
||||||
ifs||(*m_left_renderer);
|
|
||||||
ifs||(*m_right_renderer);
|
|
||||||
ifs||m_source_block_size||m_source_overlap;
|
|
||||||
ifs||m_target_block_size||m_target_overlap;
|
|
||||||
ifs||m_window_type||m_target_window_type;
|
|
||||||
ifs||m_source;
|
|
||||||
ifs||m_left_target;
|
|
||||||
ifs||m_right_target;
|
|
||||||
ifs.close();
|
ifs.close();
|
||||||
pthread_mutex_unlock(m_brain_mutex);
|
pthread_mutex_unlock(m_brain_mutex);
|
||||||
}
|
}
|
||||||
@ -191,16 +186,23 @@ void process_thread::load_session(const std::string &filename) {
|
|||||||
void process_thread::save_session(const std::string &filename) {
|
void process_thread::save_session(const std::string &filename) {
|
||||||
pthread_mutex_lock(m_brain_mutex);
|
pthread_mutex_lock(m_brain_mutex);
|
||||||
ofstream ofs(filename.c_str(),ios::binary);
|
ofstream ofs(filename.c_str(),ios::binary);
|
||||||
u32 version=0;
|
stream_session(ofs);
|
||||||
ofs||version;
|
|
||||||
ofs||(*m_left_renderer);
|
|
||||||
ofs||(*m_right_renderer);
|
|
||||||
ofs||m_source_block_size||m_source_overlap;
|
|
||||||
ofs||m_target_block_size||m_target_overlap;
|
|
||||||
ofs||m_window_type||m_target_window_type;
|
|
||||||
ofs||m_source;
|
|
||||||
ofs||m_left_target;
|
|
||||||
ofs||m_right_target;
|
|
||||||
ofs.close();
|
ofs.close();
|
||||||
pthread_mutex_unlock(m_brain_mutex);
|
pthread_mutex_unlock(m_brain_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void process_thread::stream_session(std::ios &fs) {
|
||||||
|
u32 version=1;
|
||||||
|
fs||version;
|
||||||
|
fs||(*m_left_renderer);
|
||||||
|
fs||(*m_right_renderer);
|
||||||
|
fs||m_source_block_size||m_source_overlap;
|
||||||
|
fs||m_target_block_size||m_target_overlap;
|
||||||
|
fs||m_window_type||m_target_window_type;
|
||||||
|
fs||m_source;
|
||||||
|
fs||m_left_target;
|
||||||
|
fs||m_right_target;
|
||||||
|
if (version>0) {
|
||||||
|
fs||m_stereo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -54,13 +54,16 @@ namespace spiralcore {
|
|||||||
brain m_source, m_left_target, m_right_target;
|
brain m_source, m_left_target, m_right_target;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OSC_server m_osc;
|
void stream_session(std::ios &fs);
|
||||||
|
|
||||||
|
OSC_server m_osc;
|
||||||
u32 m_source_block_size;
|
u32 m_source_block_size;
|
||||||
float m_source_overlap;
|
float m_source_overlap;
|
||||||
u32 m_target_block_size;
|
u32 m_target_block_size;
|
||||||
float m_target_overlap;
|
float m_target_overlap;
|
||||||
window::type m_window_type;
|
window::type m_window_type;
|
||||||
window::type m_target_window_type;
|
window::type m_target_window_type;
|
||||||
|
bool m_stereo;
|
||||||
pthread_t *m_thread;
|
pthread_t *m_thread;
|
||||||
|
|
||||||
// only use in mutex obvs...
|
// only use in mutex obvs...
|
||||||
|
@ -33,7 +33,7 @@ int main( int argc , char *argv[] ){
|
|||||||
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
cerr<<"Qt version: "<<qVersion()<<endl;
|
|
||||||
QSettings settings("thentrythis", "samplebrain");
|
QSettings settings("thentrythis", "samplebrain");
|
||||||
|
|
||||||
// slight over-use of OSC servers here, but the are packaged nicely for
|
// slight over-use of OSC servers here, but the are packaged nicely for
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <spiralcore/audio.h>
|
#include <spiralcore/audio.h>
|
||||||
@ -246,12 +245,10 @@ void brain::build_synapses_thresh(search_params ¶ms, double thresh) {
|
|||||||
m_average_error = calc_average_diff(params)*thresh;
|
m_average_error = calc_average_diff(params)*thresh;
|
||||||
double err = m_average_error*thresh;
|
double err = m_average_error*thresh;
|
||||||
u32 brain_size = m_blocks.size();
|
u32 brain_size = m_blocks.size();
|
||||||
std::atomic<u32> progress{0};
|
u32 outer_index = 0;
|
||||||
#pragma omp parallel for
|
for (auto &i : m_blocks) {
|
||||||
for (u32 outer_index = 0; outer_index < brain_size; ++outer_index) {
|
|
||||||
auto &i = m_blocks[outer_index];
|
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
status::update("building synapses %d%%",(int)(progress/(float)brain_size*100));
|
status::update("building synapses %d%%",(int)(outer_index/(float)brain_size*100));
|
||||||
for (auto &j : m_blocks) {
|
for (auto &j : m_blocks) {
|
||||||
if (index!=outer_index) {
|
if (index!=outer_index) {
|
||||||
// collect connections that are under threshold in closeness
|
// collect connections that are under threshold in closeness
|
||||||
@ -262,7 +259,7 @@ void brain::build_synapses_thresh(search_params ¶ms, double thresh) {
|
|||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
++progress;
|
++outer_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@ -270,25 +267,23 @@ void brain::build_synapses_thresh(search_params ¶ms, double thresh) {
|
|||||||
void brain::build_synapses_fixed(search_params ¶ms) {
|
void brain::build_synapses_fixed(search_params ¶ms) {
|
||||||
//m_average_error = calc_average_diff(params)*thresh;
|
//m_average_error = calc_average_diff(params)*thresh;
|
||||||
u32 brain_size = m_blocks.size();
|
u32 brain_size = m_blocks.size();
|
||||||
|
u32 outer_index = 0;
|
||||||
u32 num_synapses = NUM_FIXED_SYNAPSES;
|
u32 num_synapses = NUM_FIXED_SYNAPSES;
|
||||||
if (num_synapses>=m_blocks.size()) num_synapses=m_blocks.size()-1;
|
if (num_synapses>=m_blocks.size()) num_synapses=m_blocks.size()-1;
|
||||||
|
|
||||||
// need to stop the progress updates flooding osc
|
// need to stop the progress updates flooding osc
|
||||||
u32 update_period = 100;
|
u32 update_period = 100;
|
||||||
std::atomic<u32> update_tick{0};
|
u32 update_tick = 0;
|
||||||
std::atomic<u32> progress{0};
|
|
||||||
#pragma omp parallel for
|
for (auto &i:m_blocks) {
|
||||||
for (u32 outer_index = 0; outer_index < brain_size; ++outer_index) {
|
|
||||||
auto &i = m_blocks[outer_index];
|
|
||||||
if (update_tick>update_period) {
|
if (update_tick>update_period) {
|
||||||
status::update("building synapses %d%%",(int)(progress/(float)brain_size*100));
|
status::update("building synapses %d%%",(int)(outer_index/(float)brain_size*100));
|
||||||
update_tick=0;
|
update_tick=0;
|
||||||
}
|
}
|
||||||
update_tick++;
|
update_tick++;
|
||||||
|
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
vector<pair<u32,double>> collect;
|
vector<pair<u32,double>> collect;
|
||||||
collect.reserve(brain_size);
|
|
||||||
|
|
||||||
// collect comparisons to all other blocks
|
// collect comparisons to all other blocks
|
||||||
for (auto &j:m_blocks) {
|
for (auto &j:m_blocks) {
|
||||||
@ -313,7 +308,7 @@ void brain::build_synapses_fixed(search_params ¶ms) {
|
|||||||
i.get_synapse().push_back(collect[n].first);
|
i.get_synapse().push_back(collect[n].first);
|
||||||
}
|
}
|
||||||
|
|
||||||
++progress;
|
++outer_index;
|
||||||
}
|
}
|
||||||
status::update("Done: %d synapses grown for %d blocks",num_synapses*brain_size,brain_size);
|
status::update("Done: %d synapses grown for %d blocks",num_synapses*brain_size,brain_size);
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,12 @@ void audio_device::connect(const string &output_device_name, const string &clien
|
|||||||
m_client.attach(output_device_name,clientname,opt);
|
m_client.attach(output_device_name,clientname,opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_device::save_sample(const string &filename, const sample s) {
|
void audio_device::save_sample(const string &filename, unsigned int channels, const sample s) {
|
||||||
SF_INFO sfinfo;
|
SF_INFO sfinfo;
|
||||||
sfinfo.format=SF_FORMAT_WAV | SF_FORMAT_FLOAT;
|
sfinfo.format=SF_FORMAT_WAV | SF_FORMAT_FLOAT;
|
||||||
sfinfo.frames=s.get_length();
|
sfinfo.frames=s.get_length();
|
||||||
sfinfo.samplerate=m_samplerate;
|
sfinfo.samplerate=m_samplerate;
|
||||||
sfinfo.channels=1;
|
sfinfo.channels=channels;
|
||||||
sfinfo.sections=1;
|
sfinfo.sections=1;
|
||||||
sfinfo.seekable=0;
|
sfinfo.seekable=0;
|
||||||
SNDFILE* f=sf_open(filename.c_str(), SFM_WRITE, &sfinfo);
|
SNDFILE* f=sf_open(filename.c_str(), SFM_WRITE, &sfinfo);
|
||||||
@ -69,8 +69,7 @@ void audio_device::save_sample(const string &filename, const sample s) {
|
|||||||
void audio_device::start_recording(std::string filename) {
|
void audio_device::start_recording(std::string filename) {
|
||||||
m_record_filename=filename;
|
m_record_filename=filename;
|
||||||
m_recording=true;
|
m_recording=true;
|
||||||
m_record_buffer_left.clear();
|
m_record_buffer.clear();
|
||||||
m_record_buffer_right.clear();
|
|
||||||
m_record_counter=0;
|
m_record_counter=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,13 +80,19 @@ void audio_device::stop_recording() {
|
|||||||
|
|
||||||
void audio_device::maybe_record() {
|
void audio_device::maybe_record() {
|
||||||
if (m_recording) {
|
if (m_recording) {
|
||||||
m_record_buffer_left.add(left_out);
|
sample news(left_out.get_length()*2);
|
||||||
m_record_buffer_right.add(right_out);
|
for (unsigned int i=0; i<left_out.get_length(); i++) {
|
||||||
m_record_counter++;
|
news[i*2]=left_out[i];
|
||||||
if (m_record_counter%10==0) {
|
news[i*2+1]=right_out[i];
|
||||||
save_sample(m_record_filename+"-left.wav", m_record_buffer_left);
|
}
|
||||||
save_sample(m_record_filename+"-right.wav", m_record_buffer_right);
|
|
||||||
}
|
m_record_buffer.add(news);
|
||||||
|
m_record_counter++;
|
||||||
|
|
||||||
|
// save "every now and again"
|
||||||
|
if (m_record_counter%10==0) {
|
||||||
|
save_sample(m_record_filename+".wav",2,m_record_buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,12 @@ namespace spiralcore {
|
|||||||
|
|
||||||
portaudio_client m_client;
|
portaudio_client m_client;
|
||||||
|
|
||||||
void save_sample(const std::string &filename, const sample s);
|
void save_sample(const std::string &filename, unsigned int channels, const sample s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_recording;
|
bool m_recording;
|
||||||
std::string m_record_filename;
|
std::string m_record_filename;
|
||||||
sample m_record_buffer_left;
|
sample m_record_buffer;
|
||||||
sample m_record_buffer_right;
|
|
||||||
u32 m_record_counter;
|
u32 m_record_counter;
|
||||||
u32 m_samplerate;
|
u32 m_samplerate;
|
||||||
};
|
};
|
||||||
|
21
building.md
21
building.md
@ -1,8 +1,8 @@
|
|||||||
# Building from source
|
# Building from source
|
||||||
## Linux (Ubuntu)
|
## Linux (Ubuntu)
|
||||||
Install cmake:
|
Install libraries for the sample engine (use brew on mac, MinGW on win):
|
||||||
|
|
||||||
$ sudo apt install cmake
|
$ sudo apt install libsndfile1-dev portaudio19-dev liblo-dev libfftw3-dev
|
||||||
|
|
||||||
Install dependencies for the interface:
|
Install dependencies for the interface:
|
||||||
|
|
||||||
@ -16,14 +16,15 @@ Build & run it:
|
|||||||
|
|
||||||
$ mkdir build
|
$ mkdir build
|
||||||
$ cd build
|
$ cd build
|
||||||
$ cmake ..
|
$ qmake ..
|
||||||
$ cmake --build .
|
$ make
|
||||||
$ ./samplebrain
|
$ sudo make install
|
||||||
|
$ samplebrain
|
||||||
|
|
||||||
## Mac
|
## Mac
|
||||||
Install cmake:
|
Install libraries for sample engine:
|
||||||
|
|
||||||
$ brew install cmake
|
$ brew install fftw portaudio liblo libsndfile
|
||||||
|
|
||||||
Install dependencies for the interface:
|
Install dependencies for the interface:
|
||||||
|
|
||||||
@ -34,10 +35,10 @@ Build & run it:
|
|||||||
|
|
||||||
$ mkdir build
|
$ mkdir build
|
||||||
$ cd build
|
$ cd build
|
||||||
$ cmake ..
|
$ qmake ..
|
||||||
$ cmake --build .
|
$ make
|
||||||
|
|
||||||
`samplebrain.app` should then be in the build folder for you to run.
|
`samplebrain.app` should then be in the app folder for you to run.
|
||||||
|
|
||||||
# Mac build additions
|
# Mac build additions
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1188</width>
|
<width>1188</width>
|
||||||
<height>939</height>
|
<height>898</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -1473,7 +1473,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../samplebrain.qrc">
|
<iconset resource="../app/samplebrain.qrc">
|
||||||
<normaloff>:/images/images/play.png</normaloff>:/images/images/play.png</iconset>
|
<normaloff>:/images/images/play.png</normaloff>:/images/images/play.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -1500,7 +1500,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../samplebrain.qrc">
|
<iconset resource="../app/samplebrain.qrc">
|
||||||
<normaloff>:/images/images/pause.png</normaloff>:/images/images/pause.png</iconset>
|
<normaloff>:/images/images/pause.png</normaloff>:/images/images/pause.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -1520,7 +1520,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../samplebrain.qrc">
|
<iconset resource="../app/samplebrain.qrc">
|
||||||
<normaloff>:/images/images/record.png</normaloff>:/images/images/record.png</iconset>
|
<normaloff>:/images/images/record.png</normaloff>:/images/images/record.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -1540,7 +1540,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../samplebrain.qrc">
|
<iconset resource="../app/samplebrain.qrc">
|
||||||
<normaloff>:/images/images/stop.png</normaloff>:/images/images/stop.png</iconset>
|
<normaloff>:/images/images/stop.png</normaloff>:/images/images/stop.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -1606,7 +1606,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../samplebrain.qrc">
|
<iconset resource="../app/samplebrain.qrc">
|
||||||
<normaloff>:/images/images/settings.png</normaloff>:/images/images/settings.png</iconset>
|
<normaloff>:/images/images/settings.png</normaloff>:/images/images/settings.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -1639,7 +1639,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap resource="../samplebrain.qrc">:/images/images/at.png</pixmap>
|
<pixmap resource="../app/samplebrain.qrc">:/images/images/at.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -1650,8 +1650,7 @@
|
|||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../samplebrain.qrc"/>
|
<include location="../app/samplebrain.qrc"/>
|
||||||
<include location="../samplebrain.qrc"/>
|
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
71
samplebrain.pro
Normal file
71
samplebrain.pro
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
######################################################################
|
||||||
|
# Automatically generated by qmake (2.01a) Sun Jul 5 17:49:45 2015
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
TARGET = samplebrain
|
||||||
|
DEPENDPATH += . 2
|
||||||
|
INCLUDEPATH += . 2
|
||||||
|
|
||||||
|
QT += core gui widgets
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += app/MainWindow.h \
|
||||||
|
app/SettingsDialog.h
|
||||||
|
|
||||||
|
FORMS += gui/samplebrain.ui \
|
||||||
|
gui/settings.ui
|
||||||
|
|
||||||
|
SOURCES += app/MainWindow.cpp \
|
||||||
|
app/SettingsDialog.cpp \
|
||||||
|
app/sound_items.cpp \
|
||||||
|
app/audio_thread.cpp \
|
||||||
|
app/process_thread.cpp \
|
||||||
|
app/feedback.cpp \
|
||||||
|
app/qtmain.cpp \
|
||||||
|
brain/src/block.cpp \
|
||||||
|
brain/src/brain.cpp \
|
||||||
|
brain/src/fft.cpp \
|
||||||
|
brain/src/mfcc.cpp \
|
||||||
|
brain/src/renderer.cpp \
|
||||||
|
brain/src/search_params.cpp \
|
||||||
|
brain/src/status.cpp \
|
||||||
|
brain/src/window.cpp \
|
||||||
|
brain/src/block_stream.cpp \
|
||||||
|
brain/src/aquila/filter/MelFilterBank.cpp \
|
||||||
|
brain/src/aquila/filter/MelFilter.cpp \
|
||||||
|
brain/src/aquila/transform/Dct.cpp \
|
||||||
|
brain/src/spiralcore/sample.cpp \
|
||||||
|
brain/src/spiralcore/ring_buffer.cpp \
|
||||||
|
brain/src/spiralcore/command_ring_buffer.cpp \
|
||||||
|
brain/src/spiralcore/portaudio_client.cpp \
|
||||||
|
brain/src/spiralcore/audio.cpp \
|
||||||
|
brain/src/spiralcore/OSC_server.cpp \
|
||||||
|
brain/src/spiralcore/allocator.cpp \
|
||||||
|
brain/src/spiralcore/stream.cpp
|
||||||
|
|
||||||
|
INCLUDEPATH += brain/src
|
||||||
|
INCLUDEPATH += /usr/local/include
|
||||||
|
INCLUDEPATH += /opt/homebrew/include
|
||||||
|
LIBS += -L.. -L/usr/local/lib -L/opt/homebrew/lib -lportaudio -lfftw3 -lsndfile -llo -ldl -lpthread -lm
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -O3 -Wall -Wno-unused -std=c++11
|
||||||
|
|
||||||
|
# assets
|
||||||
|
RESOURCES = app/samplebrain.qrc
|
||||||
|
ICON = desktop/samplebrain.icns
|
||||||
|
|
||||||
|
PREFIX = $$(PREFIX)
|
||||||
|
isEmpty(PREFIX) {
|
||||||
|
PREFIX = /usr
|
||||||
|
}
|
||||||
|
|
||||||
|
unix:desktopfile.path = $$PREFIX/share/applications/
|
||||||
|
unix:desktopfile.files = desktop/samplebrain.desktop
|
||||||
|
unix:iconfile.path = $$PREFIX/share/icons/hicolor/scalable/apps
|
||||||
|
unix:iconfile.files = desktop/samplebrain.svg
|
||||||
|
unix:metainfofile.path = $$PREFIX/share/metainfo
|
||||||
|
unix:metainfofile.files = desktop/org.thentrythis.Samplebrain.metainfo.xml
|
||||||
|
|
||||||
|
target.path = $$PREFIX/bin
|
||||||
|
INSTALLS += target desktopfile iconfile metainfofile
|
Reference in New Issue
Block a user