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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - kant

Pages: [1]
1
Audio / setPitch() function only sets pitch up to a certain point
« on: April 17, 2022, 05:44:31 am »
when running setPitch() on a sound, the sound's pitch does not actually change. it should be noted that there are no errors in build log or build messages, and the issue still persists after rebuilding

#include <math.h>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "leh");

    note1.loadFromFile("notes/c.ogg");
    //a 1 minute sound file containing note C at octave 0
    pNote1.setBuffer(note1);
    pNote1.setPitch(pow(2, 0));
    //this should set the pitch of pNote1 to a c at octave 4
    //the actual heard note is much lower
    pNote1.play();

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.display();
    }

    return 0;
}

 

is there an upper limit to how much i can multiply a sound's pitch by?

i am using SFML 2.5.1 for GCC 7.3.0 MinGW (SEH) - 64-bit on windows 10 with code::blocks 20.03

Pages: [1]