Have you checked the Sound option in the System Preferences? It gives you the option to choose the output device. Apple MIDI allows you to set the data rate of output e.g. 24 bit, 96 kHz etc. But to get sound you need to choose the output device in system preferences; when you disconnect, the iMac likely defaulted to "internal speakers".
Good luck.
Good luck.