There are many variations on this question, so I thought it was worth writing (and answering) one for the general case.
I want to record my instrument using a computer, or use my computer to apply effects to my instrument. How do I achieve this?
Music: Practice & Theory Stack Exchange is a question and answer site for musicians, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
Acoustic instruments, of course, don't have any kind of electrical audio output. For these you need a microphone. For the purposes of this answer, a microphone is just another instrument.
Electric instruments have a socket in them through which an audio signal is output. There are various kinds of connector:
3.5mm phone – the same form as an iPod headphone plug:
1/4" phone – a guitar plug, or its stereo equivalent:
phono – as used to connect hi-fi components to each other:
XLR – the standard for professional microphones, and for carrying analogue audio over long cable runs:
Line level can be thought of as a "standard loudness" that audio devices are designed to send and receive. If you plugged a pair of headphones directly into a line-level signal, you'd hear music – probably louder than you'd normally play it.
Instruments such as keyboards output a line level signal, as do devices such as hi-fi components. Some guitar multi-fx pedals output line level. You can generally use a headphone output, with the volume turned up, as a line level substitute.
Instrument level and microphone level are the signal levels coming out of instrument pickups and microphones. These are much, much lower signals than line level. If you plugged a pair of headphones directly into an instrument level signal, you wouldn't hear anything.
In order to make use of an instrument level signal, you must plug it into an input designed to accept that quiet signal. Sometimes you will have such an input. If not, you can use a pre-amplifier ("pre-amp") to bring the signal up to line level.
Illustrated is a reasonable expensive pre-amp designed for taking microphone signals to line level. Pre-amps vary from kits you can buy for a few dollars from electronic hobbyist shops, to outrageously expensive devices for superstitious audiophiles/musos.
Most computers have a built in audio interface. The illustration shows the layout you'd typically see on the back of a desktop PC - but Macs and laptops usually have something similar.
Microphone and instrument-level sources should be plugged into the microphone socket.
Line level sources should be plugged into the line-in socket.
Built-in sound cards usually use 3.5mm stereo phone connectors. Whatever shape your instrument's output socket is, it will be possible to get adapters or converter cables to connect them to this input.
Some computers have a line-in input and no microphone socket. This can be overcome using a pre-amp.
Some computers have a mic socket and no line in. This can be overcome by turning the output volume down, but audio quality can suffer badly.
Some computers have settings in the audio driver configuration, to switch the socket from line-in mode to microphone mode.
Built in audio inputs are usually of adequate quality for music playback, games and telephony. Some audiophiles and musicians find them inadequate. As well as subjectively poor sound quality, latency becomes a problem to the musician.
Desktop users can install higher quality sound cards.
If your computer does not have mic/line-in sockets, or if you are not satisfied with the quality of your built-in sound interface, or if you require more than one input, then you can add an external audio interface.
External audio interfaces are usually connected by USB. Firewire was also used in the past.
External devices range from cheap and simple devices such as the Rocksmith guitar interface and the Griffin iMic, to studio devices with multiple inputs, high-end electronics, control knobs and indicators.
See How necessary is an USB Audio Interface? for a discussion about the necessity for one of these.
Now that your instrument is plugged into your computer, what can you do with it?