There was a very long period, from its discovery in 9th c. China to the end of the 14th c. in which the medieval world , without any real knowledge of chemistry, slowly worked out how to make gunpowder consistent. Consistency is important, because if you don't have a consistent propellant, you're not going to get much accuracy, be able to predict what you'll hit. There was likely a basic Chinese recipe that initially made it to the west. Then there was a period of experimentation, during the constant European wars of the 13-14th c. Though they didn't know why, they discovered what kind of sources offered up the highest percentages of potassium nitrate ( soil from the latrines from behind the taverns that sold wine, instead of the ones that sold beer, manure from the stalls of horses fed oats). Though they didn't understand why it worked, they discovered that boiling the leachate until there was a dense precipitate in the bottom of the pot and throwing away the liquid helped ( it was getting rid of salt, NaCl) Boiling with wood ash also helped ( it got rid of calcium nitrate). They also discovered that if the gunpowder was "corned": mixed as a damp paste for a long time, dried, broken up a sieved to that it was uniform grain size, it also worked better.
This was a lot to work out. In the meantime, there were almost constant wars to fight. How do you use gunpowder that might go "pop" the first load, "boom!" in the second load? The answer is, you fire at big targets. If you aim your cannon at a castle wall, you will likely hit the wall. Likewise, hand cannon and fire lances: pointed at whole ranks of soldiers, or in the general direction of an army, would create some shock and awe and maybe hit something. These hand cannon and fire lances were less useful than the cannon- less useful than crossbows, long bows, certainly. Quantitative questions in medieval history are notoriously hard to answer, because sources are few and often hard to understand. But because they were more useful artillery likely were more common than small hand cannon, and small-caliber multi-barrel artillery, like the ribaudequins used by Jacob Van Artevelde against the French in the battle for Ghent in 1340.
And, because these slow-loading, inaccurate guns were effective against big fixed targets like massed armies and castles, none of these gunpowder weapons were that useful in the highly mobile warfare of the Asian plains and steppes of eastern Europe. There, mounted soldiers with bows and lances would prevail into the 16th c.
In the early 15th c., because gunpowder making became much better , it became possible to predict where a projectile would go. Cannon began to look less like Dulle Griet , which could not be carefully aimed, and instead looked like Queen Elizabeth's Pocket Pistol", which could. And hand cannons and fire lances were replaced by longer arquebuses, matchlock muskets, and even rifles, that could be aimed.
Hall, B. (2001). Weapons and Warfare in Renaissance Europe: Gunpowder, Technology, and Tactics (Johns Hopkins Studies in the History of Technology) (New Ed). The Johns Hopkins University Press.