Determining whether your snoring is merely annoying, or crosses the threshold into a life-threatening problem, isn't convenient or cheap.

The gold standard for diagnosing sleep apnea -- a disease which affects roughly 1 in 13 Americans -- requires an overnight hospital stay and costs thousands of dollars. The patient sleeps in a strange bed, gets hooked up to a tangle of wires, and undergoes an intensive polysomnography test to count how many times a night he or she struggles to breathe.

By contrast, a new app developed at the University of Washington uses a smartphone to wirelessly test for sleep apnea events in a person's own bedroom. Unlike other home sleep apnea tests in use today, ApneaApp uses inaudible sound waves emanating from the phone's speakers to track breathing patterns without needing special equipment or sensors attached to the body.

In a clinical study that will be presented at the MobiSys 2015 conference in May, ApneaApp captured sleep apnea events as accurately as a hospital polysomnography test 98 percent of the time. An abstract will also appear at the 2015 Associated Professional Sleep Societies meeting in Seattle this June. Researchers believe the app could be available to consumers in the next year or two.

"Right now we don't have enough sleep clinics, sleep laboratories and sleep specialists in the country to address all the sleep apnea that is out there," said co-author Dr. Nathaniel F. Watson, professor of neurology and co-director of the UW Medicine Sleep Center.

"These initial results are impressive and suggest that ApneaApp has the potential to be a simple, noninvasive way for the average person to identify sleep apnea events at home and hopefully seek treatment."

Obstructive sleep apnea affects more than 25 million Americans. It's characterized by an obstructed airway that causes people to snort or gasp, along with breathing pauses and shallow breathing. The lack of oxygen often causes people to wake up, at least briefly.

In addition to making it harder to stay awake or focus at school or work, untreated sleep apnea can put people at higher risk for high blood pressure, stroke, heart problems, depression and diabetes.

To determine if a person is experiencing sleep apnea events, ApneaApp transforms an Android smartphone phone into an active sonar system that tracks tiny changes in a person's breathing movements. The phone's speaker sends out inaudible sound waves, which bounce off a sleeping person's body and are picked back up by the phone's microphone.

"It's similar to the way bats navigate," said Rajalakshmi Nandakumar, lead author and a doctoral candidate in the UW's department of computer science and engineering. "They send out sound signals that hit a target, and when those signals bounce back they know something is there."

ApneaApp captures minute changes in a person's breathing patterns by tracking frequency shifts in the reflected sound waves. Because those patterns can change based on distance, the app can even distinguish between the chest movements of two people sleeping in the same bed.

Because the sound waves are at a frequency adults can't hear, the app easily screens out audible background noise from people talking, cars honking or a bedroom fan. The UW team developed new algorithms and signal-processing innovations to push the boundaries of what people previously believed smartphones could do.

"Right now phones have sensing capabilities that we don't fully appreciate," said co-author Shyam Gollakota, assistant professor of computer science and engineering and director of the UW Networks and Mobile Systems lab. "If you can recalibrate the sensors that most phones already have, you can use them to achieve really amazing things."

The clinical study tested ApneaApp on 37 patients undergoing sleep studies at Harborview Medical Center because of apnea concerns. Researchers put a Samsung Galaxy S4 smartphone on a corner of the bed during the overnight sleep study. During nearly 300 hours of testing, the app tracked various respiratory events including central apnea, obstructive apnea and hypopnea with between 95 and 99 percent accuracy, compared to intensive polysomnography.

Patients are also scored using an "apnea-hypopnea index" based on the number of breathing disruptions in the night. Doctors use that calculation to diagnose patients as having no, mild, moderate or severe sleep apnea.

ApneaApp correctly classified 32 out of 37 patients in the clinical study. Four of the five patients that the app put in a different category were on the boundary between no apnea and mild apnea. In those cases, doctors typically have to make a judgment call about treatment.

Tests in a home bedroom setting showed ApneaApp works efficiently at distances of up to 3 feet, in any sleeping position and even when the person is under a blanket. The app is much simpler to use than other home sleep apnea tests. Those typically require a patient to pick up special equipment from a hospital or clinic and wire themselves up at home to multiple instruments and sensors, which can become detached and throw off results.

Because insurance companies typically only pay for a single sleep test, polysomnography results only offer a one-night snapshot. Using ApneaApp at home over the course of several nights or weeks could produce a more complete picture of real-life sleeping patterns.

The researchers are exploring the process of getting federal Food and Drug Administration approval, validating results with more laboratory and in-home testing and determining whether the sonar technology can track other minute body movements during sleep.