SFML community forums

Help => Audio => Topic started by: CosminPerRam on July 12, 2017, 12:04:39 pm

Title: Theres an option for speed/tempo?
Post by: CosminPerRam on July 12, 2017, 12:04:39 pm
Hello fellas, i wonder if there's a way to change the tempo/speed of the music? Even when the music is running? And also, how i can see at what second is the music at the moment? Also, im beginner in C++. Thanks in advance!
Title: Re: Theres an option for speed/tempo?
Post by: Flaze07 on July 12, 2017, 03:59:33 pm
ahh...you did what I told you  ;D
altho I cannot provide an answer
Title: Re: Theres an option for speed/tempo?
Post by: Laurent on July 12, 2017, 05:56:43 pm
The pitch is the only thing you can change that has an effect on the music speed:
https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1SoundSource.php#a72a13695ed48b7f7b55e7cd4431f4bb6

For the current playback position:
https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1SoundStream.php#a6070416e1e1a11b5915e9314dd6638f7
Title: Re: Theres an option for speed/tempo?
Post by: lucifercartwright on August 06, 2017, 12:52:59 pm
The pitch is the only thing you can change that has an effect on the music speed:
https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1SoundSource.php#a72a13695ed48b7f7b55e7cd4431f4bb6

For the current playback position:
https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1SoundStream.php#a6070416e1e1a11b5915e9314dd6638f7

Is there a reason why when you set the pitch higher the sound gets sped up?
Title: Re: Theres an option for speed/tempo?
Post by: Hapax on August 06, 2017, 03:21:06 pm
Yes, a higher pitch has a higher frequency so increasing the pitch technically just increases the speed at which the samples are played back.
Title: Re: Theres an option for speed/tempo?
Post by: lucifercartwright on August 07, 2017, 09:51:35 am
Yes, a higher pitch has a higher frequency so increasing the pitch technically just increases the speed at which the samples are played back.

But how do programs like Audacity manage to up the pitch while maintaining the same speed of the sound?

Or is this delving into something too complicated to explain?
Title: Re: Theres an option for speed/tempo?
Post by: Laurent on August 07, 2017, 01:17:21 pm
Quote
But how do programs like Audacity manage to up the pitch while maintaining the same speed of the sound?
They use more complicated algorithms, that are not part of OpenAL (and therefore SFML).