Fix Ziffers breaking with no dur key

This commit is contained in:
2023-09-17 22:25:25 +02:00
parent b96c670015
commit fa0f786252

View File

@ -71,7 +71,7 @@ export class Player extends Event {
};
origin = (): number => {
return this.app.clock.pulses_since_origin+1;
return this.app.clock.pulses_since_origin + 1;
};
pulse = (): number => {
@ -111,7 +111,9 @@ export class Player extends Event {
(this.current &&
this.pulseToSecond(this.origin()) >=
this.pulseToSecond(this.lastCallTime) +
this.current.duration * 4 * this.pulseToSecond(this.app.api.ppqn()) &&
this.current.duration *
4 *
this.pulseToSecond(this.app.api.ppqn()) &&
this.origin() >= this.waitTime);
// Increment index of how many times call is skipped
@ -143,8 +145,9 @@ export class Player extends Event {
"octave",
"parsedScale"
);
obj.dur = event.duration;
return new SoundEvent(obj, this.app).sound(name);
} else if(event instanceof Chord) {
} else if (event instanceof Chord) {
const pitches = event.freqs();
return new SoundEvent(event, this.app).chord(pitches).sound(name);
} else if (event instanceof ZRest) {
@ -214,16 +217,16 @@ export class Player extends Event {
return this;
}
sync(value: string|Function) {
if(this.atTheBeginning() && this.notStarted()) {
sync(value: string | Function) {
if (this.atTheBeginning() && this.notStarted()) {
const origin = this.app.clock.pulses_since_origin;
const syncId = typeof value === "function" ? value.name : value;
if(origin>0) {
if (origin > 0) {
const syncPattern = this.app.api.patternCache.get(syncId) as Player;
if(syncPattern) {
if (syncPattern) {
const syncPatternDuration = syncPattern.ziffers.duration;
const syncPatternStart = syncPattern.startCallTime;
const syncInPulses = syncPatternDuration*4*this.app.clock.ppqn;
const syncInPulses = syncPatternDuration * 4 * this.app.clock.ppqn;
this.waitTime = syncPatternStart + syncInPulses;
}
}