I had hinted at this previously. I don't understand how more powder burnt in the barrel isn't better than more burnt outside the barrel. Maybe you can help me understand.
This is a description of what happens as the powder burn rate is changed. To understand how powder speed plays into velocity you have to understand the basic principles of physics that are in play.
The first is what we call burn rate. It is a function of how fast a powder burns and generates gas from the burning of the mass of powder in the cartridge. In this respect a fast powder converts the powder mass to high temperature gas very rapidly and a slower powder takes longer to convert that mass to a high temperature gas.
The second is volume which in this case is the the free gas space between the base of the cartridge to the base of the bullet. This volume changes with time as the bullet travels down the barrel to the muzzle. Initially it is very small (only in the cartridge) and increase as the bullet begins it travel.
The third is the pressure volume relationship of real gases, which can be considered an ideal gas for this discussion. For this discussion a given mass of gas in a given volume will have a given pressure. If the volume increases the pressure decreases. If the mass increase for a given volume the pressure increases.
The fourth item is bullet inertia. The tendency of an object at rest to remain at rest and an object in motion to remain in motion. To change the velocity (acceleration) of the bullet requires a force which in this case is the pressure time the bore cross sectional area at any point along it travel.
Basic Assumptions: In this analysis it is assumed that changing the burn rate doesn't affect the gas generation. In reality this may happen so that a slower powder may generate more gas per unit mass, It is also assumed that the powder behaves consistently. In reality a very slow a powder may not burn properly if the bullet move fast enough that the pressure doesn't increase properly. A powder that is too fast may detonate.
If an extremely fast powder is used with a heavy bullet in a given cartridge the gas generation is extremely quick and before the bullet can accelerate the pressure will rise extremely fast to a given limit (SAAMI Pressure) because the total volume isn't changing very fast due to inertia of the bullet and also the interaction with the lands (engraving force). In fact the gas generation may be so fast that the mass of powder must be limited to avoid exceeding the pressure limit. Limiting the powder limits the gas generation so that once the bullet begins to travel down the barrel the increase in volume causes the pressure to decay rapidly since no more mass is being generated. We have a situation where we have adequate initial pressure but insufficient gas volume to continue the acceleration of the bullet and early burnout of the powder. The result is low muzzle pressure and velocity.
If we can slow the gas generation down then pressure doesn't rise as fast and the bullet has time to begin moving increasing the effective volume and the pressure doesn't go as high for a given amount of powder. Now we can add additional powder and stay within the pressure limit. More powder means more gas and higher average and muzzle pressure in the barrel. The result is higher velocity. But because the powder takes longer to burn the burnout of the powder occurs further down the barrel.
We can continue to slow the burn rate and increase the ultimate velocity of the projectile by increasing the powder charge until we reach a limit. Ultimately there are two limits. The first is a physical limit to the amount of powder we can put in the case. The other is the fact that eventually the barrel length will limit the burnout of the powder and the total gas generation.
So for maximum velocity we would seek a powder that provides a maximum chamber pressure that doesn't exceed our pressure limit and provides the highest average pressure down the barrel. As for barrel length the powder and bullet have no knowledge of how long the barrel is. The barrel length doesn't affect the choice of powder so long as the powder is 100% burned before muzzle exit. At some point the loss of gas due to less than 100% burnout and the change in average pressure may result in a faster powder giving better velocity.
So the old adage that the highest velocity powder in a given length barrel will be the best in a shorter barrel is actually valid, to a point. What that point is will be a function of a given powder and cartridge and barrel length. In practicality because of the geometry changes of the powder to modify burn rate the slowest practical powders give the highest velocity.