A Sublime Text 3 plugin for ChucK, featuring syntax highlighting, tab completion, snippets (and maybe REPL-ish sessions).
Currently to get sounds out of Sublime Text 3 + ChucK we've set up a simple build script. If you are new to SublimeText, the menu to look for is located in Tools -> Build System. If automatic is not ticked then tick it, or you can set it manually by selecting ChucK from this list. To hear some sounds:
.ck
to wav.wav
it can open your sound editor, if it's a .ck
it opens insitu.Build, Run, Cancel Build, and Kill are implemented. This means you write code, hit the CTRL+ENTER shortcut, and Sublime will send the file to play to ChucK . Run (CTRL+SHIFT+ENTER) will execute ChucK with an innitialize.ck
if one is in the same directory as the file in the current tab - no switching back-and-forth. Cancel Build (CTRL+C / CTRL+BREAK)[1] will end that ChucK instance. Kill (CTRL+ALT+ENTER) will end the most-recently launched chuck instance, and then the next most-recent, etc. The great thing about keeping the code editing and the ChucK player separate is that if ChucK crashes it doesn't affect Sublime. This is unlike the miniAudicle; if ChucK crashes, most likely so will the miniAudicle.
Goto error (bound to F4). When you encounter an error, if ChucK was able to provide the line on which the error occured, the error information will be printed in the ST status line. Hitting F4 will navigate the Sublime editor to that line and file (and subsequent lines, if any).
Syntax definition/coloring of all major language constructs (types, syntax etc). If your code looks OK, this is a good first indication that your syntax is correct. There are a few subtle bugs listed at the end in the bugs section, but they do not impede beyond aesthetics.
We've included many objects and methods which appear in the ChucK language. This helps you type less and shows correct spelling for the built-in stuff. Very much a work in progress.
Some short, commonly used, syntactical structures (e.g. while loops) can be inserted with only a few keystrokes.
pr
and hitting enter will insert <<< >>>;
arr
and enter will insert an array declaration; first enter the type, then hit TAB, then fill in the array name. This will produce @=> <int,string,..etc> array_name[]
.chuck_doc_search.py: searches the ChucK online help for the currently selected word. It takes:
Std
and Math
will also work; try a doc search on Math.max
or Std.mtof
.iternotate.py: despite the awkward name, this saves you from typing full for-loops. Enter the shorthand and press the keyboard shortcut and watch it expand.
i..n
(where i
is your chosen iteration variable name, and n
is a number or an int variable).i..array_name[]
can be used if you want to iterate over an array.// i..5
for(0 => int i; i<5; i++){
i;
}
// i..num_times
for(0 => int i; i<num_times; i++){
i;
}
// i..iterable[ or i..iterable[]
for(0 => int i; i<iterable.cap(); i++){
iterable[i];
}
default shortcut: "ctrl+shift+w"
Writes the current ChucK file as stereo wav to disk. We use the concept of an inline console to tell chuck_wav_writer.py what to do. An inline console is a specific set of instructions in the form of a comment. For example:
SinOsc d => dac;
20::second => now; // %> 20:demo_sound
or, add a gain value. Range 0.0 and upwards. The default, when omitted, is 1.0
SinOsc d => dac;
20::second => now; // %> 20:demo_sound:0.67
If the cursor caret is on the line with the comment using the %>
token it will try to parse what is after it. "20" means you want that many seconds, demo_sound is the name of the output stereo wav you will record.
Machine.add(me.dir() + "/kicks.ck")
, and want to see that file, simply place the key caret on that line and right-click to get the context menu. Choose "Open file under cursor..", to open the file in the current Sublime Text view.me.dir() + "/sound.wav"
Sublime will attempt to open the .wav
in your configured sound editor.The issue tracker is a good place to look if you encounter a bug, or to justify/defend a feature request. It's where we go to discuss ideas and resolve bugs.
The menu is implemented but currently it is a stub, so avoid using it for now. There are renovations going on in the code for those menu items. We have no clear timeframe for this todo, it may even happen that the ChucK menu is ditched in favour of the REPL as a console, or inline console comment-commands as implemented in chuck_wav_writer.py.
The list:
--shell
mode (server).{}
as an "on the fly" shred).The default keybinds for chuck_doc_search and iternotate conflict with Fold/Unfold.
Probably many, but we are aware of these:
Build
a shred while another shred is playing, you cannot stop the first shred anymore.
import subprocess
then subprocess.call(["chuck", "--kill"])
. This kills it with fire..cap()
will render the rest of the line in white.//
comments will sometimes cause weird highlighting in the comment itself.url#section
the same way. This issue is compounded by the ChucK docs using inconsistent rules for named ids. More about this topic here[1] CTRL+BREAK doesn't seem to work with all keyboards.