When filmmaker M. Night Shyamalan was giving notes to singer-songwriter Saleka Shyamalan — his daughter — one song he played for her was the U2 hit “With or Without You.”

The director had recruited Saleka, no stranger to collaborating with her father, to write a track for his latest film “Old,” which opens in theaters July 23. He wanted her to write a song about love that felt like Bono’s lyrics.

The film follows a group of tourists staying at a local luxury resort who discover that the secluded beach where they are relaxing turns into a nightmare, as they start to rapidly age. At the center of the story is a couple Guy (Gael García Bernal ) and Prisca (Vicky Krieps) on vacation with their two children. This vacation is a last-ditch attempt for their struggling relationship and other factors.

With “Remain,” Saleka Shaymalan took cues from her father’s favorite song and wrote a haunting ballad about love. Here she discusses her songwriting process and how the song came together.

Where did this begin for you, and what did your dad say about his idea for it?

The storyline involves Maddox (who is played by Alexa Swinton and Thomasin McKenzie), who sings this song “Remain” in the film, and my dad had this idea of the song being something she sings when she’s young – so you see that as they’re going to the beach, but also again when she’s older. It’s this full circle feeling and that is how it’s used in the film.

He wanted something original. A lot of the time he connects certain characters in his movies to our family, and especially to me and my sisters. I think that this character, in particular, was also one of those. He gave me the script to read and he told me the idea. My dad gave me this prompt where he wanted the song to highlight the relationship between Guy and Prisca and the love that exists between them.

I was overcome by insecurity, nerves and anxiety. I thought “What if he doesn’t like it? Or what if I’m not good enough to do it?” But it was such an exciting opportunity and I was in love with the story and the characters.

What about writing the song — how did that come together?

All of that inspired me to write something. It flowed naturally from there. My family’s very collaborative. We constantly talk to each other about art and the projects that we’re working on.

The sound for the song developed from a few initial lyric ideas, and a certain piano riff I had written that reminded me of the movie. Once the vocals and piano were finished, we added the other elements to support them.

Where did you begin with the lyrics, the chorus or the verse?

It began with the chorus and that piano riff that I was obsessed with. It reminded me of the ocean, the waves, and it felt cinematic to me. I wanted to write a melody that complemented that and something that felt like the movement of water. The melody came first, really.

One of the early titles for the film was a play on the words “Til death do us part,” and that was also a breakthrough moment for me. We were talking about that as a family and this relationship between Guy and Prisca who are on the verge of breaking up, but then they go to this island and this marital vow takes on a new meaning. I just found that so striking.

The lyrics are kind of intuitive of marital vows, and being with someone till the end. With the hook, it was about this vow to be with someone, to love them through comfort and pain, and in sickness and in health. The verses are more about the tumultuous aspects of the relationship and the times that it’s hard.

When my dad first was talking about the concept of the song, he played me U2’s “With or Without You.” He loves that song, and while “Remain” sounds nothing like it, the U2 song was something he loved and wanted the lyrics to feel like that song. What I took from that was “With or Without You” was this all-encompassing love, and it’s really hard. It might break you at times, but it’s also the thing that you live for, and it gives you meaning.

You’ve collaborated with your dad before, doing music for “Servant.” What was it like this time around?

“Servant” was a perfect build-up to this moment. My sister had directed a bunch of episodes, and I had written some songs for that. It was just getting used to the idea of working with my dad in that capacity. It was so natural, but I didn’t want to let him down, and I wanted to create something that would fit with his vision.

The creative process ended up being very smooth. It was also a huge moment for me just as his daughter, and it made me feel like he was proud of me. That’s the biggest support that a parent could give you, is just respecting you and wanting you to collaborate with them.

Let talk about your music career — what’s coming up for you?

Between doing a TV series, writing music for the movie and then building yourself up as an artist too, that’s a lot to juggle. It’s this new way of learning, but I feel like it’s been so beneficial to me because making music based on movies and TV is this new avenue. It has helped me learn how to write better and learn how to create better because it’s taken me out of my own head. I can write about a character and be inspired by a character and kind of imagine a whole different storyline than my own life. With “Servant,” I was able to go into more of the blues and jazz world that I also love.

(As a solo artist) I’ve got another single coming out in August, and then the album is coming out at the beginning of fall.