Coding Global Background
Coding Global

yo guys check this out i made a .wav file in c

c
3 messages
3 members
6 days ago
Z
zec
Verified

okay so this is lowkey really simple but i hadn't thought of this before. essentially a wav file is literally just a list of numbers that tell your speakers how much to move at each tiny interval in time. what im doing here is making sine waves with the math sin() funtion (the simplest tone). we just feed it the frequency we want and the current time, and it spits out a number between -1 and 1. then we convert those decimal numbers into 16-bit integers (numbers from -32,767 to 32,767) because that's what the wav format expects. each number represents how much the speaker cone should move at a given moment. the wav header at the beginning of the file is just metadata, after that its just wikipedia information and code lol

Replies (3)