The audio system in OS X offers audio processing, MIDI, input and output, and other capabilities to programs through a central Core Audio framework structure, allowing for easy audio implementation into programs and system services. Generally, you interact with the audio system through System Preferences, Apple's Audio MIDI Setup utility, or the settings of specific programs like GarageBand, but if an error occurs such as no sound, scratchy audio, a repeated audio loop, lack of device recognition, or other problems, then you may have to work around it in several ways.
The first step if a problem occurs is to check whether it is systemwide or only in the program you are using. Try opening a new audio program, such as QuickTime Player, and use it to record or play back some audio. If this works, then try changing an audio setting or two in the program that is experiencing problems. This can be as simple as toggling a bit rate change, switching between output devices, or some similar feature that will hopefully be enough to reinitialize the audio drivers. However, if this does not work, then you may have to quit and re-launch the program.
If the problem appears to be global, then the next step is to reinitialize the system's core audio daemon process (coreaudiod), which is a persistent background process that handles audio processing in OS X.
As with handling audio processing errors on a per-application basis, you can try toggling some audio format and input/output device settings in the Sound panel of System Preferences, or using the Audio MIDI Setup utility that is in your Applications > Utilities folder.
If this does not work, then you may need to reset the audio daemon, which can be done by rebooting your system; however, this may not be desired if you are in the middle of a workflow and would prefer to keep your system operating. In these cases, you can manually reset the audio daemon, by simply forcing it to quit. This can be done by opening the Terminal utility and running the following command: