Skip to content

Commit 5e948d5

Browse files
committed
Lang - rename use_random_stream to use_random_source
I'd like to keep use_random_stream for the future usecase of switching streams based on names.
1 parent 428e202 commit 5e948d5

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
### New
3434
* Completely new MIDI subsystem.
35-
* `use/with_random_stream` - change the current random stream used when selecting random values. We now have `:white`, `:light_pink`, `:pink`, `:dark_pink` and `:perlin`. Default is `:white` which is the same stream as previous releases to preserve compatibility.
35+
* `use/with_random_source` - change the current random stream used when selecting random values. We now have `:white`, `:light_pink`, `:pink`, `:dark_pink` and `:perlin`. Default is `:white` which is the same stream as previous releases to preserve compatibility.
3636
* Many Turkish scales (makams) have been added.
3737
* New user config directory for fine tuning aspects of the app such as advanced audio settings. See `~/.sonic-pi/config/README.md` for more information.
3838

app/server/ruby/lib/sonicpi/lang/core.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,13 +3420,13 @@ def with_random_seed(seed, &block)
34203420

34213421

34223422

3423-
def use_random_stream(noise_type, &block)
3424-
raise ArgumentError, "use_random_stream does not work with a block. Perhaps you meant with_random_stream" if block
3423+
def use_random_source(noise_type, &block)
3424+
raise ArgumentError, "use_random_source does not work with a block. Perhaps you meant with_random_stream" if block
34253425
raise ArgumentError, "invalid noise type '#{noise_type}' - please use one of :white, :pink, :light_pink, :dark_pink or :perlin instead" unless %w(white pink light_pink dark_pink perlin).include?(noise_type.to_s)
34263426

34273427
SonicPi::Core::SPRand.set_random_number_distribution!(noise_type)
34283428
end
3429-
doc name: :use_random_stream,
3429+
doc name: :use_random_source,
34303430
introduced: Version.new(3,3,0),
34313431
summary: "Change how random numbers are chosen",
34323432
args: [[:noise_type, :symbol]],
@@ -3455,17 +3455,17 @@ def use_random_stream(noise_type, &block)
34553455
34563456
",
34573457
examples: ["
3458-
use_random_stream :white # use white noise as the distribution (default)
3458+
use_random_source :white # use white noise as the distribution (default)
34593459
rand_reset # reset random seed
34603460
puts rand # => 0.75006103515625
34613461
puts rand # => 0.733917236328125
34623462
puts rand # => 0.464202880859375
34633463
rand_reset # reset it again
3464-
use_random_stream :pink # use pink noise as the distribution
3464+
use_random_source :pink # use pink noise as the distribution
34653465
puts rand # => 0.47808837890625
34663466
puts rand # => 0.56011962890625
34673467
rand_reset # reset it
3468-
use_random_stream :perlin # use perlin noise as the distribution
3468+
use_random_source :perlin # use perlin noise as the distribution
34693469
puts rand # => 0.546478271484375
34703470
puts rand # => 0.573150634765625
34713471
@@ -3482,7 +3482,7 @@ def use_random_stream(noise_type, &block)
34823482

34833483

34843484
def with_random_stream(noise_type, &block)
3485-
raise ArgumentError, "with_random_stream requires a block. Perhaps you meant use_random_stream" unless block
3485+
raise ArgumentError, "with_random_stream requires a block. Perhaps you meant use_random_source" unless block
34863486
raise ArgumentError, "invalid noise type '#{noise_type}' - please use one of :white, :pink, :light_pink, :dark_pink or :perlin instead" unless %w(white pink light_pink dark_pink perlin).include?(noise_type.to_s)
34873487
new_thread_gen_type = SonicPi::Core::SPRand.get_random_number_distribution
34883488

@@ -3500,17 +3500,17 @@ def with_random_stream(noise_type, &block)
35003500
accepts_block: true,
35013501
requires_block: true,
35023502
examples: ["
3503-
use_random_stream :white # use white noise as the distribution (default)
3503+
use_random_source :white # use white noise as the distribution (default)
35043504
rand_reset # reset random seed
35053505
puts rand # => 0.75006103515625
35063506
puts rand # => 0.733917236328125
35073507
puts rand # => 0.464202880859375
35083508
rand_reset # reset it again
3509-
use_random_stream :pink # use pink noise as the distribution
3509+
use_random_source :pink # use pink noise as the distribution
35103510
puts rand # => 0.47808837890625
35113511
puts rand # => 0.56011962890625
35123512
rand_reset # reset it
3513-
use_random_stream :perlin # use perlin noise as the distribution
3513+
use_random_source :perlin # use perlin noise as the distribution
35143514
puts rand # => 0.546478271484375
35153515
puts rand # => 0.573150634765625
35163516

app/server/ruby/test/lang/core/test_random.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class RandomTester < Minitest::Test
66
include SonicPi::Lang::Core
77

88
def test_rand
9-
use_random_stream :white
9+
use_random_source :white
1010
rand_reset
1111
assert_equal(rand, 0.75006103515625)
1212
assert_equal(rand, 0.733917236328125)
@@ -15,27 +15,27 @@ def test_rand
1515
end
1616

1717
def test_rand_type
18-
use_random_stream :white
18+
use_random_source :white
1919
rand_reset
2020
assert_equal(rand, 0.75006103515625)
2121
assert_equal(rand, 0.733917236328125)
22-
use_random_stream :white
22+
use_random_source :white
2323
rand_reset
2424
assert_equal(rand, 0.75006103515625)
2525
assert_equal(rand, 0.733917236328125)
26-
use_random_stream :pink
26+
use_random_source :pink
2727
rand_reset
2828
assert_equal(rand, 0.47808837890625)
2929
assert_equal(rand, 0.56011962890625)
30-
use_random_stream :light_pink
30+
use_random_source :light_pink
3131
rand_reset
3232
assert_equal(rand, 0.53851318359375)
3333
assert_equal(rand, 0.54705810546875)
34-
use_random_stream :dark_pink
34+
use_random_source :dark_pink
3535
rand_reset
3636
assert_equal(rand, 0.442596435546875)
3737
assert_equal(rand, 0.443756103515625)
38-
use_random_stream :perlin
38+
use_random_source :perlin
3939
rand_reset
4040
assert_equal(rand, 0.546478271484375)
4141
assert_equal(rand, 0.573150634765625)
@@ -49,7 +49,7 @@ def test_rand_type
4949
assert_equal(rand, 0.597015380859375)
5050

5151
# return to default
52-
use_random_stream :white
52+
use_random_source :white
5353
end
5454

5555
def test_rand_reset

0 commit comments

Comments
 (0)