wav mixer

hi everyone,

I'm doing a mixer with wav files. I can play and even apply the reverse effect to them. the logarithm is like this:

for( unsigned int i=0; i<sampleCount/2; i++ )
// swapping with the other half
double temp = samples[i];
samples[i] = samples[sampleCount-i-1];
samples[sampleCount-i-1] = temp;

Now I want to apply these effects to the files: delay, slow, and fast but I don't know how to do it.

The teacher told me that to do it slow I need to double the Samples so I tried to do this samples[i] = samples[sampleCount*2]; it does not work......Also I apply the contrary to do make the sound fast samples[i] = samples[sampleCount/2]; the samething I don't get the sound desired.

For the daley part I'm thinking on play the audio one without touch it and then repit it 8 times or more to create the delay.... I did it like this:

double temp = samples[i];
samples[i] = samples[sampleCount-i-1]+ (samples[sampleCount -i-1]*8);

It didn't work....

Also I don't know why the use of -i-1 after sampleCount!!

if you can guide me I will really appreciate it!
Also I don't know why the use of -i-1 after sampleCount!!
This is what makes the reverse effect. If sampleCount = 10, the loop will do:
Iteration 1: swap samples[0] and samples[9]
Iteration 2: swap samples[1] and samples[8]
Iteration 3: swap samples[2] and samples[7]
Iteration 4: swap samples[3] and samples[6]
Iteration 5: swap samples[4] and samples[5]

If you want to change the speed of the whole WAVE file I think you can just change the SampleRate in the WAVE header.

If you don't want to change the SampleRate you will have to resize samples. Half speed, means you will have to double the number of samples. If the samples before was 128 178 133 100, they should be 128 128 178 178 133 133 100 100 after. Maybe it sounds better if you interpolate instead of just making a copy of each sample.

Double speed means half the number of samples. One way is to just drop every other sample. If the samples before was 128 178 133 100, they would be 128 133 after. Not sure if taking the average of two samples to create one sample would sound better. In that case you would get 153 116 after instead.
Topic archived. No new replies allowed.