Each polyphonic grain in Max/MSP needs a unique instance ID to avoid shared-state collisions
When a granular synthesizer triggers many simultaneous grains using poly~ in Max/MSP, each grain instance must have a unique identifier so that parameters (amplitude, position) can be set independently per grain. Max provides the #0 symbol (hash-zero) for this: inside a patch or subpatch, #0 is replaced at runtime by a unique integer ID. If all grain instances shared the same envelope buffer name (e.g., ‘grain_env’), setting the envelope on one grain would affect all simultaneously. By using #0 as part of the buffer name, each poly~ instance gets its own uniquely-named buffer. This pattern is required for all parameters that must be per-voice rather than global.
Examples
Buffer name #0grain inside a poly~ subpatch expands to 1001grain, 1002grain, etc. for each voice. Each grain’s envelope is then isolated to its own buffer instance.
Assessment
Without #0 unique IDs, what would happen when 100 grain voices simultaneously try to write to their amplitude envelope buffer? Describe the correct Max/MSP pattern to prevent this.