Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Does setPitch() modify SoundBuffer?  (Read 2615 times)

0 Members and 1 Guest are viewing this topic.

StefanDimeski

  • Newbie
  • *
  • Posts: 1
    • View Profile
Does setPitch() modify SoundBuffer?
« 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!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Does setPitch() modify SoundBuffer?
« Reply #1 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".
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything