Companies and composers have begun using software to make music customized to your brainwaves. Soon you will be able to plug in your headphones, lean back in your chair, and relax to a playlist so synchronized with your brain’s chemistry that it increases your productivity, sleep quality, and even fights anxiety.

The frequency at which your brain resonates defines your state of mind. Need to chill out? Try alpha activity. Or what about a pre-workout pep-up? Pop on some beta waves.

As consumer desire for personalized information and outcomes increases, the ability to listen to music that is literally in tune with your brain will provide a whole new business opportunity in the world of music streaming.

“You’ve got Spotify looking at your choices of song and providing suggestions on things you selected before now,” says musician Eduardo Miranda. “If you have something that is more connected to your own biology, it’s another way of providing services that may be more personalized.”

Miranda is a musician and composer who is best known for his liberal use of the electroencephalogram (EEG) machine to create complex string arrangements. For his next act, he is using brainwave-imaging software to change how he creates his music. Specialists have long used EEGs to diagnose and study epilepsy, sleep disorders, and other medical issues, but Miranda is using the technology to measure how rhythm affects brain activity.

In one recent experiment, Miranda studied three groups of subjects with the EEG’s small metal disks and electrodes attached to their scalps. In Group A, Miranda tried to inspire happiness and energy by having subjects listen to fast-paced music; in Group B, he tried to divine sadness with slower tempo, gloomy tunes; and in Group C, a control group, listeners heard neutral music intended to sustain their current mood. The EEG recordings showed their brainwaves all became synchronized around the auditory rhythm they were listening to. They also reported a change in mood after listening to each composition.

By connecting how the brain synchronizes its electrical frequencies with the rhythm of music, Miranda posits that certain beats coerce alpha and beta waves—two of the six types of brain waves—into a desired state. He says that soon, with a few alterations, companies could use his research to create a product that empowers consumers to take greater control over their emotional state. “I’m very optimistic in about five or six years time we will have this thing working mainstream,” Miranda says.

Commercialization of Miranda’s findings currently depends on developing technology that is as precise but more user-friendly than the hefty EEG headgear users currently wear to monitor brainwaves. Some companies, such as Affectiva are experimenting with lie-detector technology that measures consumers’ mood through their sweat, heartbeat, and facial expressions. Others say the slim iOS-compatible neuroheadsets, which also regulate user brain activity, might be the answer.

But other companies are trying a different tact entirely. On website Brain.fm, listeners plug in their headphones and listen to songs that activate their alpha and beta waves in order to relax, focus, meditate, nap, or sleep. Launched in 2016, users review Brain.fm’s options, click on their desired mood, and then sit back and listen to tracks designed to produce that state.

Each track is timed to the millisecond to the rhythms required to stimulate and coerce brainwaves into the desired state.

Songs are composed by thousands of bots each assigned a character—from a raindrop to a cymbal clash—that arrange themselves to create a stanza. When patterns emerge in the first several dozen measures, the bots arrange themselves to mimic those stanzas, which produces a complex composition. Each track is timed to the millisecond to the rhythms required to stimulate and coerce brainwaves into the desired state.

After several minutes, Brain.fm asks listeners to rate its effectiveness. Since brainwave frequency varies slightly from one person to the next, the algorithm continues to modify the tracks played until the user rates their experience as “very effective.”

Recently, producers have reached out to Brain.fm to learn how to create music more biologically in key with their target audience. Artists are looking for ways to sync their songs to user brainwaves, says Brain.fm founder Junaid Kalmadi. “When a musician makes music, they say the whole ‘self expression’ bit and that it’s about me, me, me,” he says. “But most music that’s listened to has a utility.”

Our brains are sophisticated electrical factories, powered by more than 100 billion nerve cells. By synchronizing our biological rhythm to environmental cues like music, consumers will soon be able to optimize and choose when they relax, focus, and fight anxiety.