SFML community forums

Help => Audio => Topic started by: StefanDimeski on December 24, 2015, 10:23:35 pm

Title: Does setPitch() modify SoundBuffer?
Post by: StefanDimeski on December 24, 2015, 10:23:35 pm
What my program in theory does is it loads a sound from a file, modifies the pitch by some values, and each time it modifies the pitch it saves the (now pitch-modified) sound into a new file(saves the SoundBuffer). However, when I load the sounds from the new files the sound is like the original (the pitch is not modified). So I was wondering: Does Sound.setPitch() in any way modify the SoundBuffer bound with that sound? and Is it possible to save the sound taking into account the change of the pitch via Sound.setPitch?

Here's the code that modifies the sound and then save it's SoundBuffer to file:

for (int i = -7; i <= 7; i++)
{
        if (i == 0)
        {
                sound.setPitch(1.f);
        }

        sound.setPitch(sound.getPitch() + (i/1000.f)); 

        sound.getBuffer()->saveToFile("music_" + to_string(i) + ".wav");
}

Thanks in advance!
Title: Re: Does setPitch() modify SoundBuffer?
Post by: Hapax on December 24, 2015, 10:54:15 pm
No, setPitch does not modify the sound buffer; it sets the speed of playback.
Modifying the pitch of a sound buffer would require "resampling (https://www.google.co.uk/?q=resampling)".