So code and mechanical music (i.e. a recording) aren't exactly the same, but code and music compositions are more similar. Can you use a tiny snippet from a composition and still infringe copyright? Yes, you can. Maybe not however short, but there will come a point.
I can’t use a snippet from a recording no matter how short but I can use a tiny snippet of a composition. You can’t copyright a single note.