Pixel art of metremblin's Blog...

Panning

2026-04-29

I've added panning support for the next version of BooBoo. With samples, you can set the pan when you play them and adjust them on the instance returned from sample_play. For MML, you can set a global pan, but also within the MML syntax you can set pan and pan envelopes (pan values any sequence of notes can move between, like other envelopes) and adjust the instances.

Unfortunately, panning, like some other envelopes, doesn't work on samples (generators only.) One day I might handle MML samples within the MML mixing code, then I can allow all these things, but for now samples are handled in the default sample handler which knows nothing about MML.

Note: If you define a pan envelope:

				@L0 = { 0 255 }
				A @L0 abc @L0
			

The pan interpolates from channel pan, to zero, then to 255, which might not be what you expect. If you want abc the play from left to right as you might expect, put a L0 (no @) in front of the opening @L0:

				@L0 = { 255 }
				A L0 @L0 abc @L0
			

The global pan set with mml_play sticks with samples forever.

EDIT: I just realised these volume and pan envelopes can easily work, but due to the audio (sample) thread being another thread, the values won't shift as smoothly (buffer size changes.) At least it's better until/if I manage samples in MML code.

EDIT2: It'll be slower but if I call MML::mix a sample at a time, it'll all work perfectly...

EDIT3: that worked well. Volume/pan envelopes should now work on samples within MML with no shortcomings.