PageSourceSearch

https://cmajor.dev/docs/GettingStarted

html cmajor.dev collected 2026-10-04 00:24:44 UTC 75,784 bytes, 532 lines download raw bytes

1
2
3<!DOCTYPE html>
4
5<html lang="en-US">
6<head>
7  <meta charset="UTF-8">
8  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
9
10  
11
12  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
13
14
15  <link rel="stylesheet" href="/assets/css/just-the-docs-default.css">
16  <link rel="preconnect" href="https://rsms.me/">
17  <link rel="stylesheet" href="https://rsms.me/inter/inter.css">
vendor: 72 bytes, lines 17-20
17
18
19  
20    <script async src="https://www.googletagmanager.com/gtag/js?id=
20UA-2709176-10
vendor: 16 bytes, lines 20-21
20"></script>
21    
21<script>
22      
vendor: 146 bytes, lines 22-26
22window.dataLayer = window.dataLayer || [];
23      function gtag(){dataLayer.push(arguments);}
24      gtag('js', new Date());
25
26      gtag('config', '
26UA-2709176-10
vendor: 34 bytes, lines 26-27
26', { 'anonymize_ip': true });
27    
27</script>
27
28
29  
30
31  
32    
32<script src="/assets/js/vendor/lunr.min.js"></script>
32
33  
34
35  
36    
36<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
36
37  
38
39  
39<script src="/assets/js/just-the-docs.js"></script>
39
40
41  <meta name="viewport" content="width=device-width, initial-scale=1">
42
43  <!-- Begin Jekyll SEO tag v2.8.0 -->
44<title>Getting Started | Cmajor Documentation</title>
45<meta name="generator" content="Jekyll v3.10.0" />
46<meta property="og:title" content="Getting Started" />
47<meta property="og:locale" content="en_US" />
48<meta name="description" content="Documentation for the Cmajor language" />
49<meta property="og:description" content="Documentation for the Cmajor language" />
50<link rel="canonical" href="https://cmajor.dev/docs/GettingStarted" />
51<meta property="og:url" content="https://cmajor.dev/docs/GettingStarted" />
52<meta property="og:site_name" content="Cmajor Documentation" />
53<meta property="og:type" content="website" />
54<meta name="twitter:card" content="summary" />
55<meta property="twitter:title" content="Getting Started" />
56<script type="application/ld+json">
57{"@context":"https://schema.org","@type":"WebPage","description":"Documentation for the Cmajor language","headline":"Getting Started","url":"https://cmajor.dev/docs/GettingStarted"}</script>
57
58<!-- End Jekyll SEO tag -->
59
60
61  <link rel="shortcut icon" type="image/png" href="https://cmajor-lang.github.io/docs-dev/favicon.png"  style="margin-top:20px" style="margin-bottom: 30px;">
62
63
64</head>
65
66<body>
67  <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
68    <symbol id="svg-link" viewBox="0 0 24 24">
69      <title>Link</title>
70      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link">
71        <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
72      </svg>
73    </symbol>
74    <symbol id="svg-search" viewBox="0 0 24 24">
75      <title>Search</title>
76      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search">
77        <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line>
78      </svg>
79    </symbol>
80    <symbol id="svg-menu" viewBox="0 0 24 24">
81      <title>Menu</title>
82      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu">
83        <line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line>
84      </svg>
85    </symbol>
86    <symbol id="svg-arrow-right" viewBox="0 0 24 24">
87      <title>Expand</title>
88      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right">
89        <polyline points="9 18 15 12 9 6"></polyline>
90      </svg>
91    </symbol>
92    <symbol id="svg-doc" viewBox="0 0 24 24">
93      <title>Document</title>
94      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file">
95        <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline>
96      </svg>
97    </symbol>
98  </svg>
99
100  <div class="side-bar">
101    <div class="site-header">
102      <a href="https://cmajor.dev/" class="site-title lh-tight">
103<img src="/assets/images/Cmajor-Word-Logo.png" style="margin-top:20px;max-width: 150pt;max-height: 50pt;"></a>
104      <a href="#" id="menu-button" class="site-button">
105        <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-menu"></use></svg>
106      </a>
107    </div>
108    <nav role="navigation" aria-label="Main" id="site-nav" class="site-nav">
109      <ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/" class="nav-list-link">Home</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/about-us" class="nav-list-link">About Us</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Licence" class="nav-list-link">Licence</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Licence#different-cmajor-licensing-options" class="nav-list-link">Different Cmajor licensing options</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#commercial-license-terms" class="nav-list-link">Commercial License terms</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Licence#faqs" class="nav-list-link">FAQs</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#it-is-possible-to-reassign-licences-amongst-members-of-an-organisation" class="nav-list-link">It is possible to reassign licences amongst members of an organisation?</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#is-the-total-annual-revenue-or-funding-limit-determined-solely-by-sales-of-software-containing-cmajor" class="nav-list-link">Is the total annual revenue or funding limit determined solely by sales of software containing Cmajor?</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#do-i-need-a-cmajor-licence-if-i-am-not-releasing-products-containing-cmajor" class="nav-list-link">Do I need a Cmajor licence if I am not releasing products containing Cmajor?</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#how-many-licenced-developer-seats-do-i-need" class="nav-list-link">How many licenced developer seats do I need?</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#do-i-need-a-cmajor-licence-to-sell-cmajor-based-software-created-by-another-entity" class="nav-list-link">Do I need a Cmajor licence to sell Cmajor-based software created by another entity?</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#i-want-to-hire-a-contractor-to-contribute-to-software-containing-cmajor-do-i-need-a-licence-or-does-the-contractor-need-a-licence" class="nav-list-link">I want to hire a contractor to contribute to software containing cmajor. Do I need a licence or does the contractor need a licence?</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Licence#can-a-cmajor-educational-licence-be-used-by-students" class="nav-list-link">Can a Cmajor Educational licence be used by students?</a></li></ul></li></ul></li><li class="nav-list-item active"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/GettingStarted" class="nav-list-link active">Getting Started</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/GettingStarted#using-cmajor-in-vscode" class="nav-list-link">Using Cmajor in VScode</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/GettingStarted#installing-the-cmajor-command-line-tools" class="nav-list-link">Installing the Cmajor command-line tools</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/GettingStarted#the-cmaj-command-line-tool" class="nav-list-link">The `cmaj` command-line tool</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/GettingStarted#playing-a-patch-with-the-console-app" class="nav-list-link">Playing a patch with the console app</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/GettingStarted#loading-patches-in-your-daw-with-the-cmajor-vstau-plugin" class="nav-list-link">Loading patches in your DAW with the Cmajor VST/AU plugin</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/GettingStarted#creating-a-new-empty-patch" class="nav-list-link">Creating a new empty patch</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/GettingStarted#creating-your-first-patch---hello-world" class="nav-list-link">Creating your first patch - Hello, World!</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/GettingStarted#step-1---create-a-new-patch" class="nav-list-link">Step 1 - Create a New Patch</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Examples" class="nav-list-link">Examples</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/HelloWorld/" class="nav-list-link">Hello World</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/ElectricPiano/" class="nav-list-link">Electric Piano</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/808/" class="nav-list-link">808</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/Piano/" class="nav-list-link">Piano</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/Tremolo/" class="nav-list-link">Tremolo</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/RingMod/" class="nav-list-link">Ring Modulator</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/ZitaReverb/" class="nav-list-link">Zita Reverb</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/Pro54/" class="nav-list-link">Pro-54</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/GuitarLSTM/" class="nav-list-link">GuitarLSTM</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/FilterEQ/" class="nav-list-link">FilterEQ</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/PirkleFilters/" class="nav-list-link">Pirkle Filters</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/Replicant/" class="nav-list-link">Replicant</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/STunedBar6/" class="nav-list-link">Tuned Bar</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Examples/CompuFart/" class="nav-list-link">CompuFart</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/CmajorLicenceTerms" class="nav-list-link">Cmajor Licence Terms</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/CmajorLicenceTerms#cmajor-commercial-license-agreement" class="nav-list-link">Cmajor Commercial License Agreement</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#1-grant-and-scope-of-licence" class="nav-list-link">1. Grant and scope of Licence</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#2-restrictions" class="nav-list-link">2. Restrictions</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#3-fees-and-minimum-commitments" class="nav-list-link">3. Fees and Minimum Commitments.</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#4-support" class="nav-list-link">4. Support</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#5-intellectual-property-rights" class="nav-list-link">5. Intellectual Property Rights</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#6-disclaimer-of-warranty" class="nav-list-link">6. Disclaimer of Warranty</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#7-limitation-of-liability-and-indemnification" class="nav-list-link">7. Limitation of Liability and Indemnification</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#8-term-and-termination" class="nav-list-link">8. Term and Termination</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#9-communications-between-us" class="nav-list-link">9. Communications Between Us</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#10-data-privacy-and-publicity" class="nav-list-link">10. Data, Privacy and Publicity</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#11-other-important-terms" class="nav-list-link">11. Other Important Terms</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/CmajorLicenceTerms#12-definitions" class="nav-list-link">12. Definitions</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference" class="nav-list-link">Language Reference</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#lexical-rules" class="nav-list-link">Lexical Rules</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#whitespace" class="nav-list-link">Whitespace</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#comments" class="nav-list-link">Comments</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#identifiers" class="nav-list-link">Identifiers</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#reserved-keywords" class="nav-list-link">Reserved keywords</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#literals" class="nav-list-link">Literals</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#integer-literal
109s" class="nav-list-link">Integer Literals</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#boolean-literals" class="nav-list-link">Boolean Literals</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#floating-point-literals" class="nav-list-link">Floating-point Literals</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#string-literals" class="nav-list-link">String Literals</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#aggregate-literals" class="nav-list-link">Aggregate Literals</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#null-literals" class="nav-list-link">Null Literals</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#types" class="nav-list-link">Types</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#primitive-types" class="nav-list-link">Primitive Types</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#limited-range-integer-types" class="nav-list-link">Limited-range Integer Types</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#complex-numbers" class="nav-list-link">Complex Numbers</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#arrays" class="nav-list-link">Arrays</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#multi-dimensional-arrays" class="nav-list-link">Multi-Dimensional Arrays</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#arrays-vs-slices" class="nav-list-link">Arrays vs Slices</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#scope-of-slice-data" class="nav-list-link">Scope of slice data</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#constant-vs-mutable-slices" class="nav-list-link">constant vs mutable slices</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#vectors" class="nav-list-link">Vectors</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#structures" class="nav-list-link">Structures</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#string-type" class="nav-list-link">String Type</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#enums" class="nav-list-link">Enums</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#constant-types" class="nav-list-link">Constant Types</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#reference-types" class="nav-list-link">Reference Types</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#type-aliases" class="nav-list-link">Type Aliases</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#type-metafunctions" class="nav-list-link">Type Metafunctions</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#functions" class="nav-list-link">Functions</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#member-functions" class="nav-list-link">Member Functions</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#special-functions" class="nav-list-link">Special Functions</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#recursion" class="nav-list-link">Recursion</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#generic-functions" class="nav-list-link">Generic functions</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#variables-and-constants" class="nav-list-link">Variables and Constants</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#local-variables-and-parameters" class="nav-list-link">Local Variables and Parameters</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#processor-state-variables" class="nav-list-link">Processor State Variables</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#global-constants" class="nav-list-link">Global Constants</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#control-flow-and-loops" class="nav-list-link">Control-flow and Loops</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#conditions" class="nav-list-link">Conditions</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#arithmetic-operators" class="nav-list-link">Arithmetic Operators</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#casts" class="nav-list-link">Casts</a></li><li class="nav-list-item">
109<a href="https://cmajor.dev/docs/LanguageReference#namespaces-processors-and-graphs" class="nav-list-link">Namespaces, Processors and Graphs</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#namespaces" class="nav-list-link">Namespaces</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#processors" class="nav-list-link">Processors</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#processor-aliases" class="nav-list-link">Processor Aliases</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#inputoutput-endpoint-declarations" class="nav-list-link">Input/Output Endpoint Declarations</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#stream-endpoints" class="nav-list-link">Stream Endpoints</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#value-endpoints" class="nav-list-link">Value Endpoints</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#event-endpoints" class="nav-list-link">Event Endpoints</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#renaming-hoisted-endpoints" class="nav-list-link">Renaming hoisted endpoints</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#writing-to-outputs" class="nav-list-link">Writing to Outputs</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#graphs" class="nav-list-link">Graphs</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#graph-nodes" class="nav-list-link">Graph Nodes</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#connections" class="nav-list-link">Connections</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#connection-functions" class="nav-list-link">Connection Functions</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#conditional-connections" class="nav-list-link">Conditional connections</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#processor-composition" class="nav-list-link">Processor composition</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#processor-composition-caveats" class="nav-list-link">Processor composition caveats</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#when-to-use-a-processor-vs-a-graph" class="nav-list-link">When to use a processor vs a graph</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#delays-and-feedback-loops" class="nav-list-link">Delays and Feedback Loops</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#processor-and-namespace-specialisation-parameters" class="nav-list-link">Processor and Namespace Specialisation Parameters</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/LanguageReference#annotations" class="nav-list-link">Annotations</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#using-the--main--annotation" class="nav-list-link">Using the `[[ main ]]` Annotation</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#built-in-constants" class="nav-list-link">Built-in Constants</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#intrinsic-functions" class="nav-list-link">Intrinsic Functions</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/LanguageReference#calling-native-functions-from-cmajor" class="nav-list-link">Calling native functions from Cmajor</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/PatchFormat" class="nav-list-link">Patch Format</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#the-cmajorpatch-manifest-file" class="nav-list-link">The `.cmajorpatch` manifest file</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#cmajor-source-files" class="nav-list-link">Cmajor source files</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#selection-of-the-patchs-main-processor" class="nav-list-link">Selection of the patch's main processor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#patchparameters" class="nav-list-link">Patch Parameters</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#external-variable-data" class="nav-list-link">External variable data</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/PatchFormat#patch-guis" class="nav-list-link">Patch GUIs</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#specifying-a-custom-gui-for-a-patch" class="nav-list-link">Specifying a custom GUI for a patch</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#the-patchconnection-object" class="nav-list-link">The `PatchConnection` object</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#built-in-javascript-utility-classe
109s" class="nav-list-link">Built-in javascript utility classes</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#patch-workers" class="nav-list-link">Patch Workers</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#building-a-native-clap-from-a-patch" class="nav-list-link">Building a native CLAP from a patch</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#building-a-native-juce-vst-or-audiounit-from-a-patch" class="nav-list-link">Building a native JUCE VST or AudioUnit from a patch</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/PatchFormat#exporting-a-patch-as-javascriptwebassemblyweb-audio" class="nav-list-link">Exporting a patch as Javascript/WebAssembly/Web Audio</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/TestFileFormat" class="nav-list-link">Test File Format</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/TestFileFormat#running-tests" class="nav-list-link">Running Tests</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/TestFileFormat#file-format" class="nav-list-link">File Format</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/TestFileFormat#special-section-delimiters" class="nav-list-link">Special Section Delimiters</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/TestFileFormat#built-in-test-functions" class="nav-list-link">Built-in Test Functions</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/TestFileFormat#auto-updating-expected-results" class="nav-list-link">Auto-updating Expected Results</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/TestFileFormat#creating-custom-test-functions" class="nav-list-link">Creating Custom Test Functions</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/ScriptFileFormat" class="nav-list-link">Script File Format</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Tools" class="nav-list-link">Tools</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Tools/C++API" class="nav-list-link">C++ API</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/Tools/C++API#main-api-classes" class="nav-list-link">Main API classes</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Tools/C++API#helper-classes" class="nav-list-link">Helper classes</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Tools/MachineLearning" class="nav-list-link">Machine Learning</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Tools/MachineLearning#onnx" class="nav-list-link">ONNX</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/Tools/MachineLearning#onnx-operators" class="nav-list-link">ONNX Operators</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/Tools/MachineLearning#using-the-onnx-to-cmajor-python-script" class="nav-list-link">Using the ONNX to Cmajor Python script</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/Tools/MachineLearning#rtneural" class="nav-list-link">RTNeural</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/Tools/MachineLearning#supported-operators" class="nav-list-link">Supported Operators</a></li></ul></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary" class="nav-list-link">Standard Library</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_audio_data" class="nav-list-link">std.audio_data</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#audio_data" class="nav-list-link">audio_data</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#SamplePlayer" class="nav-list-link">SamplePlayer</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_convolution" class="nav-list-link">std.convolution</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#convolution" class="nav-list-link">convolution</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#ZeroLatencyProcessor" class="nav-list-link">ZeroLatencyProcessor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#BlockProcessor" class="nav-list-link">BlockProcessor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#TimeDomainProcessor" class="nav-list-link">TimeDomainProcessor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#FFT" class="nav-list-link">FFT</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#iFFT" class="nav-list-link">iFFT</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Convolve" class="nav-list-link">Convolve</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_envelopes" class="nav-list-link">std.envelopes</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#envelopes" class="nav-list-link">envelopes</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#FixedASR" class="nav-list-link">FixedASR</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_filters" class="nav-list-link">std.filters</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#filters" class="nav-list-link">filters</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#tpt" class="nav-list-link">tpt</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#onepole" class="nav-list-link">onepole</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Processor" class="nav-list-link">Processor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Mode" class="nav-list-link">Mode</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#svf" class="nav-list-link">svf</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Processor2" class="nav-list-link">Processor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#MultimodeProcessor" class="nav-list-link">MultimodeProcessor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Mode2" class="nav-list-link">Mode</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#dcblocker" class="nav-list-link">dcblocker</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Processor3" class="nav-list-link">Processor</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#butterworth" class="nav-list-link">butterworth</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Processor4" class="nav-list-link">Processor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Mode3" class="nav-list-link">Mode</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#crossover" class="nav-list-link">crossover</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Processor5" class="nav-list-link">Processor</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#simper" class="nav-list-link">simper</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Processor6" class="nav-list-link">Processor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Mode4" class="nav-list-link">Mode</a></li></ul></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_frequency" class="nav-list-link">std.frequency</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#frequency7" class="nav-list-link">frequency</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_intrinsics" class="nav-list-link">std.intrinsics</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#intrinsics" class="nav-list-link">intrinsics</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_levels" class="nav-list-link">std.levels</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#smoothing" class="nav-list-link">smoothing</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#SmoothedValueStream" class="nav-list-link">SmoothedValueStream</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#levels" class="nav-list-link">levels</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#ConstantGain" class="nav-list-link">ConstantGain</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#DynamicGain" class="nav-list-link">DynamicGain</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#SmoothedGain" class="nav-list-link">SmoothedGain</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#SmoothedGainParameter" class="nav-list-link">SmoothedGainParameter</a></li></ul></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#pan_law" class="nav-list-link">pan_law</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_matrix" class="nav-list-link">std.matrix</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#matrix" class="nav-list-link">matrix</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_midi" class="nav-list-link">std.midi</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#midi" class="nav-list-link">midi</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#MPEConverter" class="nav-list-link">MPEConverter</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#NoteToMIDI" class="nav-list-link">NoteToMIDI</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_mixers" class="nav-list-link">std.mixers</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#mixers" class="nav-list-link">mixers</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#StereoToMono" class="nav-list-link">StereoToMono</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#MonoToStereo" class="nav-list-link">MonoToStereo</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#DynamicSum" class="nav-list-link">DynamicSum</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#ConstantSum" class="nav-list-link">ConstantSum</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Interpolator" class="nav-list-link">Interpolator</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_noise" class="nav-list-link">std.noise</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#noise" class="nav-list-link">noise</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#White" class="nav-list-link">White</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Brown" class="nav-list-link">Brown</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLi
109brary#Pink" class="nav-list-link">Pink</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_notes" class="nav-list-link">std.notes</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#notes" class="nav-list-link">notes</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_oscillators" class="nav-list-link">std.oscillators</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#oscillators" class="nav-list-link">oscillators</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Phasor" class="nav-list-link">Phasor</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#Sine" class="nav-list-link">Sine</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#PolyblepOscillator" class="nav-list-link">PolyblepOscillator</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#LFO" class="nav-list-link">LFO</a></li><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#waveshape" class="nav-list-link">waveshape</a></li></ul></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_random" class="nav-list-link">std.random</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#random" class="nav-list-link">random</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_timeline" class="nav-list-link">std.timeline</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#timeline" class="nav-list-link">timeline</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#std_voices" class="nav-list-link">std.voices</a><ul class="nav-list"><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://cmajor.dev/docs/StandardLibrary#voices" class="nav-list-link">voices</a><ul class="nav-list"><li class="nav-list-item"><a href="https://cmajor.dev/docs/StandardLibrary#VoiceAllocator" class="nav-list-link">VoiceAllocator</a></li></ul></li></ul></li></ul></li></ul>
110    </nav>
111    <footer class="site-footer">
112      &copy; 2025 <a href="https://cmajor.dev">Cmajor Software Ltd.</a>
113    </footer>
114  </div>
115  <div class="main" id="top">
116    <div id="main-header" class="main-header">
117      
118        <div class="search">
119          <div class="search-input-wrap">
120            <input type="text" id="search-input" class="search-input" tabindex="0" placeholder="Search Cmajor Documentation" aria-label="Search Cmajor Documentation" autocomplete="off">
121            <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#svg-search"></use></svg></label>
122          </div>
123          <div id="search-results" class="search-results"></div>
124        </div>
125      
126      
127    </div>
128    <div id="main-content-wrap" class="main-content-wrap">
129      
130
131      <div id="main-content" class="main-content" role="main">
132        
133          <h1 id="getting-started-with-cmajor">
134        
135        
136          <a href="#getting-started-with-cmajor" class="anchor-heading" aria-labelledby="getting-started-with-cmajor"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Getting Started with Cmajor
137        
138        
139      </h1>
140    
141      <h2 id="using-cmajor-in-vscode">
142        
143        
144          <a href="#using-cmajor-in-vscode" class="anchor-heading" aria-labelledby="using-cmajor-in-vscode"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Using Cmajor in VScode
145        
146        
147      </h2>
148    
149
150<p>If you’re a VScode user, then the <a href="https://marketplace.visualstudio.com/items?itemName=
151CmajorSoftware.cmajor-tools">Cmajor VScode extension</a> offers a hassle-free way to play with the language.</p>
152
153<p>It’s a one-click process to get up and running: VScode will automatically install everything you need to create, edit and test Cmajor patches. Simply go to the extensions tab in VScode, search for “Cmajor” and click “install” on the extension.</p>
154
155<p>The extension provides syntax-highlighting for Cmajor code, and adds some new commands to the VScode command-palette. The commands include:</p>
156      <h4 id="cmajor-run-patch">
157        
158        
159          <a href="#cmajor-run-patch" class="anchor-heading" aria-labelledby="cmajor-run-patch"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">Cmajor: Run patch</code>
160        
161        
162      </h4>
163    
164
165<p>If you open a <code class="language-plaintext highlighter-rouge">.cmajorpatch</code> file in the editor, then invoking this command will build and run it.</p>
166
167<p>Any compile errors will be reported in the problems panel, making it easy to fix mistakes. When your patch compiles successfully, it’ll open a separate pop-up window showing its GUI, and any output while running will appear in the embedded terminal inside VScode. To stop the patch running, you can either close its popup window, or kill the process in the terminal.</p>
168
169<p>While a patch is running, re-saving any of the patch source files should automatically trigger a rebuild and reload, so you can immediately see the effect of your changes.</p>
170      <h4 id="cmajor-create-a-new-patch">
171        
172        
173          <a href="#cmajor-create-a-new-patch" class="anchor-heading" aria-labelledby="cmajor-create-a-new-patch"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">Cmajor: Create a new patch</code>
174        
175        
176      </h4>
177    
178
179<p>This command will prompt you to select the name of a new <code class="language-plaintext highlighter-rouge">.cmajorpatch</code>
179 file. It will then create a template patch and some simple placeholder code as a way of getting started. You can run it with the <code class="language-plaintext highlighter-rouge">Cmajor: Run patch</code> command, and use it as a starting point to build upon.</p>
180      <h4 id="cmajor-view-some-example-patches">
181        
182        
183          <a href="#cmajor-view-some-example-patches" class="anchor-heading" aria-labelledby="cmajor-view-some-example-patches"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">Cmajor: View some example patches</code>
184        
185        
186      </h4>
187    
188
189<p>This command will take you to the Cmajor repository where you can find our example patches. You can either clone the <a href="https://github.com/cmajor-lang/cmajor">whole repository</a> from github, or just download specific examples from the <a href="https://github.com/cmajor-lang/cmajor/tree/main/examples/patches">examples</a> folder.</p>
190      <h4 id="cmajor-export-patch-as-htmljavascriptwebassembly">
191        
192        
193          <a href="#cmajor-export-patch-as-htmljavascriptwebassembly" class="anchor-heading" aria-labelledby="cmajor-export-patch-as-htmljavascriptwebassembly"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">Cmajor: Export patch as HTML/Javascript/WebAssembly</code>
194        
195        
196      </h4>
197    
198
199<p>This will prompt you for a folder, into which it will export a bundle of HTML and Javascript that will run the currently focused patch.</p>
200
201<p>The command-line tool equivalent of this operation is <code class="language-plaintext highlighter-rouge">cmaj generate --target=webaudio-html</code></p>
202      <h4 id="cmajor-export-patch-as-juce-plugin">
203        
204        
205          <a href="#cmajor-export-patch-as-juce-plugin" class="anchor-heading" aria-labelledby="cmajor-export-patch-as-juce-plugin"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">Cmajor: Export patch as JUCE plugin</code>
206        
207        
208      </h4>
209    
210
211<p>This will prompt you for a folder in which to create a new JUCE project containing a complete C++ version of the patch that has focus. This allows you to build a native VST/AU/AAX plugin of your patch.</p>
212
213<p>The command-line tool equivalent of this operation is <code class="language-plaintext highlighter-rouge">cmaj generate --target=juce</code></p>
214      <h4 id="cmajor-export-patch-as-a-clap-plugin">
215        
216        
217          <a href="#cmajor-export-patch-as-a-clap-plugin" class="anchor-heading" aria-labelledby="cmajor-export-patch-as-a-clap-plugin"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">Cmajor: Export patch as a CLAP plugin</code>
218        
219        
220      </h4>
221    
222
223<p>This will prompt you for a folder in which to create a new CLAP plugin project. It will export a self-contained C++ version of the focused patch.</p>
224
225<p>The command-line tool equivalent of this operation is <code class="language-plaintext highlighter-rouge">cmaj generate --target=clap</code></p><hr />
226      <h2 id="installing-the-cmajor-command-line-tools">
227        
228        
229          <a href="#installing-the-cmajor-command-line-tools" class="anchor-heading" aria-labelledby="installing-the-cmajor-command-line-tools"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Installing the Cmajor command-line tools
230        
231        
232      </h2>
233    
234
235<p>On the Github releases page, you’ll find <a href="https://github.com/cmajor-lang/cmajor/releases">downloadable binaries for Mac and Windows</a>. These provide:</p>
236
237<ul>
238  <li>The command-line tool (<code class="language-plaintext highlighter-rouge">cmaj</code> or <code class="language-plaintext highlighter-rouge">cmaj.exe</code>) which provides a compiler, utilities and can load and run Cmajor patches.</li>
239  <li>The redistributable libraries (<code class="language-plaintext highlighter-rouge">CmajPerformer.dll</code> or <code class="language-plaintext highlighter-rouge">
239libCmajPerformer.so</code>) which are needed if you’re building your own native app which embeds the Cmajor JIT engine.</li>
240  <li>Builds of the Cmajor VST/AU plugin, which can be used in DAWs and other audio hosts to run Cmajor patches.</li>
241</ul>
242      <h3 id="the-cmaj-command-line-tool">
243        
244        
245          <a href="#the-cmaj-command-line-tool" class="anchor-heading" aria-labelledby="the-cmaj-command-line-tool"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> The <code class="language-plaintext highlighter-rouge">cmaj</code> command-line tool
246        
247        
248      </h3>
249    
250
251<p>The <code class="language-plaintext highlighter-rouge">cmaj</code> command can create, build, test and run patches, as well as perform code-generation of C++ and plugin projects, and various other tasks.</p>
252
253<p>To install, just <a href="https://github.com/cmajor-lang/cmajor/releases">download</a> and unzip the executable into a location of your choice, and you can run it from a terminal.</p>
254
255<p>For help, run:</p>
256
257<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>cmaj <span class="nb">help</span>
258</code></pre></div></div>
259
260<p>And it’ll show you the latest set of available arguments.</p>
261      <h2 id="playing-a-patch-with-the-console-app">
262        
263        
264          <a href="#playing-a-patch-with-the-console-app" class="anchor-heading" aria-labelledby="playing-a-patch-with-the-console-app"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Playing a patch with the console app
265        
266        
267      </h2>
268    
269
270<p>To get started, you might want to try some of the example patches using <code class="language-plaintext highlighter-rouge">cmaj play</code>:</p>
271
272<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>cmaj play /path-to-your-repo/examples/patches/HelloWorld/HelloWorld.cmajorpatch
273</code></pre></div></div>
274
275<p>This will open a window to display any controls that the patch may provide, and you should hear a nice tune playing. If you’ve got a MIDI keyboard then it should be opened and sent to the running patch (if it needs MIDI input).</p>
276
277<p>There are command-line options to give you a bit more control over which audio and MIDI devices are used, but the command-line app is only attempting to be a quick-and-dirty patch player. For more serious control, you probably want to load your patch into a proper audio host via our Cmajor JIT plugin, which will let you route it however you like, and provide any kind of i/o to it.</p>
278
279<p>While running a patch, the console app will detect any file changes and recompile/reload, so you can quickly experiment with changes to your code.</p>
280      <h2 id="loading-patches-in-your-daw-with-the-cmajor-vstau-plugin">
281        
282        
283          <a href="#loading-patches-in-your-daw-with-the-cmajor-vstau-plugin" class="anchor-heading" aria-labelledby="loading-patches-in-your-daw-with-the-cmajor-vstau-plugin"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Loading patches in your DAW with the Cmajor VST/AU plugin
284        
285        
286      </h2>
287    
288
289<p>In our <a href="https://github.com/cmajor-lang/cmajor/releases">binary releases</a>, you’ll find an installer for our plugin, which can be loaded into most DAWs like any other plugin.</p>
290
291<p>When you create an instance of this plugin in a DAW, you can drag-and-drop a <code class="language-plaintext highlighter-rouge">.cmajorpatch</code> file onto the plugin’s GUI to make it load that patch.</p>
292
293<p>It’s worth noting that the nature of the VST/AU plugin formats make it practically impossible for a plugin to dynamically change its parameter list or the number of input/output channels that it provides. This obviously means that when you ask the plugin to load a patch with a different number of parameters or a different endpoint configuration, DAWs aren’t always going to deal with that situation correctly. In response, we’ve had to resort to some annoying restrictions (like always having a fixed-size list of parameters regardless of how many the patch has), but we’ll keep trying to find new tricks and workarounds in the future to make this work better.</p><hr />
294      <h2 id="creating-a-new-empty-patch">
295        
296        
297          <a href="#creating-a-new-empty-patch" class="anchor-heading" aria-labelledby="creating-a-new-empty-patch"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Creating a new empty patch
298        
299        
300      </h2>
301    
302
303<p>To get started with a new patch, the <code class="language-plaintext highlighter-rouge">cmaj</code> app can generate the basic boilerplate files needed. Just run:</p>
304
305<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>
305cmaj create <span class="nt">--name</span><span class="o">=</span><span class="s2">"Hello"</span> MyNewPatchFolderName
306</code></pre></div></div>
307
308<p>This creates a new folder containing a patch called “Hello” that can be explored, renamed and built upon. For in-depth details on how these files work, see the <a href="https://cmajor.dev/docs/PatchFormat">Patch Format Guide</a></p>
309
310<p>The VScode extension also provides the <code class="language-plaintext highlighter-rouge">Cmajor: Create a new patch</code> command to do the same thing.</p><hr />
311      <h2 id="coding-in-cmajor-high-level-overview">
312        
313        
314          <a href="#coding-in-cmajor-high-level-overview" class="anchor-heading" aria-labelledby="coding-in-cmajor-high-level-overview"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Coding in Cmajor: High-Level Overview
315        
316        
317      </h2>
318    
319
320<p>This is a very quick summary of the main concepts in Cmajor. For a deep dive on the language syntax, see the <a href="https://cmajor.dev/docs/LanguageReference">Language Guide</a></p>
321      <h4 id="programs-vs-patches">
322        
323        
324          <a href="#programs-vs-patches" class="anchor-heading" aria-labelledby="programs-vs-patches"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Programs vs Patches
325        
326        
327      </h4>
328    
329
330<p>A Cmajor <em>program</em> refers to any collection of processors, graphs and namespaces. A host app can load a Cmaj program, instantiate a <em>processor</em> and use it to render audio (or any other type of data).</p>
331
332<p>A Cmajor <em>patch</em> is a bundle which has a form that makes it suitable for use as an audio plugin. A patch is a folder containing metadata files, program files, and other resources (such as GUI scripts and audio files) which a DAW-like host can load and use in the same way they might load a traditional plugin such as a VST or AU.</p>
333
334<p>The Cmajor tools include utilities to load patches via a VST/AU plugin, and can also code-generate a native VST/AU plugin from a patch.</p>
335      <h4 id="processors-and-graphs">
336        
337        
338          <a href="#processors-and-graphs" class="anchor-heading" aria-labelledby="processors-and-graphs"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Processors and Graphs
339        
340        
341      </h4>
342    
343
344<p>The main high-level structures in Cmajor that differ from other languages are the <code class="language-plaintext highlighter-rouge">processor</code> and <code class="language-plaintext highlighter-rouge">graph</code> objects.</p>
345      <h4 id="graph-declarations">
346        
347        
348          <a href="#graph-declarations" class="anchor-heading" aria-labelledby="graph-declarations"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">graph</code> declarations
349        
350        
351      </h4>
352    
353
354<p>A <code class="language-plaintext highlighter-rouge">graph</code> declares a set of nodes (which are either low-level <code class="language-plaintext highlighter-rouge">processor</code> objects or other graphs), and a list of connections between them.</p>
355
356<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Example of a graph declaration:</span>
357<span class="n">graph</span> <span class="n">TwoGainsInSeries</span>
358<span class="p">{</span>
359    <span class="c1">// This section declares the inputs and outputs of the graph:</span>
360    <span class="n">input</span>  <span class="n">stream</span> <span class="kt">float</span> <span class="n">in</span><span class="p">;</span>
361    <span class="n">output</span> <span class="n">stream</span> <span class="kt">float</span> <span class="n">out</span><span class="p">;</span>
362
363    <span class="c1">// This section declares the nodes:</span>
364    <span class="n">node</span> <span class="n">gain1</span> <span class="o">=</span> <span class="n">GainProcessor</span><span class="p">;</span>  <span class="c1">// declare two nodes, each one a GainProcessor</span>
365    <span class="n">node</span> <span class="n">gain2</span> <span class="o">=</span> <span class="n">GainProcessor</span><span class="p">;</span>
366
367    <span class="c1">// And here we list the connections between the nodes:</span>
368    <span class="n">connection</span> <span class="n">in</span> <span class="o">-&gt;</span> <span class="n">gain1</span> <span class="o">-&gt;</span> <span class="n">gain2</span> <span class="o">-&gt;</span> <span class="n">out</span><span class="p">;</span>  <span class="c1">// send our input through both gains, and the result to our output</span>
369<span class="p">}</span>
370</code></pre></div></div>
371
372<pre><code class="language-mermaid">graph TD;
373    A(["in"])--&gt;B(["gain1"]);
374    B--&gt;C(["gain2"]);
375    C--&gt;D(["out"]);
376</code></pre>
377      <h4 id="processor-declarations">
378        
379        
380          <a href="#processor-declarations" class="anchor-heading" aria-labelledby="processor-declarations"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> <code class="language-plaintext highlighter-rouge">processor</code> declarations
381        
382        
383      </h4>
384    
385
386<p>Unlike a graph, a <code class="language-plaintext highlighter-rouge">processor</code> contains functions to perform its number crunching, rather than nodes.</p>
387
388<p>Every <code class="language-plaintext highlighter-rouge">processor</code> must provide a <code class="language-plaintext highlighter-rouge">main()</code> function. This usually contains an infinite loop which reads from its inputs, performs s
388ome kind of processing, writes to its outputs, and repeats this for the lifetime of the object.</p>
389
390<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Example of a processor declaration:</span>
391<span class="n">processor</span> <span class="n">GainProcessor</span>
392<span class="p">{</span>
393    <span class="n">input</span>  <span class="n">stream</span> <span class="kt">float</span> <span class="n">in</span><span class="p">;</span>    <span class="c1">// declare an input and output stream of floats</span>
394    <span class="n">output</span> <span class="n">stream</span> <span class="kt">float</span> <span class="n">out</span><span class="p">;</span>
395
396    <span class="kt">void</span> <span class="n">main</span><span class="p">()</span>
397    <span class="p">{</span>
398        <span class="n">loop</span>   <span class="c1">// infinite loop</span>
399        <span class="p">{</span>
400            <span class="n">out</span> <span class="o">&lt;-</span> <span class="n">in</span> <span class="o">*</span> <span class="mf">0.5</span><span class="n">f</span><span class="p">;</span>  <span class="c1">// read our next input value, multiply by 0.5, and send it to our output</span>
401            <span class="n">advance</span><span class="p">();</span>         <span class="c1">// advance to the next frame</span>
402        <span class="p">}</span>
403    <span class="p">}</span>
404<span class="p">}</span>
405</code></pre></div></div>
406
407<p>A program can also contain <code class="language-plaintext highlighter-rouge">namespace</code> declarations containing helper functions, data types, and constants that the processors can use.</p>
408      <h2 id="creating-your-first-patch---hello-world">
409        
410        
411          <a href="#creating-your-first-patch---hello-world" class="anchor-heading" aria-labelledby="creating-your-first-patch---hello-world"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Creating your first patch - Hello, World!
412        
413        
414      </h2>
415    
416
417<p>Let’s start with a simple sine-wave patch with a gain control, to demonstrate how to create a custom processor, connect it up inside a graph, and provide a parameter to control something from the GUI.</p>
418      <h3 id="step-1---create-a-new-patch">
419        
420        
421          <a href="#step-1---create-a-new-patch" class="anchor-heading" aria-labelledby="step-1---create-a-new-patch"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Step 1 - Create a New Patch
422        
423        
424      </h3>
425    
426
427<p>Start by using the command-line app to create a new, empty patch:</p>
428
429<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>cmaj create AnnoyingBeep
430</code></pre></div></div>
431
432<p>This creates a basic patch in a folder called “AnnoyingBeep”. If you have a look inside at the file called <code class="language-plaintext highlighter-rouge">AnnoyingBeep.cmajor</code>, it’ll look something like this:</p>
433
434<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">graph</span> <span class="n">AnnoyingBeep</span>  <span class="p">
434[[</span><span class="n">main</span><span class="p">]]</span>
435<span class="p">{</span>
436    <span class="n">output</span> <span class="n">stream</span> <span class="kt">float</span> <span class="n">out</span><span class="p">;</span>
437
438    <span class="n">node</span> <span class="n">sine</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">oscillators</span><span class="o">::</span><span class="n">Sine</span> <span class="p">(</span><span class="kt">float</span><span class="p">,</span> <span class="mi">440</span><span class="p">);</span>
439
440    <span class="n">connection</span> <span class="n">sine</span> <span class="o">-&gt;</span> <span class="n">std</span><span class="o">::</span><span class="n">levels</span><span class="o">::</span><span class="n">ConstantGain</span> <span class="p">(</span><span class="kt">float</span><span class="p">,</span> <span class="mf">0.15</span><span class="n">f</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">out</span><span class="p">;</span>
441<span class="p">}</span>
442</code></pre></div></div>
443
444<p>If you start the patch running with:</p>
445
446<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>cmaj play AnnoyingBeep/AnnoyingBeep.cmajorpatch
447</code></pre></div></div>
448
449<p>Then you should hear a sine wave playing. While it’s running, try opening an editor on the <code class="language-plaintext highlighter-rouge">AnnoyingBeep.cmajor</code> file, and modify the “440” to change its pitch. When you re-save the file, the player should pick this up and you’ll hear the sound changing.</p>
450
451<p>As an example, let’s update the code to add a parameter for the volume. Try changing the code to:</p>
452
453<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">graph</span> <span class="n">AnnoyingBeep</span>  <span class="p">
453[[</span><span class="n">main</span><span class="p">]]</span>
454<span class="p">{</span>
455    <span class="n">output</span> <span class="n">stream</span> <span class="kt">float</span> <span class="n">out</span><span class="p">;</span>
456    <span class="n">input</span> <span class="n">gain</span><span class="p">.</span><span class="n">volume</span><span class="p">;</span>
457
458    <span class="n">node</span> <span class="n">sine</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">oscillators</span><span class="o">::</span><span class="n">Sine</span> <span class="p">(</span><span class="kt">float</span><span class="p">,</span> <span class="mi">440</span><span class="p">);</span>
459    <span class="n">node</span> <span class="n">gain</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">levels</span><span class="o">::</span><span class="n">SmoothedGain</span> <span class="p">(</span><span class="kt">float</span><span class="p">);</span>
460
461    <span class="n">connection</span> <span class="n">sine</span> <span class="o">-&gt;</span> <span class="n">gain</span><span class="p">.</span><span class="n">in</span><span class="p">;</span>
462    <span class="n">connection</span> <span class="n">gain</span><span class="p">.</span><span class="n">out</span> <span class="o">-&gt;</span> <span class="n">out</span><span class="p">;</span>
463<span class="p">}</span>
464</code></pre></div></div>
465
466<p>..and you should see a “Volume” parameter appear on the GUI which controls the level, and you’ll be relieved to be able to turn it down.</p>
467
468<p>If you type anything wrong, you’ll see the GUI go blank, and the command-line app will show you the compile errors.</p>
469
470<p>Now let’s add a parameter to control the pitch:</p>
471
472<div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">graph</span> <span class="n">AnnoyingBeep</span>  <span class="p">
472[[</span><span class="n">main</span><span class="p">]]</span>
473<span class="p">{</span>
474    <span class="n">output</span> <span class="n">stream</span> <span class="kt">float</span> <span class="n">out</span><span class="p">;</span>
475    <span class="n">input</span> <span class="n">gain</span><span class="p">.</span><span class="n">volume</span><span class="p">;</span>
476    <span class="n">input</span> <span class="n">sine</span><span class="p">.</span><span class="n">frequencyIn</span><span class="p">;</span>
477
478    <span class="n">node</span> <span class="n">sine</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">oscillators</span><span class="o">::</span><span class="n">Sine</span> <span class="p">(</span><span class="kt">float</span><span class="p">,</span> <span class="mi">440</span><span class="p">);</span>
479    <span class="n">node</span> <span class="n">gain</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">levels</span><span class="o">::</span><span class="n">SmoothedGain</span> <span class="p">(</span><span class="kt">float</span><span class="p">);</span>
480
481    <span class="n">connection</span> <span class="n">sine</span> <span class="o">-&gt;</span> <span class="n">gain</span><span class="p">.</span><span class="n">in</span><span class="p">;</span>
482    <span class="n">connection</span> <span class="n">gain</span><span class="p">.</span><span class="n">out</span> <span class="o">-&gt;</span> <span class="n">out</span><span class="p">;</span>
483<span class="p">}</span>
484</code></pre></div></div>
485
486<p>..and when you save that, the GUI should update to now have two parameter controls for volume and pitch.</p>
487
488<p>Have fun exploring - there are lots more examples to look at in the ‘examples’ folder!</p>
489
490        
491
492        
493
494        
495          <hr>
496          <footer>
497            
498              <p><a href="#top" id="back-to-top">Back to top</a></p>
499            
500            
501
502            
503              <div class="d-flex mt-2">
504                
505                
506              </div>
507            
508          </footer>
509        
510
511      </div>
512    </div>
513
514    
515      
516
517      <div class="search-overlay"></div>
518    
519  </div>
520
521  
522  
522<script>
523    var config = {
524    theme: "neutral"
525};
526    mermaid.initialize(config);
527    window.mermaid.init(undefined, document.querySelectorAll('.language-mermaid'));
528  </script>
528
529  
530</body>
531</html>
532

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.