Edgar Barrera writes, often without ever really writing anything down.

Sometimes the Roma-raised songsmith will get his phone and record himself, uttering words into a microphone that’ll later wind up on the latest Selena Gomez album or being belted out on stage by Shakira.

Most of the time, he’ll just recite those lyrics to himself, bouncing them around over and over again in his head and seeing what sticks.

What sticks, he said, is what sells.

“If you remember the lyrics, people will remember your lyrics,” he said. “If you have to write them down it’s probably not the lyrics that are supposed to be done for the song you have. It has to be memorable.”

Barrera, 30, writes like that 24 hours, seven days a week.

“Like this weekend I woke up and I told my wife I was dreaming I was writing a song,” he said. “I’m even writing when I’m asleep. It’s this passion I have for writing songs, doing music, and I feel this every day.”

Evidently the method works. Over the past decade the son of a stay-at-home mom and a musician from Roma has turned a passion for music into a career that’s won him 14 Latin Grammys and a Grammy Award, and put his name on albums released by Ariana Grande and Maluma and Christian Nodal.

Edgar Barrera and Christian Nodal (Couresty: Omar Cruz)

The list of albums Barrera’s name appears on, as a songwriter, producer or engineer, is approaching 200.

Those albums and Barrera’s climb to the top of Latin music charts are the product of a desire — almost a need — to hustle and a mind that lets him connect with people.

“I have the luck — maybe the blessing — that people identify with what I write,” he said. “You know, people keep calling me for songs. You do one and it connects, you do another and it connects. You get to a point where you have a lot of artists calling you for songs.”

Barrera’s career started when he was a kid. He learned how to play guitar and saxophone, and later he and a couple of family members and a friend started their own band.

Always more of a fan of the writing part of music than the performing part, Barrera wrote his class song for graduation, and kept writing when he was going to college at what’s now the University of Texas Rio Grande Valley.

Barrera learned what kind of writing worked for other people too, memorizing Latin hits to play with his band at the bars down on 17th Street in McAllen.

“I think that the advantage that a lot of people in the Valley have is it’s enriched in culture,” he said. “I feel like my advantage that I have with other writers and producers is that I was more exposed to all this different type of music. All this type of genres, all this type of stuff.”

A guitar professor at the university told him he needed to get out of the Valley if he really wanted to make it in the music industry, so he started looking for an avenue up. He auditioned for Berklee College of Music and got in.

A scholarship Barrera received would have paid for some of his tuition, but not most of it, and he decided he needed to give the industry a try so he messaged a music producer in Miami.

The producer said he couldn’t pay him, but told the 20-year-old that he was welcome to come be an intern. In January 2011, Barrera packed his things and drove to Miami.

Barrera started out delivering food to the studio and serving coffee. He swept and mopped and set up cables.

“Doing the work that nobody wants,” he said.

Gradually, Barrera wedged himself into the conversations about what was being recorded.

He started showing off his own lyrics on occasion. The artists liked them.

“Little by little they started giving me a shot, and that’s when I decided to stay. I never went to Berklee, never got the education that probably my parents wanted me to get,” he said, laughing, “but you know, I think I did pretty good staying over here in Miami.”

Barrera has done pretty good, by just about any standard. He’s gotten to sit down with genuine global superstars, talking to them about themselves and making them feel at ease, something he says has to happen if you want to write a song that fits someone.

“With every artist it’s different,” he said. “Like with Maluma, we go out a lot. He loves horses, so when I’m out there in Colombia we work like two days and then we go out to the ranch and it’s just horse riding, horse riding and being out there with the animals.”

Earlier this year Barrera spent a week with Maluma hanging on an island in the Turks and Caicos. A lot has changed since he was playing cover songs on 17th Street and fetching coffee at that Miami music studio.

Edgar Barrera and Maluma (Courtesy: PHRAA)

What hasn’t changed is that passion — that drive that keeps Barrera writing 24/7, and makes him wake up in the middle of the night dreaming about songwriting.

“It’s trial and error,” he said. “To get to the good song you have to write the bad songs first. I mean, I wrote a lot, a lot, a lot of bad songs that have never been released and never offered to any artist. I see it as math. The more songs you write, the more probability you have of writing a good song.”

Barrera says his focus now is to maintain. He comes up with new ideas and tries to evolve, finding new artists to connect with and studying what’s doing well on the charts.

Mostly, though, he writes.

“I just keep on doing the same thing,” he said.