How to make loops look like they're running simultaneously?

I'm new to Arduino and I've been playing around with the Redboard and a solderless breadboard. I've gotten the hang of creating different sketches to serve different functions (ex. blinking LEDs, using a Piezo buzzer, etc.) but I was wondering if it would be possible to merge these sketches somehow. According to my research, Arduino won't let me run two sketches simultaneously, but is there a way to mimic this?

More specifically, I'm looking to play a simple song using the Piezo buzzer and run a LED light show to the tune of the song. Nothing complex, just Twinkle Twinkle for now, but that's the idea. I have a sketch for the song, and a different sketch for the light show currently.

A friend of mine suggested defining them as different functions, and then using some sort of if/then statements, which I'm not sure is feasible. Is there any way to accomplish my goal without having to splice the code together (which I'm not quite sure how I'd go about, anyways)?

Thanks in Advance,
FredStark

Have a look at the demo several things at a time

...R

First of all your loop() functions (tasks) must not contain any significant delays, be delay() or long running loops. Then you can either merge both loop() functions into one, or keep them separate with different names, and call each in the new loop(). It's essential that no task will block the other one for a too long time.

Thank you!

I ended up making the loop and the delays shorter, then splicing the code together... not ideal for a longer project, but definitely suitable for the tiny project I had going right now!