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