Some music was original, some was public domain music such as folk songs.
The decision to include any music into a video game meant that at some point it would have to be transcribed into computer code. The first video game to feature continuous, melodic background music was Rally-X, released by Namco in 1980, featuring a simple tune that repeats continuously during gameplay. It had four descending chromatic bass notes repeating in a loop, though it was dynamic and interacted with the player, increasing pace as the enemies descended on the player.
The first game to use a continuous background soundtrack was Tomohiro Nishikado's Space Invaders, released by Taito in 1978. While this allowed for inclusion of music in early arcade video games, it was usually monophonic, looped or used sparingly between stages or at the start of a new game, such as the Namco titles Pac-Man (1980) composed by Toshio Kai or Pole Position (1982) composed by Nobuyuki Ohnogi.