You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
-
deffreesound(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)
2728
2726
arg_h=resolve_synth_opts_hash_or_array(opts)
2729
2727
fallback=arg_h[:fallback]
2730
2728
@@ -2739,23 +2737,23 @@ def freesound(id, *opts)
2739
2737
end
2740
2738
2741
2739
end
2742
-
docname: :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
Copy file name to clipboardExpand all lines: etc/doc/tutorial/03.6-External-Samples.md
+20-18Lines changed: 20 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
Whilst the built-in samples can get you up and started quickly, you
4
4
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.
7
7
8
8
## Portablility
9
9
@@ -21,35 +21,37 @@ for others to manipulate, mash-up and experiment with your work. Of
21
21
course this shouldn't stop you from using your own samples, it's just
22
22
something to consider.
23
23
24
+
<!-- ## Freesound Support -->
24
25
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. -->
26
33
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: -->
34
35
35
-
If you currently have internet access, try it for yourself:
36
+
<!-- ``` -->
37
+
<!-- freesound 24787 -->
38
+
<!-- ``` -->
36
39
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 -->
42
42
43
43
44
44
## Local Samples
45
45
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`:
47
48
48
49
```
49
50
sample "/Users/sam/Desktop/my-sound.wav"
50
51
```
51
52
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`:
0 commit comments