Lunar Boom Learning

3.4 · Diffusion Models

Section 3.4 of 3.6

Diffusion Models

Generating music through repeated denoising

Learn how diffusion models corrupt training examples with noise, learn to reverse that corruption, and generate music by gradually refining a noisy waveform, spectrogram, or latent representation.

About 13 minutes

Guiding question

How does random noise become structured audio?

By the end, you’ll be able to
  • Describe the forward noising process and reverse denoising process.
  • Explain how a noise schedule controls the amount of corruption at each diffusion step.
  • Distinguish diffusion in waveform, spectrogram, and latent spaces.
  • Explain why latent diffusion can reduce sequence size and computational cost.
  • Compare diffusion generation with autoregressive token generation.
  • Describe how DiffWave, AudioLDM, Noise2Music, Moûsai, and Stable Audio apply diffusion to audio or music.

The previous sections described models that generate a sequence by choosing one token after another. Diffusion models take a different route.

They begin with a noisy representation and repeatedly revise it. At first, the representation contains almost no recognisable music. After several denoising steps, broad shapes begin to appear. Later steps refine rhythm, timbre, texture, and local detail.

The model does not remove real microphone noise from an existing recording. It reverses an artificial corruption process created for training.

The two sides of diffusion

Swipe sideways to view the full comparison

ProcessDirectionWhat happensWhen it is used
Forward processClean data toward noiseKnown amounts of noise are added to a training examplePreparing training inputs
Reverse processNoise toward structured dataA trained model repeatedly estimates a cleaner representationGenerating new audio

Teaching the model with artificial corruption

Begin with a clean training representation called x0. This could be a waveform, spectrogram, or compressed latent.

The forward process adds a controlled amount of Gaussian noise:

x0 → x1 → x2 → ... → xT

Early versions remain close to the original. Later versions are increasingly corrupted. At a sufficiently noisy endpoint, xT resembles random noise much more than music.

Because the training system added the noise itself, it knows how much corruption was applied.

The schedule controls the difficulty

The model must learn from examples containing many levels of corruption. A nearly clean example requires small corrections. A heavily corrupted example requires the model to infer broad structure from weak evidence.

The noise schedule determines which corruption levels exist and how they are distributed across timesteps. A poor schedule can make useful learning or efficient sampling harder.

Later diffusion research introduced alternative schedules and samplers that reduce the number of model evaluations needed for generation.

What the model learns

Training does not always require running through the full corruption chain one step at a time.

A typical training step can:

  1. Select a clean example.
  2. Select a random diffusion timestep.
  3. Add the amount of noise associated with that timestep.
  4. Give the noisy representation and timestep to the model.
  5. Ask the model to predict the added noise or another equivalent denoising target.
  6. Compare the prediction with the known target.

The model repeats this task across many recordings and noise levels.

One diffusion training step

  1. Load a clean representation

    Use a waveform, spectrogram, or latent representation from the training dataset.

  2. Choose a timestep

    Select how strongly the example will be corrupted.

  3. Sample random noise

    Generate a known noise tensor with the same shape as the representation.

  4. Create the noisy input

    Combine the clean representation and noise according to the schedule.

  5. Predict the denoising target

    Give the model the noisy input, timestep, and any conditions.

  6. Calculate the loss

    Compare the prediction with the known noise or equivalent training target.

Generating from noise

Once training is complete, the model no longer needs a clean example.

Generation begins with random noise called xT. The model receives that noisy state, the current timestep, and any condition such as a text prompt. It predicts how the representation should change.

The sampler uses that prediction to create a slightly cleaner state. The process repeats:

xT → x(T-1) → ... → x1 → x0

The final x0 is decoded or played as the generated audio.

The diffusion generation loop

  1. Sample the initial noise

    Create a random tensor in the waveform, spectrogram, or latent space.

  2. Read the current timestep

    Tell the model how noisy the current representation is expected to be.

  3. Apply conditioning

    Provide text, timing, melody, or another control signal when the model supports it.

  4. Predict a denoising direction

    Estimate the noise or another target needed by the sampler.

  5. Update the representation

    Move to a slightly cleaner state according to the sampler.

  6. Repeat and decode

    Continue until the final representation can be converted into audio.

More steps are not automatically better

Early diffusion systems often used long sampling chains. Later samplers showed that useful outputs could be produced with fewer evaluations.

Reducing the step count can make generation faster, but an aggressive reduction may weaken detail, stability, or prompt adherence. The best setting depends on the trained model, sampler, representation, and task.

A model trained with one noise process can also support more than one sampling procedure.

In practice

Real-world technique: DDIM sampling

Denoising Diffusion Implicit Models showed that models trained with the standard diffusion objective could be sampled through a different, non-Markovian process. This made it possible to reduce the number of sampling steps while preserving the same training procedure.

Diffusion and autoregression

Swipe sideways to view the full comparison

QuestionAutoregressive modelDiffusion model
Starting pointA prompt, prefix, or start tokenA random or partially corrupted representation
Main operationChoose the next tokenRefine the current representation
CommitmentEarlier selected tokens become fixed contextMany positions can change across several denoising steps
Generation orderUsually left to right or according to a token orderingRepeated updates across the representation
Main costOne model evaluation for each generated token or token groupRepeated model evaluations for denoising steps
Typical representationDiscrete event or codec tokensContinuous waveform, spectrogram, or latent values

Where can diffusion happen?

Diffusion is a method for modelling a distribution. It does not require one specific music representation.

An audio model can diffuse:

    1. Raw waveform values
    2. Spectrogram values
    3. Compressed continuous latents
    4. An intermediate representation inside a cascade

The choice changes the size of the problem, what information is represented directly, and which decoder is needed afterward.

Choosing the diffusion space

Swipe sideways to view the full comparison

SpaceMain advantageMain challengeExample
WaveformModels playable audio directlyVery large representation with many samplesDiffWave
SpectrogramMakes frequency structure explicitRequires phase recovery or a vocoderSpectrogram-based audio systems
Compressed latentReduces the size of the denoising problemQuality depends on the encoder and decoderAudioLDM, Moûsai, Stable Audio
Intermediate cascade representationSeparates generation from final audio refinementErrors can pass from one stage into the nextNoise2Music

Why generate in a latent space?

A waveform sampled at 44.1 kHz contains 44,100 sample values per channel for every second of audio. A compressed latent can represent the same duration with far fewer positions.

Diffusion in that latent space reduces the size of each model input and denoising update. The model can spend more capacity on musically useful variation instead of reconstructing every waveform sample directly.

The trade-off is that the autoencoder becomes part of the final quality limit. If the latent representation loses a transient, stereo cue, or high-frequency texture, the diffusion model cannot fully recover it later.

In practice

Real-world example: DiffWave

DiffWave applies diffusion directly to waveforms. It can generate audio unconditionally or work as a neural vocoder conditioned on a mel-spectrogram. The model converts white noise into a structured waveform over a fixed series of denoising steps.

Real-world example: AudioLDM

AudioLDM performs diffusion in a compressed audio representation rather than directly in waveform space.

Its autoencoder represents mel-spectrogram information in a latent space. The diffusion model generates that latent, after which the latent is decoded to a mel-spectrogram and converted into a waveform.

AudioLDM also uses CLAP, a shared audio-language embedding model. During training, audio embeddings can provide the condition. During text-to-audio sampling, aligned text embeddings guide generation.

In practice

Why the AudioLDM setup matters

AudioLDM showed that a latent diffusion system trained with audio conditions could use aligned text embeddings during sampling. This reduced its dependence on paired text descriptions for every training recording while still allowing text-guided generation.

Real-world example: Noise2Music

Noise2Music uses a cascade of diffusion models for text-conditioned music generation.

A generator first creates an intermediate audio representation from the text condition. A cascader then generates higher-fidelity audio while conditioning on that intermediate result and, depending on the configuration, the text.

The system was designed to generate 30-second music clips. It demonstrates that diffusion can be combined with the hierarchical design discussed in Section 3.

In practice

Real-world example: Moûsai

Moûsai uses a two-stage latent diffusion design. A diffusion autoencoder compresses audio, and a text-conditioned latent diffusion model generates inside that compressed space. The paper reports stereo music generation at 48 kHz over multi-minute durations.

Real-world example: Stable Audio

The Stable Audio research system uses a diffusion Transformer operating on a highly downsampled continuous audio latent.

Its conditioning includes text and timing information. Timing lets the model receive a requested duration and position within the training audio, rather than treating every clip as an unstructured fixed-length segment.

The paper reports generation of music lasting up to 4 minutes and 45 seconds using a latent rate of 21.5 positions per second.

Guiding the denoising path

Without a condition, the model learns to generate examples from its overall data distribution. With a condition, the model learns how the denoising direction changes for a prompt, class, melody, timing signal, or another input.

A prompt such as slow ambient strings with distant choir should make some denoising paths more likely than others. The condition does not select one finished recording. It influences the repeated updates that shape the result.

Common diffusion misconceptions

Swipe sideways to view the full comparison

MisconceptionMore accurate explanation
The model cleans an existing noisy recordingStandard generation starts from newly sampled noise and constructs an original representation
The song is already hidden inside the noiseThe generated path is created by the trained model, sampler, conditions, and random seed
Every denoising step adds one musical eventEach step can revise values across the complete current representation
Latent noise should sound like hissA latent may not correspond directly to audible sound until decoded
More denoising steps always improve the resultUseful step counts depend on the sampler and model
Diffusion is fully parallelPositions can be updated together, but denoising iterations remain sequential
Strengths and limitations of diffusion

Swipe sideways to view the full comparison

AreaStrengthLimitation
Global revisionMany positions can change during each denoising stepSeveral full model evaluations are still required
ConditioningText and other signals can guide every refinement stageGuidance can reduce diversity or create artifacts
Latent modellingCompression makes long audio more manageableThe autoencoder can remove useful detail
EditingPartial corruption can support inpainting and transformationPreserving untouched content precisely can be difficult
VariationDifferent seeds can produce different results from one promptResults can be difficult to reproduce without recording all settings
Long-form musicLow-rate latents can cover long durationsLong duration does not automatically guarantee coherent musical form

Interactive lesson

Scrub Through Diffusion Steps

Try it: Start with the latent-space example and inspect the visual clean estimate at several steps. Compare the same deterministic seed with different prompts, guidance scales, and step counts. Then switch to waveform and spectrogram modes to see how the chosen representation changes the process.

A diffusion model begins with random values in a waveform, spectrogram, or latent space. It repeatedly predicts how the representation should change toward cleaner data. Conditions such as text guide each denoising update, and a decoder converts the final latent or spectrogram into playable audio.

Directing the result

Diffusion explains how a noisy representation becomes music, but it does not yet explain how a user controls that process.

The next section, Conditioning and Control, follows text prompts, melody inputs, timing signals, audio references, and guidance scales through the model. It also examines what happens when several conditions point in different directions.

Check your understanding

Ready for a quick check?

Test whether you can explain forward corruption, reverse denoising, latent diffusion, sampling, and real music-diffusion systems.

Ready to continue?

Save this section to your account and continue from any device.

Checking your account…
Sources for this lesson (11)
  1. Denoising Diffusion Probabilistic Models — Jonathan Ho, Ajay Jain, and Pieter Abbeel (2020)
  2. Improved Denoising Diffusion Probabilistic Models — Alexander Quinn Nichol and Prafulla Dhariwal (2021)
  3. Denoising Diffusion Implicit Models — Jiaming Song, Chenlin Meng, and Stefano Ermon (2021)
  4. High-Resolution Image Synthesis with Latent Diffusion Models — Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer (2022)
  5. Classifier-Free Diffusion Guidance — Jonathan Ho and Tim Salimans (2022)
  6. DiffWave: A Versatile Diffusion Model for Audio Synthesis — Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro (2021)
  7. AudioLDM: Text-to-Audio Generation with Latent Diffusion Models — Haohe Liu et al. (2023)
  8. Noise2Music: Text-Conditioned Music Generation with Diffusion Models — Qingqing Huang et al. (2023)
  9. Moûsai: Text-to-Music Generation with Long-Context Latent Diffusion — Flavio Schneider, Ojasv Kamal, Zhijing Jin, and Bernhard Schölkopf (2023)
  10. Long-form Music Generation with Latent Diffusion — Zach Evans, Julian D. Parker, CJ Carr, Zack Zukowski, Josiah Taylor, and Jordi Pons (2024)
  11. Stable Audio Open — Zach Evans, Julian D. Parker, CJ Carr, Zack Zukowski, Josiah Taylor, and Jordi Pons (2024)
Browse all contextual sources →