These changes made agriculture much more productive, supporting population growth, urbanisation, and increased stratification of society. Muslim engineers in the Islamic world made wide use of hydropower, along with early uses of tidal power, wind power, fossil fuels such as petroleum, and large factory complexes (tiraz in Arabic). A variety of industrial mills were employed in the Islamic world, including fulling mills, gristmills, hullers, sawmills, ship mills, stamp mills, steel mills, and tide mills. By the 11th century, every province throughout the Islamic world had these industrial mills in operation. Muslim engineers also employed water turbines and gears in mills and water-raising machines, and pioneered the use of dams as a source of water power, used to provide additional power to watermills and water-raising machines. Many of these technologies were transferred to medieval Europe. Wind-powered machines used to grind grain and pump water, the windmill and wind pump, first appeared in what are now Iran, Afghanistan and Pakistan by the 9th century. They were used to grind grains and draw up water, and used in the gristmilling and sugarcane industries. Sugar mills first appeared in the medieval Islamic world. They were first driven by watermills, and then windmills from the 9th and 10th centuries in what are today Afghanistan, Pakistan and Iran. Crops such as almonds and citrus fruit were brought to Europe through Al-Andalus, and sugar cultivation was gradually adopted across Europe. Arab merchants dominated trade in the Indian Ocean until the arrival of the Portuguese in the 16th century. The Muslim world adopted papermaking from China. The earliest paper mills appeared in Abbasid-era Baghdad during 794–795. The knowledge of gunpowder was also transmitted from China via predominantly Islamic countries, where formulas for pure potassium nitrate were developed. The spinning wheel was invented in the Islamic world by the early 11th century. It was later widely adopted in Europe, where it was adapted into the spinning jenny, a key device during the Industrial Revolution. The crankshaft was invented by Al-Jazari in 1206, and is central to modern machinery such as the steam engine, internal combustion engine and automatic controls. The camshaft was also first described by Al-Jazari in 1206. Early programmable machines were also invented in the Muslim world. The first music sequencer, a programmable musical instrument, was an automated flute player invented by the Banu Musa brothers, described in their Book of Ingenious Devices, in the 9th century.