Fix Ziffers breaking with no dur key
This commit is contained in:
@ -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 => {
|
||||||
@ -105,14 +105,16 @@ export class Player extends Event {
|
|||||||
const howAboutNow =
|
const howAboutNow =
|
||||||
// If pattern is just starting
|
// If pattern is just starting
|
||||||
(this.notStarted() &&
|
(this.notStarted() &&
|
||||||
(this.pulse() === 0 || this.origin() >= this.nextBeatInTicks()) &&
|
(this.pulse() === 0 || this.origin() >= this.nextBeatInTicks()) &&
|
||||||
this.origin() >= this.waitTime) ||
|
this.origin() >= this.waitTime) ||
|
||||||
// If pattern is already playing
|
// If pattern is already playing
|
||||||
(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 *
|
||||||
this.origin() >= this.waitTime);
|
4 *
|
||||||
|
this.pulseToSecond(this.app.api.ppqn()) &&
|
||||||
|
this.origin() >= this.waitTime);
|
||||||
|
|
||||||
// Increment index of how many times call is skipped
|
// Increment index of how many times call is skipped
|
||||||
this.skipIndex = howAboutNow ? 0 : this.skipIndex + 1;
|
this.skipIndex = howAboutNow ? 0 : this.skipIndex + 1;
|
||||||
@ -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,22 +217,22 @@ 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;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = (): void => {
|
out = (): void => {
|
||||||
// TODO?
|
// TODO?
|
||||||
|
|||||||
Reference in New Issue
Block a user