fix typing and build errors
This commit is contained in:
@ -2094,7 +2094,7 @@ export class UserAPI {
|
||||
return this.app.clock.nudge;
|
||||
};
|
||||
|
||||
public bpm = (n?: number): number => {
|
||||
public tempo = (n?: number): number => {
|
||||
/**
|
||||
* Sets or returns the current bpm.
|
||||
*
|
||||
@ -2107,7 +2107,7 @@ export class UserAPI {
|
||||
this.app.clock.bpm = n;
|
||||
return n;
|
||||
};
|
||||
tempo = this.bpm;
|
||||
// tempo = this.bpm;
|
||||
|
||||
public bpb = (n?: number): number => {
|
||||
/**
|
||||
|
||||
@ -17,7 +17,6 @@ import { oscilloscope } from "./documentation/more/oscilloscope";
|
||||
import { synchronisation } from "./documentation/more/synchronisation";
|
||||
import { about } from "./documentation/more/about";
|
||||
import { bonus } from "./documentation/more/bonus";
|
||||
import { samples } from "./documentation/samples";
|
||||
import { chaining } from "./documentation/chaining";
|
||||
import { interaction } from "./documentation/interaction";
|
||||
import { time } from "./documentation/time/time";
|
||||
@ -32,7 +31,6 @@ import { variables } from "./documentation/variables";
|
||||
import { probabilities } from "./documentation/probabilities";
|
||||
import { lfos } from "./documentation/lfos";
|
||||
import { ziffers } from "./documentation/ziffers";
|
||||
import { reference } from "./documentation/reference";
|
||||
import { synths } from "./documentation/synths";
|
||||
|
||||
// Setting up the Markdown converter with syntax highlighting
|
||||
@ -85,7 +83,6 @@ export const documentation_factory = (application: Editor) => {
|
||||
cyclic: cyclical_time(application),
|
||||
longform: long_forms(application),
|
||||
sound: sound(application),
|
||||
samples: samples(application),
|
||||
synths: synths(application),
|
||||
chaining: chaining(application),
|
||||
patterns: patterns(application),
|
||||
@ -95,7 +92,6 @@ export const documentation_factory = (application: Editor) => {
|
||||
variables: variables(application),
|
||||
probabilities: probabilities(application),
|
||||
functions: functions(application),
|
||||
reference: reference(),
|
||||
shortcuts: shortcuts(application),
|
||||
amplitude: amplitude(application),
|
||||
reverb_delay: reverb(application),
|
||||
|
||||
@ -9,7 +9,9 @@ export type ElementMap = {
|
||||
| HTMLInputElement
|
||||
| HTMLSelectElement
|
||||
| HTMLCanvasElement
|
||||
| HTMLFormElement;
|
||||
| HTMLFormElement
|
||||
| HTMLInputElement
|
||||
;
|
||||
};
|
||||
|
||||
export const singleElements = {
|
||||
|
||||
@ -263,7 +263,7 @@ export const initializeSelectedUniverse = (app: Editor): void => {
|
||||
app.universes[app.selected_universe] = structuredClone(template_universe);
|
||||
}
|
||||
}
|
||||
app.interface.universe_viewer.placeholder! = `${app.selected_universe}`;
|
||||
(app.interface.universe_viewer as HTMLInputElement).placeholder! = `${app.selected_universe}`;
|
||||
};
|
||||
|
||||
export const emptyUrl = () => {
|
||||
@ -334,7 +334,7 @@ export const loadUniverse = (
|
||||
// Updating references to the currently selected universe
|
||||
app.settings.selected_universe = selectedUniverse;
|
||||
app.selected_universe = selectedUniverse;
|
||||
app.interface.universe_viewer.placeholder! = `${selectedUniverse}`;
|
||||
(app.interface.universe_viewer as HTMLInputElement).placeholder! = `${selectedUniverse}`;
|
||||
// Updating the editor View to reflect the selected universe
|
||||
app.updateEditorView();
|
||||
// Evaluating the initialisation script for the selected universe
|
||||
|
||||
@ -64,7 +64,7 @@ export class MidiConnection {
|
||||
constructor(api: UserAPI, settings: AppSettings) {
|
||||
this.api = api;
|
||||
this.settings = settings;
|
||||
this.lastBPM = api.bpm();
|
||||
this.lastBPM = api.tempo();
|
||||
this.roundedBPM = this.lastBPM;
|
||||
this.initializeMidiAccess();
|
||||
}
|
||||
@ -519,7 +519,7 @@ export class MidiConnection {
|
||||
const estimatedBPM = this.estimatedBPM();
|
||||
if (estimatedBPM !== this.roundedBPM) {
|
||||
console.log("Estimated BPM: ", estimatedBPM);
|
||||
this.api.bpm(estimatedBPM);
|
||||
this.api.tempo(estimatedBPM);
|
||||
this.roundedBPM = estimatedBPM;
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,22 +116,20 @@ export const installInterfaceLogic = (app: Editor) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.interface.universe_viewer.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||
app.interface.universe_viewer.addEventListener("keydown", (event: any) => {
|
||||
if (event.key === "Enter") {
|
||||
let content = app.interface.universe_viewer.value.trim();
|
||||
console.log("boum")
|
||||
|
||||
let content = (app.interface.universe_viewer as HTMLInputElement).value.trim();
|
||||
if (content.length > 2 && content.length < 40) {
|
||||
if (content !== app.selected_universe) {
|
||||
Object.defineProperty(app.universes, content,
|
||||
// @ts-ignore
|
||||
Object.getOwnPropertyDescriptor(app.universes, app.selected_universe));
|
||||
delete app.universes[app.selected_universe];
|
||||
}
|
||||
|
||||
app.selected_universe = content;
|
||||
loadUniverse(app, app.selected_universe);
|
||||
app.interface.universe_viewer.placeholder = content;
|
||||
app.interface.universe_viewer.value = '';
|
||||
(app.interface.universe_viewer as HTMLInputElement).placeholder = content;
|
||||
(app.interface.universe_viewer as HTMLInputElement).value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -22,6 +22,8 @@ The sampler is a rather complex beast. There is a lot you can do by manipulating
|
||||
| <ic>cut</ic> | | Set with <ic>0</ic> or <ic>1</ic>. Will cut the sample as soon as another sample is played on the same bus |
|
||||
| <ic>clip</ic> | | Multiply the duration of the sample with the given number |
|
||||
| <ic>pan</ic> | | Stereo position of the audio playback (<ic>0</ic> = left, <ic>1</ic> = right)|
|
||||
| <ic>vib</ic> | | vibrato speed (in hertz)|
|
||||
| <ic>vibmod</ic> | | vibrato depth (from <ic>0</ic> to <ic>n</ic>)|
|
||||
|
||||
Let's apply some of these methods naïvely. We will then break everything using simpler examples.
|
||||
|
||||
@ -127,4 +129,16 @@ beat(0.125)::sound('notes')
|
||||
+ [-12,12].beat()).out()
|
||||
`, true)}
|
||||
|
||||
## Adding vibrato to samples
|
||||
|
||||
You can add vibrato to any sample using <ic>vib</ic> and <ic>vibmod</ic>:
|
||||
|
||||
${makeExample("Adding vibrato to a sample", `
|
||||
|
||||
beat(1)::sound('fhang').vib([1, 2, 4].bar()).vibmod([0.5, 2].beat()).out()
|
||||
`, true)}
|
||||
|
||||
|
||||
`}
|
||||
|
||||
|
||||
|
||||
@ -555,19 +555,12 @@ const completionDatabase: CompletionDatabase = {
|
||||
"Base function to play audio (samples / synths). Alias for <code>sound<code>.",
|
||||
example: "sound('bd').out()",
|
||||
},
|
||||
bpm: {
|
||||
name: "bpm",
|
||||
category: "time",
|
||||
description: "Get or set the current beats per minute.",
|
||||
example: "bpm(135) // set the bpm to 135",
|
||||
},
|
||||
tempo: {
|
||||
name: "tempo",
|
||||
category: "time",
|
||||
description: "Get or set the current beats per minute.",
|
||||
example: "tempo(135) // set the bpm to 135",
|
||||
},
|
||||
|
||||
out: {
|
||||
name: "out",
|
||||
category: "audio",
|
||||
|
||||
@ -140,7 +140,7 @@ flipbar(2)
|
||||
${makeExample(
|
||||
"Using onbar for filler drums",
|
||||
`
|
||||
bpm(150);
|
||||
tempo(150);
|
||||
// Only play on the third and fourth bar of the cycle.
|
||||
onbar([3,4], 4)::beat(.25)::snd('hh').out();
|
||||
// Using JavaScript regular control flow
|
||||
|
||||
@ -27,7 +27,7 @@ ${makeExample(
|
||||
midi_outputs()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
- <ic>midi_output(output_name: string)</ic>: enter your desired output to connect to it.
|
||||
|
||||
@ -37,7 +37,7 @@ ${makeExample(
|
||||
midi_output("MIDI Rocket-Trumpet")
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
That's it! You are now ready to play with MIDI.
|
||||
|
||||
@ -55,7 +55,7 @@ ${makeExample(
|
||||
rhythm(.5, 5, 8) :: midi(50).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"MIDI note using three parameters: note, velocity, channel",
|
||||
@ -64,7 +64,7 @@ ${makeExample(
|
||||
rhythm(.5, 5, 8) :: midi(50, 50 + usine(.5) * 20, 0).out()
|
||||
`,
|
||||
false
|
||||
)}
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"MIDI note by passing an object",
|
||||
@ -73,21 +73,21 @@ ${makeExample(
|
||||
rhythm(.5, 5, 8) :: midi({note: 50, velocity: 50 + usine(.5) * 20, channel: 0}).out()
|
||||
`,
|
||||
false
|
||||
)}
|
||||
)}
|
||||
|
||||
We can now have some fun and starting playing a small piano piece:
|
||||
|
||||
${makeExample(
|
||||
"Playing some piano",
|
||||
`
|
||||
bpm(80) // Setting a default BPM
|
||||
tempo(80) // Setting a default BPM
|
||||
beat(.5) && midi(36 + [0,12].beat()).sustain(0.02).out()
|
||||
beat(.25) && midi([64, 76].pick()).sustain(0.05).out()
|
||||
beat(.75) && midi([64, 67, 69].beat()).sustain(0.05).out()
|
||||
beat(.25) && midi([64, 67, 69].beat() + 24).sustain(0.05).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
## Control and Program Changes
|
||||
|
||||
@ -100,7 +100,7 @@ control_change({control: [24,25].pick(), value: irand(1,120), channel: 1})
|
||||
control_change({control: [30,35].pick(), value: irand(1,120) / 2, channel: 1})
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
- <ic>program_change(program: number, channel: number)</ic>: send a MIDI Program Change. This function takes two arguments to specify the program and the channel (_e.g._ <ic>program_change(1, 1)</ic>).
|
||||
|
||||
@ -110,7 +110,7 @@ ${makeExample(
|
||||
program_change([1,2,3,4,5,6,7,8].pick(), 1)
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
|
||||
## System Exclusive Messages
|
||||
@ -124,7 +124,7 @@ ${makeExample(
|
||||
sysex(0x90, 0x40, 0x7f)
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
## Clock
|
||||
|
||||
@ -136,7 +136,7 @@ ${makeExample(
|
||||
beat(.25) && midi_clock() // Sending clock to MIDI device from the global buffer
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
## Using midi with ziffers
|
||||
|
||||
@ -148,7 +148,7 @@ ${makeExample(
|
||||
z1('0 2 e 5 2 q 4 2').midi().port(2).channel(4).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"Setting the channel within the pattern",
|
||||
@ -156,7 +156,7 @@ ${makeExample(
|
||||
z1('(0 2 e 5 2):0 (4 2):1').midi().out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
)}
|
||||
|
||||
`;
|
||||
};
|
||||
|
||||
@ -113,7 +113,7 @@ ${makeExample(
|
||||
beat(0.5)::sound('notes').n([1,2].dur(1, 2))
|
||||
.room(0.5).size(8).delay(0.125).delayt(1/8)
|
||||
.speed(0.5).ad(0, .125).out()
|
||||
// Kick (3 beats), Snare (1 beat)
|
||||
// Kick (3 beats), Snare (1bpm beat)
|
||||
beat(1)::sound(['kick', 'fsnare'].dur(3, 1))
|
||||
.n([0,3].dur(3, 1)).out()
|
||||
`,
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
export const reference = (): string => {
|
||||
return ``;
|
||||
};
|
||||
@ -1,12 +0,0 @@
|
||||
import { type Editor } from "../main";
|
||||
import { makeExampleFactory } from "../Documentation";
|
||||
|
||||
export const samples = (application: Editor): string => {
|
||||
const makeExample = makeExampleFactory(application);
|
||||
return `
|
||||
# Audio Samples
|
||||
|
||||
Audio samples are dynamically loaded from the web. By default, Topos is providing some samples coming from the classic [Dirt-Samples](https://github.com/tidalcycles/Dirt-Samples) but also from the [Topos-Samples](https://github.com/Bubobubobubobubo/Topos-Samples) repository. You can contribute to the latter if you want to share your samples with the community! For each sample folder, we are indicating how many of them are available in parentheses. The samples starting with <ic>ST</ic> are coming from [a wonderful collection](https://archive.org/details/AmigaSoundtrackerSamplePacksst-xx) of Ultimate Tracker Amiga audio samples released by Karsten Obarski. They are very high-pitched as was usual in the tracker era. Pitch them down using <ic>.speed(0.5)</ic>.
|
||||
|
||||
`;
|
||||
};
|
||||
@ -78,7 +78,7 @@ You can also add some amount of vibrato to the sound using the <ic>vib</ic> and
|
||||
${makeExample(
|
||||
"Different vibrato settings",
|
||||
`
|
||||
bpm(140);
|
||||
tempo(140);
|
||||
beat(1) :: sound('triangle')
|
||||
.freq(400).release(0.2)
|
||||
.vib([1/2, 1, 2, 4].beat())
|
||||
@ -94,7 +94,7 @@ A certain amount of brown noise can be added by using the <ic>.noise</ic> key:
|
||||
${makeExample(
|
||||
"Different vibrato settings",
|
||||
`
|
||||
bpm(140);
|
||||
tempo(140);
|
||||
beat(1) :: sound('triangle')
|
||||
.freq(400).release(0.2)
|
||||
.noise([0.2,0.4,0.5].bar())
|
||||
@ -609,7 +609,7 @@ ${makeExample(
|
||||
${makeExample(
|
||||
"Live coded poetry with array and string chaining",
|
||||
`
|
||||
bpm(70)
|
||||
tempo(70)
|
||||
|
||||
const croissant = [
|
||||
"Volant", "Arc-en-ciel", "Chocolat", "Dansant",
|
||||
|
||||
Reference in New Issue
Block a user