Code Monkey home page Code Monkey logo

cmajor's People

Contributors

cesaref avatar hazza-music avatar julianstorer avatar lucasthompson avatar reedrosenbluth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmajor's Issues

[ Feature Request ] Direct generate to VST3 plugin

From what I understand, at the moment you need to first render to a JUCE patch, then compile the JUCE patch in order to use it as a plugin. Would it be possible to directly compile it to a VST3 plugin?

Creating a GUI Patch Project example does not show the custom GUI in VSCode when run

Was just messing around trying to figure this out, I had installed the new CMajor Tools VSCode extension and realized by looking at the current examples of CustomGUI in github;

https://github.com/cmajor-lang/cmajor/blob/main/examples/patches/CustomGUI/demo_ui/index.js

window.customElements.define ("VIEWDemoGUI", DemoGUI_View);

needs to be this:

window.customElements.define ("demo-patch-view", DemoGUI_View);

Where demo-patch-view is the new id selector.

in the VSCode project generator.

.dmg file for older MacOS

Any change of you making available a .dmg file for older MacOS, like 10.11? Anything other than APFS. Or is Cmajor not compatible at all with older ones?

Is it possible to resize with a fixed aspect ratio?

Is there any way to fix the aspect ratio in cmajor, I have looked at various documents, sources, etc. for the view item in patch file, but have not found anything specific.
(something like setFixedAspectRatio in JUCE)

Is there a way to successfully input keys on the host DAW?

When the plug-in is in focus, keyboard input is not performed correctly on the host DAW side.
For example, pressing the space key (play/stop) while the plug-in is in focus does not respond at all.

This occurs not only with home-made GUI using Javascript and CMajor's generic GUI.
Does anyone know how to get this to work properly?

Graphs with 1000+ nodes start to become infeasible

In testing graphs of various sizes, I observed more-or-less the following timings (2021 MacBook M1 Pro):

(x-axis = number of nodes, y-axis = number of seconds to compile*)

* or more specifically, the time it takes for engine.link() to return

Screenshot 2024-03-17 at 10 02 36

Compilation errors on Linux

Hey Jules & Ces!
Thank you for open-sourcing cmajor!
I get some compiler errors when compiling according to the readme instructions on arch-linux.
uname -r: 6.7.6-arch1-1
gcc --version: 13.2.1 20230801


The errors mostly come from the graphviz dependency. However, it is also reporting some possibly dangling references in cmaj_LLVMPerformer.
I figured it's mostly warnings being treated as errors, but as the compilation fails when just following the readme instructions, I thought I should report this.
I've attached the output logs from ninja in this issue.
Thanks in advance!

ninja-output-log.txt

cli tool: render: `output` not found despite being provided

TL;DR

Using cmaj render always returns ' Expected the option --output' despite providing the correct flag.

Setup

  • Arch Linux running 6.8.5-arch1-1 kernel according to uname -r
  • Cmajor version: 1.0.2454

Steps to reproduce

  • When in root of repository, execute: cmaj render --input input.wav --output output.wav ../examples/patches/ZitaReverb/ZitaReverb.cmajorpatch, assuming that input file is actually somewhere on disk.
  • Actually, just running cmaj render --help will give you the same result

I can't run patches.

Hello, I am following the steps to configure cmajor, the problem is that when I run an example or create a new project, it does not show the gui or play any sound. I have installed cmajor VS extension, created a newProject "Annoying Beep" and in terminal VS I have run (and also test it with other example .cmajorpatchs):

cmaj play Annoying Beep/Annoying Beep.cmajorpatch

then I get this message in the terminal:
MIDI In Opening: Komplete Kontrol A DAW
MIDI input opening: KOMPLETE KONTROL A25 MIDI

nothing happens in any case. no GUI or sound.

the docs say:
"You should then hear a sine wave."

Among other things it is possible that something is wrong with the audio config. But I have no idea why the UI is not displayed when the patch I run have UI components.

thank you.

MIDI Out support?

Is MIDI Out planned? I don't see it mentioned in the document and the examples.

Use cases: MIDI Fx, Sequencers (notes and CC)

Web view content doesn't load with local builds of JUCE plugins with custom UIs

Just for the record, I'm reporting here an issue we were chatting about on Discurse regarding an issue I'm experiencing with local builds of the HYCE plugin.

@cesaref has done some fixes recently to the JUCE plugin to solve a problem with the state of the webview on first load.
He passed me the VST3 and standalone binaries for the CutomGUI example patch, and they work fine.

However, builds done my be on different machines, and by a collegue of mine, with the same cmajor 1.0.2444 are not working.
In the case of CustomGUI I see an empty black panel (it's a webview since I can see the contextual menu).
With Pro54 instead I get the usual grey panel of JUCE, with the JUCE logo.

I've built the CutomGUI with the DevTools option enabled. By inspecting the console log I see the following error reported:

Uncaught (in promise) SyntaxError: Invalid or unexpected token (index.js:94).

Indeed, the createPatchView promise is never fullfilled (console logs placed inside it do not print).

Maybe the js file included in the compiled binary is somehow corrupted? I don't know...

The only reason I can think of for such a diffence could be the build tools. We're using Visual Studio 17 2022 with MSVC v143 and Windows 11 SDK 10.0.22621.0.

some errors in the outputted js for examples in vscode

..there are a few trailing ")" in your js code outputs...
...
specifically on the lines::
331 -341of the Cmajorwrapper::
this.memoryInt64_0[(byteOffset) / 8)] = sourceValue["frameIndex"];

...there is an extra ")" after the 8 in these lines.

......

in the function _unpack_o3_i64_f64_f64::
there is again an extra ")" after the "/8" and also an unnecessary semicolon - " / 8)];, " should be " / 8], " i think...
eg..
this.memoryFloat64_4[(sourceOffset + 8) / 8)];, this.memoryFloat64_4[(sourceOffset + 16) / 8)]; };


... porting these to typescript so i have some code completion...perhaps it might be a 'more elegant solution for you to generate ts files?


... needing a very reliable clock for mid event output from web app so i'm looking at your midi hello world and timeline examples ...

Loving your library and the ideas behind it !
fantastic work, keep going there!
All bests, jez.

Compilation errors

With current cmajor/choc includes:

/usr/local/include/cmajor/API/cmaj_Engine.h:291:20: error: no matching member function for call to 'serialise'
    auto s = value.serialise();
             ~~~~~~^~~~~~~~~
/usr/local/include/cmajor/API/../../choc/audio/../containers/choc_Value.h:2320:17: note: candidate function template not viable: requires single argument 'output', but no arguments were provided
void ValueView::serialise (OutputStream& output) const
                ^
In file included from cmajor-faust-player.cpp:29:
In file included from /usr/local/include/faust/dsp/cmajorpatch-dsp.h:36:
/usr/local/include/cmajor/API/cmaj_Engine.h:291:20: error: no matching member function for call to 'serialise'
    auto s = value.serialise();
             ~~~~~~^~~~~~~~~
/usr/local/include/cmajor/API/../../choc/audio/../containers/choc_Value.h:2320:17: note: candidate function template not viable: requires single argument 'output', but no arguments were provided
void ValueView::serialise (OutputStream& output) const
                ^
1 error generated.
make: *** [cmajor-faust-tester] Error 1
make: *** Waiting for unfinished jobs....
In file included from cmajor-faust-player.cpp:35:
/usr/local/include/cmajor/helpers/cmaj_PatchUtilities.h:1729:42: error: no matching member function for call to 'serialise'
        auto serialisedMessage = message.serialise();
                                 ~~~~~~~~^~~~~~~~~
/usr/local/include/cmajor/helpers/../../choc/containers/choc_Value.h:2320:17: note: candidate function template not viable: requires single argument 'output', but no arguments were provided
void ValueView::serialise (OutputStream& output) const

castToRefSkippingReferences error passing std::notes in struct init

Minimum Reproduction Steps

  • Define a struct that has a std::notes::NoteOn member.
  • Initialize the struct using the “parenthesized list of member values” form
    • Note it’s not necessary to actually pass a value with the parens. Using empty parens to get the default zero’d values still causes the error.
  • Run the patch. Note the error:

    error: Internal compiler error: "castToRefSkippingReferences:87"

processor Untitled  [[ main ]]
{
  output stream float out;
  struct NoteStruct 
  {
    std::notes::NoteOn note;
  }

  void main() 
  {
    let s = NoteStruct(); //> error: Internal compiler error: "castToRefSkippingReferences:87"
    advance();
  }
}

Of Note

This doesn’t seem to be a general problem with structs in structs. If I make my own nominally equivalent NoteOn struct, there’ no error:

processor Untitled  [[ main ]]
{
  output stream float out;
  struct MyNote 
  {
    int32 channel;
    float32 pitch;
    float32 velocity;
  }
  struct NoteStruct 
  {
    MyNote note;
  }

  void main() 
  {
    let s = NoteStruct(); //> No error.
    advance();
  }
}

Workarounds

This only affects initializing struct members via a parenthesized list. Creating a struct and/or directly assigning values works fine:

    NoteStruct s;
    s = NoteStruct(n); //> Error.

    NoteStruct s;
    s.note = n; //> No error.

Providing an `external` audio buffer at runtime

By looking at the C++ API, I can see that externals are resolved at compile time of a Cmajor program within the Engine::load() method. Is this correct?

If that's the case, is it instead somehow possible to provide them at runtime to a cmaj::Performer instance? I'm mainly thinking about audio buffers, not other kinds of more complex externals.

“View examples” command in VS Code extension errors out.

Environment

OS: macOS 14.2.1 (23C71) [Apple M1]
VS Code: v1.87.1 (Universal)
Cmajor Tools extension: v1.0.2367

Reproduce

  • Open VS Code
  • Open the Command Palette (⇧⌘P)
  • Select “Cmajor: View some example patches"
  • Observe the following error dialog
    Screenshot 2024-03-08 at 9 28 54 AM
  • Also note the error in the extension host console:

2024-03-08 09:32:11.285 [error] ReferenceError: getFileStatIfExists is not defined
at showExamples (/Users/jemmons/.vscode/extensions/cmajorsoftware.cmajor-tools-1.0.2367-darwin-arm64/src/cmaj_extension.js:149:17)
at l.h (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:184839)
at l.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:185699)
at s.S (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:147:5519)
at s.Q (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:147:5285)
at s.M (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:147:4375)
at s.L (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:147:3454)
at w.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:147:2241)
at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
at n.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
at r.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:105:14091)
at w.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:173:8050)
at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
at n.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
at r.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:105:14091)
at MessagePortMain. (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:173:6330)
at MessagePortMain.emit (node:events:514:28)
at Object.emit (node:electron/js2c/utility_init:2:2285) cmajor.show.examples {"value":"CmajorSoftware.cmajor-tools","_lower":"cmajorsoftware.cmajor-tools"}

Of note

I use command frequently and only recently started getting an error. So maybe a recent regression? Also possible I’ve screwed up something basic and remedial in VS Code. It is not my usual text editor.

Assigning to matrices

Have been enjoying exploring matrices but am a bit stuck as to whether they are mutable or not?

I want to assign to a location in the matrix after it’s been instantiated, something like this:

let m = float[2, 3] ((1.0f, 2.0f, 3.0f),
                             (4.0f, 5.0f, 6.0f));
m[1][2] = 7.0f;

This code gives error:

error: Expected an assignable target on the left of the '=' operator
        m[1][2] = 7.0f;
        ^

Can't find any mention of changing matrix values in docs or tests. Would it be possible to do this, am I using the wrong syntax?

Any pointers gratefully received

Lots of compile errors when building the cmajor tools on Windows

Just trying to build the tools with the usual commands from the repo root:

cmake -S . -B build 
cmake --build build --config RelWithDebInfo

I get flooded with lots of different compile errors lile:

MSBuild version 17.7.2+d6990bcfa for .NET Framework

  Checking File Globs
  1>Checking Build System
  Generating CmajPlugin_artefacts/JuceLibraryCode/CmajPlugin_resources.rc
  Building Custom Rule D:/me/MUSICA/dev/cmajor/cmajor/tools/CmajPlugin/CMakeLists.txt
  CmajPlugin_rc_lib.vcxproj -> D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\CmajPlugin_rc_lib.dir\Debug\CmajPl
  ugin_rc_lib.lib
  Building Custom Rule D:/me/MUSICA/dev/cmajor/cmajor/tools/CmajPlugin/CMakeLists.txt
  cmaj_Program.cpp
  cmaj_CPlusPlusGenerator.cpp
  cmaj_CPlusPlusPerformer.cpp
  cmaj_LLVMPerformer.cpp
  cmaj_wasm_libs_binaryen1.cpp
  cmaj_wasm_libs_binaryen2.cpp
  cmaj_wasm_libs_binaryen3.cpp
  cmaj_wasm_libs_binaryen4.cpp
  cmaj_wasm_libs_binaryen5.cpp
  cmaj_WebAssemblyGenerator.cpp
  cmaj_WebAssemblyPerformer.cpp
  cmaj_EngineTypeList.cpp
  cmaj_ErrorHandling.cpp
  cmaj_Transformations.cpp
  cmaj_AllocationChecker.cpp
D:\me\MUSICA\dev\include\cmajor\COM\cmaj_ProgramInterface.h(36,1): error C2011: 'cmaj::SyntaxTreeOptions': 'struct' typ
e redefinition (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPerfor
mer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\cmajor\cmajor\include\cmajor\COM\cmaj_ProgramInterface.h(35,8): message : see declaration of 'cmaj::Sy
ntaxTreeOptions' (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPerf
ormer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\include\cmajor\COM\cmaj_ProgramInterface.h(56,26): error C2011: 'cmaj::ProgramInterface': 'struct' typ
e redefinition (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPerfor
mer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\cmajor\cmajor\include\cmajor\COM\cmaj_ProgramInterface.h(56,8): message : see declaration of 'cmaj::Pr
ogramInterface' (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPerfo
rmer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\include\cmajor\COM\cmaj_PerformerInterface.h(50,29): error C2011: 'cmaj::PerformerInterface': 'struct'
 type redefinition (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPe
rformer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\cmajor\cmajor\include\cmajor\COM\cmaj_PerformerInterface.h(50,8): message : see declaration of 'cmaj::
PerformerInterface' (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMP
erformer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\include\cmajor\COM\cmaj_CacheDatabaseInterface.h(40,33): error C2011: 'cmaj::CacheDatabaseInterface':
'struct' type redefinition (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cma
j_LLVMPerformer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\cmajor\cmajor\include\cmajor\COM\cmaj_CacheDatabaseInterface.h(40,8): message : see declaration of 'cm
aj::CacheDatabaseInterface' (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cm
aj_LLVMPerformer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\include\cmajor\COM\cmaj_EngineInterface.h(47,26): error C2011: 'cmaj::EngineInterface': 'struct' type
redefinition (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPerforme
r.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\cmajor\cmajor\include\cmajor\COM\cmaj_EngineInterface.h(47,8): message : see declaration of 'cmaj::Eng
ineInterface' (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules\compiler\src\backends\LLVM\cmaj_LLVMPerform
er.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.vcxproj]
D:\me\MUSICA\dev\cmajor\cmajor\include\../../../include/cmajor/COM/cmaj_EngineFactoryInterface.h(44,33): error C2011: '
cmaj::EngineFactoryInterface': 'struct' type redefinition (compiling source file D:\me\MUSICA\dev\cmajor\cmajor\modules
\compiler\src\backends\LLVM\cmaj_LLVMPerformer.cpp) [D:\me\MUSICA\dev\cmajor\cmajor\build\tools\CmajPlugin\cmajor_lib.v
cxproj]
(...)

and many more of different types down the road.

This is the output from the cmake generator:

-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.37.32822.0
-- The CXX compiler identification is MSVC 19.37.32822.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Defaulting CMAJ_VERSION to 1.0
Including the command line tool
Configuring Cmajor lib:           command_cmaj_lib
CMAJ_INCLUDE_SERVER:              TRUE
CMAJ_INCLUDE_SCRIPTING:           TRUE
CMAJ_INCLUDE_PLAYBACK:            TRUE
CMAJ_ENABLE_PERFORMER_LLVM:       TRUE
CMAJ_ENABLE_PERFORMER_WEBVIEW:    TRUE
CMAJ_ENABLE_PERFORMER_CPP:        TRUE
CMAJ_ENABLE_CODEGEN_CPP:          TRUE
CMAJ_ENABLE_CODEGEN_LLVM_WASM:    TRUE
CMAJ_ENABLE_CODEGEN_BINARYEN:     TRUE
Including wasm
Including x64
Including the Cmajor shared library
Configuring Cmajor lib:           performer_cmaj_lib
CMAJ_INCLUDE_SERVER:              FALSE
CMAJ_INCLUDE_SCRIPTING:           FALSE
CMAJ_INCLUDE_PLAYBACK:            TRUE
CMAJ_ENABLE_PERFORMER_LLVM:       TRUE
CMAJ_ENABLE_PERFORMER_WEBVIEW:    FALSE
CMAJ_ENABLE_PERFORMER_CPP:        FALSE
CMAJ_ENABLE_CODEGEN_CPP:          FALSE
CMAJ_ENABLE_CODEGEN_LLVM_WASM:    FALSE
CMAJ_ENABLE_CODEGEN_BINARYEN:     FALSE
Including wasm
Including x64
Including plugin build
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
Configuring Cmajor lib:           cmajor_lib
CMAJ_INCLUDE_SERVER:              FALSE
CMAJ_INCLUDE_SCRIPTING:           FALSE
CMAJ_INCLUDE_PLAYBACK:            TRUE
CMAJ_ENABLE_PERFORMER_LLVM:       TRUE
CMAJ_ENABLE_PERFORMER_WEBVIEW:    FALSE
CMAJ_ENABLE_PERFORMER_CPP:        FALSE
CMAJ_ENABLE_CODEGEN_CPP:          FALSE
CMAJ_ENABLE_CODEGEN_LLVM_WASM:    FALSE
CMAJ_ENABLE_CODEGEN_BINARYEN:     FALSE
Including wasm
Including x64
Including example projects
Configuring Cmajor lib:           examples_cmaj_lib
CMAJ_INCLUDE_SERVER:              FALSE
CMAJ_INCLUDE_SCRIPTING:           FALSE
CMAJ_INCLUDE_PLAYBACK:            TRUE
CMAJ_ENABLE_PERFORMER_LLVM:       TRUE
CMAJ_ENABLE_PERFORMER_WEBVIEW:    FALSE
CMAJ_ENABLE_PERFORMER_CPP:        FALSE
CMAJ_ENABLE_CODEGEN_CPP:          FALSE
CMAJ_ENABLE_CODEGEN_LLVM_WASM:    FALSE
CMAJ_ENABLE_CODEGEN_BINARYEN:     FALSE
Including wasm
Including x64
-- Configuring done (28.6s)
-- Generating done (0.4s)

How to create seperate controls for multiple instances of the same processor?

Hi all, I just learned about the language and have been playing with it all day today, it is so cool!
I was trying to make a quad delay, with each channel having its own delay control.

graph DelayTest   [[ main ]]
{
    input stream float audioIn;
    output stream float<2> audioOut;
    
    input delay.wet  [[ name: "Wet Level",       min: 0, max: 1, init:  0.5, unit: "",  step: 0.1 ]];
    input delay.dry  [[ name: "Dry Level",       min: 0, max: 1, init:  0.5, unit: "",  step: 0.1 ]];
    input delay2.wet;

    //==============================================================================

    node delay = AudioDelay(float, 44100);
    node delay2 = AudioDelay(float, 44100);
...
}

When I wrote something like this, the compiler throws error: The name 'wet' is already in use input delay2.wet; . What is the correct way to add individual controls for different instances of the same processor?

Changes are not applied dynamically when the patch file is saved

If I'm not wrong, when a cmajor patch file is saved while running (either with the VSCode extension or with cmaj play) the changes should be recompiled and applied on the fly. This is not working for me. I need to stop the running patch and rerun it.

I'm on Windows 11 with the latest release (1.0.2416) for Windows.

"Lost connection..."-error when test running patches on WSL2

I've just started using Cmajor but I've been running code in Windows Subsystem for Linux (WSL2) for the most part and I would always get Lost connection to the Cmajor Server process! when testing out the demo patches provided by the VSCode extension.

Switching back to Windows and this problem would be non-existent, the demo patches will run as intended.

I'm not entirely clear as to what the reason is. Is it just not supported for WSL?

Windows VST Plugin

I must admit I feel a little bit dumb at the moment. I've been trying to find the VST3 plugin referenced in the documentation to be able to run patches on my DAW, but with no luck. Here are the things I've tried and the places I've looked for:

  • I tried installing the tool through the provided binaries. I do have the cmaj command tool working, but I don't know or see a VST3 plugin anywhere
  • I inspected the installed files within C:\Program Files\SoundStacks\Cmajor. No VST3 plugin there either
  • I looked through the list of binaries, in case the VST3 plugin for windows was on a previous release.
  • I inspected the dmg binary for mac. I know there's a VST3 plugin there ready to use for mac, but it doesn't seem to be windows compatible
  • I looked within my DAW in case it was installed there somehow.

At this point I'm only missing trying to build the VST myself through the source code. Is this the intended way of getting the VST3 for windows? Or am I blind and haven't been able to see an obvious link to the VST3 plugin?

Any help is greatly appreciated, I really want to start playing with cmajor!

[Bug] Recursing on a mutable vector crashes the host

Hello,
i've been implementing the reverb from Signalsmiths ADC Talk and found that when i try to recurse on a vector, calling a generic function with slices of the vector, cmajor crashes. When i do the same with an array, the processor works as expected. I understand that i might be misusing the vector here, but the expected behaviour would be getting an error message, without crashing the host. As a more general question: are all crashes of cmajor considered a bug? Intuitively i'd say yes, but not sure if you are aiming for that.

Here's a more or less minimal version of the code causing the crash:

graph Crash [[ main ]] 
{
    input stream float<8> in;
    output stream float<8> out;

    node matrix = Hadamard();

    connection in -> matrix -> out;
}

processor Hadamard(using SampleType = float32, int N = 8)
{
    input  stream SampleType<N> in;
    output stream SampleType<N> out;

    let scalingFactor = sqrt(1.0f/SampleType(N));

    void recursiveUnscaled<Frame>(Frame& frame)
    {
        static_assert(frame.isVector && frame.elementType.isFloat, "input must be a float<N>");
    
        if const (frame.isVector && frame.elementType.isFloat && frame.size > 1) {
            let halfSize = frame.size / 2;

            recursiveUnscaled(frame[0:halfSize]);
            recursiveUnscaled(frame[halfSize:frame.size]);

            for (wrap<halfSize> i) {
                SampleType a = frame[i];
                SampleType b = frame[wrap<frame.size>(i + halfSize)];
                frame[i] = (a + b);
                frame[wrap<frame.size>(i + halfSize)] = (a - b);
            }
        }
    }

    void main() 
    {   
        loop {
            SampleType<N> frame = in;
            recursiveUnscaled(frame);
            out <- frame * scalingFactor;
            advance();
        }
    }
}

And here's the error from the command line:

Audio device: Built-in Output (CoreAudio)
48000Hz, 128 frames, latency: 18ms, output channels: (0, 1), input channels: (0, 1)
Loading: Crash.cmajorpatch
Assertion failed: (isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"), function InsertElementInst, file Instructions.cpp, line 1904.
[1]    55207 abort      cmaj play Crash.cmajorpatch

I'm on OSX 12.5.6, running cmajor 0.9.2051

Cannot use `value` in an event handler?

Issue

Given the following minimal patch:

processor ValueInEvent  [[ main ]]
{
    input event std::midi::Message midiIn;
    input value std::timeline::Tempo tempoIn;
    output stream float out;

    event midiIn(std::midi::Message midi) 
    {
        console <- tempoIn;
    }
}

I get the following error:

error: Streams cannot be used in event callback functions

It seems like this error is meant for using streams in an event instead of values, and maybe values ought to be allowed?

Workaround

If not, I can treat values as events instead. Then cache them to access them from other events. Which works but seems like needless boilerplate:

processor Untitled  [[ main ]]
{
    input event std::midi::Message midiIn;
    input event std::timeline::Tempo tempoIn;
    output stream float out;

    float bpm;

    event tempoIn(std::timeline::Tempo tempo) 
    {
        bpm = tempo.bpm;
    }

    event midiIn(std::midi::Message midi) 
    {
        console <- bpm;
    }
}

Environment

  • Cmajor Tools: v1.0.2397
  • macOS v14.2.1 (23C71)
  • Apple Silicon M1

[Feature Request] Ability to "compile" to a patch

If I load a patch, that has some parameter inputs. For example (from Creating your first patch - Hello, World! )

graph AnnoyingBeep  [[main]]
{
    output stream float out;
    input gain.volume;
    input sine.frequencyIn;

    node sine = std::oscillators::Sine (float, 440);
    node gain = std::levels::SmoothedGain (float);

    connection sine -> gain.in;
    connection gain.out -> out;
}

Then if I load the patch and programmatically change the value using the native API, I'd like to be able to re-export or compile to the patch format to inspect. What this would look like might be if I change sine.frequencyIn to be 1000 Hz instead of 440 Hz, I should be able to compile to the patch format and the new code might be something like the following.

graph AnnoyingBeep  [[main]]
{
    output stream float out;
    input gain.volume;
    input sine.frequencyIn;

    node sine = std::oscillators::Sine (float, 1000);
    node gain = std::levels::SmoothedGain (float);

    connection sine -> gain.in;
    connection gain.out -> out;
}

For more complex patches, I think it would be fine for it to not match so exactly. For example, if comments were stripped or orders swapped or anything else as a by-product of the implementation. The goal is to be able to save state in the patch format itself.

wrong allocation in FL studio

Hi,
I'm just here to say thank you 1st.
But in Fl Studio, the Cmajor Gui is opening as a Mixing plugin, in which case we can use it as a VST and make melodies with.

Thanks

cmajor vst3 plugin as effect instead of instrument

I just wonder if this is the intended behaviour or if something could be done about this. When I use the available cmajor vst3 plugin on Mac in my DAW of preference (Reason 12) it is added as an effect and not as an instrument.

Would it be possible to have the vst3 plugin to be created so it's recognized as an instrument, not as an effect?

«Internal compiler error: "createCast:1075"» with nested graph.

Reproduction

Given the following patch:

graph Main [[main]]
{    
    output stream float<2> out;
    node osc = StereoOsc;
    connection osc -> out;
}

graph StereoOsc 
{
    input osc.foo;
    output stream float<2> out;

    node osc = Oscillator[2];

    connection float<2> ( osc[0].out, osc[1].out ) -> out;
}

processor Oscillator
{
    input value float foo;
    output stream float out;

    let frequency = 200.0f;

    void main ()
    {
        let phaseDelta = processor.id * float (frequency * processor.period * twoPi);

        loop
        {
            out <- volume * sin (phase);
            phase = addModulo2Pi (phase, phaseDelta);
            advance();
        }
    }

    let volume = 0.15f;
    float phase;
}

running it via cmaj play or the VScode host gives the error:

Internal compiler error: "createCast:1075"

Note: the underlying error here is mine. At line 10 I’m trying to hoist a property on osc, and osc is an array. Cmaj tries to make this an array of endpoints, and that’s not supported.

Workarounds

If the graph is not nested (that is, if StereoOsc is [[main]]), the error is reported correctly:

error: Language feature not yet implemented: top-level arrays of inputs!

It’s only if StereoOsc is referenced from somewhere else that the internal error crops up.

Priority

Very low. The internal error is really only getting in the way of better verbiage to help me diagnose my syntax error. Still, it’s an exposed internal error, so I'm making note of it here.

Environment

Cmajor: version 1.0.2454
OS: macOS 14.4.1 (23E224)
CPU: Apple M1

CmajPlugin not included in released Win binaries.

According to
https://cmajor.dev/docs/GettingStarted#loading-patches-in-your-daw-with-the-cmajor-vstau-plugin
the CmajPlugin should be included in the released binaries.
But it seems not to be in the last 3 released versions of 'cmajor_win_x64.exe'.
This installer for Windows for me just installs the cmd-line tool cmaj.exe, the CmajPerformer.dll and some example patches.
Seems also not to be contained in the binaries for Linux, but I found it's name in the MacOS binaries.

How to write to wav file?

As a proof of concept, could I see an example of what it would look like to output a sine tone to a wav file for X seconds?

Solution to API language interoperability

Happy to see the compiler has been open sourced!

I was looking into generating bindings to the cmajor API to interop with other languages and ran into a few hurdles. Since API/ is all C++ I assumed the best approach would be to build bindings to COM/, but it seems that this interface is implemented in C++ as well, which would preclude automatic binding generation with something like bindgen or ffigen. Furthermore, it looks like the COM interface returns C++ data structures like choc::com::Ptr<ProgramInterface>, which again would make interop complicated and potentially bug-prone.

Obviously, I could implement my own C wrapper or reverse engineer the in-memory representation of the data structures returned by the COM API, but it seems to me like having an included C API would benefit the community. If it was me I would have designed the COM API to return C types and added the choc C++ abstractions in API/, but perhaps there's a reason I'm not aware of that the compiler must return smart pointers, or perhaps you all had a better approach to interop in mind.

If there's interest in adding a C API I'd be happy to implement it with some guidance on the design. If there's a better approach to interop, let me know that as well.

Failed to do git clone

$ git clone --recursive https://github.com/SoundStacks/cmajor
Cloning into 'cmajor'...
remote: Enumerating objects: 2270, done.
remote: Counting objects: 100% (2270/2270), done.
remote: Compressing objects: 100% (908/908), done.
remote: Total 2270 (delta 1392), reused 2206 (delta 1344), pack-reused 0
Receiving objects: 100% (2270/2270), 1.37 MiB | 4.50 MiB/s, done.
Resolving deltas: 100% (1392/1392), done.
Submodule '3rdParty/choc' ([email protected]:Tracktion/choc.git) registered for path 'include/choc'
Cloning into '/home/Administrator/cmajor/include/choc'...
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:Tracktion/choc.git' into submodule path '/home/Administrator/cmajor/include/choc' failed
Failed to clone 'include/choc'. Retry scheduled
Cloning into '/home/Administrator/cmajor/include/choc'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:Tracktion/choc.git' into submodule path '/home/Administrator/cmajor/include/choc' failed
Failed to clone 'include/choc' a second time, aborting

[Feature Request] Custom Allocator Support

I'm following the directions regarding The Cmajor native API,
It would be great to be able to optionally use classes with a custom allocator.

Reasons:

  • Multiple large projects at different companies I've worked on have used them, for different reasons.
  • They're popular in the game development world
  • Makes it easier for an integrator to track the runtime memory cost

One could argue about just hooking new/delete on the integrator's side, but I haven't checked to see if Cmajor is using new/delete or malloc or something else. Also, one might want to use Allocator A for the audio engine, and Allocator B for video, etc.

Casting error caused by sample rate change

I've chased this one around a little but I've found it a bit tricky to pin down exactly what's causing it. Here's a small example which gives the error:

graph ExampleGraph [[ main ]]
{
    output stream float audioOut  [[ name: "Audio Out" ]];

    node
    {
        resonator = Resonator / 2;
    }

    connection 
    {
        resonator.audioOut[0] -> audioOut;
    }
}

processor Resonator
{

    input stream float64 audioIn[2];
    output stream float audioOut[2];

    var weights = float64 [2, 2] ((0.0, 0.0), (0.0, 0.0));

    let numInputs = 2;

    void main()
    {
        console <- "Resonator::main";

        loop
        {
            var in = float64[numInputs, 1] ((audioIn[0]), (audioIn[1]));

            let out = std::matrix::dot (weights, in);

            audioOut[0] <- float32(out[0][0]);

            advance();
        }
    }
}

Gives error:

error: Internal compiler error: "createCast:1067"

It seems some combination of altering the sample rate of the processor on the graph (resonator = Resonator / 2;) with casting the audio inputs into an array (var in = float64[numInputs, 1] ((audioIn[0]), (audioIn[1]));) causes this error. The console statement also affects whether the error occurs, though I think this might just be because the code sometimes gets optimised away without a side effect

Any advice to get around this is very welcome, or if there are better ways of doing matrix operations on arrays of inputs/outputs any tips would be gratefully received. Hope all's well with you!

Feature Request: OSC Support

I find Open Sound Control essential in my practice, and would love to see it in CMajor as I develop projects with it.

Pro-54 HPF button - ackhthually...

...it is highpass only in OLD filter mode. In NEW and NEW AA modes it's a bandpass. So the graphic should switch from HPF to BPF depending on this parameter's value.

Providing an allocator for `Engine::createPerformer()`

Hello!

I was looking into the C++ API to see how feasible would be to embed the Cmajor JIT compiler within SuperCollider. The one thing that stops me is the need for it to be using SuperCollider's real-time allocator when creating a new instance from a compiled Cmajor program.

Compiling the program is not a problem, as that can be executed in a background thread, but allocating new instances of them via SuperCollider UGens could be problematic, as this happens on the audio thread. I was wondering if it would then be possible to pass a custom alloc function (which would point to SuperCollider's RTAlloc function) to Engine::createPerformer() for it to allocate the memory of each created instance with a custom allocator.

Thanks!

Possible to console.log in UI files?

I'm experimenting with custom UIs for Cmajor patches and I have a hard time debugging the JS files. In the docs you casually mention the possibility to print logs to the console, but I can't see them anywhere. Any ideas?

How to assign use input value in defining a variable?

I was hoping to use a knob to adjust the delay time, but when I try the code below I get
error: Expected a value int delayInSample = delayMs1 * 48000;
What is the correct way to use an input value/stream/event to create a variable?

graph DelayTest  [[ main ]]
{
    input stream float audioIn;
    output stream float audioOut;
    
    input delay.wet wet1          [[ name: "Wet1 Level",       min: 0, max: 1, init:  0.5, unit: "",  step: 0.1 ]];
    input delay.dry dry1          [[ name: "Dry1 Level",       min: 0, max: 1, init:  0.5, unit: "",  step: 0.1 ]];
    input value int delayMs1                [[ name: "Delay1 ms",       min: 0, max: 5000, init:  0, unit: "",  step: 50 ]];

    //==============================================================================
    int delayInSample = delayMs1 * 48000;
    node delay = AudioDelay(float, 48000, delayInSample);

    connection
    {
        audioIn->delay.in;
        delay.out->audioOut;
    }
}

Couldn't build release 0.9.2006 -> choc::json::create() not found

Your help would be great. After cmaking a build I got the following errors:

cmajor/examples/native_apps/HelloCmajor/../../../include/cmajor/API/cmaj_DiagnosticMessages.h:179:24: error: 
      no member named 'create' in namespace 'choc::json'
    return choc::json::create ("severity", getSeverity(),
           ~~~~~~~~~~~~^

/include/cmajor/API/cmaj_Endpoints.h:419:26: error: 
      no member named 'create' in namespace 'choc::json'
    auto o = choc::json::create ("endpointID",   endpointID.toString(),
             ~~~~~~~~~~~~^

/include/cmajor/API/cmaj_ExternalVariables.h:80:47: error: 
      no member named 'create' in namespace 'choc::json'
            list.addArrayElement (choc::json::create ("name", e.name,
                                  ~~~~~~~~~~~~^

[Edit] Note: I cloned choc repo directly, not as a git submodule.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.