Skip to content

Language Documentation

Antiloope edited this page Oct 12, 2020 · 17 revisions

Welcome to ChordScript language documentation

Intro

This documentation is a detailed description of the main syntax and characteristics of the language with examples on each section. It's designed for developers and it can be a bit tedious. If you are new with ChordScript, you should start with the tutorial and go back here if you have a specific query.

Index

  1. Intro

  2. Language basics

  3. Data types and methods

  4. Flow control

  5. Functions

  6. Synthesis

  7. Annex: Pre-defined variables

Language basics

What CS do?

ChordScript is a dynamic, strongly typed and interpreted language, that executes code to generate sounds. In order to execute sounds on different operative systems, it needs to "connect" with different sound systems and drivers.

To simplify this communication, ChordScript uses Jack Audio Connection Kit. It works as a server mounted over current OS sound diver, and ChordScript connects to it as a client. For this reason, when you install CS you also install Jack. This architecture, does not only makes ChordScript able to run on different OS, but also offers the possibility to work with low latency audio generation.

So, CS allows you to trigger pre-recorded samples, synthesize sounds using basic functions and apply some effects on this sounds, using programming as interface.

For this reasons, ChordScript can be a good alternative for live coding, creative coding, algorithmic composition or for any musician/programmer who wants to use programming as a powerful instrument for composition, giving also the possibility to record and store it as a .wav file.

General syntax

ChordScript takes some syntax rules from other popular languages. This decision was made to take it easy to learn other languages if you start your programming path here. It takes the strong rules of C/C++ and the dynamics of python.

Here is a list with the basic rules:

  • The type of a variable must be specified in assignation:

  • number myVariable = 10;

See data types section for a list of all valid data types

  • Assignations and executions lines, must end with a semicolon:

  • string name = "my name";

  • Variable names must start with a letter and can continue with more letters, numbers or the character underscore '_' :

  • MyVariable_3 Valid name.

  • 4_aVariable Invalid name.

Demo examples

There are some code examples that you can copy and paste in your ChordScript IDE and then modify or play to understand or take as a base for your compositions. If you want to install the IDE go to the ChordScript Page.

This demo, shows a lot of capabilities of the language. In order to read simpler examples continue to specific sections.

Base with simple chords

** Insert example here **

Synthesize using loops

** Insert example here **

Data types and methods

There are a list with all data types in ChordScript:

Basics

  • number
  • boolean
  • string
  • argument
  • group (not implemented yet)
  • array (not implemented yet)

Playables

  • sound
  • sample

Some of this data types has defined methods that are listed and explained on each particular section.

Basic types

Basic types are data types that are useful for programming but has not a particular usage for playing music. These are used as control variables in for loops, as flags in flow control or in general to simplify the algorithmic programming.

number

In the code, numbers are simply any kind of number, with or without decimal part. Some examples of numbers could be number myNumber = 1; or number mySecondNumber = 4.53;

Only a dot can be used to separate decimal part, comma it's not allowed.

Playables

Flow control

FOR statement

IF statement

Functions

Definition

Synthesis

Concepts

Operations

Pre-defined variables

Clone this wiki locally