Loading Modules
Learn how to replace the workspace with a module from a file.
Security Warning
Only load modules from sources you trust. Module expressions are executed as code when loaded. A malicious module could potentially access browser data or perform unwanted actions. Never load modules from unknown or untrusted sources.
Loading from Menu
Load from File
Load a module JSON file from your computer:
- Click the Menu button (plus/minus icon) in the top bar
- Click Load Module to expand the dropdown
- Click Load Module from file…
- Select a JSON file from your computer
- The entire workspace is replaced with the module contents
WARNING
Loading a module replaces everything in the workspace. All existing notes are removed. Save your current work first if needed!
Reset Default Module
Reset to the built-in default module (Bach's Neverending Canon):
- Click the Menu button (plus/minus icon) in the top bar
- Click Load Module to expand the dropdown
- Click Reset Default Module
- The workspace is replaced with the default module
Loading into Module Bar
You can add module files to the Module Bar for quick access:
- Expand the Module Bar (drag the pull tab below the top bar)
- Find the category where you want to add the module
- Click the + placeholder at the end of that category
- Select a JSON file from your computer
- The module appears in that category
Modules added this way are saved in your browser's local storage and persist across sessions.
See Module Bar for more details on organizing and using the Module Bar.
What Happens When You Load
When you load a module via the menu:
- Current workspace is cleared - All existing notes are removed
- BaseNote is set - From the module's baseNote definition
- Notes are created - From the module's notes array
- Expressions are compiled - To binary bytecode
- Dependencies are calculated - The dependency graph is built
- Rendering updates - The workspace displays the new content
Module File Format
Modules are JSON files with this structure:
{
"baseNote": {
"frequency": "440",
"startTime": "0",
"tempo": "120",
"beatsPerMeasure": "4"
},
"notes": [
{
"id": 1,
"frequency": "base.f * (3/2)",
"startTime": "base.t",
"duration": "beat(base)",
"color": "rgba(255, 100, 100, 0.7)",
"instrument": "sine-wave"
}
]
}Legacy JavaScript syntax (also supported)
{
"baseNote": {
"frequency": "new Fraction(440)",
"startTime": "new Fraction(0)",
"tempo": "new Fraction(120)",
"beatsPerMeasure": "new Fraction(4)"
},
"notes": [
{
"id": 1,
"frequency": "module.baseNote.getVariable('frequency').mul(new Fraction(3, 2))",
"startTime": "module.baseNote.getVariable('startTime')",
"duration": "new Fraction(60).div(module.findTempo(module.baseNote))",
"color": "rgba(255, 100, 100, 0.7)",
"instrument": "sine-wave"
}
]
}See Module Format for complete schema documentation.
Troubleshooting
Module won't load
- Check that it's a valid JSON file
- Ensure the file follows the module schema
- Look for syntax errors in expressions
- Check browser console for error messages
Notes appear in wrong positions
- Verify expression syntax is correct
- Check for circular dependencies
- Ensure referenced note IDs exist
No sound when playing
- Check that notes have valid frequency expressions
- Verify startTime and duration are set
- Ensure the module has at least one note
Tips
- Save first - Export your current work before loading a new module
- Start from saves - Load a previously saved module or one from the default set, then modify it
- Load vs Drop - Menu loading replaces the workspace; dragging from Module Bar integrates into it
- Trust the source - Only load modules from people or sources you trust