Added z0-z16 as string prototypes
This commit is contained in:
@ -5,7 +5,6 @@ export {};
|
||||
// Extend String prototype
|
||||
declare global {
|
||||
interface String {
|
||||
z(): Player;
|
||||
speak(): void;
|
||||
rate(speed: number): string;
|
||||
pitch(pitch: number): string;
|
||||
@ -13,6 +12,24 @@ declare global {
|
||||
voice(voice: number): string;
|
||||
lang(language: string): string;
|
||||
options(): SpeechOptions;
|
||||
z(): Player;
|
||||
z0(): Player;
|
||||
z1(): Player;
|
||||
z2(): Player;
|
||||
z3(): Player;
|
||||
z4(): Player;
|
||||
z5(): Player;
|
||||
z6(): Player;
|
||||
z7(): Player;
|
||||
z8(): Player;
|
||||
z9(): Player;
|
||||
z10(): Player;
|
||||
z11(): Player;
|
||||
z12(): Player;
|
||||
z13(): Player;
|
||||
z14(): Player;
|
||||
z15(): Player;
|
||||
z16(): Player;
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,9 +76,78 @@ export const makeStringExtensions = (api: UserAPI) => {
|
||||
return stringObject(this.valueOf(), {voice: voice});
|
||||
};
|
||||
|
||||
String.prototype.z = function () {
|
||||
return api.z(this.valueOf());
|
||||
String.prototype.z = function (options: {[key: string]: any} = {}) {
|
||||
return api.z(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z0 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z0(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z1 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z1(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z2 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z2(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z3 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z3(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z4 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z4(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z5 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z5(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z6 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z6(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z7 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z7(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z8 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z8(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z9 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z9(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z10 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z10(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z11 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z11(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z12 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z12(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z13 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z13(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z14 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z14(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z15 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z15(this.valueOf(), options);
|
||||
};
|
||||
|
||||
String.prototype.z16 = function (options: {[key: string]: any} = {}) {
|
||||
return api.z16(this.valueOf(), options);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
type SpeechOptions = {
|
||||
|
||||
@ -409,5 +409,19 @@ z1('q (0 3 1 5)+(2 5) e (0 5 2)*(2 3) (0 5 2)>>(2 3) (0 5 2)%(2 3)').sound('sine
|
||||
true
|
||||
)}
|
||||
|
||||
## String prototypes
|
||||
|
||||
You can also use string prototypes as an alternative syntax for creating Ziffers patterns
|
||||
|
||||
${makeExample(
|
||||
"String prototypes",
|
||||
`
|
||||
"q 0 e 5 2 6 2 q 3".z0().sound('sine').out()
|
||||
"q 2 7 8 6".z1().octave(-1).sound('sine').out()
|
||||
"q 2 7 8 6".z2({key: "C2", scale: "aeolian"}).sound('sine').scale("minor").out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
|
||||
`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user