The cochlea is by far the most complex part of the ear. Its job is to take the physical vibrations caused by the sound wave and translate them into electrical information the brain can recognize as distinct sound.
The cochlea structure consists of three adjacent tubes separated from each other by sensitive membranes. In reality, these tubes are coiled in the shape of a snail shell, but it's easier to understand what's going on if you imagine them stretched out. It's also clearer if we treat two of the tubes, the scala vestibuli and the scala media, as one chamber. The membrane between these tubes is so thin that sound waves travel as if the tubes weren't separated at all.
The piston action of the stapes moves the fluid in the cochlea. This causes a vibration wave to travel down the basilar membrane.
The stapes moves back and forth, creating pressure waves in the entire cochlea. The round window membrane separating the cochlea from the middle ear gives the fluid somewhere to go. It moves out when the stapes pushes in and moves in when the stapes pulls out.
The middle membrane, the basilar membrane, is a rigid surface that extends across the length of the cochlea. When the stapes moves in and out, it pushes and pulls on the part of the basilar membrane just below the oval window. This force starts a wave moving along the surface of the membrane. The wave travels something like ripples along the surface of a pond, moving from the oval window down to the other end of the cochlea.
The basilar membrane has a peculiar structure. It's made of 20,000 to 30,000 reed-like fibers that extend across the width of the cochlea. Near the oval window, the fibers are short and stiff. As you move toward the other end of the tubes, the fibers get longer and more limber.
This gives the fibers different resonant frequencies. A specific wave frequency will resonate perfectly with the fibers at a certain point, causing them to vibrate rapidly. This is the same principle that makes tuning forks and kazoos work -- a specific pitch will start a tuning fork ringing, and humming in a certain way will cause a kazoo reed to vibrate.
As the wave moves along most of the membrane, it can't release much energy -- the membrane is too tense. But when the wave reaches the fibers with the same resonant frequency, the wave's energy is suddenly released. Because of the increasing length and decreasing rigidity of the fibers, higher-frequency waves vibrate the fibers closer to the oval window, and lower frequency waves vibrate the fibers at the other end of the membrane. In the next section, we'll look at how tiny hairs help us hear sound.
(Source: How stuff works?)