1
I’m trying to make a volume change in a WAV file that I just don’t understand because it’s not right. I am a beginner and ask you help to understand the volume pq get very burst and noisy when I try to decrease the volume. Basically if I try to increase the volume works well, but when I put for example "factor = 0.5" which is intended to decrease the audio volume by half does not work. NOTE: it is already said that the file in question has the header with 44 bytes and the samples 16 bits
// TODO: Copy header from input file to output file
// HEADER_SIZE = tamanho do cabeçalho do input
// BYTE = uint8_t
BYTE bytes[HEADER_SIZE];
fread(bytes,sizeof(BYTE),HEADER_SIZE,input);
fwrite(bytes,sizeof(BYTE),HEADER_SIZE,output);
// TODO: Read samples from input file and write updated data to output file
// BYTE16 = uint16_t
BYTE16 tbytes;
fseek(input,44,0);
fseek(output,44,0);
while(fread(&tbytes, sizeof(BYTE16),1,input))
{
tbytes = (BYTE16)(tbytes * factor);
fwrite(&tbytes, sizeof(BYTE16), 1, output);
}
Even putting 0.9 or 0.8 does not change anything, the audio gets extremely loud , burst and noise
– Victor Ivan