If you are using the recently released Sonic Pi 3.1 on Rasbian Buster then this is NOT really a fully fledged version 3.1 In particular it does NOT support midi or OSC messages, even though the help file suggests that it does!
Sam Aaron has had nothing at all to do with this release on Raspbian, and was not consulted about it. We are not even sure who has done it. It doesn’t include the necessary support (osmid m20 and 02m files and erlang support) for midi to work.
I have suggested on the Raspberry Pi forums that this should NOT be called Sonic Pi 3.1 precisely to avoid the problems that you are finding, but should be renamed something else.
If you are indeed using the latest noobs install then the only solution at present is to build your own version. I have given details of how to do this here.
At present Sam Aaron does not have the resources to build and release a version for Raspbiam Buster, which involves quite a bit of work in producing a suitable .deb package. Building your own obviates the need for such a package.
There is another solution on a Pi3 (not a Pi4). Use an earlier Stretch distribution of Raspbian. On this you can use version 3.0.1 which will support midi.
See http://downloads.raspberrypi.org/raspbian/images/raspbian-2019-04-09/ for a suitable Rasbian Stretch distribution.