If you want an Arduino that can produce MIDI input and output signals through a USB connector you need the Arduino Micro or Leonardo to do this.
If you want to supply signals from a Uno, Nano classic or Mega, then you have to use a helper app running on your computer or laptop that will convert the normal serial signals from these processors into a MIDI signal. It used to be simple, you would use an application called Hairless. This works with Windows, Mac and Linux.
However, now the big problem here is that it is an old application, a 32 bit one, and newer operating systems will only support 64 bit applications. In the Mac world the last OS to support both 32 and 64 bit applications is Moajve. So that is why I am stuck on the old OS.
Now I did write a book on MIDI Audio & MIDI Arduino which the publishers want to update. So I had to find an alternative solution to Hairless. An internet search for a replacement suggested using MIDI Patch bay. This is a rubbish suggestion because you need a USB MIDI signal before you can use MIDI Patch bay. It is a case of someone not understanding what is needed and then everyone else simply copies the suggestion.
Anyway I did find a solution, that uses Python on your computer or laptop that works.
Further details is in this link:-
Forum thread about the new replacement for Hairless