The Smurfs and the Magic Flute

This story is set at a castle during the Middle Ages. One day a merchant brings musical instruments to sell to Peewit, the court jester, but because Peewit is such a terrible musician the King throws the merchant out before Peewit arrives. However he has left behind a flute that only has six holes. The King throws it into the fireplace in his room, which starts to emit green smoke. When the fire is put out, Peewit retrieves the flute from the ashes unharmed. He cleans it and starts playing it for the whole castle realizing that it causes everyone to dance when it is played.
That night a man named Matthew McCreep learns from the merchant that the same flute he had been looking for is at the castle. He heads over to the castle and steals the flute from Peewit. The king sends Peewit and the young knight Johan out to catch McCreep who uses the flute to rob people of their money. However McCreep uses the flute to stop them. Johan and Peewit then go to the house of Homnibus the wizard. Using a spell called Hypnokenesis, the wizard sends Johan and Peewit to Smurfland where the magic flute was built.
Upon arriving they meet a smurf who leads them to the village. Papa Smurf greets the two of them and tells them that they'll make a new flute in order to counter McCreep's flute. The smurfs head into the forest and chop down a huge tree to get wood from the tree trunk's very centre as only this kind of wood can be useful in crafting a magical flute. Afterwards they celebrate with a party. However, just as Papa Smurf is about to give the flute to Johan and Peewit, the two are warped back to the wizard's house. Homnibus tries the spell again but passes out from a headache.
Meanwhile, McCreep, who has now stolen over 7,000 gold pieces, arrives at the castle of his secret partner, Earl Flatbroke. McCreep tells Flatbroke of his plan to go to an island to hire people for an army to raise war on the King's castle; fortunately, two Smurfs had been listening to this. Back at the wizard's house, the Smurfs regroup with Johan and Peewit and give them the magic flute. Then they head to the port of Terminac where McCreep sets sail for the island. However they are too late. Papa Smurf tells Johan and Peewit about Flatbroke's castle and Johan comes up with a plan.
Flatbroke receives a letter from McCreep (written by Johan) to come to the island. He heads over to Terminac to board a ship where Johan and Peewit are also on board in disguise as well as Papa Smurf and 3 others. They head to the island where Johan and Peewit tail Flatbroke. Suddenly Peewit comes face to face with McCreep and they both start playing their flutes to each other. They both become exhausted soon after, but Peewit knocks out McCreep with a final note.
With McCreep and Flatbroke being brought back to the castle and all the stolen money recovered, Peewit now has two magic flutes. Johan tells him that the flutes are dangerous and must be brought back to the Smurfs, but Peewit begins to carve a phony flute to give to them instead. At the castle, Johan and Peewit give the flutes back to the smurfs, and after they leave, Peewit starts playing the flute, only to realize (to his horror) that it has no effect on the townsfolk; it is the fake flute he had made!

Question: What time period is this story set in?
Answer: The Middle Ages.