(Headphones recommended) The goal of this project is to get better control over stereo output—more specifically, direct control over how loud the left and right output channels are. To do this, I had to figure out the behavior of the panning effect block. Here's what I found: The panning effect block controls stereo panning—set it to -100 and you get full volume in the left ear. Set it to 100 and you get full volume in the right ear. And leave it at 0, and you get equal volume in both ears. This is the fairly obvious part, anyone who plays around with the effect can pretty quickly figure this out. What's less obvious is exactly what relationship the volumes for each ear follow for all values in between. Recording the audio output while linearly increasing panning from -100 to 100 reveals that the amplitudes for the left and right ear follow a sinusoidal relationship with the panning effect value. For the left ear, the relationship matches the first quarter of the period of a cosine wave, and for the right ear, the relationship matches the first quarter of the period of a sine wave. So: amount in left = cos(180 * (panning + 100) / 400) amount in right = sin(180 * (panning + 100) / 400) There is one more detail though. These formulas say that if the panning effect is set to 0, then the output volume in both left and right should be at sqrt(2)/2, or ~0.707. And if the panning effect is set to any value close to 0, like 0.01, ~0.707 is what we get. But if the panning effect is set to exactly 0, then Scratch will set full volume for both ears, creating a discontinuity at that point. So we have to work around this when we use the panning effect. After figuring all this out, I then figured out how to convert in the other direction—from left and right volumes to volume and panning (volumes in 0-1 range): volume = sqrt(left^2 + right^2) panning = 400 * asin(right / volume) / 180 - 100 or panning = 400 * atan(right / left) / 180 - 100 I made a desmos graph with these formulas and some visualization: https://www.desmos.com/calculator/widdazmt81 tired of the piano loop yet? #Sound #Panning