I'm trying to take a wav file and create gaps of silence in it at 1-second intervals. The gaps of silence aren't for pausing the file and then playing it again, they serve a 'mute' function, so if the input wav file was 10 seconds long then the output file would be 10 seconds long too.
I have access to all properties of the input wav file such as buffer size, I'm afraid I just have no idea how to go about reading from said file in this context. My best guess is something like this:
int gapLength = 1 * sampleRate;
for (int f = 0; f < numOfSamples; f++) {
if (f <= gapLength) {
buffer[f] = silence
}
else {
buffer[f] = sample[f] from audio input
}
}
sf_writef_double(sndFile, buffer, numOfSamples);
Going off this, I need to find out how to have the for loop check for the gap again after the first time, and some way to obtain sample[f] from the input wav file - maybe I could iterate through both wav files at the same time? Any advice at all would be a big help.