Skip to content
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif ()

if (WIN32)
set(BONZOMATIC_WINDOWS_FLAVOR "GLFW" CACHE STRING "Windows renderer flavor selected at CMake configure time (DX11, DX9 or GLFW)")
set_property(CACHE BONZOMATIC_WINDOWS_FLAVOR PROPERTY STRINGS DX11 DX9 GLFW)
set_property(CACHE BONZOMATIC_WINDOWS_FLAVOR PROPERTY STRINGS DX11 DX9 GLFW)
endif ()

if (NOT (UNIX AND (NOT APPLE))) #if not linux
Expand Down Expand Up @@ -151,7 +151,7 @@ set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} bzc_jsonxx)
##############################################################################
# NDI
if (WIN32 AND BONZOMATIC_NDI)
if(DEFINED ENV{NDI_SDK_DIR})
if(DEFINED ENV{NDI_SDK_DIR})
set(NDI_SDK_DIR "$ENV{NDI_SDK_DIR}")
else()
message(FATAL_ERROR "Could not find NDI SDK. The NDI_SDK_DIR environment variable must be set to the SDK path.")
Expand Down Expand Up @@ -330,6 +330,8 @@ if (APPLE)
set(BZC_PLATFORM_SRCS
${CMAKE_SOURCE_DIR}/src/platform_glfw/Renderer.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/FFT.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Utils.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Config.cpp
${CMAKE_SOURCE_DIR}/src/platform_x11/MIDI.cpp
${CMAKE_SOURCE_DIR}/src/platform_osx/Misc.mm
${CMAKE_SOURCE_DIR}/src/platform_x11/Timer.cpp
Expand All @@ -346,18 +348,22 @@ elseif (UNIX)
set(BZC_PLATFORM_SRCS
${CMAKE_SOURCE_DIR}/src/platform_glfw/Renderer.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/FFT.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Utils.cpp
${CMAKE_SOURCE_DIR}/src/platform_x11/MIDI.cpp
${CMAKE_SOURCE_DIR}/src/platform_x11/Misc.cpp
${CMAKE_SOURCE_DIR}/src/platform_x11/SetupDialog.cpp
${CMAKE_SOURCE_DIR}/src/platform_x11/Timer.cpp
${CMAKE_SOURCE_DIR}/src/platform_x11/Clipboard.cpp
${CMAKE_SOURCE_DIR}/src/platform_linux/Config.cpp
)
source_group("Bonzomatic\\Platform" FILES ${BZC_PLATFORM_SRCS})
elseif (WIN32)
if (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "DX11")
set(BZC_PLATFORM_SRCS
${CMAKE_SOURCE_DIR}/src/platform_w32_dx11/Renderer.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/FFT.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Utils.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Config.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/MIDI.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/Misc.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/SetupDialog.cpp
Expand All @@ -369,6 +375,8 @@ elseif (WIN32)
set(BZC_PLATFORM_SRCS
${CMAKE_SOURCE_DIR}/src/platform_w32_dx9/Renderer.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/FFT.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Utils.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Config.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/MIDI.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/Misc.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/SetupDialog.cpp
Expand All @@ -380,6 +388,8 @@ elseif (WIN32)
set(BZC_PLATFORM_SRCS
${CMAKE_SOURCE_DIR}/src/platform_glfw/Renderer.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/FFT.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Utils.cpp
${CMAKE_SOURCE_DIR}/src/platform_common/Config.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/MIDI.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/Misc.cpp
${CMAKE_SOURCE_DIR}/src/platform_w32_common/SetupDialog.cpp
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ On recent macOS, to allow sound input to be captured (for FFT textures to be gen
## Configuration
You can configure Bonzomatic by creating a `config.json` and placing it next to the binary executable you're planning to run in the working directory for the binary; Bonzomatic will helpfully print this directory out for you when you run it, and you can also pass a file (with absolute or relative path, whichever you want) to load any other file as `config.json`. This allows you to have multiple configurations for multiple situations.

On Linux this file will be searched, in this order, in the executable directory, then in `~/.config/bonzomatic`, and finally in `/etc/bonzomatic`. Data (textures and last shader) will then be searched in a directory relative to where the `config.json` file was found. The only exception is if `config.json` is found in `/etc/bonzomatic` then data will be searched in `/usr/share/bonzomatic`.

The file can have the following contents: (all fields are optional)
``` javascript
{
Expand Down
41 changes: 41 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"window":{ // default window size / state, if there's a setup dialog, it will override it
"width":1920,
"height":1080,
"fullscreen":true,
},
// "font":{ // all paths in the file are also relative to the binary, but again, can be absolute paths if that's more convenient
// "file":"Input-Regular_(InputMono-Medium).ttf",
// "size":16,
// },
"rendering":{
"fftSmoothFactor": 0.9, // 0.0 means there's no smoothing at all, 1.0 means the FFT is completely smoothed flat
"fftAmplification": 1.0, // 1.0 means no change, larger values will result in brighter/stronger bands, smaller values in darker/weaker ones
},
"textures":{ // the keys below will become the shader variable names
"texChecker":"textures/checker.png",
"texNoise":"textures/noise.png",
"texTex1":"textures/tex1.jpg",
},
"gui":{
"outputHeight": 200,
"opacity": 192, // 255 means the editor occludes the effect completely, 0 means the editor is fully transparent
"texturePreviewWidth": 128,
"spacesForTabs": false,
"tabSize": 8,
"visibleWhitespace": false,
"autoIndent": "smart", // can be "none", "preserve" or "smart"
},
"midi":{ // the keys below will become the shader variable names, the values are the CC numbers
"fMidiKnob": 16, // e.g. this would be CC#16, i.e. by default the leftmost knob on a nanoKONTROL 2
},
// this section is if you want to enable NDI streaming; otherwise just ignore it
"ndi":{
"enabled": true,
"connectionString": "<ndi_product something=\"123\"/>", // metadata sent to the receiver; completely optional
"identifier": "hello!", // additional string to the device name; helps source discovery/identification in the receiver if there are multiple sources on the network
"frameRate": 60.0, // frames per second
"progressive": true, // progressive or interleaved?
},
"postExitCmd":"copy_to_dropbox.bat" // this command gets ran when you quit Bonzomatic, and the shader filename gets passed to it as first parameter. Use this to take regular backups.
}
61 changes: 61 additions & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include "jsonxx.h"

#include "Utils.h"

#include <string>

namespace Config
{

class ApplicationSettings
{
public:
enum Location
{
LOC_SYSTEM,
LOC_USER,
LOC_DIRECTORY,
LOC_NONE
};

ApplicationSettings( const std::string& cfg_filename )
: location_( LOC_NONE ), config_filename_( cfg_filename ) {}

void load()
{
find_location();
if( location_ != LOC_NONE )
{
read_config();
}
}

const jsonxx::Object get_options() const { return options_; }
const std::string get_config_directory_() const { return config_directory_; }
const std::string get_data_directory() const { return data_directory_; }

private:
void find_location();
void read_config()
{
std::string config_path( config_directory_ + "/" + config_filename_ );
std::vector< char > data;
Utils::read_file( config_path, data );
options_.parse( &data[ 0 ] );
}

Location location_;
std::string config_filename_;
jsonxx::Object options_;

std::string config_directory_;
std::string data_directory_;
};





}
11 changes: 11 additions & 0 deletions src/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <string>
#include <vector>

namespace Utils
{

bool read_file( const std::string& filename, std::vector< char >& out );

}
Loading