{"course":{"slug":"making-things-with-ai","title":"Making Things with AI","url":"https://addaly.com/learn/making-things-with-ai","level":"beginner","track":"create"},"lesson":{"slug":"how-audio-is-generated","title":"How a machine writes a waveform","url":"https://addaly.com/learn/making-things-with-ai/how-audio-is-generated","position":59,"of":84,"minutes":8,"answer":"Music models generate stacks of discrete audio tokens produced by a neural codec, so the codec's bitrate sets the ceiling on quality and the token rate sets the cost of length.","keyIdea":"Music models generate stacks of discrete audio tokens produced by a neural codec, so the codec's bitrate sets the ceiling on quality and the token rate sets the cost of length."},"body":{"format":"markdown","text":"## Audio is a lot of numbers\n\nA stereo track at CD quality is 44,100 samples per second per channel. Three minutes is about 16 million numbers. Predicting those directly, one at a time, was tried and is impractical for anything beyond a few seconds.\n\nThe solution is the same one the voice module described, applied at higher quality. A **neural audio codec** learns to compress audio into a small stream of discrete tokens and to reconstruct it. A common configuration produces tokens at 50 per second, with four to eight stacked codebooks, so one second of music is a few hundred integers rather than 88,000 samples.\n\nThe stacking matters and is worth understanding. The first codebook carries the coarse structure: roughly, the shape of the sound. Each subsequent codebook encodes the residual error left by the previous ones, adding detail. This is **residual vector quantisation**, and it means you can trade quality for speed by generating fewer codebooks, which is exactly what fast preview modes do.\n\nGiven that representation, generation is sequence prediction: a transformer predicts the next tokens conditioned on a text description, a melody, or the tokens so far. The codec decoder turns the result back into sound.\n\n## The other approach, and why both survive\n\nSome systems work on **spectrograms** instead (the time-frequency picture of a sound) treating them as images and applying diffusion. A vocoder converts the spectrogram back to a waveform.\n\nThis inherits the strengths of image diffusion: strong texture, parallel generation, good conditioning tools. It also inherits the vocoder problem, because a spectrogram discards phase information, and reconstructing phase is where the characteristic metallic or watery artefacts in some generated music come from.\n\nCurrent strong systems are frequently hybrids. Which one you are using is usually stated in the model card, and it predicts the artefacts: token-based systems tend toward abrupt glitches and structural drift, spectrogram-based ones toward smearing and phasiness.\n\n## The numbers that govern quality\n\n**Codec bitrate is the ceiling.** No amount of model capacity produces audio better than the codec can reconstruct. The test from the image module works identically here: run a real track through the codec's encoder and straight back out, with no generation at all. What comes back is the best the system can ever produce. Do this once and you will stop expecting master-quality output from a model whose codec cannot deliver it.\n\n**Sample rate.** Many open music models generate at 32 kHz rather than 44.1, which means nothing above 16 kHz. On a phone this is inaudible. On good headphones the top end sounds slightly closed, and it matters if the track will be mastered alongside recorded material.\n\n**Token rate times duration** is the cost, which is why generated tracks are typically 30 seconds to a few minutes and why extending is done in chunks with the same drift problem as video.\n\n## What free tools exist\n\nThe open end of this field is usable:\n\n- Open music-generation models run on consumer hardware and produce instrumental tracks of reasonable quality. Licences vary considerably: several are non-commercial only, which is a detail people miss until it matters. Read the licence before using output in paid work.\n- Some open models are trained specifically on permissively licensed and public-domain audio, which materially changes the rights position and is worth seeking out.\n- **Audacity** for editing, **LMMS** and **Ardour** for full production, all free.\n\n## Where the quality actually is\n\nBeing specific rather than dismissive: current generated music is good at texture, atmosphere and short loops. A four-bar bed, an ambient wash, a percussion loop, a sting: these are frequently indistinguishable from library music and take seconds.\n\nIt is weak at everything that depends on structure over time, which is the next lesson, and it is weak at anything with a lead vocal that has to be intelligible, expressive and in tune across a whole song.\n\nThere is one more setting worth finding in whatever tool you use: the number of codebooks or the quality tier. Fast preview modes generate fewer residual codebooks, which is why the draft sounds thin and grainy and the final render does not. People frequently judge a model on its preview output and conclude it is poor. Generate one full-quality render before forming an opinion, and use the preview for what it is good for, which is deciding whether the idea is right.\n\nThe limitation to carry: audio quality has a hard ceiling set by a component most users never look at, and structure has a soft ceiling set by the same attention-window problem as every other medium in this course. Neither is a matter of prompting better."},"check":{"question":"A generated track sounds slightly closed at the top end compared with commercial recordings. What is the most likely cause?","options":[{"text":"The model generates at a sample rate that carries no content above about 16 kHz.","correct":true},{"text":"The generation used too few denoising steps, so the high-frequency detail was never resolved.","correct":false,"tempting":"Step counts affect detail in diffusion pipelines generally; a systematic absence of the top octave points at the sample rate instead."},{"text":"The prompt did not describe the desired brightness, so the model produced a darker mix by default.","correct":false,"tempting":"A prompt can shift the tonal balance within what the format carries; it cannot add frequencies the sample rate excludes."},{"text":"The stereo field was collapsed to mono during generation, which removes the perception of high-frequency air in the recording.","correct":false,"tempting":"Mono collapse changes the sense of space rather than the frequency content, and would be audible as narrowness rather than as a closed top end."}]},"prev":{"slug":"music-and-its-sources","title":"Music, and whose music it learned from","url":"https://addaly.com/learn/making-things-with-ai/music-and-its-sources"},"next":{"slug":"why-music-is-hard","title":"Why music is harder than speech","url":"https://addaly.com/learn/making-things-with-ai/why-music-is-hard"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'How a machine writes a waveform', in Making Things with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/making-things-with-ai/how-audio-is-generated (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"How a machine writes a waveform","courseTitle":"Making Things with AI","module":{"index":7,"slug":"music-and-sound","title":"Music and sound"},"answer":null,"keyIdea":"Music models generate stacks of discrete audio tokens produced by a neural codec, so the codec’s bitrate sets the ceiling on quality and the token rate sets the cost of length.","hero":{"kind":"plate","image":null,"alt":null,"caption":null},"blocks":[{"t":"h2","id":"audio-is-a-lot-of-numbers","runs":[{"text":"Audio is a lot of numbers"}]},{"t":"p","runs":[{"text":"A stereo track at CD quality is 44,100 samples per second per channel. Three minutes is about 16 million numbers. Predicting those directly, one at a time, was tried and is impractical for anything beyond a few seconds."}]},{"t":"p","runs":[{"text":"The solution is the same one the voice module described, applied at higher quality. A "},{"text":"neural audio codec","b":true},{"text":" learns to compress audio into a small stream of discrete tokens and to reconstruct it. A common configuration produces tokens at 50 per second, with four to eight stacked codebooks, so one second of music is a few hundred integers rather than 88,000 samples."}]},{"t":"p","runs":[{"text":"The stacking matters and is worth understanding. The first codebook carries the coarse structure: roughly, the shape of the sound. Each subsequent codebook encodes the residual error left by the previous ones, adding detail. This is "},{"text":"residual vector quantisation","b":true},{"text":", and it means you can trade quality for speed by generating fewer codebooks, which is exactly what fast preview modes do."}]},{"t":"p","runs":[{"text":"Given that representation, generation is sequence prediction: a transformer predicts the next tokens conditioned on a text description, a melody, or the tokens so far. The codec decoder turns the result back into sound."}]},{"t":"h2","id":"the-other-approach-and-why-both-survive","runs":[{"text":"The other approach, and why both survive"}]},{"t":"p","runs":[{"text":"Some systems work on "},{"text":"spectrograms","b":true},{"text":" instead (the time-frequency picture of a sound) treating them as images and applying diffusion. A vocoder converts the spectrogram back to a waveform."}]},{"t":"p","runs":[{"text":"This inherits the strengths of image diffusion: strong texture, parallel generation, good conditioning tools. It also inherits the vocoder problem, because a spectrogram discards phase information, and reconstructing phase is where the characteristic metallic or watery artefacts in some generated music come from."}]},{"t":"p","runs":[{"text":"Current strong systems are frequently hybrids. Which one you are using is usually stated in the model card, and it predicts the artefacts: token-based systems tend toward abrupt glitches and structural drift, spectrogram-based ones toward smearing and phasiness."}]},{"t":"h2","id":"the-numbers-that-govern-quality","runs":[{"text":"The numbers that govern quality"}]},{"t":"p","runs":[{"text":"Codec bitrate is the ceiling.","b":true},{"text":" No amount of model capacity produces audio better than the codec can reconstruct. The test from the image module works identically here: run a real track through the codec’s encoder and straight back out, with no generation at all. What comes back is the best the system can ever produce. Do this once and you will stop expecting master-quality output from a model whose codec cannot deliver it."}]},{"t":"p","runs":[{"text":"Sample rate.","b":true},{"text":" Many open music models generate at 32 kHz rather than 44.1, which means nothing above 16 kHz. On a phone this is inaudible. On good headphones the top end sounds slightly closed, and it matters if the track will be mastered alongside recorded material."}]},{"t":"p","runs":[{"text":"Token rate times duration","b":true},{"text":" is the cost, which is why generated tracks are typically 30 seconds to a few minutes and why extending is done in chunks with the same drift problem as video."}]},{"t":"h2","id":"what-free-tools-exist","runs":[{"text":"What free tools exist"}]},{"t":"p","runs":[{"text":"The open end of this field is usable:"}]},{"t":"ul","items":[[{"text":"Open music-generation models run on consumer hardware and produce instrumental tracks of reasonable quality. Licences vary considerably: several are non-commercial only, which is a detail people miss until it matters. Read the licence before using output in paid work."}],[{"text":"Some open models are trained specifically on permissively licensed and public-domain audio, which materially changes the rights position and is worth seeking out."}],[{"text":"Audacity","b":true},{"text":" for editing, "},{"text":"LMMS","b":true},{"text":" and "},{"text":"Ardour","b":true},{"text":" for full production, all free."}]]},{"t":"h2","id":"where-the-quality-actually-is","runs":[{"text":"Where the quality actually is"}]},{"t":"p","runs":[{"text":"Being specific rather than dismissive: current generated music is good at texture, atmosphere and short loops. A four-bar bed, an ambient wash, a percussion loop, a sting: these are frequently indistinguishable from library music and take seconds."}]},{"t":"p","runs":[{"text":"It is weak at everything that depends on structure over time, which is the next lesson, and it is weak at anything with a lead vocal that has to be intelligible, expressive and in tune across a whole song."}]},{"t":"p","runs":[{"text":"There is one more setting worth finding in whatever tool you use: the number of codebooks or the quality tier. Fast preview modes generate fewer residual codebooks, which is why the draft sounds thin and grainy and the final render does not. People frequently judge a model on its preview output and conclude it is poor. Generate one full-quality render before forming an opinion, and use the preview for what it is good for, which is deciding whether the idea is right."}]},{"t":"p","runs":[{"text":"The limitation to carry: audio quality has a hard ceiling set by a component most users never look at, and structure has a soft ceiling set by the same attention-window problem as every other medium in this course. Neither is a matter of prompting better."}]}],"check":{"question":[{"text":"A generated track sounds slightly closed at the top end compared with commercial recordings. What is the most likely cause?"}],"options":[{"text":[{"text":"The model generates at a sample rate that carries no content above about 16 kHz."}],"correct":true,"tempting":null},{"text":[{"text":"The generation used too few denoising steps, so the high-frequency detail was never resolved."}],"correct":false,"tempting":[{"text":"Step counts affect detail in diffusion pipelines generally; a systematic absence of the top octave points at the sample rate instead."}]},{"text":[{"text":"The prompt did not describe the desired brightness, so the model produced a darker mix by default."}],"correct":false,"tempting":[{"text":"A prompt can shift the tonal balance within what the format carries; it cannot add frequencies the sample rate excludes."}]},{"text":[{"text":"The stereo field was collapsed to mono during generation, which removes the perception of high-frequency air in the recording."}],"correct":false,"tempting":[{"text":"Mono collapse changes the sense of space rather than the frequency content, and would be audible as narrowness rather than as a closed top end."}]}],"order":[3,0,1,2],"why":null},"prev":{"slug":"music-and-its-sources","title":"Music, and whose music it learned from","minutes":8},"next":{"slug":"why-music-is-hard","title":"Why music is harder than speech","minutes":8}}}