What is paper work to switch from permanent employee to freelancer?

Hello folks!
How can I switch from permanent employee to freelancer world in Germany? My wife is German and currently, I am employed as a permanent employee as a software engineer. I would like to work as a freelancer in different projects? So, do I need to get any other Visa or I have to do any sort of paper work?
Thank you :)

This depends on your current visa:Only if it allows all kinds of work, are you good to go!
Please inform yourself also about registration, licensing, accountancy health insurance and tax requirements for your endeavour.

Thanks @beppi
How can I know if my Visa allow me to work as a freelancer? I read on a blog that if it says "Selbständige Tätigkeit gestattet" then I am allowed to do freelancing. I have checked my residence permit and it says "erwerbstätigkeit gestattet". So I guess, I need to apply for the freelancer visa.
Could you please guide me, how to do?
Thank you in advance.

Ask at your local Auslaenderamt what you can and what you cannot do on your visa, rather than relying on strangers from the Internet who did not even see your visa and related paperwork!

@beppi
Thank you for your suggestion