adding interaction page in documentation
This commit is contained in:
@ -127,6 +127,7 @@
|
|||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<p rel="noopener noreferrer" id="docs_introduction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Introduction </p>
|
<p rel="noopener noreferrer" id="docs_introduction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Introduction </p>
|
||||||
<p rel="noopener noreferrer" id="docs_interface" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interface</p>
|
<p rel="noopener noreferrer" id="docs_interface" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interface</p>
|
||||||
|
<p rel="noopener noreferrer" id="docs_interaction" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Interaction</p>
|
||||||
<p rel="noopener noreferrer" id="docs_shortcuts" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Keyboard</p>
|
<p rel="noopener noreferrer" id="docs_shortcuts" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Keyboard</p>
|
||||||
<p rel="noopener noreferrer" id="docs_code" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Coding</p>
|
<p rel="noopener noreferrer" id="docs_code" class="pl-2 pr-2 lg:text-xl text-sm hover:bg-neutral-800 py-1 my-1 rounded-lg">Coding</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { introduction } from "./documentation/introduction";
|
|||||||
import { samples } from "./documentation/samples";
|
import { samples } from "./documentation/samples";
|
||||||
import { chaining } from "./documentation/chaining";
|
import { chaining } from "./documentation/chaining";
|
||||||
import { software_interface } from "./documentation/interface";
|
import { software_interface } from "./documentation/interface";
|
||||||
|
import { interaction } from "./documentation/interaction";
|
||||||
import { time } from "./documentation/time";
|
import { time } from "./documentation/time";
|
||||||
import { midi } from "./documentation/midi";
|
import { midi } from "./documentation/midi";
|
||||||
import { code } from "./documentation/code";
|
import { code } from "./documentation/code";
|
||||||
@ -53,6 +54,7 @@ export const documentation_factory = (application: Editor) => {
|
|||||||
return {
|
return {
|
||||||
introduction: introduction(application),
|
introduction: introduction(application),
|
||||||
interface: software_interface(application),
|
interface: software_interface(application),
|
||||||
|
interaction: interaction(application),
|
||||||
code: code(application),
|
code: code(application),
|
||||||
time: time(application),
|
time: time(application),
|
||||||
sound: sound(application),
|
sound: sound(application),
|
||||||
|
|||||||
@ -22,7 +22,7 @@ ${makeExample(
|
|||||||
v('my_cool_variable', 2)
|
v('my_cool_variable', 2)
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Getting that variable back and printing!",
|
"Getting that variable back and printing!",
|
||||||
@ -31,7 +31,7 @@ ${makeExample(
|
|||||||
log(v('my_cool_variable'))
|
log(v('my_cool_variable'))
|
||||||
`,
|
`,
|
||||||
false
|
false
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
## Counter and iterators
|
## Counter and iterators
|
||||||
@ -55,7 +55,7 @@ ${makeExample(
|
|||||||
rhythm(.25, 6, 8) :: sound('dr').n($(1)).end(.25).out()
|
rhythm(.25, 6, 8) :: sound('dr').n($(1)).end(.25).out()
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Using a more complex counter",
|
"Using a more complex counter",
|
||||||
@ -64,7 +64,7 @@ ${makeExample(
|
|||||||
rhythm(.25, 6, 8) :: sound('dr').n($(1, 20, 5)).end(.25).out()
|
rhythm(.25, 6, 8) :: sound('dr').n($(1, 20, 5)).end(.25).out()
|
||||||
`,
|
`,
|
||||||
false
|
false
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Calling the drunk mechanism",
|
"Calling the drunk mechanism",
|
||||||
@ -73,7 +73,7 @@ ${makeExample(
|
|||||||
rhythm(.25, 6, 8) :: sound('dr').n(drunk()).end(.25).out()
|
rhythm(.25, 6, 8) :: sound('dr').n(drunk()).end(.25).out()
|
||||||
`,
|
`,
|
||||||
false
|
false
|
||||||
)}
|
)}
|
||||||
|
|
||||||
## Scripts
|
## Scripts
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ ${makeExample(
|
|||||||
beat(1) :: script(1)
|
beat(1) :: script(1)
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Calling mutliple scripts at the same time.",
|
"Calling mutliple scripts at the same time.",
|
||||||
@ -97,48 +97,10 @@ ${makeExample(
|
|||||||
beat(1) :: script(1, 3, 5)
|
beat(1) :: script(1, 3, 5)
|
||||||
`,
|
`,
|
||||||
false
|
false
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Mouse
|
|
||||||
|
|
||||||
You can get the current position of the mouse on the screen by using the following functions:
|
|
||||||
|
|
||||||
- <ic>mouseX()</ic>: the horizontal position of the mouse on the screen (as a floating point number).
|
|
||||||
- <ic>mouseY()</ic>: the vertical position of the mouse on the screen (as a floating point number).
|
|
||||||
|
|
||||||
${makeExample(
|
|
||||||
"FM Synthesizer controlled using the mouse",
|
|
||||||
`
|
|
||||||
beat(.25) :: sound('sine')
|
|
||||||
.fmi(mouseX() / 100)
|
|
||||||
.fmh(mouseY() / 100)
|
|
||||||
.vel(0.2)
|
|
||||||
.room(0.9).out()
|
|
||||||
`,
|
|
||||||
true
|
|
||||||
)}
|
|
||||||
|
|
||||||
Current mouse position can also be used to generate notes:
|
|
||||||
|
|
||||||
- <ic>noteX()</ic>: returns a MIDI note number (0-127) based on the horizontal position of the mouse on the screen.
|
|
||||||
- <ic>noteY()</ic>: returns a MIDI note number (0-127) based on the vertical position of the mouse on the screen.
|
|
||||||
|
|
||||||
|
|
||||||
${makeExample(
|
|
||||||
"The same synthesizer, with note control!",
|
|
||||||
`
|
|
||||||
beat(.25) :: sound('sine')
|
|
||||||
.fmi(mouseX() / 100)
|
|
||||||
.note(noteX())
|
|
||||||
.fmh(mouseY() / 100)
|
|
||||||
.vel(0.2)
|
|
||||||
.room(0.9).out()
|
|
||||||
`,
|
|
||||||
true
|
|
||||||
)}
|
|
||||||
|
|
||||||
## Low Frequency Oscillators
|
## Low Frequency Oscillators
|
||||||
|
|
||||||
Low Frequency Oscillators (_LFOs_) are an important piece in any digital audio workstation or synthesizer. Topos implements some basic waveforms you can play with to automatically modulate your paremeters.
|
Low Frequency Oscillators (_LFOs_) are an important piece in any digital audio workstation or synthesizer. Topos implements some basic waveforms you can play with to automatically modulate your paremeters.
|
||||||
@ -150,7 +112,7 @@ ${makeExample(
|
|||||||
"Modulating the speed of a sample player using a sine LFO",
|
"Modulating the speed of a sample player using a sine LFO",
|
||||||
`beat(.25) && snd('cp').speed(1 + usine(0.25) * 2).out()`,
|
`beat(.25) && snd('cp').speed(1 + usine(0.25) * 2).out()`,
|
||||||
true
|
true
|
||||||
)};
|
)};
|
||||||
|
|
||||||
- <ic>triangle(freq: number = 1, offset: number= 0): number</ic>: returns a triangle oscillation between <ic>-1</ic> and <ic>1</ic>.
|
- <ic>triangle(freq: number = 1, offset: number= 0): number</ic>: returns a triangle oscillation between <ic>-1</ic> and <ic>1</ic>.
|
||||||
- <ic>utriangle(freq: number = 1, offset: number= 0): number</ic>: returns a triangle oscillation between <ic>0</ic> and <ic>1</ic>. The <ic>u</ic> stands for _unipolar_.
|
- <ic>utriangle(freq: number = 1, offset: number= 0): number</ic>: returns a triangle oscillation between <ic>0</ic> and <ic>1</ic>. The <ic>u</ic> stands for _unipolar_.
|
||||||
@ -160,7 +122,7 @@ ${makeExample(
|
|||||||
"Modulating the speed of a sample player using a triangle LFO",
|
"Modulating the speed of a sample player using a triangle LFO",
|
||||||
`beat(.25) && snd('cp').speed(1 + utriangle(0.25) * 2).out()`,
|
`beat(.25) && snd('cp').speed(1 + utriangle(0.25) * 2).out()`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
- <ic>saw(freq: number = 1, offset: number= 0): number</ic>: returns a sawtooth-like oscillation between <ic>-1</ic> and <ic>1</ic>.
|
- <ic>saw(freq: number = 1, offset: number= 0): number</ic>: returns a sawtooth-like oscillation between <ic>-1</ic> and <ic>1</ic>.
|
||||||
- <ic>usaw(freq: number = 1, offset: number= 0): number</ic>: returns a sawtooth-like oscillation between <ic>0</ic> and <ic>1</ic>. The <ic>u</ic> stands for _unipolar_.
|
- <ic>usaw(freq: number = 1, offset: number= 0): number</ic>: returns a sawtooth-like oscillation between <ic>0</ic> and <ic>1</ic>. The <ic>u</ic> stands for _unipolar_.
|
||||||
@ -170,7 +132,7 @@ ${makeExample(
|
|||||||
"Modulating the speed of a sample player using a saw LFO",
|
"Modulating the speed of a sample player using a saw LFO",
|
||||||
`beat(.25) && snd('cp').speed(1 + usaw(0.25) * 2).out()`,
|
`beat(.25) && snd('cp').speed(1 + usaw(0.25) * 2).out()`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
- <ic>square(freq: number = 1, offset: number= 0, duty: number = .5): number</ic>: returns a square wave oscillation between <ic>-1</ic> and <ic>1</ic>. You can also control the duty cycle using the <ic>duty</ic> parameter.
|
- <ic>square(freq: number = 1, offset: number= 0, duty: number = .5): number</ic>: returns a square wave oscillation between <ic>-1</ic> and <ic>1</ic>. You can also control the duty cycle using the <ic>duty</ic> parameter.
|
||||||
- <ic>usquare(freq: number = 1, offset: number= 0, duty: number = .5): number</ic>: returns a square wave oscillation between <ic>0</ic> and <ic>1</ic>. The <ic>u</ic> stands for _unipolar_. You can also control the duty cycle using the <ic>duty</ic> parameter.
|
- <ic>usquare(freq: number = 1, offset: number= 0, duty: number = .5): number</ic>: returns a square wave oscillation between <ic>0</ic> and <ic>1</ic>. The <ic>u</ic> stands for _unipolar_. You can also control the duty cycle using the <ic>duty</ic> parameter.
|
||||||
@ -179,7 +141,7 @@ ${makeExample(
|
|||||||
"Modulating the speed of a sample player using a square LFO",
|
"Modulating the speed of a sample player using a square LFO",
|
||||||
`beat(.25) && snd('cp').speed(1 + usquare(0.25, 0, 0.25) * 2).out()`,
|
`beat(.25) && snd('cp').speed(1 + usquare(0.25, 0, 0.25) * 2).out()`,
|
||||||
true
|
true
|
||||||
)};
|
)};
|
||||||
|
|
||||||
- <ic>noise()</ic>: returns a random value between -1 and 1.
|
- <ic>noise()</ic>: returns a random value between -1 and 1.
|
||||||
|
|
||||||
@ -187,7 +149,7 @@ ${makeExample(
|
|||||||
"Modulating the speed of a sample player using noise",
|
"Modulating the speed of a sample player using noise",
|
||||||
`beat(.25) && snd('cp').speed(1 + noise() * 2).out()`,
|
`beat(.25) && snd('cp').speed(1 + noise() * 2).out()`,
|
||||||
true
|
true
|
||||||
)};
|
)};
|
||||||
|
|
||||||
## Probabilities
|
## Probabilities
|
||||||
|
|
||||||
@ -202,7 +164,7 @@ ${makeExample(
|
|||||||
rhythm(0.125, 10, 16) :: sound('sid').n(4).note(50 + irand(50, 62) % 8).out()
|
rhythm(0.125, 10, 16) :: sound('sid').n(4).note(50 + irand(50, 62) % 8).out()
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
- <ic>prob(p: number)</ic>: return <ic>true</ic> _p_% of time, <ic>false</ic> in other cases.
|
- <ic>prob(p: number)</ic>: return <ic>true</ic> _p_% of time, <ic>false</ic> in other cases.
|
||||||
@ -217,7 +179,7 @@ prob(60) :: script(2);
|
|||||||
prob(80) :: script(toss() ? script(3) : script(4))
|
prob(80) :: script(toss() ? script(3) : script(4))
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
- <ic>seed(val: number|string)</ic>: sets the seed of the random number generator. You can use a number or a string. The same seed will always return the same sequence of random numbers.
|
- <ic>seed(val: number|string)</ic>: sets the seed of the random number generator. You can use a number or a string. The same seed will always return the same sequence of random numbers.
|
||||||
|
|
||||||
@ -249,7 +211,7 @@ ${makeExample(
|
|||||||
rarely(8) :: sound('east').out(); // Rarely in 8 beats is even less
|
rarely(8) :: sound('east').out(); // Rarely in 8 beats is even less
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Using chance with other operators",
|
"Using chance with other operators",
|
||||||
@ -259,7 +221,7 @@ ${makeExample(
|
|||||||
sometimes() :: onbeat(1,3) :: sound('snare').out();
|
sometimes() :: onbeat(1,3) :: sound('snare').out();
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Using chance with chaining",
|
"Using chance with chaining",
|
||||||
@ -276,7 +238,7 @@ ${makeExample(
|
|||||||
.out()
|
.out()
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
## Math functions
|
## Math functions
|
||||||
|
|
||||||
@ -297,7 +259,7 @@ beat(.5) :: delay(usine(.125) * 80, () => sound('east').out())
|
|||||||
beat(.5) :: delay(50, () => sound('east').out())
|
beat(.5) :: delay(50, () => sound('east').out())
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
- <ic>delayr(ms: number, nb: number, func: Function): void</ic>: Delays the execution of a function by a given number of milliseconds, repeated a given number of times.
|
- <ic>delayr(ms: number, nb: number, func: Function): void</ic>: Delays the execution of a function by a given number of milliseconds, repeated a given number of times.
|
||||||
|
|
||||||
@ -308,6 +270,6 @@ beat(1) :: delayr(50, 4, () => sound('east').speed([0.5,.25].beat()).out())
|
|||||||
flip(2) :: beat(2) :: delayr(150, 4, () => sound('east').speed([0.5,.25].beat() * 4).out())
|
flip(2) :: beat(2) :: delayr(150, 4, () => sound('east').speed([0.5,.25].beat() * 4).out())
|
||||||
`,
|
`,
|
||||||
true
|
true
|
||||||
)};
|
)};
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|||||||
54
src/documentation/interaction.ts
Normal file
54
src/documentation/interaction.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { type Editor } from "../main";
|
||||||
|
import { makeExampleFactory } from "../Documentation";
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
export const interaction = (application: Editor): string => {
|
||||||
|
const makeExample = makeExampleFactory(application);
|
||||||
|
return `
|
||||||
|
# Interaction
|
||||||
|
|
||||||
|
Topos can interact with the physical world or react to events coming from outside the system (_MIDI_, physical control, etc).
|
||||||
|
|
||||||
|
|
||||||
|
## Mouse
|
||||||
|
|
||||||
|
You can get the current position of the mouse on the screen by using the following functions:
|
||||||
|
|
||||||
|
- <ic>mouseX()</ic>: the horizontal position of the mouse on the screen (as a floating point number).
|
||||||
|
- <ic>mouseY()</ic>: the vertical position of the mouse on the screen (as a floating point number).
|
||||||
|
|
||||||
|
${makeExample(
|
||||||
|
"FM Synthesizer controlled using the mouse",
|
||||||
|
`
|
||||||
|
beat(.25) :: sound('sine')
|
||||||
|
.fmi(mouseX() / 100)
|
||||||
|
.fmh(mouseY() / 100)
|
||||||
|
.vel(0.2)
|
||||||
|
.room(0.9).out()
|
||||||
|
`,
|
||||||
|
true
|
||||||
|
)}
|
||||||
|
|
||||||
|
Current mouse position can also be used to generate notes:
|
||||||
|
|
||||||
|
- <ic>noteX()</ic>: returns a MIDI note number (0-127) based on the horizontal position of the mouse on the screen.
|
||||||
|
- <ic>noteY()</ic>: returns a MIDI note number (0-127) based on the vertical position of the mouse on the screen.
|
||||||
|
|
||||||
|
|
||||||
|
${makeExample(
|
||||||
|
"The same synthesizer, with note control!",
|
||||||
|
`
|
||||||
|
beat(.25) :: sound('sine')
|
||||||
|
.fmi(mouseX() / 100)
|
||||||
|
.note(noteX())
|
||||||
|
.fmh(mouseY() / 100)
|
||||||
|
.vel(0.2)
|
||||||
|
.room(0.9).out()
|
||||||
|
`,
|
||||||
|
true
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
@ -37,7 +37,7 @@ import { makeStringExtensions } from "./StringExtensions";
|
|||||||
localStorage.openpages = Date.now();
|
localStorage.openpages = Date.now();
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
"storage",
|
"storage",
|
||||||
function (e) {
|
function(e) {
|
||||||
if (e.key == "openpages") {
|
if (e.key == "openpages") {
|
||||||
// Listen if anybody else is opening the same page!
|
// Listen if anybody else is opening the same page!
|
||||||
localStorage.page_available = Date.now();
|
localStorage.page_available = Date.now();
|
||||||
@ -827,6 +827,7 @@ export class Editor {
|
|||||||
[
|
[
|
||||||
"introduction",
|
"introduction",
|
||||||
"interface",
|
"interface",
|
||||||
|
"interaction",
|
||||||
"code",
|
"code",
|
||||||
"time",
|
"time",
|
||||||
"sound",
|
"sound",
|
||||||
|
|||||||
Reference in New Issue
Block a user