codeformat
This commit is contained in:
parent
858f4f74b3
commit
51a4c4d13b
8 changed files with 60 additions and 40 deletions
|
|
@ -9,7 +9,7 @@ import { JsDoc } from '../../docs/JsDoc';
|
|||
|
||||
# Strudel Code
|
||||
|
||||
Now that we have played some notes using different sounds, let's take a step back and look how we actually achieved this using _code_.
|
||||
Now that we have played some notes using different sounds, let's take a step back and look how we actually achieved this using _code_.
|
||||
|
||||
Let's look at this simple example again. What do we notice?
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ So far, we've seen the following syntax:
|
|||
xxx("foo").yyy("bar")
|
||||
```
|
||||
|
||||
Generally, `xxx` and `yyy` are called [_functions_](https://en.wikipedia.org/wiki/Function_(computer_programming)), while `foo` and `bar` are called function [_arguments_ or _parameters_](https://en.wikipedia.org/wiki/Parameter_(computer_programming)).
|
||||
Generally, `xxx` and `yyy` are called [_functions_](<https://en.wikipedia.org/wiki/Function_(computer_programming)>), while `foo` and `bar` are called function [_arguments_ or _parameters_](<https://en.wikipedia.org/wiki/Parameter_(computer_programming)>).
|
||||
So far, we've used the functions to declare which aspect of the sound we want to control, and their arguments for the actual data.
|
||||
The `yyy` function is called a [_chained_ function](https://en.wikipedia.org/wiki/Method_chaining), because it is appended with a dot (`.`).
|
||||
|
||||
|
|
@ -52,7 +52,8 @@ You can think of this as being similar to chaining audio effects together using
|
|||
|
||||
Strudel makes heavy use of chained functions. Here is a more sophisticated example:
|
||||
|
||||
<MiniRepl client:idle
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`note("a3 c#4 e4 a4")
|
||||
.s("sawtooth")
|
||||
.cutoff(500)
|
||||
|
|
@ -63,14 +64,14 @@ Strudel makes heavy use of chained functions. Here is a more sophisticated examp
|
|||
# Comments
|
||||
|
||||
The `//` in the example above is a line comment, resulting in the `delay` function being ignored.
|
||||
It is a handy way to quickly turn code on and off.
|
||||
It is a handy way to quickly turn code on and off.
|
||||
Try uncommenting this line by deleting `//` and refreshing the pattern.
|
||||
You can also use the keyboard shortcut `cmd-/` to toggle comments on and off.
|
||||
|
||||
# Strings
|
||||
|
||||
Ok, so what about the content inside the quotes (e.g. `"a3 c#4 e4 a4"`)?
|
||||
In JavaScript, as in most programming languages, this content is referred to as being a [_string_](https://en.wikipedia.org/wiki/String_(computer_science)).
|
||||
Ok, so what about the content inside the quotes (e.g. `"a3 c#4 e4 a4"`)?
|
||||
In JavaScript, as in most programming languages, this content is referred to as being a [_string_](<https://en.wikipedia.org/wiki/String_(computer_science)>).
|
||||
A string is simply a sequence of individual characters.
|
||||
In TidalCycles, strings are used to write _patterns_ using the mini-notation, and you may hear the phrase _pattern string_ from time to time.
|
||||
|
||||
|
|
@ -78,4 +79,4 @@ The good news is, that this covers 99% of the JavaScript syntax needed for Strud
|
|||
|
||||
Let's now look at the way we can express [Rhythms](/learn/mini-notation)...
|
||||
|
||||
<br/>
|
||||
<br />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue