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

tonal fixes #607

Merged
merged 3 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tonal/tonal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const scaleTranspose = register('scaleTranspose', function (offset /* : n
export const scale = register('scale', function (scale, pat) {
// Supports ':' list syntax in mininotation
if (Array.isArray(scale)) {
scale = scale.join(' ');
scale = scale.flat().join(' ');
}
return pat.withHap((hap) => {
const isObject = typeof hap.value === 'object';
Expand Down
2 changes: 1 addition & 1 deletion website/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const SIDEBAR: Sidebar = {
{ text: 'Signals', link: 'learn/signals' },
{ text: 'Conditional Modifiers', link: 'learn/conditional-modifiers' },
{ text: 'Accumulation', link: 'learn/accumulation' },
{ text: 'Tonal Modifiers', link: 'learn/tonal' },
{ text: 'Tonal Functions', link: 'learn/tonal' },
],
Development: [
{ text: 'REPL', link: 'technical-manual/repl' },
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/learn/accumulation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ import { JsDoc } from '../../docs/JsDoc';

<JsDoc client:idle name="stut" h={0} />

There are also [Tonal Modifiers](/learn/tonal).
There are also [Tonal Functions](/learn/tonal).
34 changes: 17 additions & 17 deletions website/src/pages/learn/tonal.mdx
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
---
title: Tonal API
title: Tonal Functions
layout: ../../layouts/MainLayout.astro
---

import { MiniRepl } from '../../docs/MiniRepl';
import { JsDoc } from '../../docs/JsDoc';

# Tonal API
# Tonal Functions

The Tonal API, uses [tonaljs](https://github.com/tonaljs/tonal) to provide helpers for musical operations.

### transpose(semitones)

Transposes all notes to the given number of semitones:

<MiniRepl client:only="react" tune={`"c2 c3".fast(2).transpose("<0 -2 5 3>".slow(2)).note()`} />

This method gets really exciting when we use it with a pattern as above.

Instead of numbers, scientific interval notation can be used as well:

<MiniRepl client:only="react" tune={`"c2 c3".fast(2).transpose("<1P -2M 4P 3m>".slow(2)).note()`} />
These functions use [tonaljs](https://github.com/tonaljs/tonal) to provide helpers for musical operations.

### scale(name)

Expand All @@ -29,14 +17,26 @@ Turns numbers into notes in the scale (zero indexed). Also sets scale for other
<MiniRepl
client:idle
tune={`"0 2 4 6 4 2"
.scale(seq('C2 major', 'C2 minor').slow(2))
.note()`}
.scale("C2:major C2:minor").slow(2))
.note().s("piano")`}
/>

Note that the scale root is octaved here. You can also omit the octave, then index zero will default to octave 3.

All the available scale names can be found [here](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts).

### transpose(semitones)

Transposes all notes to the given number of semitones:

<MiniRepl client:only="react" tune={`"c2 c3".fast(2).transpose("<0 -2 5 3>".slow(2)).note()`} />

This method gets really exciting when we use it with a pattern as above.

Instead of numbers, scientific interval notation can be used as well:

<MiniRepl client:only="react" tune={`"c2 c3".fast(2).transpose("<1P -2M 4P 3m>".slow(2)).note()`} />

### scaleTranspose(steps)

Transposes notes inside the scale by the number of steps:
Expand Down