Skip to content

Commit 208a0e0

Browse files
committed
Remove freesound support for v2.1
- needs a little more thought
1 parent f8ba436 commit 208a0e0

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

app/server/sonicpi/lib/sonicpi/mods/sound.rb

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,8 +1535,6 @@ def load_sample(path)
15351535
else
15361536
raise "No sample exists with path #{path}"
15371537
end
1538-
when Numeric
1539-
freesound(path)
15401538
else
15411539
raise "Unknown sample description: #{path}"
15421540
end
@@ -2682,11 +2680,11 @@ def set_current_synth(name)
26822680
Thread.current.thread_variable_set(:sonic_pi_mod_sound_current_synth_name, name)
26832681
end
26842682

2685-
def freesound_path(id)
2683+
def __freesound_path(id)
26862684
cache_dir = home_dir + '/freesound/'
26872685
ensure_dir(cache_dir)
26882686

2689-
cache_file = cache_dir + id.to_s + ".wav"
2687+
cache_file = cache_dir + "freesound-" + id.to_s + ".wav"
26902688

26912689
return cache_file if File.exists?(cache_file)
26922690

@@ -2713,18 +2711,18 @@ def freesound_path(id)
27132711
end
27142712
return nil
27152713
end
2716-
doc name: :freesound_path,
2717-
introduced: Version.new(2,1,0),
2718-
summary: "Return local path for sound from freesound.org",
2719-
doc: "Download and cache a sample by ID from freesound.org. Returns path as string if cached. If not cached, returns nil and starts a background thread to download the sample.",
2720-
args: [[:id, :number]],
2721-
opts: nil,
2722-
accepts_block: false,
2723-
examples: ["
2724-
puts freesound(250129) # preloads a freesound and prints its local path, such as '/home/user/.sonic_pi/freesound/250129.wav'"]
2725-
2726-
def freesound(id, *opts)
2727-
path = freesound_path(id)
2714+
# doc name: :freesound_path,
2715+
# introduced: Version.new(2,1,0),
2716+
# summary: "Return local path for sound from freesound.org",
2717+
# doc: "Download and cache a sample by ID from freesound.org. Returns path as string if cached. If not cached, returns nil and starts a background thread to download the sample.",
2718+
# args: [[:id, :number]],
2719+
# opts: nil,
2720+
# accepts_block: false,
2721+
# examples: ["
2722+
# puts freesound(250129) # preloads a freesound and prints its local path, such as '/home/user/.sonic_pi/freesound/250129.wav'"]
2723+
2724+
def __freesound(id, *opts)
2725+
path = __freesound_path(id)
27282726
arg_h = resolve_synth_opts_hash_or_array(opts)
27292727
fallback = arg_h[:fallback]
27302728

@@ -2739,23 +2737,23 @@ def freesound(id, *opts)
27392737
end
27402738

27412739
end
2742-
doc name: :freesound,
2743-
introduced: Version.new(2,1,0),
2744-
summary: "Play sample from freesound.org",
2745-
doc: "Fetch from cache (or download then cache) a sample by ID from freesound.org, and then play it.",
2746-
args: [[:id, :number]],
2747-
opts: {:fallback => "Symbol representing built-in sample to play if the freesound id isn't yet downloaded"},
2748-
accepts_block: false,
2749-
examples: ["
2750-
freesound(250129) # takes time to download the first time, but then the sample is cached locally
2751-
",
2752-
"
2753-
loop do
2754-
sample freesound(27130)
2755-
sleep sample_duration(27130)
2756-
end
2757-
"
2758-
]
2740+
# doc name: :freesound,
2741+
# introduced: Version.new(2,1,0),
2742+
# summary: "Play sample from freesound.org",
2743+
# doc: "Fetch from cache (or download then cache) a sample by ID from freesound.org, and then play it.",
2744+
# args: [[:id, :number]],
2745+
# opts: {:fallback => "Symbol representing built-in sample to play if the freesound id isn't yet downloaded"},
2746+
# accepts_block: false,
2747+
# examples: ["
2748+
# freesound(250129) # takes time to download the first time, but then the sample is cached locally
2749+
# ",
2750+
# "
2751+
# loop do
2752+
# sample freesound(27130)
2753+
# sleep sample_duration(27130)
2754+
# end
2755+
# "
2756+
# ]
27592757
end
27602758
end
27612759
end

etc/doc/tutorial/03.6-External-Samples.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Whilst the built-in samples can get you up and started quickly, you
44
might wish to experiment with other recorded sounds in your music. Sonic
5-
Pi totally supports this with two approaches. First though, let's have a
6-
quick discussion on the portability of your piece.
5+
Pi totally supports this. First though, let's have a quick discussion on
6+
the portability of your piece.
77

88
## Portablility
99

@@ -21,35 +21,37 @@ for others to manipulate, mash-up and experiment with your work. Of
2121
course this shouldn't stop you from using your own samples, it's just
2222
something to consider.
2323

24+
<!-- ## Freesound Support -->
2425

25-
## Freesound Support
26+
<!-- One way to get the ability to experiment with new sounds whilst keeping -->
27+
<!-- code portability is to use the [Freesound](http:freesound.org) -->
28+
<!-- support. http://freesound.org is a website which allows people to upload -->
29+
<!-- and share their samples. Each sample uploaded gets a special number -->
30+
<!-- (kind of like a phone number) which you can use to dial up that sample -->
31+
<!-- from Sonic Pi. The only drawback is that you need to have internet -->
32+
<!-- access for it to work. -->
2633

27-
One way to get the ability to experiment with new sounds whilst keeping
28-
code portability is to use the [Freesound](http:freesound.org)
29-
support. http://freesound.org is a website which allows people to upload
30-
and share their samples. Each sample uploaded gets a special number
31-
(kind of like a phone number) which you can use to dial up that sample
32-
from Sonic Pi. The only drawback is that you need to have internet
33-
access for it to work.
34+
<!-- If you currently have internet access, try it for yourself: -->
3435

35-
If you currently have internet access, try it for yourself:
36+
<!-- ``` -->
37+
<!-- freesound 24787 -->
38+
<!-- ``` -->
3639

37-
```
38-
freesound 27130
39-
```
40-
41-
You might have to wait a moment.
40+
<!-- The first time you do this you'll hear a standard `:elec_beep` as a -->
41+
<!-- placeholder for the sound. Y -->
4242

4343

4444
## Local Samples
4545

46-
Sonic Pi also supports the ability to play any arbitrary wav or aif file on your computer. All you need to do is pass the path to that file to `sample`:
46+
So how do you play any arbitrary wav or aif file on your computer? All
47+
you need to do is pass the path to that file to `sample`:
4748

4849
```
4950
sample "/Users/sam/Desktop/my-sound.wav"
5051
```
5152

52-
Sonic Pi will automatically load and play the sample. You can also pass all the standard params you're used to passing `sample`:
53+
Sonic Pi will automatically load and play the sample. You can also pass
54+
all the standard params you're used to passing `sample`:
5355

5456
```
5557
sample "/Users/sam/Desktop/my-sound.wav", rate: 0.5, amp: 0.3

0 commit comments

Comments
 (0)