Compare commits

...

10 Commits

Author SHA1 Message Date
Claude Heiland-Allen 58f9f49c10 Merge branch 'parallel-synapse-generation' into 'main'
parallelize synapse generation using OpenMP

See merge request then-try-this/samplebrain!6
2022-09-29 12:01:14 +00:00
Alex McLean e3619746a4 Update README.md 2022-09-29 11:36:21 +00:00
Alex McLean 74eb5b0b9b Update README.md 2022-09-29 11:30:07 +00:00
Alex McLean 287ba85c14 Update README.md 2022-09-29 11:29:41 +00:00
Alex McLean a7b866b4fc Update README.md 2022-09-29 10:44:56 +00:00
dave griffiths 7bda8195c9 Merge branch 'packaging/flatpak' into 'main'
linux: Prepare for Flathub submission

See merge request then-try-this/samplebrain!9
2022-09-29 07:23:43 +00:00
Owen D'Aprile dc0c047ad6
linux: add AppStream metadata
Adds an AppStream metainfo file that is used to display the app in
graphical app stores on Linux. This is also required for submission to
Flathub.
2022-09-28 18:19:48 -04:00
Owen D'Aprile 672fb1868f
linux: add a screenshot for the metadata
AppStream metadata requires a screenshot. This screenshot will be used
in the graphical app stores.
2022-09-28 18:12:32 -04:00
Owen D'Aprile 30d93be49c
linux: update desktop file
Remove unnecessary keys, tweak the comment, and add categories.
2022-09-28 18:12:31 -04:00
Claude Heiland-Allen 8aa0dee3d1 parallelize synapse generation using OpenMP
- only tested on Debian Linux with a 16-thread amd64 CPU
- Windows may need DLLs to be shipped with the EXE
- using `-fopenmp` should be made optional via qmake somehow
  (without the flag, parallelization pragmas are ignored
  and it reverts to serial operation)
- assumes `status::update()` among other code is thread-safe,
  it seems to work on my machine without issues...
2022-09-27 13:19:04 +01:00
7 changed files with 69 additions and 26 deletions

View File

@ -157,3 +157,6 @@ License version 2 (see LICENCE).
Written by [Dave Griffiths at Then Try This](http://thentrythis.org).
## Links
To find related tech like [CataRT](http://imtr.ircam.fr/imtr/CataRT), [bbcut2](https://composerprogrammer.com/bbcut2.html), [eargram](https://sites.google.com/site/eargram/) and [sCrAmBlEd?HaCkZ!](https://www.youtube.com/watch?v=eRlhKaxcKpA) search up [granular synthesis](http://granularsynthesis.com/guide.php), [concatenative synthesis](https://hal.archives-ouvertes.fr/hal-01161337), [neural audio synthesis](https://github.com/acids-ircam/RAVE), [sinewave speech](http://www.lifesci.sussex.ac.uk/home/Chris_Darwin/SWS/), automated breakbeat cutting, audio mosaicing and plunderphonics/plundermatics.

View File

@ -16,6 +16,7 @@
#include <iostream>
#include <algorithm>
#include <atomic>
#include <sndfile.h>
#include <float.h>
#include <spiralcore/audio.h>
@ -242,10 +243,12 @@ void brain::build_synapses_thresh(search_params &params, double thresh) {
m_average_error = calc_average_diff(params)*thresh;
double err = m_average_error*thresh;
u32 brain_size = m_blocks.size();
u32 outer_index = 0;
for (auto &i : m_blocks) {
std::atomic<u32> progress{0};
#pragma omp parallel for
for (u32 outer_index = 0; outer_index < brain_size; ++outer_index) {
auto &i = m_blocks[outer_index];
u32 index = 0;
status::update("building synapses %d%%",(int)(outer_index/(float)brain_size*100));
status::update("building synapses %d%%",(int)(progress/(float)brain_size*100));
for (auto &j : m_blocks) {
if (index!=outer_index) {
// collect connections that are under threshold in closeness
@ -256,30 +259,32 @@ void brain::build_synapses_thresh(search_params &params, double thresh) {
}
++index;
}
++outer_index;
++progress;
}
}
void brain::build_synapses_fixed(search_params &params) {
//m_average_error = calc_average_diff(params)*thresh;
u32 brain_size = m_blocks.size();
u32 outer_index = 0;
u32 num_synapses = NUM_FIXED_SYNAPSES;
if (num_synapses>=m_blocks.size()) num_synapses=m_blocks.size()-1;
// need to stop the progress updates flooding osc
u32 update_period = 100;
u32 update_tick = 0;
for (auto &i:m_blocks) {
std::atomic<u32> update_tick{0};
std::atomic<u32> progress{0};
#pragma omp parallel for
for (u32 outer_index = 0; outer_index < brain_size; ++outer_index) {
auto &i = m_blocks[outer_index];
if (update_tick>update_period) {
status::update("building synapses %d%%",(int)(outer_index/(float)brain_size*100));
status::update("building synapses %d%%",(int)(progress/(float)brain_size*100));
update_tick=0;
}
update_tick++;
u32 index = 0;
vector<pair<u32,double>> collect;
collect.reserve(brain_size);
// collect comparisons to all other blocks
for (auto &j:m_blocks) {
@ -304,7 +309,7 @@ void brain::build_synapses_fixed(search_params &params) {
i.get_synapse().push_back(collect[n].first);
}
++outer_index;
++progress;
}
status::update("Done: %d synapses grown for %d blocks",num_synapses*brain_size,brain_size);
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>org.thentrythis.Samplebrain</id>
<name>Samplebrain</name>
<summary>A custom sample mashing app designed by Aphex Twin</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0-only</project_license>
<description>
<p>
Samplebrain chops samples up into a &apos;brain&apos; of interconnected small sections called blocks which are connected into a network by similarity. It processes a target sample, chopping it up into blocks in the same way, and tries to match each block with one in it&apos;s brain to play in realtime.
</p>
<p>
This allows you to interpret a sound with a different one. As we worked on it (during 2015 and 2016) we gradually added more and more tweakable parameters until it became slightly out of control.
</p>
</description>
<launchable type="desktop-id">samplebrain.desktop</launchable>
<categories>
<category>AudioVideo</category>
<category>Music</category>
</categories>
<content_rating type="oars-1.0"></content_rating>
<url type="homepage">https://thentrythis.org/projects/samplebrain/</url>
<url type="bugtracker">https://gitlab.com/then-try-this/samplebrain/-/issues</url>
<url type="vcs-browser">https://gitlab.com/then-try-this/samplebrain</url>
<screenshots>
<screenshot type="default">
<image type="source" width="1280" height="720">https://gitlab.com/then-try-this/samplebrain/-/raw/main/desktop/screenshots/01-main-with-project.png</image>
</screenshot>
</screenshots>
<releases>
<release version="0.18" date="2022-09-22"/>
</releases>
</component>

View File

@ -1,10 +1,8 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Samplebrain
Comment=A sample masher designed by Aphex Twin
Exec=samplebrain
Comment=A custom sample mashing app designed by Aphex Twin
Icon=samplebrain
Terminal=false
Categories=GNOME;Application;
Exec=samplebrain
Categories=AudioVideo;Music
StartupNotify=true

View File

@ -1,7 +0,0 @@
[Desktop Entry]
Type=Application
Version=1.0
Name=Samplebrain
GenericName="Samplebrain"
Exec=samplebrain
Icon=samplebrain

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -44,9 +44,9 @@ SOURCES += app/MainWindow.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
LIBS += -L.. -L/usr/local/lib -L/opt/homebrew/lib -lportaudio -lfftw3 -lsndfile -llo -ldl -lpthread -lm -fopenmp
QMAKE_CXXFLAGS += -O3 -Wall -Wno-unused -std=c++11
QMAKE_CXXFLAGS += -O3 -fopenmp -Wall -Wno-unused -std=c++11
# assets
RESOURCES = app/samplebrain.qrc
@ -61,6 +61,8 @@ 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
INSTALLS += target desktopfile iconfile metainfofile