In the Max tutorial on abstractions, you can find a classic example of why the {{maxword|name=bucket}} object is so useful - [//www.cycling74.com/docs/max6/dynamic/c74_docs.html#basicchapter15 this Max tutorial] demonstrates its use as a single sample delay for number values useful for constructing drawing commands.

=={{maxword|name=bucket}} Tips and Workarounds==

=={{maxword|name=bucket}} Tips and Workarounds==

+

+

===Velocity and Acceleration===

+

+

Lots of people use the <strong>bucket</strong> object for shifting data in series, it's computationally useful for calculating first and second derivatives for streams of data. The terms "first and second derivative" are math-speak for keeping track of:

+

+

* the rate that things are changing (that's what velocity (the first derivative) is - the rate of change in a value over time.

+

+

* the ''rate of the rate'' that things are changing - that's what acceleration (the second derivative) is.

+

+

[[File:Bucket-in-action.png|550px]]

+

+

Here's a patch that does that:

+

+

<maxpat>

+

----------begin_max5_patcher----------

+

863.3oc4XFrbaBCDF9r8SgJmZmwICRf.bu0mgbrISGLHaqDP3QHbcZl7tWoE

+

vA2ZrAFC8Pu.dEBs69oesR32lOyZU1AVtE5qnuilM6s4ylAMYZXVk8LqzvCQ

+

Ig4P2rhxRSYBk0hxmoXGTP6psLjLTwPYqQM+cz1PwF1ihOmyhxDwnXljuOTw

+

2y9xih5QIgKzOsP.CEopQQQJWjvTfewUMtKTEskK17CIKRUF2d1d2au.4rz2

+

bC6EXt4pMPOU8R7XHDyV87cjk09bclPIBSYvi9ljGlX8giyJT0d1tt+xMq.6

+

6saLB47eAi.lbr4cRVtlP5bLSbRXRg.y1L.n5KnmLuz6ymatr3FNGbj6q4xb

+

0HfcW+flXGiuH1CFOrO..pc0JlzpmYrS.AR0xYPJbkX2RB612DlbzwRcuUL4

+

OXhvUIrSfw4Ubkih50crx.0haDGHqUZIf0fTXoEIJddBOt+TpZ4HojOXLXgc

+

BZgSjgSiblRGR53tzw2QONubzS5tjqds70nsQKCplbLUs7oqXBOpXpkRV0wn

+

i6okrlF3px1rQO38cQJApG4srd04EViZednh6.TO6RtoVCUkqcTCgCtYZH6i

+

0AmJwff8ScN7W63oiWY1YwF4pXqpNtK9RZDreeqii6Ys5gWjtElDKKDuXxND

+

8rjw45jg.qd7cuHY7FaxL3kTs.lOcmV31WwR81Y1NvocJKHhaAImkHODJxQO

+

nO+05dgEpOlz5Bo0IYg2V3rpH5ElBQF318XO3Vf+k3CYP7gL.9byKzLHsS89

+

mcQ637en1ohOcR639OT6.wC70R+wmJC4jo8SYVdVgLpd3pJLf9HqhY4Jt.Nr

+

Ui9XNIbiNskGGyDM2CNlma1VFPx4+nmtFNlON4pwio9NhLIwiSWvC9J3IkGu

+

KSukQ0TjqVNQ0I.Ivbqo0GN5lk..qtJPCltIX6tDO9SV7zI931uIXGGOyTJl

+

BkMplfAqwXB1uqqXlnIXsmvWKbNoOWkmdAN.AWB+MUd5u4q1ZD3IoK3bxnYm

+

p+LrxONvV+zR1dpElBa64goGsFAR61AkhS+TJTJsgRgZ6MlJktrUky.UJk6q

+

Gta2dlLuZHg.QepmmyjFSuEfIWTZBGlwRx1yq6ObBCqPo9rMJ8AaJjkGL4Pf

+

m0biede9u0DMhQJ

+

-----------end_max5_patcher-----------

+

</maxpat>

+

+

===Running Averages===

+

+

I also tend to use the object quite a bit in situations where I desire a running average over some finite set of events (if you want a running average for an stream or unspecified set of values, you'd use the {{maxword|name=mean}} object). Here's an example that calculates the average of the last 8 floating point input values:

+

+

<maxpat>

+

----------begin_max5_patcher----------

+

498.3ocuV1sajBBEG+Z8ofvkabm.9AZ6c84nYyFFkYKsJZTrc11z28UO3z1Y

+

CyHocJwnjywCG9wePN9RX.da6dw.FcM5VTPvKgAAfqYGAK1A3F99xZ9.DFtc

+

TWKz3HyqTiMR0jM7N56NMQAdIKd635x6jp+76dQo1Lhz7zMjHTbbFz71SzuV

+

5irxLlau+m4GFxx1lFgBx.FO650vv4GQNNA.dsxOwJ+zU4mUbB7MYQ+2NgId

+

L11LicolYJwSS46P1zh8lT8CDYCMNy5TNdw4tVkdP9LvIMdymUInWQmaRuBj

+

Bx4jhc0sbsU83MRmgRwafdfuoWxqufpRGu7AztiurJQEWXIJwzvHaxVSirJO

+

odQddtFML1702yDutfvRf8LYqumAGcBMIwKZx1wxGDZTwYO7yIUoXcUgvbea

+

RzYtsIWT2jKnq3Zo5+qP.XO6+XMbncru7.TKeIidm6JwfVp3ZYq5CwjeTL2I

+

qpDpOdXbkbfusV.vSrtV5JMLGng5MZRbflLuQSpCzj3MZlWEnqPS5Qw7cSSr

+

CzD6MZRbflDuQSpCzj5MZxbflLuQCyAZXdilbGnI2azPbflOy4MlxV7ttGE8

+

CKoD.YpH+8s8ylrHvTpLlPsabu3Q4g3geaAy6mpNqmJMO1aJQtufMUfbZbdM

+

7efczjOq

+

-----------end_max5_patcher-----------

+

</maxpat>

+

+

===A Bucket for Symbols===

+

+

The {{maxword|name=bucket}} object is a little unusual in that you don't need to worry about using arguments to the object in order to have it work with floating point values. In fact, {{maxword|name=bucket}} is ''so'' useful that people often ask whether or not there's a Max object that is similar but will work with symbols or lists. While there isn't a specific object, here's a Max patch that does exactly that (and it also helpfully outputs stuff in standard right-to-left order, too):

+

+

<maxpat>

+

----------begin_max5_patcher----------

+

778.3oc2X10bhBCEF9Z7WACWy5jOfjvd296Xmc1A0Ta5ffCDacam9eeIm.pc

+

KsDEw05zYTOGfj22mdxW7xDufYEakUA9e2+m9dduLwyCRYR30D6ErJc67rzJ

+

31BVIqpRWJCBsWSK2pg72UrorMY9lUp7LoFdBRSx0kxJYtNUqJx+cobt11q7

+

D9z3PeBYJJzG07g+u12REazsMEtsoR0yuWku78MSLzLTh42XwAMjZAnxhYO7

+

MJtUm2UjqySWIgK8iRUZV6Urcp9Oqk1lOHXWKYdnJ0yvEv0cmI6qSlX9HbfL

+

TeeoTdRPjJL9lDMPHRoG.QnI+PHhtZg3SEmBBYLKBGXcHiCOqK0gjjqUDVj+

+

4UgtSCbryzP7UkFePAkHhCETb9vpnDTfdDjEknOaTIgciMpjyvf4E3ANyVTh

+

6PL9la8AF2Ze9.wHiwcGiQWqXr2sp3LOhEQtyC5+adjKepVHuCGOm4WJWdRk

+

U1o2wwtruCRuKSfiguhPVl9AX7j18V3WDTRPnAhxDg6nDcihR6jTX9vPIWfb

+

Fk3ja5pRgXXnTvntiR5ULJ09Y9yL+0IMwcxkn9m3CYWdtc00tAC+D4xrz7ku

+

6aWXEbOAYp7+8MD.Nwj+s.rpdc04s8bih8w65oExJsJGJwN3dLSB4u2u2qVr

+

PBWG0jYkZw5BUttQCbDeJlUeZMdcaSXFfYRE2Dsu2TUoyxj.95t.3XbAoGWX

+

F+eTtPjLUPoTLcuKpSMxtf1mKnGmKDbxNIG9lnQv.lCHdf351A7iy.LRjQxB

+

X32AAig7SFA4yStTxmhN+xmGAqJbQjO97KeAheojO2A0Sv8H+yXsrKECly+c

+

vr+iodvtL1xbr9KkdntnG1ESODWp9MmO8Z5+W39zSGKoBueQ3vnhHbGQQw1Q

+

rzcQiwL8tL5.P.9311yd+viSrupg2D03NLZTcmS0RniycMyd13GFm0Qj0cbh

+

vc2Y2.a550OJKqZTHXr585+PQoIjEBgpbaHrC9fR4ip16mBYRKq25ttde6aJ

+

sa6dqfELwzOuN4u.mi5K2B

+

-----------end_max5_patcher-----------

+

</maxpat>

+

+

+

===Arbitrary List Rotation ===

+

+

One way to think of the {{maxword|name=bucket}} object is a as an object that adds new input values and rotates the list by one position. While you can rotate a list forward or backward using the ''r2l'' and ''l2r'' messages to the {{maxword|name=bucket}} object, performing arbitrary list rotations can be done using the {{maxword|name=zl}} object and specifying the '''rot''' option:

+

+

[[File:Bucket-in-action-2.png|550px]]

+

+

<maxpat>

+

----------begin_max5_patcher----------

+

1116.3oc2Y1zbaqBEFds8uBtZtK80iPf9HcWW1scamNYP1DGZk.O.xIoc5+8

+

q.jh+H1wXEEZFOYhrEBc3bdz6AyA86oShJEORUQfOA9FXxjeOcxDaSlFlzc9

+

jnZxiKpHJa2hVHpqobczL20zzG011+xcfmDMfGHbMPK.RglnolljfJlRCJeB

+

TKjTf9dBGH3TvZghoYB9LPixzLE7qJysADk+ftPOG7UZMstjJM2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

mzAEL5jbN5jGN5j6IcRBFcfmiNYgiNYdRGXvny47Fyd8EJ5f7jNgwc74YEDG

+

rGV93NgKOGOBKMslsbsfw0psU4lZV.drcuuvaOa63Ldq.vC+GGLZ5yjlv3fI

+

0fd4OgqxCX5GJsOzmeUIObOs7QKCGZoGtpXIqWugJUc1z5Js07+CgzbZ1L6o

+

Lt6TaA6QRpYG7c829pBhHx1Rt0s0a2Hc07+XgY6EZGm+L8+wpYGFn

+

-----------end_max5_patcher-----------

+

</maxpat>

==Third-Party Max externals similar to the {{maxword|name=bucket}} object==

==Third-Party Max externals similar to the {{maxword|name=bucket}} object==

In the Max tutorial on abstractions, you can find a classic example of why the bucket object is so useful - this Max tutorial demonstrates its use as a single sample delay for number values useful for constructing drawing commands.

Lots of people use the bucket object for shifting data in series, it's computationally useful for calculating first and second derivatives for streams of data. The terms "first and second derivative" are math-speak for keeping track of:

the rate that things are changing (that's what velocity (the first derivative) is - the rate of change in a value over time.

the rate of the rate that things are changing - that's what acceleration (the second derivative) is.

Here's a patch that does that:

-- Pasted Max Patch, click to expand. --

Copy all of the following text.Then, in Max, select New From Clipboard.

I also tend to use the object quite a bit in situations where I desire a running average over some finite set of events (if you want a running average for an stream or unspecified set of values, you'd use the mean object). Here's an example that calculates the average of the last 8 floating point input values:

-- Pasted Max Patch, click to expand. --

Copy all of the following text.Then, in Max, select New From Clipboard.

The bucket object is a little unusual in that you don't need to worry about using arguments to the object in order to have it work with floating point values. In fact, bucket is so useful that people often ask whether or not there's a Max object that is similar but will work with symbols or lists. While there isn't a specific object, here's a Max patch that does exactly that (and it also helpfully outputs stuff in standard right-to-left order, too):

-- Pasted Max Patch, click to expand. --

Copy all of the following text.Then, in Max, select New From Clipboard.

One way to think of the bucket object is a as an object that adds new input values and rotates the list by one position. While you can rotate a list forward or backward using the r2l and l2r messages to the bucket object, performing arbitrary list rotations can be done using the zl object and specifying the rot option:

-- Pasted Max Patch, click to expand. --

Copy all of the following text.Then, in Max, select New From Clipboard.