Crucial factor - saltpetre
A mixture of saltpetre crystals from a compost heap, ground charcoal and flowers of sulphur would go "Poof!" but that's mainly due to bad mixing and impurities in the saltpetre.
A recipe from the 1600s speaks of 'thrice dissolved saltpetre', the solution being evaporated by a process similar to brine boiling, then redissolved and evaporated again. The first stage would have got rid of unreacted urine and solids, the second may have removed dissolved salt (halite) by removal of crystals during evaporation. The third I'm not sure about.
Mixing is a bit more complex - the greater the degree of mixing with a soft charcoal, the better the joint reaction that makes the bang. By the late 1800s, the French had made poudre brun, with the charcoal being calcined rye straw. The actual mixing was done using metal wheels revolving in leather-protected circular troughs, giving compression without friction. I have seen three actual examples of these units. An alternative (still used in Spain) was the ball mill, with rotating barrels holding the mixture and oak balls.
The point about this is that getting to gunpowder could follow a number of trails - sulphur and charcoal as a stomach powder, mixed with purified nitre (saltpetre). Alternatively, consider one of half a dozen possible Greek Fire mixes, with oil, saltpetre and sulphur, but with charcoal substituted for a more stable mix, more portable on land. Sulphur and salpetre together are the basis for flare mixtures, used in fireworks and other items. As sulphur is more expensive than charcoal, again there is the possibility of substitution and discovery of a bang.
Hope this helps.