About CakeScript
BandLab Membership
CakeScript is exclusive to active BandLab Membership subscribers.
CakeScript is a modern, Lua-based scripting interface built into Cakewalk Sonar. It replaces the legacy Cakewalk Application Language (CAL) with a safer, more powerful, and extensible scripting platform.
CakeScript lets you automate repetitive tasks, manipulate projects, and create custom workflows directly within Cakewalk Sonar. Whether you're creating simple utility scripts or building advanced automation, CakeScript provides a modern foundation for extending Sonar's capabilities.
Note
This article provides an overview of CakeScript and how it works in Cakewalk Sonar. It is intended for users who have a basic understanding of the Lua programming language.
What can CakeScript do?
CakeScript provides access to many areas of a Sonar project, allowing scripts to automate common editing and management tasks.
With CakeScript, you can:
- Open, save, and close projects
- Create, modify, move, and delete tracks, folders, and buses
- Add, edit, and remove audio or MIDI clips
- Import media into a project
- Add, modify, and remove sends
- Add, modify, reorder, or remove audio effects on tracks and buses
- Create and edit automation envelopes
- Modify project selections
- Change application and project settings
- Run built-in Sonar commands
- Execute other CakeScript scripts
- Convert between musical and absolute time
- Control the project Now Time
Running a CakeScript
CakeScript files use the .lua file extension.
To run a CakeScript:
- Open Process > Run CakeScript.
- Browse to the desired
.luafile. - Select the script and click Open.
Important
CakeScript cannot be executed while playback or recording is in progress.
Using the CakeScript Panel
The CakeScript panel provides an interface for browsing, running, and debugging CakeScript files directly within Cakewalk Sonar.
The panel consists of the following sections:
Tab Heading
The CakeScript panel contains two tabs:
- Script
Displays the CakeScript directory as a file tree, allowing you to browse available scripts.
- Output
Displays script output, including messages from the Lua
printcommand, trace information, and any script errors.
CakeScript Directory
The Script tab displays the configured CakeScript directory as a file tree.
- Single-click a script to select it.
- Double-click a script to run it using the currently selected Run Mode.
Current Script
Displays the name of the currently selected CakeScript.
Run Mode
CakeScript supports three execution modes:
- Normal
Runs the script from start to finish. Any output generated by the script is displayed in the Output tab.
- Trace
Executes the script while displaying each statement in the Output tab as it runs. This is useful for following the script's execution.
- Step
Runs the script one statement at a time. The Output tab displays the next statement that will be executed.
While paused in Step mode, you can interact with the Cakewalk Sonar interface to verify the results before continuing. Avoid making changes that could affect the script's expected state.
To continue execution, click Step. To stop execution, click Stop.
Note
Scripts run significantly slower in Trace and Step modes than in Normal mode.
Run / Stop Button
When displaying the Run (▶) icon, clicking the button starts the selected CakeScript using the current Run Mode.
When a script is paused in Step mode, the button changes to Stop (■), allowing you to cancel script execution.
Step Button
When using Step mode, click Step to execute the next statement in the script.
Undo Protection
CakeScript is designed to safely modify your project.
When a script completes successfully, all changes made by the script are stored as a single Undo step. This allows you to undo the entire operation with a single Undo command.
If a script encounters an error while running, Cakewalk Sonar automatically restores the project to its previous state and displays the reason the script failed.
Current Limitations
CakeScript is still under active development. At this time, the following features are not available or are only partially supported:
- Take Lanes and Automation Lanes
- Tempo Track and Tempo Map
- Meter and Key Changes
- Markers
- Arranger
- FX Chains (partial support only)
Additional functionality will be introduced in future Cakewalk Sonar releases.
Learn More
For complete documentation of the CakeScript API, Lua objects, classes, and available functions, see the CakeScript Reference Guide included with Cakewalk Sonar.
To open the reference guide:
- Launch Cakewalk Sonar.
- Go to Help > CakeScript Reference Guide.
If you're looking for examples, have questions about writing scripts, or want to share your own, visit the CakeScript section of the Cakewalk Community forum:
https://discuss.cakewalk.com/forum/54-cakescript/
The CakeScript community is a great place to learn from other users, discover community-created scripts, ask questions, and share your own CakeScript projects.
Comments
Article is closed for comments.