├── logo
├── logo.ai
├── logo.png
└── logo_text.png
├── gui
├── syntacts.ico
├── syntacts.rc
├── src
│ ├── Widget.cpp
│ ├── Debugger.hpp
│ ├── Widget.hpp
│ ├── Designer.hpp
│ ├── Player.hpp
│ ├── Visualizer.hpp
│ ├── Workspace.hpp
│ ├── main.cpp
│ ├── Gui.hpp
│ ├── Palette.hpp
│ ├── StatusBar.hpp
│ ├── Theme.hpp
│ ├── DeviceBar.hpp
│ ├── FileWatcher.hpp
│ ├── PolyBezier.hpp
│ ├── Library.hpp
│ ├── Sequencer.hpp
│ ├── Visualizer.cpp
│ ├── Workspace.cpp
│ ├── Designer.cpp
│ ├── DragAndDrop.hpp
│ ├── Spatializer.hpp
│ ├── FileWatcher.cpp
│ ├── Custom.hpp
│ ├── Gui.cpp
│ ├── DragAndDrop.cpp
│ ├── Debugger.cpp
│ └── Palette.cpp
└── CMakeLists.txt
├── unity
└── SyntactsDemo
│ ├── ProjectSettings
│ ├── ProjectVersion.txt
│ ├── ClusterInputManager.asset
│ ├── PresetManager.asset
│ ├── EditorBuildSettings.asset
│ ├── XRSettings.asset
│ ├── TimeManager.asset
│ ├── VFXManager.asset
│ ├── AudioManager.asset
│ ├── TagManager.asset
│ ├── UnityConnectSettings.asset
│ ├── EditorSettings.asset
│ ├── DynamicsManager.asset
│ ├── NavMeshAreas.asset
│ ├── Physics2DSettings.asset
│ └── GraphicsSettings.asset
│ ├── Assets
│ ├── Syntacts
│ │ ├── Editor
│ │ │ ├── logo.png
│ │ │ ├── SyntactsHubEditor.cs.meta
│ │ │ └── logo.png.meta
│ │ ├── Editor.meta
│ │ ├── Plugins.meta
│ │ ├── Syntacts.cs.meta
│ │ ├── SyntactsHub.cs.meta
│ │ ├── Plugins
│ │ │ └── syntacts_c.dll.meta
│ │ └── SyntactsHub.cs
│ ├── Demo
│ │ ├── Demo.unity.meta
│ │ ├── BouncyBall.mat.meta
│ │ ├── BouncyBall.physicMaterial.meta
│ │ ├── BouncyBall.cs.meta
│ │ ├── LibraryButton.cs.meta
│ │ ├── BouncyBall.physicMaterial
│ │ ├── BouncyBall.cs
│ │ ├── LibraryButton.cs
│ │ └── BouncyBall.mat
│ ├── Demo.meta
│ └── Syntacts.meta
│ ├── .gitignore
│ └── Packages
│ └── manifest.json
├── template
├── .gitignore
├── main.cpp
└── CMakeLists.txt
├── csharp
├── Syntacts
│ └── Syntacts.csproj
├── README.md
├── examples
│ ├── example_basic
│ │ ├── example_basic.csproj
│ │ └── example_basic.cs
│ ├── example_music
│ │ ├── example_music.csproj
│ │ └── example_music.cs
│ ├── example_devices
│ │ ├── example_devices.csproj
│ │ └── example_devices.cs
│ ├── example_library
│ │ ├── example_library.csproj
│ │ └── example_library.cs
│ ├── example_signals
│ │ ├── example_signals.csproj
│ │ └── example_signals.cs
│ ├── example_sequences
│ │ ├── example_sequences.csproj
│ │ └── example_sequences.cs
│ └── example_spatializer
│ │ ├── example_spatializer.csproj
│ │ └── example_spatializer.cs
└── .gitignore
├── tests
├── CMakeLists.txt
├── dll.cpp
└── benchmark.cpp
├── .gitmodules
├── .gitignore
├── python
├── example_devices.py
├── example_spatializer.py
├── example.py
├── example_music.py
├── example_sequences.py
├── example_toh.py
├── example_library.py
├── .gitignore
└── example_basic.py
├── src
├── Tact
│ ├── Operator.cpp
│ ├── Signal.cpp
│ ├── Oscillator.cpp
│ ├── Sequence.cpp
│ ├── MemoryPool.cpp
│ ├── Process.cpp
│ ├── Envelope.cpp
│ └── Util.cpp
└── Filesystem.hpp
├── .vscode
└── cmake-variants.yaml
├── examples
├── CMakeLists.txt
├── example_rtti.cpp
├── example_spatializer.cpp
├── example_devices.cpp
├── example_sequences.cpp
├── example_signals.cpp
├── example_music.cpp
├── example_library.cpp
└── example_basic.cpp
├── include
├── Tact
│ ├── Detail
│ │ ├── Sequence.inl
│ │ ├── Oscillator.inl
│ │ ├── Operator.inl
│ │ └── Signal.inl
│ ├── Error.hpp
│ ├── Serialization.hpp
│ ├── Library.hpp
│ ├── Process.hpp
│ ├── Config.hpp
│ ├── Util.hpp
│ ├── Operator.hpp
│ ├── Sequence.hpp
│ ├── Oscillator.hpp
│ └── Spatializer.hpp
└── syntacts
├── cmake
└── SyntactsConfig.cmake.in
├── LICENSE
├── TODO.md
├── c
└── CMakeLists.txt
└── README.md
/logo/logo.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahilab/Syntacts/HEAD/logo/logo.ai
--------------------------------------------------------------------------------
/logo/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahilab/Syntacts/HEAD/logo/logo.png
--------------------------------------------------------------------------------
/gui/syntacts.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahilab/Syntacts/HEAD/gui/syntacts.ico
--------------------------------------------------------------------------------
/gui/syntacts.rc:
--------------------------------------------------------------------------------
1 |
2 | GLFW_ICON ICON "syntacts.ico"
3 |
4 |
--------------------------------------------------------------------------------
/logo/logo_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahilab/Syntacts/HEAD/logo/logo_text.png
--------------------------------------------------------------------------------
/gui/src/Widget.cpp:
--------------------------------------------------------------------------------
1 | #include "Widget.hpp"
2 | #include "Gui.hpp"
3 |
4 | Widget::Widget(Gui& _gui) : gui(_gui) { }
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 2019.4.11f1
2 | m_EditorVersionWithRevision: 2019.4.11f1 (2d9804dddde7)
3 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/Editor/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahilab/Syntacts/HEAD/unity/SyntactsDemo/Assets/Syntacts/Editor/logo.png
--------------------------------------------------------------------------------
/template/.gitignore:
--------------------------------------------------------------------------------
1 | # C++
2 | [Bb]uild/
3 | [Bb]uild*/
4 | ipch/
5 | .vscode/
6 | .vs/
7 |
8 | *.dll
9 | *.lib
10 | *.exe
11 | *.dylib
12 | *.so
13 |
14 | .DS_Store
--------------------------------------------------------------------------------
/csharp/Syntacts/Syntacts.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/PresetManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1386491679 &1
4 | PresetManager:
5 | m_ObjectHideFlags: 0
6 | m_DefaultList: []
7 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/Demo.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9fc0d4010bbf28b4594072e72b8655ab
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/gui/src/Debugger.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 |
5 | class Debugger : public Widget {
6 | public:
7 | using Widget::Widget;
8 | void update() override;
9 | public:
10 | bool show = false;
11 | };
--------------------------------------------------------------------------------
/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(dll dll.cpp)
2 | target_link_libraries(dll syntacts_c)
3 | target_include_directories(dll PUBLIC "../c/")
4 |
5 | add_executable(benchmark benchmark.cpp)
6 | target_link_libraries(benchmark syntacts)
--------------------------------------------------------------------------------
/template/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace tact;
4 |
5 | int main(int argc, char const *argv[])
6 | {
7 | Session s;
8 | s.open();
9 | s.playAll(Sine(440));
10 | sleep(2);
11 | return 0;
12 | }
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 81435aa2cb7d9af4bb9afc03ded282ff
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 83938bb5fc072fa4b813fe3730dfe30e
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 687b9aefb4373ad488342349228ab146
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a7499f17ea51c9848a478978e16de643
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes: []
8 | m_configObjects: {}
9 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/XRSettings.asset:
--------------------------------------------------------------------------------
1 | {
2 | "m_SettingKeys": [
3 | "VR Device Disabled",
4 | "VR Device User Alert"
5 | ],
6 | "m_SettingValues": [
7 | "False",
8 | "False"
9 | ]
10 | }
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/BouncyBall.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e6ef143084cd27945bac1e2482d4acd6
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/BouncyBall.physicMaterial.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c34c7a1783e9c8d439b26c5023739966
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 13400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/gui/src/Widget.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | class Gui;
6 |
7 | class Widget {
8 | public:
9 | Widget(Gui& gui);
10 | virtual void update() { };
11 | public:
12 | mahi::gui::Vec2 position, size;
13 | Gui& gui;
14 | };
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.33333334
8 | m_TimeScale: 1
9 | Maximum Particle Timestep: 0.03
10 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/BouncyBall.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0665b2bea6d2aee4cb5d999e8bf817d5
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/csharp/README.md:
--------------------------------------------------------------------------------
1 | First, build Syntacts from the `csharp/Syntacts` directory:
2 |
3 | ```shell
4 | > dotnet build
5 | ```
6 |
7 | Then, change directories to the desired example and run it:
8 |
9 | ```shell
10 | > cd ../example_basic
11 | > dotnet run
12 | ```
13 |
14 | Ensure that each example folder contains the C library `syntactsc.dll`.
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/LibraryButton.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c84d9db8be04f84c99cd30e0e326aa1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/gui/src/Designer.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 | #include "Nodes.hpp"
5 |
6 | class Designer : public Widget {
7 | public:
8 | Designer(Gui& _gui);
9 | tact::Signal buildSignal();
10 | void update() override;
11 | void edit(const tact::Signal& sig);
12 | private:
13 | std::shared_ptr m_root;
14 | };
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "3rdparty/mahi-gui"]
2 | path = 3rdparty/mahi-gui
3 | url = https://github.com/mahilab/mahi-gui
4 | [submodule "3rdparty/cereal"]
5 | path = 3rdparty/cereal
6 | url = https://github.com/USCiLab/cereal
7 | [submodule "3rdparty/portaudio"]
8 | path = 3rdparty/portaudio
9 | url = https://git.assembla.com/portaudio.git
10 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/Editor/SyntactsHubEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d138f055a43604b4386663dd65a2d282
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/csharp/examples/example_basic/example_basic.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp/examples/example_music/example_music.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp/examples/example_devices/example_devices.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp/examples/example_library/example_library.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp/examples/example_signals/example_signals.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/VFXManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!937362698 &1
4 | VFXManager:
5 | m_ObjectHideFlags: 0
6 | m_IndirectShader: {fileID: 0}
7 | m_CopyBufferShader: {fileID: 0}
8 | m_SortShader: {fileID: 0}
9 | m_RenderPipeSettingsPath:
10 | m_FixedTimeStep: 0.016666668
11 | m_MaxDeltaTime: 0.05
12 |
--------------------------------------------------------------------------------
/csharp/examples/example_sequences/example_sequences.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/csharp/examples/example_spatializer/example_spatializer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp3.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # C++
2 | [Bb]uild/
3 | [Bb]uild*/
4 | ipch/
5 | .vscode/*
6 | .vs/
7 | !.vscode/cmake-variants.yaml
8 |
9 | *.dll
10 | *.lib
11 | *.exe
12 | *.dylib
13 | *.so
14 |
15 | asiosdk/
16 | asiosdk*/
17 | asiosdk.zip
18 | asiosdk*.zip
19 | asio.zip
20 |
21 | relative/
22 | *.sig
23 | *.wav
24 | *.wave
25 | *.aiff
26 | *.aifc
27 | *.csv
28 |
29 | .DS_Store
30 |
31 | debug.log
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/Syntacts.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e97b0ce0e31aeb042b61bf0bed3081e8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {fileID: 2800000, guid: f37ce78e955c1eb4cb8c25996487548b, type: 3}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/SyntactsHub.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e10de8f2496aaef49ab143f2d911b04b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {fileID: 2800000, guid: f37ce78e955c1eb4cb8c25996487548b, type: 3}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/BouncyBall.physicMaterial:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!134 &13400000
4 | PhysicMaterial:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_Name: BouncyBall
10 | dynamicFriction: 0
11 | staticFriction: 0
12 | bounciness: 1
13 | frictionCombine: 2
14 | bounceCombine: 3
15 |
--------------------------------------------------------------------------------
/gui/src/Player.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 |
5 | class Player : public Widget {
6 | public:
7 |
8 | Player(Gui& gui);
9 | void update() override;
10 |
11 | private:
12 |
13 | void updateChannels();
14 | void playCh(int ch);
15 | void playSelected();
16 | void rechannel();
17 |
18 | private:
19 | int m_payload;
20 | float m_masterVol = 1.0f;
21 | float m_masterPitch = 0.0f;
22 | };
--------------------------------------------------------------------------------
/python/example_devices.py:
--------------------------------------------------------------------------------
1 | from syntacts import *
2 |
3 | session = Session()
4 |
5 | for dev in session.available_devices:
6 | print("")
7 | print("Index: ", dev.index)
8 | print("Name: ", dev.name)
9 | print("Default: ", dev.is_default)
10 | print("API: ", dev.api_name)
11 | print("API Default: ", dev.is_api_default)
12 | print("Max Channels:", dev.max_channels)
13 | print("Sample Rates:", dev.sample_rates)
--------------------------------------------------------------------------------
/gui/src/Visualizer.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 |
5 | class Visualizer : public Widget {
6 | public:
7 | Visualizer(Gui& gui);
8 | void setRenderedSignal(tact::Signal sig, mahi::gui::Color color);
9 | void update() override;
10 | private:
11 | float m_tl = 0, m_tr = 1;
12 | bool m_lg = false, m_rg = false, m_cg = false;
13 | tact::Signal m_signal;
14 | mahi::gui::Color m_color;
15 | std::vector m_points;
16 | };
--------------------------------------------------------------------------------
/gui/src/Workspace.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Designer.hpp"
3 | #include "Sequencer.hpp"
4 | #include "Spatializer.hpp"
5 |
6 | class Workspace : public Widget {
7 | public:
8 | enum Tab {
9 | TabDesigner,
10 | TabSequencer,
11 | TabSpatializer
12 | };
13 | Workspace(Gui& gui);
14 | void update() override;
15 | public:
16 | Tab activeTab;
17 | Designer designer;
18 | Sequencer sequencer;
19 | Spatializer spatializer;
20 | };
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Volume: 1
8 | Rolloff Scale: 1
9 | Doppler Factor: 1
10 | Default Speaker Mode: 2
11 | m_SampleRate: 0
12 | m_DSPBufferSize: 1024
13 | m_VirtualVoiceCount: 512
14 | m_RealVoiceCount: 32
15 | m_SpatializerPlugin:
16 | m_AmbisonicDecoderPlugin:
17 | m_DisableAudio: 0
18 | m_VirtualizeEffects: 1
19 | m_RequestedDSPBufferSize: 1024
20 |
--------------------------------------------------------------------------------
/gui/src/main.cpp:
--------------------------------------------------------------------------------
1 | #ifndef DEBUG
2 | #define MAHI_GUI_NO_CONSOLE
3 | // #define MAHI_GUI_USE_DISCRETE_GPU
4 | #endif
5 | #include "Gui.hpp"
6 |
7 | int main(int argc, char const *argv[])
8 | {
9 | mahi::gui::Application::Config config;
10 |
11 | config.title = "Syntacts";
12 | config.width = 960;
13 | config.height = 540;
14 | config.resizable = false;
15 | config.msaa = true;
16 | config.center = true;
17 | // config.decorated = false;
18 |
19 | Gui gui(config);
20 | gui.run();
21 | return 0;
22 | }
23 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | -
12 | - Water
13 | - UI
14 | -
15 | -
16 | -
17 | -
18 | -
19 | -
20 | -
21 | -
22 | -
23 | -
24 | -
25 | -
26 | -
27 | -
28 | -
29 | -
30 | -
31 | -
32 | -
33 | -
34 | -
35 | -
36 | -
37 | -
38 | -
39 | -
40 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/src/Tact/Operator.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace tact
5 | {
6 |
7 | IOperator::IOperator(Signal _lhs, Signal _rhs) :
8 | lhs(std::move(_lhs)), rhs(std::move(_rhs))
9 | { }
10 |
11 | double Sum::sample(double t) const {
12 | return lhs.sample(t) + rhs.sample(t);
13 | }
14 |
15 | double Sum::length() const {
16 | return std::max(lhs.length(), rhs.length());
17 | }
18 |
19 | double Product::sample(double t) const {
20 | return lhs.sample(t) * rhs.sample(t);
21 | }
22 |
23 | double Product::length() const {
24 | return std::min(lhs.length(), rhs.length());
25 | }
26 |
27 | } // namespace tact
28 |
--------------------------------------------------------------------------------
/.vscode/cmake-variants.yaml:
--------------------------------------------------------------------------------
1 | buildType:
2 | default: release
3 | description: "Build Type"
4 | choices:
5 | release:
6 | short: Release
7 | long: "Building with optimizations"
8 | buildType: Release
9 | debug:
10 | short: Debug
11 | long: "Build with debugging info"
12 | buildType: Debug
13 |
14 | static:
15 | default: off
16 | choices:
17 | on:
18 | short: Static Runtime
19 | long: "Build with static runtime linkage"
20 | settings:
21 | SYNTACTS_USE_STATIC_STD_LIBS: ON
22 | off:
23 | short: Dynamic Runtime
24 | long: "Build with dynamic runtime linkage"
25 | settings:
26 | SYNTACTS_USE_STATIC_STD_LIBS: OFF
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | macro(syntacts_example SYNTACTS_EXAMPLE_NAME)
2 | add_executable(${SYNTACTS_EXAMPLE_NAME} "example_${SYNTACTS_EXAMPLE_NAME}.cpp")
3 | target_link_libraries(${SYNTACTS_EXAMPLE_NAME} syntacts)
4 | set_target_properties(${SYNTACTS_EXAMPLE_NAME} PROPERTIES DEBUG_POSTFIX -d)
5 | install(TARGETS ${SYNTACTS_EXAMPLE_NAME}
6 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
7 | )
8 | endmacro()
9 |
10 | syntacts_example(basic)
11 | syntacts_example(signals)
12 | syntacts_example(devices)
13 | syntacts_example(library)
14 | syntacts_example(music)
15 | syntacts_example(rtti)
16 | syntacts_example(sequences)
17 | syntacts_example(spatializer)
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Syntacts/Plugins/syntacts_c.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eb673f43654b2ce48b14c239ca99eea3
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | defineConstraints: []
9 | isPreloaded: 0
10 | isOverridable: 0
11 | isExplicitlyReferenced: 0
12 | validateReferences: 1
13 | platformData:
14 | - first:
15 | Any:
16 | second:
17 | enabled: 1
18 | settings: {}
19 | - first:
20 | Editor: Editor
21 | second:
22 | enabled: 0
23 | settings:
24 | DefaultValueInitialized: true
25 | userData:
26 | assetBundleName:
27 | assetBundleVariant:
28 |
--------------------------------------------------------------------------------
/src/Tact/Signal.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace tact
4 | {
5 |
6 | Signal::Signal() : Signal(Scalar(0)) {}
7 |
8 | #ifndef SYNTACTS_USE_SHARED_PTR
9 | Signal::Signal(const Signal& other) :
10 | gain(other.gain),
11 | bias(other.bias),
12 | m_ptr(other.m_ptr->copy())
13 | { }
14 | Signal& Signal::operator=(const Signal& other)
15 | {
16 | return *this = Signal(other);
17 | }
18 | #endif // SYNTACTS_USE_SHARED_PTR
19 |
20 | std::type_index Signal::typeId() const
21 | {
22 | return m_ptr->typeId();
23 | }
24 |
25 | void* Signal::get() const
26 | {
27 | return m_ptr->get();
28 | }
29 |
30 | int Signal::Concept::s_count = 0;
31 |
32 | } // namespace tact
--------------------------------------------------------------------------------
/gui/src/Gui.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include "DeviceBar.hpp"
5 | #include "Workspace.hpp"
6 | #include "Player.hpp"
7 | #include "Visualizer.hpp"
8 | #include "StatusBar.hpp"
9 | #include "Library.hpp"
10 | #include "Theme.hpp"
11 | #include "Debugger.hpp"
12 |
13 | class Gui : public mahi::gui::Application {
14 | public:
15 | Gui(const Application::Config config);
16 | void update() override;
17 | void positionWindows();
18 | const std::string& saveDir();
19 | public:
20 | ThemeManager theme;
21 | StatusBar status;
22 | DeviceBar device;
23 | Player player;
24 | Workspace workspace;
25 | Library library;
26 | Visualizer visualizer;
27 | Debugger debug;
28 | };
--------------------------------------------------------------------------------
/gui/src/Palette.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "Widget.hpp"
4 |
5 | enum class PItem {
6 | Unknown = 0,
7 | Time,
8 | Scalar,
9 | Ramp,
10 | Noise,
11 | Expression,
12 | Sum,
13 | Product,
14 | Repeater,
15 | Stretcher,
16 | Reverser,
17 | Sequencer,
18 | Sine,
19 | Square,
20 | Saw,
21 | Triangle,
22 | FM,
23 | Chirp,
24 | Pwm,
25 | Envelope,
26 | ASR,
27 | ADSR,
28 | ExponentialDecay,
29 | KeyedEnvelope,
30 | SignalEnvelope,
31 | PolyBezier
32 | };
33 |
34 | /// Returns the name of a Syntacts signal
35 | const std::string& paletteName(PItem id);
36 |
37 | class Palette : public Widget {
38 | public:
39 | using Widget::Widget;
40 | void update() override;
41 | };
--------------------------------------------------------------------------------
/gui/src/StatusBar.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 |
5 | class StatusBar : public Widget {
6 | public:
7 |
8 | enum InfoLevel {
9 | Info = 0,
10 | Warning = 1,
11 | Error = 2
12 | };
13 |
14 | StatusBar(Gui& gui);
15 | void update() override;
16 | void pushMessage(const std::string& text, InfoLevel level = Info);
17 | void showTooltip(const std::string& tooltip);
18 | private:
19 | void renderText();
20 | void renderButtons();
21 | private:
22 | bool m_showThemeEdit = false;
23 | mahi::gui::Sequence m_cpuGradient;
24 | mahi::gui::Sequence m_fadeColors;
25 | std::string m_notification;
26 | std::string m_tooltip;
27 | float m_fadeTime;
28 | float m_fadeDuration = 5.0f;
29 | };
--------------------------------------------------------------------------------
/template/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13.0)
2 | project(MySyntactsProject VERSION 1.0.0)
3 |
4 | # OPTION 1: find_package - use if you built and installed Syntacts to your system using CMake
5 |
6 | find_package(syntacts REQUIRED)
7 |
8 | # OPTION 2: FetchContent - use if you did not installed Syntacts and/or want to build an inplace copy
9 |
10 | # include(FetchContent)
11 | # set(SYNTACTS_BUILD_GUI OFF CACHE BOOL "" FORCE)
12 | # set(SYNTACTS_BUILD_C_DLL OFF CACHE BOOL "" FORCE)
13 | # set(SYNTACTS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
14 | # set(SYNTACTS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
15 | # FetchContent_Declare(syntacts GIT_REPOSITORY https://github.com/mahilab/Syntacts.git)
16 | # FetchContent_MakeAvailable(syntacts)
17 |
18 | add_executable(myApp main.cpp)
19 | target_link_libraries(myApp syntacts)
--------------------------------------------------------------------------------
/gui/src/Theme.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Widget.hpp"
3 |
4 | struct ThemeManager : public Widget {
5 | public:
6 |
7 | enum Theme {
8 | DarkDefault = 0,
9 | LightDefault,
10 | DarkAlt1,
11 | DarkAlt2,
12 | Valve,
13 | Theme_Count
14 | };
15 |
16 | ThemeManager(Gui& gui);
17 | ~ThemeManager();
18 | void cycle();
19 | void setTheme(Theme theme);
20 | void update() override;
21 | public:
22 | mahi::gui::Color libraryColor = mahi::gui::Blues::LightSkyBlue;
23 | mahi::gui::Color designerColor = mahi::gui::Purples::Plum;
24 | mahi::gui::Color sequencerColor = mahi::gui::Oranges::DarkOrange;
25 | mahi::gui::Color spatializerColor = mahi::gui::Greens::Chartreuse;
26 | bool showEditor = false;
27 | private:
28 | Theme m_theme;
29 | };
--------------------------------------------------------------------------------
/src/Tact/Oscillator.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace tact
5 | {
6 |
7 | IOscillator::IOscillator() :
8 | IOscillator(100)
9 | { }
10 |
11 | IOscillator::IOscillator(double hertz) :
12 | x(std::move(TWO_PI * hertz * Time()))
13 | { }
14 |
15 | IOscillator::IOscillator(double initial, double rate) :
16 | x(std::move( ( TWO_PI * initial + PI * rate * Time() ) * Time() ))
17 | { }
18 |
19 | IOscillator::IOscillator(Signal _x) :
20 | x(std::move(_x))
21 | { }
22 |
23 | IOscillator::IOscillator(double hertz, Signal modulation, double index) :
24 | x(std::move(TWO_PI * hertz * Time() + index * modulation))
25 | { }
26 |
27 | Pwm::Pwm(double _frequency, double _dutyCycle) :
28 | frequency(_frequency),
29 | dutyCycle(clamp01(_dutyCycle))
30 | { }
31 |
32 | } // namespace tact
--------------------------------------------------------------------------------
/include/Tact/Detail/Sequence.inl:
--------------------------------------------------------------------------------
1 | namespace tact
2 | {
3 |
4 | inline Sequence& Sequence::operator<<(double rhs) {
5 | return push(rhs);
6 | }
7 |
8 | inline Sequence& Sequence::operator<<(Signal rhs) {
9 | return push(rhs);
10 | }
11 |
12 | inline Sequence& Sequence::operator<<(Sequence rhs) {
13 | return push(rhs);
14 | }
15 |
16 | inline Sequence operator<<(Signal lhs, Signal rhs) {
17 | Sequence seq;
18 | seq.push(lhs);
19 | seq.push(rhs);
20 | return seq;
21 | }
22 |
23 | inline Sequence operator<<(Signal lhs, double rhs) {
24 | Sequence seq;
25 | seq.push(lhs);
26 | seq.head += rhs;
27 | return seq;
28 | }
29 |
30 | inline Sequence operator<<(double lhs, Signal rhs) {
31 | Sequence seq;
32 | seq.head += lhs;
33 | seq.push(rhs);
34 | return seq;
35 | }
36 |
37 | } // namespace tact
38 |
--------------------------------------------------------------------------------
/python/example_spatializer.py:
--------------------------------------------------------------------------------
1 | from syntacts import *
2 | from time import sleep
3 | from math import sin
4 | from math import pi
5 |
6 | #----------------------------------------------------------
7 | s = Session()
8 | s.open()
9 |
10 | sig = Noise()
11 |
12 | sp = Spatializer(s)
13 |
14 | # set up channels
15 | chs = s.channel_count # choose the number of channels you want to use here
16 | spc = 1.0 / (chs - 1)
17 | for i in range(chs):
18 | sp.set_position(i, (i * spc, 0))
19 |
20 | # set up target
21 | sp.target = (0,0) # arbitrary position
22 | sp.radius = 0.1 # arbitrtary radius
23 |
24 | # play
25 | sp.play(sig)
26 |
27 | # do something cool
28 | t = 0
29 | while (t < 10):
30 | x = 0.5 + 0.5 * sin(2*pi*t)
31 | sp.target = (x, 0)
32 | sleep(0.01)
33 | t = t + 0.01
34 |
35 | del sp # ensure Spatializer deleted before Session
36 |
37 | print("Finished!")
--------------------------------------------------------------------------------
/include/Tact/Detail/Oscillator.inl:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace tact {
4 |
5 | double IOscillator::length() const {
6 | return INF;
7 | }
8 |
9 | inline double Sine::sample(double t) const {
10 | return std::sin(x.sample(t));
11 | }
12 |
13 | inline double Square::sample(double t) const {
14 | return std::sin(x.sample(t)) > 0 ? 1.0 : -1.0;
15 | }
16 |
17 | inline double Saw::sample(double t) const {
18 | return -2 * INV_PI * std::atan(std::cos(0.5 * x.sample(t)) / std::sin(0.5 * x.sample(t)));
19 | }
20 |
21 | inline double Triangle::sample(double t) const {
22 | return 2 * INV_PI * std::asin(std::sin(x.sample(t)));
23 | }
24 |
25 |
26 | inline double Pwm::sample(double t) const {
27 | return std::fmod(t, 1.0 / frequency) * frequency < dutyCycle ? 1.0 : -1.0;
28 | }
29 |
30 | inline double Pwm::length() const {
31 | return INF;
32 | }
33 |
34 | } // namespace tact
--------------------------------------------------------------------------------
/python/example.py:
--------------------------------------------------------------------------------
1 | from syntacts import *
2 | from time import sleep
3 | from math import sin
4 | from math import pi
5 |
6 | s = Session()
7 | s.open()
8 |
9 | x = Sine(440) * Triangle(20) * ASR(1,2,3)
10 | y = Square(440, 1000) * ADSR(1,1,1,1)
11 | z = Pwm(500,0.5) * Envelope(1)
12 |
13 | s.play(0, x)
14 | sleep(x.length)
15 | s.play(1, y)
16 | sleep(y.length)
17 |
18 | seq = Sequence()
19 |
20 | seq << 1 << x << -2 << y
21 | seq.insert(z, 4)
22 |
23 | Library.save_signal(seq,'python')
24 | loaded = Library.load_signal('python')
25 |
26 | s.play_all(loaded)
27 | sleep(loaded.length)
28 |
29 | noise = Noise()
30 | sp = Spatializer(s)
31 | sp.set_position(0, (0,0))
32 | sp.set_position(1, (1,0))
33 | sp.target = (0,0)
34 | sp.radius = 0.5
35 | sp.play(noise)
36 |
37 | t = 0
38 | while t < 10:
39 | xPos = 0.5 + 0.5 * sin(2*pi*t)
40 | sp.target = (xPos, 0)
41 | sleep(0.01)
42 | t += 0.01
43 |
44 | del sp
--------------------------------------------------------------------------------
/gui/src/DeviceBar.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 | #include
5 |
6 | class DeviceBar : public Widget {
7 | public:
8 | DeviceBar(Gui& gui);
9 | ~DeviceBar();
10 | void initialize();
11 | void switchDevice(const tact::Device& dev, double sampleRate = 0);
12 | void switchApi(const std::string& api);
13 | void switchSampleRate(double sampleRate);
14 | void update() override;
15 | private:
16 | void renderApiSelection();
17 | void renderDeviceSelection();
18 | void renderDeviceSampleRates();
19 | void renderDeviceDetails();
20 | void getCurrent();
21 | void getAvailable();
22 | public:
23 | mahi::util::Event onSessionOpen;
24 | mahi::util::Event onSessionDestroy;
25 | std::shared_ptr session;
26 | private:
27 | tact::Device m_currentDev;
28 | std::string m_currentApi;
29 | std::map> m_available;
30 | };
--------------------------------------------------------------------------------
/csharp/examples/example_devices/example_devices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using Syntacts;
4 |
5 | // run with the following console command:
6 | // dotnet run
7 |
8 | class Example
9 | {
10 | static void Main(string[] args)
11 | {
12 | Session session = new Session();
13 |
14 | foreach (Device dev in session.availableDevices) {
15 | Console.WriteLine("");
16 | Console.WriteLine("Index: {0}", dev.index);
17 | Console.WriteLine("Name: {0}", dev.name);
18 | Console.WriteLine("Default: {0}", dev.isDefault);
19 | Console.WriteLine("API: {0}", dev.apiName);
20 | Console.WriteLine("API Default: {0}", dev.isApiDefault);
21 | Console.WriteLine("Max Channels: {0}", dev.maxChannels);
22 | Console.WriteLine("Sample Rates: [{0}]", string.Join(", ", dev.sampleRates));
23 | }
24 | }
25 |
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/examples/example_rtti.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using namespace tact;
6 | using std::string;
7 |
8 | // This example demonstrates how a Signal can be deconstructed with RTTI once
9 | // it has been type erased. This isn't normally recommended, but under certain
10 | // circumstances it may be necessary to know what the underlying type(s)
11 | // of a Signal are (e.g. see Nodes in the GUI source code)
12 |
13 | // This example is quite advanced and only applies if you hope to load, edit,
14 | // and resave cues.
15 |
16 | void signalPrinter(const Signal& sig, int depth) {
17 | std::cout << std::string(depth*2,' ') << signalName(sig) << std::endl;
18 | }
19 |
20 | int main(int argc, char const *argv[]) {
21 | Signal x;
22 | if (!Library::loadSignal(x,"funky")) {
23 | std::cout << "Run example_music first!" << std::endl;
24 | return -1;
25 | }
26 | recurseSignal(x, signalPrinter);
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/examples/example_spatializer.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace tact;
4 |
5 | int main(int argc, char const *argv[])
6 | {
7 | Session ss;
8 | ss.open();
9 |
10 | Signal sig = Noise();
11 |
12 | // Create spatializer
13 | Spatializer sp(&ss);
14 |
15 | // set up position of channels, evenly distributed
16 | int chs = ss.getChannelCount();
17 | double spc = 1.0 / (chs - 1);
18 | for (int i = 0; i < ss.getChannelCount(); ++i)
19 | sp.setPosition(i, i * spc);
20 |
21 | // set up target where vibration will be played
22 | sp.setTarget(0.0);
23 | sp.setRadius(0.5);
24 |
25 | // play
26 | sp.play(sig);
27 |
28 | // make moving target on pre-described path
29 | double t = 0;
30 | while (t < 10) {
31 | double x = 0.5 + 0.5 * std::sin(2*PI*t);
32 | sp.setTarget(x);
33 | sleep(0.01);
34 | t += 0.01;
35 | }
36 |
37 | std::cout << "Finished!" << std::endl;
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/gui/src/FileWatcher.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | enum class FileStatus
12 | {
13 | Created,
14 | Modified,
15 | Erased
16 | };
17 |
18 | class FileWatcher
19 | {
20 | public:
21 | // Keep a record of files from the base directory and their last modification time
22 | FileWatcher(std::string watchPath, int delayMilliseconds);
23 | // Monitor "watchPath" for changes and in case of a change execute the user supplied "action" function
24 | void start(const std::function &action);
25 | void stop();
26 | private:
27 | std::string m_watchPath;
28 | std::chrono::duration m_delay;
29 | std::unordered_map m_paths;
30 | std::atomic_bool m_running;
31 | private:
32 | bool contains(const std::string &key);
33 | };
34 |
--------------------------------------------------------------------------------
/cmake/SyntactsConfig.cmake.in:
--------------------------------------------------------------------------------
1 | get_filename_component(SYNTACTS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
2 |
3 | include(CMakeFindDependencyMacro)
4 |
5 | list(APPEND CMAKE_MODULE_PATH ${SYNTACTS_CMAKE_DIR})
6 |
7 | set(SYNTACTS_CMAKE_DIR_ABOVE ${SYNTACTS_CMAKE_DIR})
8 | get_filename_component(SYNTACTS_CMAKE_DIR_ABOVE ${SYNTACTS_CMAKE_DIR_ABOVE} DIRECTORY)
9 | set(portaudio_DIR ${SYNTACTS_CMAKE_DIR_ABOVE}/portaudio)
10 | find_package(portaudio REQUIRED)
11 | set(portaudio_INCLUDE_DIR ${portaudio_DIR})
12 | get_filename_component(portaudio_INCLUDE_DIR ${portaudio_INCLUDE_DIR} DIRECTORY)
13 | get_filename_component(portaudio_INCLUDE_DIR ${portaudio_INCLUDE_DIR} DIRECTORY)
14 | get_filename_component(portaudio_INCLUDE_DIR ${portaudio_INCLUDE_DIR} DIRECTORY)
15 | set(portaudio_INCLUDE_DIR "${portaudio_INCLUDE_DIR}/include")
16 |
17 | list(REMOVE_AT CMAKE_MODULE_PATH -1)
18 |
19 | if(NOT TARGET syntacts::syntacts)
20 | include("${SYNTACTS_CMAKE_DIR}/SyntactsTargets.cmake")
21 | endif()
22 |
23 | set(SYNTACTS_LIBRARIES syntacts::syntacts)
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 1
7 | m_Enabled: 0
8 | m_TestMode: 0
9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com
12 | m_TestInitMode: 0
13 | CrashReportingSettings:
14 | m_EventUrl: https://perf-events.cloud.unity3d.com
15 | m_Enabled: 0
16 | m_LogBufferSize: 10
17 | m_CaptureEditorExceptions: 1
18 | UnityPurchasingSettings:
19 | m_Enabled: 0
20 | m_TestMode: 0
21 | UnityAnalyticsSettings:
22 | m_Enabled: 0
23 | m_TestMode: 0
24 | m_InitializeOnStartup: 1
25 | UnityAdsSettings:
26 | m_Enabled: 0
27 | m_InitializeOnStartup: 1
28 | m_TestMode: 0
29 | m_IosGameId:
30 | m_AndroidGameId:
31 | m_GameIds: {}
32 | m_GameId:
33 | PerformanceReportingSettings:
34 | m_Enabled: 0
35 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/BouncyBall.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using Syntacts;
5 |
6 | public class BouncyBall : MonoBehaviour
7 | {
8 | public SyntactsHub syntacts;
9 | private Rigidbody rb;
10 |
11 | public int collisionChannel = 0;
12 | public int velocityChannel = 1;
13 |
14 | public float collisionFreq = 500;
15 | public float velocityFreq = 200;
16 |
17 |
18 | // Start is called before the first frame update
19 | void Start()
20 | {
21 | syntacts.session.Play(velocityChannel, new Sine(velocityFreq) * new Sine(5));
22 | rb = GetComponent();
23 | }
24 |
25 | // Update is called once per frame
26 | void Update()
27 | {
28 | syntacts.session.SetPitch(velocityChannel, 1 + rb.velocity.magnitude* 0.1);
29 | }
30 |
31 | void OnCollisionEnter(Collision col) {
32 | Signal collision = new Square(collisionFreq) * new ASR(0.05, 0.05, 0.05);
33 | syntacts.session.Play(collisionChannel, collision);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/gui/src/PolyBezier.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace ImGui {
6 |
7 | struct PolyBezier {
8 | PolyBezier(ImVec4 color = ImVec4(0,1,1,1), ImVec2 min = ImVec2(0,0), ImVec2 max = ImVec2(1,1));
9 | int pointCount();
10 | int bezierCount();
11 | void clearPoints();
12 | void addPoint(ImVec2 cpL, ImVec2 pos, ImVec2 cpR);
13 | void getPoint(int index, ImVec2* cpL, ImVec2* pos, ImVec2* cpR);
14 | void getBezier(int index, ImVec2* pos0, ImVec2* cp0, ImVec2* cp1, ImVec2* pos1);
15 |
16 | ImVec2 min;
17 | ImVec2 max;
18 | ImVec4 color;
19 | float thickness;
20 | int segments;
21 | bool constrainEndpoints;
22 | float grabRadius;
23 |
24 | private:
25 | friend void PolyBezierEdit(const char*,PolyBezier*,int,int,ImVec2);
26 | struct Point;
27 | struct Group;
28 | std::shared_ptr root;
29 | std::shared_ptr head;
30 | };
31 |
32 | void PolyBezierEdit(const char* label, PolyBezier* polyBezier, int gridX = 10, int gridY = 10, ImVec2 size = ImVec2(-1,0));
33 |
34 | } // namespace ImGui
--------------------------------------------------------------------------------
/gui/src/Library.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Widget.hpp"
4 | #include "StatusBar.hpp"
5 | #include "Designer.hpp"
6 | #include
7 | #include "Palette.hpp"
8 | #include "Visualizer.hpp"
9 | #include "FileWatcher.hpp"
10 |
11 |
12 | class Library : public Widget {
13 | public:
14 |
15 | Library(Gui& gui);
16 |
17 | struct Entry {
18 | std::string name;
19 | tact::Signal disk;
20 | bool loaded = false;
21 | };
22 |
23 | void update() override;
24 | private:
25 | void init();
26 | void renderCreateDialog();
27 | void renderLibraryList();
28 | void renderLibraryControls();
29 | tact::Signal getSelectedSignal();
30 | private:
31 |
32 | void onFileChange(std::string path, FileStatus status);
33 | void onFileDrop(const std::vector& paths);
34 |
35 | public:
36 | Palette palette;
37 | private:
38 | std::mutex m_mtx;
39 | FileWatcher m_watcher;
40 | std::string m_selected;
41 | int m_selection = -1;
42 | char m_inputBuffer[64] = "";
43 | std::map m_lib;
44 | bool m_ignoreFilChange = false;
45 | bool m_focused;
46 | };
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Mechatronics and Haptic Interfaces Lab
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/python/example_music.py:
--------------------------------------------------------------------------------
1 | from syntacts import *
2 | from time import sleep
3 | from math import sin
4 | from math import pi
5 |
6 | # Returns musical note corresponding to name and octave
7 | def key(name, octave):
8 | names = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B']
9 | idx = names.index(name)
10 | i = idx - 9 + (octave - 4) * 12
11 | a = 2**(1/12)
12 | freq = 440 * a**i
13 | return Square(freq) * ASR(0.05, 0.10, 0.1)
14 |
15 |
16 | funkytown = Sequence()
17 | Dsharp = key("D#",6)
18 | Csharp = key("C#",6)
19 | Asharp = key("A#",5)
20 | Gsharp = key("G#",6)
21 | G = key("G", 6)
22 | funkytown << Dsharp << Dsharp << Csharp << Dsharp << 0.2 << Asharp << 0.2 << Asharp << Dsharp << Gsharp << G << Dsharp
23 |
24 | dixie = Sequence()
25 | dixie << key("B", 5) << key("G#",5) << key("E", 5) << key("E", 5) << key("E", 5) << key("F#",5) << key("G#",5) << key("A", 5) << key("B", 5) << key("B", 5) << key("B", 5) << key("G#",5)
26 |
27 | session = Session()
28 | session.open()
29 | Library.save_signal(funkytown, "funky")
30 | session.play_all(funkytown)
31 | sleep(funkytown.length + 0.25)
32 | session.play_all(dixie)
33 | sleep(dixie.length + 0.25)
34 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/Assets/Demo/LibraryButton.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using Syntacts;
5 |
6 | public class LibraryButton : MonoBehaviour
7 | {
8 | [Tooltip("Reference to a SyntactsHub in the scene.")]
9 | public SyntactsHub syntacts;
10 | [Tooltip("Name of Library signal to load and play.")]
11 | public string signalName = "mySignal";
12 | [Tooltip("The channel the signal will be played on.")]
13 | public int channel = 0;
14 |
15 | // Start is called before the first frame update
16 | void Start()
17 | {
18 | // make "mySignal" so demo works initially
19 | Signal mySignal = new Sine(440, 500) * new ASR(0.1,0.1,0.1);
20 | Library.SaveSignal(mySignal, "mySignal");
21 | }
22 |
23 | void OnGUI() {
24 | if (GUI.Button(new Rect(10, 10, 125, 25), "Play Library Signal")) {
25 | Signal signal;
26 | if (Library.LoadSignal(out signal, signalName)) {
27 | syntacts.session.Play(channel, signal);
28 | }
29 | else {
30 | Debug.LogError("Failed to load signal: " + signalName);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/gui/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(syntacts_gui
2 | src/main.cpp
3 | src/Gui.hpp
4 | src/Gui.cpp
5 | src/Widget.hpp
6 | src/Widget.cpp
7 | src/DeviceBar.hpp
8 | src/DeviceBar.cpp
9 | src/StatusBar.hpp
10 | src/Palette.hpp
11 | src/Palette.cpp
12 | src/StatusBar.cpp
13 | src/Visualizer.hpp
14 | src/Visualizer.cpp
15 | src/Library.hpp
16 | src/Library.cpp
17 | src/FileWatcher.hpp
18 | src/FileWatcher.cpp
19 | src/Nodes.hpp
20 | src/Nodes.cpp
21 | src/DragAndDrop.hpp
22 | src/DragAndDrop.cpp
23 | src/Workspace.hpp
24 | src/Workspace.cpp
25 | src/Designer.hpp
26 | src/Designer.cpp
27 | src/PolyBezier.hpp
28 | src/PolyBezier.cpp
29 | src/Sequencer.hpp
30 | src/Sequencer.cpp
31 | src/Spatializer.hpp
32 | src/Spatializer.cpp
33 | src/Player.hpp
34 | src/Player.cpp
35 | src/Debugger.hpp
36 | src/Debugger.cpp
37 | src/Theme.hpp
38 | src/Theme.cpp
39 | src/Custom.hpp
40 | src/Custom.cpp
41 | syntacts.rc)
42 |
43 | target_link_libraries(syntacts_gui syntacts mahi::gui)
44 | set_target_properties(syntacts_gui PROPERTIES DEBUG_POSTFIX -d)
45 | install(TARGETS syntacts_gui RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 9
7 | m_ExternalVersionControlSupport: Visible Meta Files
8 | m_SerializationMode: 2
9 | m_LineEndingsForNewScripts: 2
10 | m_DefaultBehaviorMode: 0
11 | m_PrefabRegularEnvironment: {fileID: 0}
12 | m_PrefabUIEnvironment: {fileID: 0}
13 | m_SpritePackerMode: 0
14 | m_SpritePackerPaddingPower: 1
15 | m_EtcTextureCompressorBehavior: 1
16 | m_EtcTextureFastCompressor: 1
17 | m_EtcTextureNormalCompressor: 2
18 | m_EtcTextureBestCompressor: 4
19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref
20 | m_ProjectGenerationRootNamespace:
21 | m_CollabEditorSettings:
22 | inProgressEnabled: 1
23 | m_EnableTextureStreamingInEditMode: 1
24 | m_EnableTextureStreamingInPlayMode: 1
25 | m_AsyncShaderCompilation: 1
26 | m_EnterPlayModeOptionsEnabled: 0
27 | m_EnterPlayModeOptions: 3
28 | m_ShowLightmapResolutionOverlay: 1
29 | m_UseLegacyProbeSampleCount: 1
30 | m_AssetPipelineMode: 1
31 | m_CacheServerMode: 0
32 | m_CacheServerEndpoint:
33 | m_CacheServerNamespacePrefix: default
34 | m_CacheServerEnableDownload: 1
35 | m_CacheServerEnableUpload: 1
36 |
--------------------------------------------------------------------------------
/unity/SyntactsDemo/.gitignore:
--------------------------------------------------------------------------------
1 | # Unity
2 |
3 | # This .gitignore file should be placed at the root of your Unity project directory
4 | #
5 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
6 | #
7 |
8 | syntactsc.dll.meta
9 | libsyntactsc.dylib.meta
10 |
11 | /[Ll]ibrary/
12 | /[Tt]emp/
13 | /[Oo]bj/
14 | /[Bb]uild/
15 | /[Bb]uilds/
16 | /[Ll]ogs/
17 | /[Mm]emoryCaptures/
18 |
19 | # Never ignore Asset meta data
20 | !/[Aa]ssets/**/*.meta
21 |
22 | # Uncomment this line if you wish to ignore the asset store tools plugin
23 | # /[Aa]ssets/AssetStoreTools*
24 |
25 | # Autogenerated Jetbrains Rider plugin
26 | [Aa]ssets/Plugins/Editor/JetBrains*
27 |
28 | # Visual Studio cache directory
29 | .vs/
30 | .vscode/
31 |
32 | # Gradle cache directory
33 | .gradle/
34 |
35 | # Autogenerated VS/MD/Consulo solution and project files
36 | ExportedObj/
37 | .consulo/
38 | *.csproj
39 | *.unityproj
40 | *.sln
41 | *.suo
42 | *.tmp
43 | *.user
44 | *.userprefs
45 | *.pidb
46 | *.booproj
47 | *.svd
48 | *.pdb
49 | *.mdb
50 | *.opendb
51 | *.VC.db
52 |
53 | # Unity3D generated meta files
54 | *.pidb.meta
55 | *.pdb.meta
56 | *.mdb.meta
57 |
58 | # Unity3D generated file on crash reports
59 | sysinfo.txt
60 |
61 | # Builds
62 | *.apk
63 | *.unitypackage
64 |
65 | # Crashlytics generated file
66 | crashlytics-build.properties
67 |
--------------------------------------------------------------------------------
/examples/example_devices.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace tact;
5 |
6 | // This example will load all devices and display their information for your computer.
7 | // Run the exe from a window that will stay open once it runs so you can see the results
8 |
9 | int main(int argc, char const *argv[])
10 | {
11 | Session session;
12 |
13 | for (auto& d : session.getAvailableDevices())
14 | {
15 | auto& dev = d.second;
16 | std::cout << std::endl;
17 | std::cout << "Index: " << dev.index << std::endl;
18 | std::cout << "Name: " << dev.name << std::endl;
19 | std::cout << "Default: " << (dev.isDefault ? "True" : "False") << std::endl;
20 | std::cout << "API: " << dev.apiName << std::endl;
21 | std::cout << "API Default: " << (dev.isApiDefault ? "True" : "False") << std::endl;
22 | std::cout << "Max Channels: " << dev.maxChannels << std::endl;
23 | std::cout << "Sample Rates: [";
24 | for (auto& s : dev.sampleRates)
25 | std::cout << s << (s != dev.sampleRates.back() ? ", " : "");
26 | std::cout << "]" << std::endl;
27 | }
28 | std::cout << std::endl;
29 |
30 |
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/include/syntacts:
--------------------------------------------------------------------------------
1 | // MIT License
2 | //
3 | // Syntacts
4 | // Copyright (c) 2020 Mechatronics and Haptic Interfaces Lab - Rice University
5 | //
6 | // Permission is hereby granted, free of charge, to any person obtaining a copy
7 | // of this software and associated documentation files (the "Software"), to deal
8 | // in the Software without restriction, including without limitation the rights
9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the Software is
11 | // furnished to do so, subject to the following conditions:
12 | //
13 | // The above copyright notice and this permission notice shall be included in
14 | // all copies or substantial portions of the Software.
15 | //
16 | // Author(s): Evan Pezent, Brandon Cambio
17 |
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
--------------------------------------------------------------------------------
/unity/SyntactsDemo/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!55 &1
4 | PhysicsManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 11
7 | m_Gravity: {x: 0, y: -9.81, z: 0}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_BounceThreshold: 2
10 | m_SleepThreshold: 0.005
11 | m_DefaultContactOffset: 0.01
12 | m_DefaultSolverIterations: 6
13 | m_DefaultSolverVelocityIterations: 1
14 | m_QueriesHitBackfaces: 0
15 | m_QueriesHitTriggers: 1
16 | m_EnableAdaptiveForce: 0
17 | m_ClothInterCollisionDistance: 0
18 | m_ClothInterCollisionStiffness: 0
19 | m_ContactsGeneration: 1
20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21 | m_AutoSimulation: 1
22 | m_AutoSyncTransforms: 0
23 | m_ReuseCollisionCallbacks: 1
24 | m_ClothInterCollisionSettingsToggle: 0
25 | m_ContactPairsMode: 0
26 | m_BroadphaseType: 0
27 | m_WorldBounds:
28 | m_Center: {x: 0, y: 0, z: 0}
29 | m_Extent: {x: 250, y: 250, z: 250}
30 | m_WorldSubdivisions: 8
31 | m_FrictionType: 0
32 | m_EnableEnhancedDeterminism: 0
33 | m_EnableUnifiedHeightmaps: 1
34 | m_DefaultMaxAngluarSpeed: 7
35 |
--------------------------------------------------------------------------------
/csharp/examples/example_spatializer/example_spatializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using Syntacts;
4 |
5 | // run with the following console command:
6 | // dotnet run
7 |
8 | class Example
9 | {
10 | static void Main(string[] args)
11 | {
12 | Session ss = new Session();
13 | ss.Open();
14 |
15 | Signal sig = new Noise();
16 |
17 | // Create spatializer
18 | Spatializer sp = new Spatializer(ss);
19 |
20 | // set up position of channels, evenly distributed
21 | int chs = ss.channelCount;
22 | double spc = 1.0 / (chs - 1);
23 | for (int i = 0; i < ss.channelCount; ++i)
24 | sp.SetPosition(i, new Point(i * spc,0));
25 |
26 | // set up target where vibration will be played
27 | sp.target = new Point(0,0);
28 | sp.radius = 0.1;
29 |
30 | // play
31 | sp.Play(sig);
32 |
33 | // make moving target on pre-described path
34 | double t = 0;
35 | while (t < 10) {
36 | double xPos = 0.5 + 0.5 * Math.Sin(2*Math.PI*t);
37 | sp.target = new Point(xPos, 0);
38 | Sleep(0.01);
39 | t += 0.01;
40 | }
41 |
42 | Console.WriteLine("Finished");
43 | ss.Dispose();
44 | }
45 | static void Sleep(double seconds) {
46 | Thread.Sleep((int)(seconds*1000));
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/gui/src/Sequencer.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "Widget.hpp"
3 |
4 | ///////////////////////////////////////////////////////////////////////////////
5 | // CUSTOM IMGUI
6 |
7 | namespace ImGui {
8 |
9 | struct SeqInterface {
10 |
11 | struct Track {
12 | tact::Signal signal;
13 | std::string label;
14 | double t = 0;
15 | bool visible = true;
16 | bool held = false;
17 | bool populated = false;
18 | bool expanded = false;
19 | };
20 |
21 | std::vector