This commit is contained in:
2023-08-25 19:11:29 +02:00
parent bc97fae2bb
commit 953626303d
3 changed files with 30 additions and 29 deletions

View File

@ -32,6 +32,7 @@ declare global {
repeatPair(amount: number): T;
repeatOdd(amount: number): T;
loop(index: number): T;
div(division: number): T;
shuffle(): this;
rotate(steps: number): this;
unique(): this;
@ -39,11 +40,15 @@ declare global {
}
Array.prototype.shuffle = function () {
let currentIndex = this.length, randomIndex;
let currentIndex = this.length,
randomIndex;
while (currentIndex !== 0) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
[this[currentIndex], this[randomIndex]] = [this[randomIndex], this[currentIndex]];
[this[currentIndex], this[randomIndex]] = [
this[randomIndex],
this[currentIndex],
];
}
return this;
};
@ -135,7 +140,7 @@ Array.prototype.repeatPair = function <T>(this: T[], amount: number) {
this.length = 0;
this.push(...result);
return this;
}
};
Array.prototype.repeatOdd = function <T>(this: T[], amount: number) {
if (amount < 1) {
@ -159,9 +164,7 @@ Array.prototype.repeatOdd = function <T>(this: T[], amount: number) {
this.length = 0;
this.push(...result);
return this;
}
};
Array.prototype.palindrome = function <T>() {
let left_to_right = Array.from(this);
@ -200,13 +203,12 @@ Array.prototype.in = function <T>(this: T[], value: T): boolean {
};
export async function loadSamples() {
// const ds = "https://raw.githubusercontent.com/felixroos/dough-samples/main/";
return Promise.all([
initAudioOnFirstClick(),
samples("github:Bubobubobubobubo/Topos-Samples/main"),
samples("github:tidalcycles/Dirt-Samples/master").then(() =>
registerSynthSounds()
),
samples("github:Bubobubobubobubo/Topos-Samples/main"),
]);
}

View File

@ -523,7 +523,7 @@ There are three basic filters: a _lowpass_, _highpass_ and _bandpass_ filters wi
\`\`\`javascript
mod(.5) && snd('sawtooth')
.cutoff(pick(2000,500)) + usine(.5) * 4000)
.cutoff(pick(2000,500) + usine(.5) * 4000)
.resonance(0.9).freq(pick(100,150))
.out()
\`\`\`

View File

@ -1,6 +1,6 @@
import { type Editor } from '../main';
import { AudibleEvent } from './AbstractEvents';
import { midiToFreq, noteFromPc } from 'zifferjs';
import { type Editor } from "../main";
import { AudibleEvent } from "./AbstractEvents";
import { midiToFreq, noteFromPc } from "zifferjs";
import {
superdough,
@ -8,7 +8,6 @@ import {
} from "superdough";
export class SoundEvent extends AudibleEvent {
constructor(sound: string | object, public app: Editor) {
super(app);
if (typeof sound === "string") this.values = { s: sound, dur: 0.5 };