Update zifferjs and fix some bugs
This commit is contained in:
16
src/API.ts
16
src/API.ts
@ -905,6 +905,13 @@ export class UserAPI {
|
||||
return this.app.clock.pulses_since_origin;
|
||||
};
|
||||
|
||||
signature = (): number[] => {
|
||||
/**
|
||||
* Returns the current time signature
|
||||
*/
|
||||
return this.app.clock.time_signature;
|
||||
};
|
||||
|
||||
// =============================================================
|
||||
// Time Filters
|
||||
// =============================================================
|
||||
@ -966,14 +973,11 @@ export class UserAPI {
|
||||
*/
|
||||
let final_pulses: boolean[] = [];
|
||||
beat.forEach((b) => {
|
||||
const beat =
|
||||
b % this.app.clock.time_signature[0] ||
|
||||
this.app.clock.time_signature[0];
|
||||
const beat = b % this.signature()[0];
|
||||
const integral_part = Math.floor(beat);
|
||||
const decimal_part = (beat - integral_part) * this.app.clock.ppqn + 1;
|
||||
const decimal_part = (beat - integral_part) * this.ppqn() + 1;
|
||||
final_pulses.push(
|
||||
integral_part === this.app.clock.time_position.beat &&
|
||||
this.app.clock.time_position.pulse === decimal_part
|
||||
integral_part === this.beat() && this.pulse() === decimal_part
|
||||
);
|
||||
});
|
||||
return final_pulses.some((p) => p == true);
|
||||
|
||||
@ -1424,6 +1424,24 @@ z1('q 0 3 {10 14} e 8 4 {5 10 12 14 7 0}').sound('sine')
|
||||
true
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"Scala scale from variable",
|
||||
`
|
||||
const werckmeister = "107.82 203.91 311.72 401.955 503.91 605.865 701.955 809.775 900. 1007.82 1103.91 1200."
|
||||
|
||||
z0('s (0,3) ^ 0 3 ^ 0 (3,6) 0 _ (3,5) 0 _ 3 ^ 0 (3,5) ^ 0 6 0 _ 3 0')
|
||||
.key('C3')
|
||||
.scale(werckmeister)
|
||||
.sound('sine')
|
||||
.fmi(1 + usine(0.5) * irand(1,10))
|
||||
.cutoff(100 + usine(.5) * 100)
|
||||
.out()
|
||||
|
||||
onbeat(1,1.5,3) :: sound('bd').cutoff(100 + usine(.25) * 1000).out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
|
||||
- Algorithmic operations
|
||||
|
||||
${makeExample(
|
||||
|
||||
@ -16,7 +16,7 @@ export class TransportNode extends AudioWorkletNode {
|
||||
if (message.data && message.data.type === "bang") {
|
||||
this.logicalTime = message.data.logicalTime;
|
||||
|
||||
let futureTimeStamp = this.convertTicksToTimeposition(this.app.clock.tick);
|
||||
const futureTimeStamp = this.convertTicksToTimeposition(this.app.clock.tick);
|
||||
// console.log("BANG", this.logicalTime, futureTimeStamp);
|
||||
|
||||
this.app.clock.time_position = futureTimeStamp;
|
||||
|
||||
@ -71,7 +71,7 @@ export class Player extends Event {
|
||||
};
|
||||
|
||||
origin = (): number => {
|
||||
return this.app.clock.pulses_since_origin;
|
||||
return this.app.clock.pulses_since_origin+1;
|
||||
};
|
||||
|
||||
pulse = (): number => {
|
||||
@ -86,6 +86,10 @@ export class Player extends Event {
|
||||
return this.app.clock.next_beat_in_ticks;
|
||||
};
|
||||
|
||||
nextBeatInTicks = (): number => {
|
||||
return this.app.clock.next_beat_in_ticks;
|
||||
};
|
||||
|
||||
// Check if it's time to play the event
|
||||
areWeThereYet = (): boolean => {
|
||||
// If clock has stopped
|
||||
@ -100,17 +104,14 @@ export class Player extends Event {
|
||||
const howAboutNow =
|
||||
// If pattern is just starting
|
||||
(this.notStarted() &&
|
||||
(this.app.clock.time_position.pulse === 1 ||
|
||||
this.app.clock.pulses_since_origin >=
|
||||
this.app.clock.next_beat_in_ticks) &&
|
||||
this.app.clock.pulses_since_origin >= this.waitTime) || // If pattern is already playing
|
||||
(this.pulse() === 1 || this.origin() >= this.nextBeatInTicks()) &&
|
||||
this.origin() >= this.waitTime) ||
|
||||
// If pattern is already playing
|
||||
(this.current &&
|
||||
this.pulseToSecond(this.app.clock.pulses_since_origin) >=
|
||||
this.pulseToSecond(this.lastCallTime) +
|
||||
this.current.duration *
|
||||
4 *
|
||||
this.pulseToSecond(this.app.api.ppqn()) &&
|
||||
this.app.clock.pulses_since_origin >= this.waitTime);
|
||||
this.pulseToSecond(this.origin()) >=
|
||||
this.pulseToSecond(this.lastCallTime) +
|
||||
this.current.duration * 4 * this.pulseToSecond(this.app.api.ppqn()) &&
|
||||
this.origin() >= this.waitTime);
|
||||
|
||||
// Increment index of how many times call is skipped
|
||||
this.skipIndex = howAboutNow ? 0 : this.skipIndex + 1;
|
||||
|
||||
Reference in New Issue
Block a user