Does not work use_bpm

Hello. Use_bpm does not work with this example.

use_bpm = 300
play_pattern_timed [:c4, :b3, :a3, :ab3,
:e4, :d4, :c4, :b3,
[ 1, 1, 1, 1,
1, 1, 1,1,
0.5, 0.5, 2,1,
], pan: -1, amp: 3

Welcome @Aleksandr!
It’s almost correct. In Sonic Pi, use_bpm is a function, and we want to pass the function the value of 300 as the bpm that it will set for us. However, by using the = here, we’re actually changing the use_bpm function itself to 300! (Edit - ha. Sam is correct, by using the = we in fact tell Sonic Pi to make a new variable called use_bpm and assign 300 to it)
Just remove the = from that line and it will work.

1 Like

Hi @Aleksandr, thanks for your question and welcome to our forums.

The simple answer is that the function use_bpm is used as follows:

use_bpm 300

In your example, you’re using the = assignment operator which is assigning the value 300 to a new variable use_bpm which isn’t quite what you meant.

Take a look at some of the examples for use_bpm in the help system:

1 Like

Thanks! I was inattentive :slight_smile:

No worries. We’re all learning :slight_smile: