Tinnitus can occur as a sleep disorder - -this is called the "exploding head syndrome". This most often occurs while falling asleep or waking up. It is a tremendously loud noise. Some theorize that this syndrome is due to a brief seizure in auditory cortex. It is not dangerous.(Green 2001; Palikh and Vaughn 2010). Logically, anticonvulsants might be useful for treatment.
A common cause of tinnitus is inner ear hair cell damage. Tiny, delicate hairs in your inner ear move in relation to the pressure of sound waves. This triggers cells to release an electrical signal through a nerve from your ear (auditory nerve) to your brain. Your brain interprets these signals as sound. If the hairs inside your inner ear are bent or broken, they can "leak" random electrical impulses to your brain, causing tinnitus.