Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How To Use The Pitch Block For Speed THE RIGHT WAY
- LSPECTRONIZTAR
-
Scratcher
100+ posts
How To Use The Pitch Block For Speed THE RIGHT WAY
Introduction
Are you making a rhythm game and want to make a song speed feature? But no matter how many times you try this script, it just does not seem to work. My name is Adrien, and today I'll show you a script on how to make a song speed using the pitch block the right way. The reason the script below does not work is because Scratch's pitch system does not work the way we expect.
Overview of the pitch block
When the pitch changes by 10 the sound changes by one semitone For example, if a song is in Eb or D# (i.e. Camellia's “Exit This Earth's AtOmosphere,” a song I have recently taken to liking), it will be transposed to an E. Twelve semitones equal an octave (there are twelve keys for each octave). An octave is where the pitch is high-pitched but still in the same key.
Explaining the speed system
Many Scratchers expect the speed system to work like this:
But in reality, it goes like this:
As you can see, the speed doubles by 2 each time the pitch changes by 120. So therefore, if you set the pitch to 60, the song rate DOES NOT equal 1.5x. Anyway, I was doing some experimental work with pitch blocks in my rhythm game, and this is what I concluded with:
While the pitch effects can be somewhat accurate, they are not entirely accurate. After a while in 1.75x speed, the song becomes a bit offset.
The perfect code
The other day, I was playing PolyRhythm, and I was playing Exit This Earth's Atomosphere (I had played it twice in Beat Saber on Expert+ with No Arrows that day). Like my rhythm game I'm working on right now, it uses a beat timer, so even in Turbo Mode, the beats appear perfectly. Also, it too has a playback rate, and so I found a perfect code that explains everything (credit to DecaTen):
So yeah, that's how to use the pitch block for song speeds
BONUS: How to make a beat timer
Okay, bye
Edit 1/9/2024: Fixed a spelling mistake
Are you making a rhythm game and want to make a song speed feature? But no matter how many times you try this script, it just does not seem to work. My name is Adrien, and today I'll show you a script on how to make a song speed using the pitch block the right way. The reason the script below does not work is because Scratch's pitch system does not work the way we expect.
if <(SONG RATE) < [1]> then
set [pitch v] effect to (((SONG RATE) - (1)) * (120))::sound
else
set [pitch v] effect to (((SONG RATE) - (1)) * (240))::sound
end
Overview of the pitch block
When the pitch changes by 10 the sound changes by one semitone For example, if a song is in Eb or D# (i.e. Camellia's “Exit This Earth's AtOmosphere,” a song I have recently taken to liking), it will be transposed to an E. Twelve semitones equal an octave (there are twelve keys for each octave). An octave is where the pitch is high-pitched but still in the same key.
Explaining the speed system
Many Scratchers expect the speed system to work like this:
<(120) pitch effect = (2)x speed rate::sound>
<(240) pitch effect = (3)x speed rate::sound>
<(360) pitch effect = (4)x speed rate::sound>
But in reality, it goes like this:
<(120) pitch effect = (2)x speed rate::sound>
<(240) pitch effect = (4)x speed rate::sound>
<(360) pitch effect = (8)x speed rate::sound>
As you can see, the speed doubles by 2 each time the pitch changes by 120. So therefore, if you set the pitch to 60, the song rate DOES NOT equal 1.5x. Anyway, I was doing some experimental work with pitch blocks in my rhythm game, and this is what I concluded with:
<(38.625) pitch effect = (1.25)x speed rate::sound>
<(70) pitch effect = (1.5)x speed rate::sound>
<(96.5) pitch effect = (1.75)x speed rate::sound>
<(120) pitch effect = (2)x speed rate::sound>
While the pitch effects can be somewhat accurate, they are not entirely accurate. After a while in 1.75x speed, the song becomes a bit offset.
The perfect code
The other day, I was playing PolyRhythm, and I was playing Exit This Earth's Atomosphere (I had played it twice in Beat Saber on Expert+ with No Arrows that day). Like my rhythm game I'm working on right now, it uses a beat timer, so even in Turbo Mode, the beats appear perfectly. Also, it too has a playback rate, and so I found a perfect code that explains everything (credit to DecaTen):
set [pitch v] effect to ((120) * (([ln v] of (SONG RATE)) / ([ln v] of (2))))::sound//And I thought I'd never need to use the 'ln' block :)
So yeah, that's how to use the pitch block for song speeds

BONUS: How to make a beat timer
reset timer
start sound [Exit This Earth's Atomosphere v]::sound
forever
set [BEAT TIMER v] to ((BPM) / ((60) / (timer)))
end
Okay, bye

Edit 1/9/2024: Fixed a spelling mistake

Last edited by LSPECTRONIZTAR (Jan. 9, 2024 12:01:23)
- medians
-
Scratcher
1000+ posts
How To Use The Pitch Block For Speed THE RIGHT WAY
Uhm, what do you mean pitch block? Why is there “start sound”?
And sorry if you put a lot of effort into this, but you're only meant to make topics here if you're the person who needs the help.
And sorry if you put a lot of effort into this, but you're only meant to make topics here if you're the person who needs the help.
- LSPECTRONIZTAR
-
Scratcher
100+ posts
How To Use The Pitch Block For Speed THE RIGHT WAY
Uhm, what do you mean pitch block? Why is there “start sound”?Alright, so where do I put stuff like this??
And sorry if you put a lot of effort into this, but you're only meant to make topics here if you're the person who needs the help.
- LSPECTRONIZTAR
-
Scratcher
100+ posts
How To Use The Pitch Block For Speed THE RIGHT WAY
And also, I used Start Sound to make the place feel like Scratch 3.0. I was also using “The Extension That Must Not Be Named.”
- medians
-
Scratcher
1000+ posts
How To Use The Pitch Block For Speed THE RIGHT WAY
And also, I used Start Sound to make the place feel like Scratch 3.0. I was also using “The Extension That Must Not Be Named.”OHH wait I'm used to “play sound” and not “start sound”. So I'm guessing the pitch thing is also a 3.0 thing?
Edit: Yep. https://en.scratch-wiki.info/wiki/Set_()_Effect_to_()_(Sound_block)
You could use a project or put it when someone asks for it here.Uhm, what do you mean pitch block? Why is there “start sound”?Alright, so where do I put stuff like this??
And sorry if you put a lot of effort into this, but you're only meant to make topics here if you're the person who needs the help.
Last edited by medians (April 9, 2023 20:38:21)
- LSPECTRONIZTAR
-
Scratcher
100+ posts
How To Use The Pitch Block For Speed THE RIGHT WAY
Oh alright thxAnd also, I used Start Sound to make the place feel like Scratch 3.0. I was also using “The Extension That Must Not Be Named.”OHH wait I'm used to “play sound” and not “start sound”. So I'm guessing the pitch thing is also a 3.0 thing?
Edit: Yep. https://en.scratch-wiki.info/wiki/Set_()_Effect_to_()_(Sound_block)You could use a project or put it when someone asks for it here.Uhm, what do you mean pitch block? Why is there “start sound”?Alright, so where do I put stuff like this??
And sorry if you put a lot of effort into this, but you're only meant to make topics here if you're the person who needs the help.
- Discussion Forums
- » Help with Scripts
-
» How To Use The Pitch Block For Speed THE RIGHT WAY

