Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correcting examples of vortex functions #270

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/sardine_doc/src/pattern_languages/vortex/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ These functions typically take up to **n** patterns to form a single pattern tha
- `layer`: Layer up multiple functions on one pattern. For example, the following will play two versions of the pattern at the same time, one reversed and one at twice the speed.

```python
d1 * s("arpy [~ arpy:4]").layer(rev, lambda p: p.fast(2)])
d1 * s("arpy [~ arpy:4]").layer(rev, lambda p: p.fast(2))
```

If you want to include the original version of the pattern in the layering, use the `id` function:

```python
d1 * s("arpy [~ arpy:4]").layer(id, rev, lambda p: p.fast(2)])
d1 * s("arpy [~ arpy:4]").layer(id, rev, lambda p: p.fast(2))
```

## Pattern degradation
Expand Down Expand Up @@ -118,7 +118,7 @@ The `sometimes` family of function can sometimes apply a function to a pattern..
d1 * s('drum(5,8)').n('1 2 3 4').always(fast(2))
```

- `almostAlways`: will apply the function 90% of the time, at random.
- `almostAlways` | `almost_always`: will apply the function 90% of the time, at random.

```python
d1 * s('drum(5,8)').n('1 2 3 4').almostAlways(fast(2))
Expand Down Expand Up @@ -146,7 +146,7 @@ The `sometimes` family of function can sometimes apply a function to a pattern..
d1 * s('drum(5,8)').n('1 2 3 4').rarely(fast(2))
```

- `almostNever`: will apply the function 10% of the time, at random.
- `almostNever` | `almost_never`: will apply the function 10% of the time, at random.

```python
d1 * s('drum(5,8)').n('1 2 3 4').almostNever(fast(2))
Expand All @@ -163,7 +163,7 @@ The `sometimes` family of function can sometimes apply a function to a pattern..
- `every`: allows you to apply a function based on a condition. You need a function to determine when the function should be applied (*e.g.* a number **n** to apply the function every **n** cycles). You also need a transformation such as `rev` (reverse a pattern) or `fast` (make a pattern faster).

```python
d1 * s('[bd(5,8), jvbass(3,8)]').every(3, lambda p: p.superimpose(fast 2))
d1 * s('[bd(5,8), jvbass(3,8)]').every(3, lambda p: p.superimpose(fast(2)))
```

- `somecycles`: Apply a function on certain cycles (*e.g* on cycle `3`) ???
Expand Down Expand Up @@ -325,7 +325,7 @@ Signal functions are functions generating streams of values to apply to a patter
- `run`
- `scan`

- `choosewith`
- `choose_with`
- `choose`
- `choose_cycles`
- `wchoose`
2 changes: 1 addition & 1 deletion sardine_core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
player_names.remove("SC") # NOTE: used by SuperCollider command
player_names.remove("PC") # NOTE: used by MIDI Program Change
# player_names += [''.join(tup) for tup in list(product(ascii_lowercase, repeat=3))]
for player in player_names:
for player in filter(lambda p: p not in ['id'], player_names):
p = Player(name=player)
globals()[player] = p
bowl.add_handler(p)
Expand Down
23 changes: 22 additions & 1 deletion sardine_core/sequences/tidal_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,33 @@ def tidal(key, pattern=None, data_only: bool = False):


def hush_factory(env, osc_client, tidal_players):
def hush():
def _hush_all():
for stream in __streams.values():
stream.pattern = silence
tidal_players.remove(stream)
__streams.clear()

def _hush(pat):
streams = (
(n, s) for n, s in __streams.items() if pat in [n, s.name]
)
name, stream = next(streams, (None, None))
if not stream:
raise TypeError(f'Stream "{pat}" not found')

stream.pattern = silence
tidal_players.remove(stream)
__streams.pop(name)

def hush(pat=None):
if pat is None:
return _hush_all()
if isinstance(pat, str):
return _hush(pat)
if not hasattr(pat, 'name') or not isinstance(pat.name, str):
raise TypeError(f'Object of type {type(pat)} is not recognized')
_hush(pat.name)

return hush


Expand Down
10 changes: 10 additions & 0 deletions sardine_core/sequences/tidal_parser/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
"hcutoff",
"a pattern of numbers from 0 to 1. Applies the cutoff frequency of the high-pass filter. Also has alias @hpf@",
),
(
"f",
"hpf",
"a pattern of numbers from 0 to 1. Applies the cutoff frequency of the high-pass filter.",
),
(
"f",
"hold",
Expand All @@ -120,6 +125,11 @@
"hresonance",
"a pattern of numbers from 0 to 1. Applies the resonance of the high-pass filter. Has alias @hpq@",
),
(
"f",
"hpq",
"a pattern of numbers from 0 to 1. Applies the resonance of the high-pass filter.",
),
("f", "lagogo", ""),
("f", "lclap", ""),
("f", "lclaves", ""),
Expand Down
9 changes: 5 additions & 4 deletions sardine_core/sequences/tidal_parser/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,21 +810,22 @@ def sometimes(self, func):
def always(self, func):
return self.sometimes_by(1.0, func)

def always(self, func):
return self.sometimes_by(1.0, func)

def almost_always(self, func):
return self.sometimes_by(0.9, func)

almostAlways = almost_always

def often(self, func):
return self.sometimes_by(0.75, func)

def rarely(self, func):
return self.sometimes_by(0.25, func)

def almostNever(self, func):
def almost_never(self, func):
return self.sometimes_by(0.10, func)

almostNever = almost_never

def never(self, func):
return self.sometimes_by(0.0, func)

Expand Down