-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from Bubobubobubobubo/spl-refactoring
Merging dev branch with new features
- Loading branch information
Showing
38 changed files
with
1,105 additions
and
840 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
# Sardine Pattern Language | ||
|
||
The pattern language is everywhere in **Sardine**. Everytime you use any of the senders (`D()`, `N()`, `P()` and their lowercase variants), you are likely to encounter it. **Sardine** automatically turns every argument it receives as a `string` in an expression that is read using the **pattern language**: | ||
## What and where are patterns? | ||
|
||
You will find the pattern language pretty much everywhere in **Sardine**. Everytime you use any of the senders like `D()`, `N()`, `P()` and their lowercase variants, you are likely using the pattern language already. **Sardine** automatically turns every `string` argument it receives into a pattern using the **Sardine Pattern Language**: | ||
|
||
```python | ||
D('bd', speed=1, legato=2) # speed and legato are using regular Python types | ||
D('b', speed='1|2', legato='1~4') # speed and legato are now patterns (string) | ||
``` | ||
**Pattern Object** | ||
Sardine also has a pattern object. This is useful and required when patterning outside of Senders. Examples would be to pattern the period value in the `again()` statement, or patterning the `clock.tempo` value. | ||
|
||
See [Diving Deeper > Pattern Object](../diving_deeper/pattern_object.md). | ||
Think of it as having a second programming language inside your main programming language. This language is a welcomed addition: | ||
|
||
- It is an efficient way to create variety in the musical output of your code. | ||
- It saves space and makes it easier to express complex pattern transformations. | ||
- It gives you access to new operators that **Python** doesn't provide by default. | ||
- It makes writing lists way easier and less verbose compared to Python. | ||
|
||
Note that pattern languages are one of the basic tools used in most live coding environments. Each environment comes with its own flavour, and Sardine comes with multiple pattern languages! | ||
|
||
### Patterning - a programming language within | ||
You can't even use a synthesizer or play a note without writing at least one pattern (the initial string). One call to the senders/handlers can result in multiple patterns being interpreted by the **Sardine pattern language** at once. | ||
## Pattern Object | ||
|
||
Think of it as having a second programming language inside your main programming language. | ||
Sardine also has a pattern object, named `P()`. This object is very useful when you start exploring on your own and start building your own abstractions. The most typical usage of the `P()` is to pattern the `again` call in a **swimming function** like so: | ||
|
||
So, why use the Sardine pattern language? | ||
```python | ||
@swim | ||
def donothing(p=1, i=0): | ||
print('I do nothing really interesting!') | ||
again(donothing, p=P('1 2 0.5!4', i), i=i+1) | ||
``` | ||
|
||
- It is an efficient way to create change and variety in musical output. | ||
- It saves space, it makes it easier to express complex transformations fast. | ||
- It gives you access to new operators that **Python** doesn't provide. | ||
- It makes writing lists way easier and less verbose. | ||
- It is the key that unlocks Sardine's expressive potential. | ||
- Patterning is a basic tool available in most livecoding environments. | ||
If you want to learn more about it, I encourage you to read: [Diving Deeper > Pattern Object](../diving_deeper/pattern_object.md). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 60 additions & 76 deletions
136
docs/sardine_doc/src/pattern_languages/sardine/combinatorics_functions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,88 @@ | ||
# Combinatorics | ||
|
||
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"> | ||
This category of functions is containing many functions that perform many simple but important operations on lists. | ||
|
||
<colgroup> | ||
# rev | ||
|
||
<col class="org-left" /> | ||
Reverse a list. | ||
|
||
<col class="org-left" /> | ||
- **Arguments:** | ||
- **None** | ||
|
||
<col class="org-left" /> | ||
**Example:** | ||
```python | ||
(rev 1 2 3 [1 2 3]) | ||
``` | ||
|
||
<col class="org-left" /> | ||
</colgroup> | ||
<tbody> | ||
<tr> | ||
<td class="org-left">Function name</td> | ||
<td class="org-left"> Arguments</td> | ||
<td class="org-left">Description</td> | ||
<td class="org-left">Return type</td> | ||
</tr> | ||
# pal | ||
|
||
Creates a palindrome. This will keep the list as is but will also append the list in reverse. | ||
|
||
<tr> | ||
<td class="org-left">invert</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">???</td> | ||
<td class="org-left"> </td> | ||
</tr> | ||
- **Arguments:** | ||
- **cut:** whether to repeat the last/first value of reversed list or not. | ||
|
||
**Example:** | ||
```python | ||
(pal [1:10] ::cut 1) # or ::cut 0 | ||
``` | ||
|
||
<tr> | ||
<td class="org-left">aspeed</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">Add one more silence to the pattern for every element it crosses.</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
# shuf | ||
|
||
Shuffle any list. | ||
|
||
<tr> | ||
<td class="org-left">expand</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left"> </td> | ||
<td class="org-left"> </td> | ||
</tr> | ||
Description ... | ||
- **Arguments:** | ||
- **None** | ||
|
||
**Example:** | ||
```python | ||
(shuf 1 2 3 4 5) | ||
``` | ||
|
||
<tr> | ||
<td class="org-left">pal</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">Return a palindrome of the given pattern</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
# leave | ||
|
||
Braid multiple lists of uneven length. | ||
|
||
<tr> | ||
<td class="org-left">rev</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">Reverse the pattern</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
- **Arguments:** | ||
- **...:** feed multiple lists to braid them together. | ||
|
||
**Example:** | ||
```python | ||
(leave [1 2 3] [3 4 5] [1 2] [4 8 6 4]) | ||
``` | ||
|
||
<tr> | ||
<td class="org-left">leave</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">Interleave function</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
# insertp | ||
|
||
Insert a fixed element as pair element of each list. | ||
|
||
<tr> | ||
<td class="org-left">insertp</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">Braid a pattern with the first pattern being even and the second odd index numbers</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
- **Arguments:** | ||
- **None** | ||
|
||
**Example:** | ||
```python | ||
``` | ||
|
||
<tr> | ||
<td class="org-left">insert</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">???</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
# insert | ||
|
||
Insert a fixed element as odd element of each list. | ||
|
||
<tr> | ||
<td class="org-left">insertprot</td> | ||
<td class="org-left"> </td> | ||
<td class="org-left">???</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
- **Arguments:** | ||
- **None** | ||
|
||
**Example:** | ||
```python | ||
``` | ||
|
||
<tr> | ||
<td class="org-left">shuf</td> | ||
<td class="org-left">[pattern]</td> | ||
<td class="org-left">Shuffle/randomize a given pattern</td> | ||
<td class="org-left">[pattern]</td> | ||
</tr> | ||
# insertprot | ||
|
||
</tbody> | ||
</table> | ||
Description ... | ||
|
||
- **Arguments:** | ||
- **None** | ||
|
||
**Example:** | ||
```python | ||
``` | ||
|
||
# insertrot | ||
# aspeed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
docs/sardine_doc/src/pattern_languages/sardine/euclidian_functions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.