By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: How I Built an Infinite Retro Game Soundtrack Generator Using Quantum Physics and Gemini 2.5 Flash | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > How I Built an Infinite Retro Game Soundtrack Generator Using Quantum Physics and Gemini 2.5 Flash | HackerNoon
Computing

How I Built an Infinite Retro Game Soundtrack Generator Using Quantum Physics and Gemini 2.5 Flash | HackerNoon

News Room
Last updated: 2025/12/11 at 9:40 PM
News Room Published 11 December 2025
Share
How I Built an Infinite Retro Game Soundtrack Generator Using Quantum Physics and Gemini 2.5 Flash | HackerNoon
SHARE

We’ve all been there. You’re building an indie game, and you need background music. You don’t have the budget to license tracks, and you definitely don’t have the time to learn music theory.

So, I asked myself: Can I build a machine that generates infinite, royalty-free, copyright-cleared retro game music using Python?

The answer is yes. But to make it actually good, I had to do something a little crazy. I had to abandon standard computer randomness and use Quantum Vacuum Fluctuations and Google’s Gemini 2.5 Flash.

Here is how I built the Quantum Retro Composer.

The Problem with random.randint()

My first attempt was simple: use Python’s random library to pick notes from a scale.

# The "Robot Chaos" approach
note = random.choice(['C', 'E', 'G', 'B'])

The result? It sounded like a robot falling down the stairs. It was random, but it wasn’t music. Music isn’t just random events; it’s structure, repetition, and “vibe.” Standard pseudo-random number generators (PRNGs) are deterministic and boring. They don’t have souls.

To fix this, I needed two things:

  1. True Entropy: Randomness derived from the physical world, not an algorithm.
  2. Musical Intelligence: Something that understands the difference between a “boss fight” and a “stealth mission.”

Step 1: Harvesting Entropy from the Vacuum

To get “organic” variation, I connected my Python script to the Australian National University (ANU) Quantum Random Numbers API.

This API measures the quantum fluctuations of the vacuum in real-time. By measuring the noise of a laser, we get true, unpredictable entropy. I combined this with my computer’s hardware entropy and the current nanosecond time to generate a Cryptographic Seed.

def get_quantum_seed():
    # 1. Get Hardware Entropy
    hw = secrets.token_bytes(32)

    # 2. Get Quantum Vacuum Data (from ANU API)
    qw = requests.get("https://qrng.anu.edu.au/API/jsonI.php...").content

    # 3. Hash them together
    hasher = hashlib.sha256()
    hasher.update(hw + qw)
    return int(hasher.hexdigest(), 16)

Now, every song my script generates is mathematically unique in the universe.

Step 2: The Conductor (Gemini 2.5 Flash)

Randomness gives us variation, but it doesn’t give us structure. This is where Gemini 2.5 Flash comes in.

Instead of writing complex rules for music theory (which is hard), I treat the LLM as a “Composer.” I feed it my Quantum Seed and a prompt describing the vibe I want (“High energy retro game boss fight”), and I ask it to return a JSON “Music Sheet.”

Here is the secret sauce: I don’t ask Gemini for audio. I ask for Data.

prompt = f"""
You are a legendary Retro Game Composer. Seed: {seed}.
Create a BUSY, CONTINUOUS Retro Game Soundtrack (3 Phases).

JSON Structure:
{{
  "bpm": 125,
  "phase_1": {{ "kick": [0, 4, 8...], "bass": [ {{ "step": 0, "freq": 55.0 }} ] }},
  "phase_2": {{ ... }}
}}
"""

Gemini understands syncopation. It knows that if the kick drum hits on beat 1, the snare usually hits on beat 2. It handles the “music theory” so I don’t have to.

Step 3: The Synthesizer (Pure Math)

I didn’t want to rely on external sample packs (MP3s) because that limits variation. Instead, I built a Digital Signal Processing (DSP) engine in Python using numpy.

Every instrument is generated from scratch using sine waves, noise, and math.

The “Retro” Kick Drum: To sound like a 90s console, you don’t use a real drum recording. You take a sine wave and pitch-shift it down rapidly.

def synth_kick_retro():
    t = np.linspace(0, 0.4, int(44100 * 0.4))
    # Drop pitch from 150Hz to 40Hz quickly
    freq = 150 * np.exp(-12 * t) + 40
    wave = np.sin(2 * np.pi * freq * t)
    # Clip it for that "crunchy" 16-bit sound
    return np.clip(wave * 1.5, -0.8, 0.8)

I built similar mathematical models for:

  • Snare: White noise + a short sine wave “thud.”
  • Bass: A square wave (NES style).
  • Keys: Pulse waves with a simple LFO (Low Frequency Oscillator) for tremolo.

Step 4: The “Glue” (Solving the Silence)

The early versions of the script had a flaw: they were too sparse. The AI would write a cool beat for 2 seconds and then leave 2 seconds of silence. It sounded like a ticker tape.

To solve this, I wrote a Density Enforcer.

Before rendering the audio, my script scans the JSON returned by Gemini. If the drum pattern is too empty, or if the loop doesn’t extend to the end of the bar, the Python script mechanically injects “filler” notes—like a steady hi-hat or a drone pad—to ensure there is never dead air.

def ensure_density(data):
    # If the AI forgot to write Hi-Hats, force 8th notes
    if len(data.get("closed_hat", [])) < 16:
        data["closed_hat"] = list(range(0, 64, 2))
    return data

I also added a Pad Drone—a low-volume background synthesizer that plays the root note continuously. This acts as “audio glue,” blending the disjointed AI notes into a cohesive track.

The Result: Infinite Retro Bops

The final script exports a .wav file that is:

  1. Seamlessly Looping: It calculates the exact sample count to cut the file on the beat.
  2. Bit-Crushed: I added a downsampling algorithm to emulate the SNES audio chip.
  3. Copyright Free: Generated by math + entropy.

I can now generate a unique, 3-minute evolving boss theme in about 15 seconds. It starts with a stealthy intro, builds into a groove, hits a chaotic climax, and fades back out—all dictated by the roll of a quantum dice.

Check it out on GitHub

This project was completed by Gemini in the browser. Visual Studio Code was used for testing. As always, I am a very blind individual, and I use special tools to help me do my projects. Centaur Model ftw! (for the win)

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article New Front-End Framework Ripple Blends React and Svelte Together New Front-End Framework Ripple Blends React and Svelte Together
Next Article HBO Max Subscribers Are Obsessed With A 2025 Comedy That Took 30 Years To Make – BGR HBO Max Subscribers Are Obsessed With A 2025 Comedy That Took 30 Years To Make – BGR
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

a maneuver that aims to cut ground on Google’s Gemini 3
a maneuver that aims to cut ground on Google’s Gemini 3
Mobile
Former Intel directors oppose TSMC’s takeover of Intel’s foundry · TechNode
Former Intel directors oppose TSMC’s takeover of Intel’s foundry · TechNode
Computing
Sat, 12/13/2025 – 18:00 – Editors Summary
News
The 13 Best Trailers of the Game Awards 2025
The 13 Best Trailers of the Game Awards 2025
News

You Might also Like

Former Intel directors oppose TSMC’s takeover of Intel’s foundry · TechNode
Computing

Former Intel directors oppose TSMC’s takeover of Intel’s foundry · TechNode

1 Min Read
Phantom Blade Zero to launch on Sept. 9, 2026, S-GAME says at TGA 2025 · TechNode
Computing

Phantom Blade Zero to launch on Sept. 9, 2026, S-GAME says at TGA 2025 · TechNode

1 Min Read
👨🏿‍🚀 Daily – Court freezes Kenya’s US healthcare deal |
Computing

👨🏿‍🚀 Daily – Court freezes Kenya’s US healthcare deal |

5 Min Read
Chinese bubble-tea giant Mixue pops 47% on debut as investor demand surges · TechNode
Computing

Chinese bubble-tea giant Mixue pops 47% on debut as investor demand surges · TechNode

3 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?