Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Bubobubobubobubo/Topos
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubobubobubobubo committed Nov 14, 2023
2 parents 04d4450 + 3e967a1 commit 2631ab5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/extensions/ArrayExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare global {
repeatEven(amount: number): T;
repeatOdd(amount: number): T;
beat(division: number): T;
dur(durations: number[]): T;
dur(...durations: number[]): T;
b(division: number): T;
bar(): T;
pick(): T;
Expand Down Expand Up @@ -170,13 +170,12 @@ export const makeArrayExtensions = (api: UserAPI) => {
};
Array.prototype.b = Array.prototype.beat;

Array.prototype.dur = function (...durations) {
Array.prototype.dur = function (...durations: number[]) {
const timepos = api.app.clock.pulses_since_origin;
const ppqn = api.ppqn();
const adjustedDurations = this.map(
const adjustedDurations: number[] = this.map(
(_, index) => durations[index % durations.length]
);
// @ts-ignore
const totalDurationInPulses = adjustedDurations.reduce(
// @ts-ignore
(acc, duration) => acc + duration * ppqn,
Expand Down

0 comments on commit 2631ab5

Please sign in to comment.