In my application I need to record some wav files and set them to a specific volume and pitch. Right now I can record and play the .wav files using winmm.dll but I have no idea how to modify them.
private void Record()
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
private void StopRecord(string file)
{
string path = "C:\\Users\\Workshop\\Dani\\audiofiles\\audiofiles\\" + this.Name + '\\' + file + ".wav";
mciSendString("save recsound " + path, "", 0, 0);
mciSendString("close recsound", "", 0, 0);
}
private void Reproduce (string path)
{
SoundPlayer player = new SoundPlayer(path);
player.Load();
player.Play();
}
I've seen, by searching the internet, that using the NAudio.dll it is possible to modify the .wav files, but I'm not fully understanding how it works.
By using Naudio library is possible to get all the samples of a .wav file and modify them as you want.
It's important to keep in mind that each sample is a float an its value goes from -1.0f to 1.0f. Also it's important to know in how many channels the audio has been recorded, in my case it was only one channel, that's why I used a[0], but if there where more channels i should use a[0],a[1],...,a[nChannels]