I am planning to make a Local-Area-Network personal music server program.
The idea is that the program lets you host your music so you can stream it from any of your devices on your local network (though no music is distributed with the program itself). It may also do some analysis on the music, which means it will need to operate on the music files themselves in some cases (stuff like genre classification).
Can I, the developer of the program, be held responsible if an end user uses the software on copyright infringing material?
Are home music servers legal in general?
What if the user makes the server public? (publicly hosts it, port forwarding, etc)
Yes, of course. They are plenty of perfectly legal home music servers around and I don't see why yours would be any different.
You are just distributing content around the house. Your software has no part in the acquisition of the music (legal or not)
Your software doesn't "encourage" copyright violations, it has no way of knowing if content is "legal" or not
It may be against some of the more aggressive Terms and Conditions of some of the record labels, especially of you can play the same song on multiple players in different instances (not synchronized) simultaneously. However, for almost all other songs this is perfectly legal, and it's not your job to enforce this. These T&Cs tend to be a bit bizarre and are unlikely to hold up in court anyway. Hence the labels don't push them.
It's more and more moot these days: local libraries are quickly disappearing and are being replaced with streaming services.
Connecting to a streaming service and redistributing a stream, is a different can of worms, I'd recommend to stay away from this.
Law Stack Exchange is for educational purposes only and is not a substitute for individualized advice from a qualified legal practitioner. Communications on Law Stack Exchange are not privileged communications and do not create an attorney-client relationship.