Fix chord & note issues
This commit is contained in:
@ -2,6 +2,7 @@ import { type UserAPI } from "../API";
|
||||
import { MidiEvent } from "../classes/MidiEvent";
|
||||
import { Player } from "../classes/ZPlayer";
|
||||
import { SoundEvent } from "../classes/SoundEvent";
|
||||
import { SkipEvent } from "../classes/SkipEvent";
|
||||
|
||||
declare global {
|
||||
interface Number {
|
||||
@ -24,7 +25,7 @@ declare global {
|
||||
z15(): Player;
|
||||
z16(): Player;
|
||||
midi(): MidiEvent;
|
||||
sound(name: string): SoundEvent;
|
||||
sound(name: string): SoundEvent|SkipEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,11 +102,11 @@ export const makeNumberExtensions = (api: UserAPI) => {
|
||||
return api.midi(this.valueOf(), ...kwargs);
|
||||
};
|
||||
|
||||
Number.prototype.sound = function (name: string) {
|
||||
Number.prototype.sound = function (name: string): SoundEvent|SkipEvent {
|
||||
if (Number.isInteger(this.valueOf())) {
|
||||
return (api.sound(name) as SoundEvent).note(this.valueOf());
|
||||
} else {
|
||||
return (api.sound(name) as SoundEvent).freq(this.valueOf());
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user