From b225fecc652631497d7fa60749f431761520856c Mon Sep 17 00:00:00 2001 From: Emlyn Corrin Date: Sat, 10 May 2025 20:36:48 +0100 Subject: [PATCH] Update docs to mention that mp3s are supported. Fixes #3458. --- app/server/ruby/lib/sonicpi/lang/sound.rb | 12 ++++++------ etc/doc/tutorial/03.6-External-Samples.md | 2 +- etc/doc/tutorial/03.7-Sample-Packs.md | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/server/ruby/lib/sonicpi/lang/sound.rb b/app/server/ruby/lib/sonicpi/lang/sound.rb index 3087439127..70cdc027b2 100644 --- a/app/server/ruby/lib/sonicpi/lang/sound.rb +++ b/app/server/ruby/lib/sonicpi/lang/sound.rb @@ -2114,7 +2114,7 @@ def sample_loaded?(*args) doc name: :sample_loaded?, introduced: Version.new(2,2,0), summary: "Test if sample was pre-loaded", - doc: "Given a path to a `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga` or `.flac` file, returns `true` if the sample has already been loaded.", + doc: "Given a path to a `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga`, `.flac` or `.mp3` file, returns `true` if the sample has already been loaded.", args: [[:path, :string]], opts: nil, accepts_block: false, @@ -2132,7 +2132,7 @@ def load_sample(*args) doc name: :load_sample, introduced: Version.new(2,0,0), summary: "Pre-load first matching sample", - doc: "Given a path to a `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga` or `.flac` file, pre-loads the sample into memory. + doc: "Given a path to a `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga`, `.flac` or `.mp3` file, pre-loads the sample into memory. You may also specify the same set of source and filter pre-args available to `sample` itself. `load_sample` will then load all matching samples. See `sample`'s docs for more information." , args: [[:path, :string]], @@ -2162,7 +2162,7 @@ def load_samples(*args) doc name: :load_samples, introduced: Version.new(2,0,0), summary: "Pre-load all matching samples", - doc: "Given a directory containing multiple `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga` or `.flac` files, pre-loads all the samples into memory. + doc: "Given a directory containing multiple `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga`, `.flac` or `.mp3` files, pre-loads all the samples into memory. You may also specify the same set of source and filter pre-args available to `sample` itself. `load_sample` will load all matching samples (not just the sample `sample` would play given the same opts) - see `sample`'s docs for more information." , args: [[:paths, :list]], @@ -2278,7 +2278,7 @@ def sample_duration(*args) doc name: :sample_duration, introduced: Version.new(2,0,0), summary: "Get duration of sample in beats", - doc: "Given the name of a loaded sample, or a path to a `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga` or `.flac` file returns the length of time in beats that the sample would play for. `sample_duration` understands and accounts for all the opts you can pass to `sample` which have an effect on the playback duration such as `rate:`. The time returned is scaled to the current BPM. + doc: "Given the name of a loaded sample, or a path to a `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga`, `.flac` or `.mp3` file returns the length of time in beats that the sample would play for. `sample_duration` understands and accounts for all the opts you can pass to `sample` which have an effect on the playback duration such as `rate:`. The time returned is scaled to the current BPM. *Note:* avoid using `sample_duration` to set the sleep time in `live_loop`s, prefer stretching the sample with the `beat_stretch:` opt or changing the BPM instead. See the examples below for details.", args: [[:path, :string]], @@ -2528,7 +2528,7 @@ def sample(*args, &blk) doc name: :sample, introduced: Version.new(2,0,0), summary: "Trigger sample", - doc: "Play back a recorded sound file (sample). Sonic Pi comes with lots of great samples included (see the section under help) but you can also load and play `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga` or `.flac` files from anywhere on your computer too. To play a built-in sample use the corresponding keyword such as `sample :bd_haus`. To play any file on your computer use a full path such as `sample \"/path/to/sample.wav\"`. + doc: "Play back a recorded sound file (sample). Sonic Pi comes with lots of great samples included (see the section under help) but you can also load and play `.wav`, `.wave`, `.aif`, `.aiff`, `.ogg`, `.oga`, `.flac` or `.mp3` files from anywhere on your computer too. To play a built-in sample use the corresponding keyword such as `sample :bd_haus`. To play any file on your computer use a full path such as `sample \"/path/to/sample.wav\"`. There are many opts for manipulating the playback. For example, the `rate:` opt affects both the speed and the pitch of the playback. To control the rate of the sample in a pitch-meaningful way take a look at the `rpitch:` opt. @@ -3452,7 +3452,7 @@ def normalise_args!(args_h, defaults={}) # TODO - this method doesn't seem to be used def find_sample_with_path(path) - ["wav", "wave", "aif", "aiff","flac", "ogg", "oga"].each do |ext| + ["wav", "wave", "aif", "aiff","flac", "ogg", "oga", "mp3"].each do |ext| full = "#{path}.#{ext}" return full if File.exist?(full) end diff --git a/etc/doc/tutorial/03.6-External-Samples.md b/etc/doc/tutorial/03.6-External-Samples.md index 7b85a0940b..7d5a818213 100644 --- a/etc/doc/tutorial/03.6-External-Samples.md +++ b/etc/doc/tutorial/03.6-External-Samples.md @@ -25,7 +25,7 @@ something to consider. ## Local Samples -So how do you play any arbitrary WAV, AIFF, OGG, OGA or FLAC file on your computer? +So how do you play any arbitrary WAV, AIFF, OGG, OGA, FLAC or MP3 file on your computer? All you need to do is pass the path of that file to `sample`: ``` diff --git a/etc/doc/tutorial/03.7-Sample-Packs.md b/etc/doc/tutorial/03.7-Sample-Packs.md index 1995aeb9f3..b1fa9688c5 100644 --- a/etc/doc/tutorial/03.7-Sample-Packs.md +++ b/etc/doc/tutorial/03.7-Sample-Packs.md @@ -145,7 +145,7 @@ of potential candidates. A source can take two forms: The `sample` fn will first gather all sources and use them to create a large list of candidates. This list is constructed by first adding all valid paths and then by adding all the valid `.flac`, `.aif`, `.aiff`, -`.wav`, `.wave` files contained within the directories. +`.wav`, `.wave`, `.mp3` files contained within the directories. For example, take a look at the following code: