Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 05ea9c8

Browse files
committed
working
1 parent 6e29210 commit 05ea9c8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/core/controls.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,3 +1780,32 @@ export const as = register('as', (mapping, pat) => {
17801780
return v;
17811781
});
17821782
});
1783+
1784+
/**
1785+
* Allows you to scrub an audio file like a tape loop by passing values that represents the position in the audio file
1786+
* in the optional array syntax ex: "0.5:2", the second value controls the speed of playback
1787+
* @name scrub
1788+
* @memberof Pattern
1789+
* @returns Pattern
1790+
* @example
1791+
* samples('github:switchangel/pad')
1792+
* s("swpad:0").scrub("{0.1!2 .25@3 0.7!2 <0.8:1.5>}%8")
1793+
* @example
1794+
* samples('github:yaxu/clean-breaks/main');
1795+
* s("amen/4").fit().scrub("{0@3 0@2 4@3}%8".div(16))
1796+
*/
1797+
1798+
register(
1799+
'scrub',
1800+
(beginPat, pat) => {
1801+
return beginPat.outerBind((v) => {
1802+
if (!Array.isArray(v)) {
1803+
v = [v];
1804+
}
1805+
const [beginVal, speedMultiplier = 1] = v;
1806+
1807+
return pat.begin(beginVal).mul(speed(speedMultiplier)).clip(1);
1808+
});
1809+
},
1810+
false,
1811+
);

0 commit comments

Comments
 (0)