Difference between revisions of "Sound Clips"
m (Specify in # samples as well to be more precise) |
|||
(13 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
=== Functional Spec === | === Functional Spec === | ||
* | * 30(.000) seconds '''maximum'''. [[Sound Clips#Discussion_for_future_improvements | (STC)]] | ||
* PCM WAV format, 16-bit, 44. | * {{abbr|PCM|Pulse-Code Modulation}} {{mono|{{abbr|WAV|Waveform Audio File Format, developed by Microsoft and IBM using RIFF}}}} format, 16-bit signed<ref>Note that if your audio editing software has the option to choose signed vs. unsigned 16 bits, select ''signed''.</ref>, 44.1 kHz, mono/stereo (downmixed to mono by the viewer at upload time) | ||
Second Life supports in-world sound clips, which can be played to all residents within range. The maximum time any clip can be is | Second Life supports in-world sound clips, which can be played to all residents within range. The maximum time any clip can be is 30 seconds, requiring longer sounds to be stitched together. There are [[:Category:LSL Sound|various LSL functions that can be used to play sound clips]], as well as a built-in system for [[gestures]]. Uploading a sound clip has a variable cost (see below), and the clip must be compatible with SL. As [https://community.secondlife.com/knowledgebase/english/uploading-assets-r75/#Section__2_3 the Knowledge Base says]: | ||
{{blockquote| | |||
=== | Sound files must be: | ||
* {{mono|WAV}} files in standard PCM format. | |||
* 16-bit with 44.1 kHz sample rate. | |||
* Mono format. Stereo format will be automatically converted to mono. | |||
* 30 seconds or less in length. Or more precisely: 1,323,000 samples or less in length. | |||
}} | |||
On Unix and Unix-like operating systems (including macOS), the command {{mono|file audiofilename.wav}} will produce something like: | |||
{{mono|{{abbr|RIFF|Resource Interchange File Format, defined by Microsoft and IBM}} (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 44100 Hz}} | |||
If you have the {{mono|ffmpeg}} package installed (see below; versions exist for all operating systems), you should also have the {{mono|ffprobe}} application, which you can invoke with {{mono|ffprobe -show_streams -pretty audiofilename.wav}}, and this will show additional information from the audio file: | |||
* The codec to be used is '''PCM signed 16-bit little-endian''' (which {{mono|ffmpeg}} calls {{mono|pcm_s16le}}; it's the most common codec and generally used by default when writing WAV files). | |||
* Sample rate: 44.100000 KHz | |||
* 1 channel (it's mono, after all) and 16 bits per sample. | |||
Also note that if you upload a stereo (or multi-channel) audio file, it ''will'' be converted to mono, but this might produce unexpected results in the audio (it's not quite clear what exactly the SL Viewer ''does'', or if it's handled server-side). To give you a much higher degree of control over how exactly the channels are mixed together — there are many different ways of doing so, some of which might not have existed yet when LL wrote the audio uploading code — you should best leave that to ''your'' audio software; in other words, you'll get better results by using the below-mentioned software to mix the channels into just one, than simply relying on SL's viewers and servers to do it (hint: it's the same as with textures; you get far sharper images if you resize them yourself to powers-of-two width and height before uploading). | |||
=== Why mono? I want stereo! === | |||
Second Life's in-world audio system is actually "more than stereo" — it's 3D, full-surround, immersive, so-called ''spatial sound'', vaguely similar to how [https://www.dolby.com/technologies/dolby-atmos/ Dolby Atmos] or [https://en.wikipedia.org/wiki/Ambisonics Ambisonics] works (but probably not so sophisticated!). | |||
That means that sounds can come from anywhere, from any distance, and they will play appropriately on each channel of your speakers or headphones to give you clues about the origin of the sound and how far away it is. These sounds are necessarily "mono" (one channel) in nature and then mixed together with all other sounds in a scene to produce the final stereo sound that gets delivered to your speakers/headphones. | |||
If you wish to play stereo music inside SL, your best choice is via a [[Streaming Music|streaming server]]. | |||
=== Pricing Model === | |||
The cost of uploading a sound clip is as follows: | |||
{| class="wikitable" style="margin:auto; width: 85%; text-align: center;" | |||
|+ Account Level | |||
|- | |||
! scope="col" style="background-color:#A7C1F2" | Basic | |||
! scope="col" style="background-color:#A7C1F2" | Premium | |||
! scope="col" style="background-color:#A7C1F2" | Premium Plus | |||
|- | |||
| 10 L$ || 10 L$ || 0 L$ | |||
|} | |||
Note that the price is fixed; it doesn't depend on sample size, length, or quality. If you make a mistake, however, you need to upload a new sample and will be charged again (just like with uploading other assets), even if the filename is the same. | |||
==== | === Audio software === | ||
{{{!}} class="sortable" width="100%" {{Prettytable}} | |||
{{!}}- {{Hl2}} | |||
! '''Windows''' | |||
! '''Mac''' | |||
! '''Linux''' | |||
{{!}}- | |||
{{!!}} | |||
; [https://aiaicapta.in/audio-for-sl-converter/ Audio for SL] | |||
: A purpose-built program for converting audio files for use in Second Life. Provides format and sample rate conversion, automatic splitting for files longer than the max allowable for upload, and volume normalization. | |||
; [https://www.audacityteam.org/download/ Audacity] | |||
: Audacity is a free and open-source digital audio editor and recording application software. Torley Linden did a video tutorial on creating and uploading sounds via Audacity, viewable at http://www.youtube.com/watch?v=QBVmFafFatE | |||
: Note: in some scenarios, the resulting audio file, after uploading, will have a much lower volume than average (even using scripts setting the volume to maximum). I have not been able to track the source of this discrepancy, but it's easily fixed — just boost the volume on Audacity just below the threshold where you start getting unacceptable distortion, and ''then'' upload it to SL. | |||
; [https://community.ardour.org/download?architecture=x86_64&type=compiled Ardour] | |||
: Ardour is a free hard disk recorder and digital audio workstation application. It may be more suitable for users familiar with audio editing & {{abbr|DAW|Digital Audio Workstation}}s in general. | |||
; [https://ffmpeg.org/download.html ffmpeg] | |||
: ffmpeg is a command-line tool, designed for processing of video and audio files. Recommended for advanced users only! See below example. | |||
; [https://www.voxengo.com/product/r8brain/ r8brain] | |||
: r8brain is a basic, free audio transcoder. | |||
{{!!}} | |||
; [https://www.audacityteam.org/download/ Audacity] | |||
: Audacity is a free and open-source digital audio editor and recording application software. Torley Linden did a video tutorial on creating and uploading sounds via Audacity, viewable at http://www.youtube.com/watch?v=QBVmFafFatE | |||
; [https://community.ardour.org/download?architecture=x86_64&type=compiled Ardour] | |||
: Ardour is a free hard disk recorder and digital audio workstation application. It may be more suitable for users familiar with audio editing & DAWs in general. | |||
; [https://ffmpeg.org/download.html ffmpeg] | |||
: ffmpeg is a command-line tool, designed for processing of video and audio files. Recommended for advanced users only! See below example. | |||
; [https://www.apple.com/uk/mac/garageband/ GarageBand] | |||
: GarageBand is a line of digital audio workstations for macOS, iPadOS, and iOS devices. | |||
{{!!}} | |||
; [https://www.audacityteam.org/download/ Audacity] | |||
: Audacity is a free and open-source digital audio editor and recording application software. Torley Linden did a video tutorial on creating and uploading sounds via Audacity, viewable at http://www.youtube.com/watch?v=QBVmFafFatE | |||
; [https://community.ardour.org/download?architecture=x86_64&type=compiled Ardour] | |||
: Ardour is a free hard disk recorder and digital audio workstation application. It may be more suitable for users familiar with audio editing & DAWs in general. | |||
; [https://ffmpeg.org/download.html ffmpeg] | |||
: ffmpeg is a command-line tool, designed for processing of video and audio files. Recommended for advanced users only! See below example. | |||
{{!}}} | |||
==== ffmpeg ==== | |||
The following command | The following section assumes some familiarity with a Linux-based operating system and {{mono|bash}} scripting. | ||
One of the best tools for audio conversion under Linux is the tool [https://ffmpeg.org ffmpeg.] It is a command line tool that can convert both video and audio from one supported format to other supported formats. Source code for {{mono|ffmpeg}} can be downloaded from the link but most modern Linux distributions come with a modern version already installed or ready for download in their package management system. Consult your distribution's documents on how to install packages and what package management system is supported. | |||
< | The following command will use {{mono|ffmpeg}} to convert a sound file to a Second Life compatible {{mono|WAV}} file while cutting it just under 30 second segments for instant upload. | ||
''<syntaxhighlight lang="bash">ffmpeg -i <filename> -f segment -segment_time 29.9 -ac 1 -ar 44100 <output filename>.%03d.wav</syntaxhighlight> | |||
Command line explanation as follows. | Command line explanation as follows. | ||
* '''-i <filename>''' The input file to convert. | * '''-i <filename>''' The input file to convert. | ||
* '''-f segment -segment_time | * '''-f segment -segment_time 29.9''' Save the output file in 29.9 second segments. You can specify any time duration in the {{mono|segment_time}} option, including 30 for 30 seconds. But experimenting using 30 as a segment size sometimes produces file sizes too large for uploading. The 29.9 entry seems to be the perfect size for uploading without issues. | ||
* '''-ac 1''' Converts a multi channel, stereo, stream into a single, mono, output stream. | * '''-ac 1''' Converts a multi-channel, stereo, stream into a single, mono, output stream. | ||
*'''-ar 44100''' Makes sure the output frequency is 44100 | *'''-ar 44100''' Makes sure the output frequency is 44100 Hz. | ||
*'''<output filename>.%03d.wav''' Specifies the output name and format for the numbering of each segment. The %03d format will save the output stream in sequential 3 digit segments. example: mozart.000.wav, mozart.001.wav, mozart.002.wav. | *'''<output filename>.%03d.wav''' Specifies the output name and format for the numbering of each segment. The {{mono|%03d}} format will save the output stream in sequential 3-digit segments. example: {{mono|mozart.000.wav}}, {{mono|mozart.001.wav}}, {{mono|mozart.002.wav}}. | ||
Once created, the resulting {{mono|WAV}} files should be ready to upload into Second Life. | |||
===== Batch conversion ===== | |||
The following batch command can be used to convert an entire directory of {{mono|mp3}} files into segmented {{mono|WAV}} files for direct upload. | |||
<syntaxhighlight lang="bash"> $ for i in *.mp3; do ffmpeg -i ${i} -f segment -segment_time 29.9 -ac 1 -ar 44100 ${i/mp3/}%03d.wav ; done </syntaxhighlight> | |||
===== Windows ===== | |||
The following command, similar to the prior Linux section, will convert a file to the correct {{mono|WAV}} format using [https://ffmpeg.org ffmpeg] on Windows. | |||
''<syntaxhighlight lang="bash">ffmpeg -i <input> -c:a pcm_s16le -ac 1 -ar 44100 <output>.wav</syntaxhighlight> | |||
==== Online tools ==== | |||
An online converter which provides complete control over the conversion process can be viewed at [https://audio.online-convert.com/convert-to-wav Online-Convert]. | |||
=== Test scripts === | === Test scripts === | ||
[[Audio Test]] | [[Audio Test]] | ||
=== Relationship to other features === | === Relationship to other features === | ||
==== List of features that need to be tested when this feature changes, and why. ==== | |||
[[Upload Assets]] - Upload a sound clip and make sure it still works. | [[Upload Assets]] - Upload a sound clip and make sure it still works. | ||
Line 52: | Line 126: | ||
=== User Guides === | === User Guides === | ||
(none) | (none) | ||
<hr> | |||
=== Notes === | |||
{{References}} |
Latest revision as of 13:36, 21 September 2024
Feature Design Document
(none)
Functional Spec
- 30(.000) seconds maximum. (STC)
- PCM WAV format, 16-bit signed[1], 44.1 kHz, mono/stereo (downmixed to mono by the viewer at upload time)
Second Life supports in-world sound clips, which can be played to all residents within range. The maximum time any clip can be is 30 seconds, requiring longer sounds to be stitched together. There are various LSL functions that can be used to play sound clips, as well as a built-in system for gestures. Uploading a sound clip has a variable cost (see below), and the clip must be compatible with SL. As the Knowledge Base says:
Sound files must be:
- WAV files in standard PCM format.
- 16-bit with 44.1 kHz sample rate.
- Mono format. Stereo format will be automatically converted to mono.
- 30 seconds or less in length. Or more precisely: 1,323,000 samples or less in length.
On Unix and Unix-like operating systems (including macOS), the command file audiofilename.wav will produce something like:
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 44100 Hz
If you have the ffmpeg package installed (see below; versions exist for all operating systems), you should also have the ffprobe application, which you can invoke with ffprobe -show_streams -pretty audiofilename.wav, and this will show additional information from the audio file:
- The codec to be used is PCM signed 16-bit little-endian (which ffmpeg calls pcm_s16le; it's the most common codec and generally used by default when writing WAV files).
- Sample rate: 44.100000 KHz
- 1 channel (it's mono, after all) and 16 bits per sample.
Also note that if you upload a stereo (or multi-channel) audio file, it will be converted to mono, but this might produce unexpected results in the audio (it's not quite clear what exactly the SL Viewer does, or if it's handled server-side). To give you a much higher degree of control over how exactly the channels are mixed together — there are many different ways of doing so, some of which might not have existed yet when LL wrote the audio uploading code — you should best leave that to your audio software; in other words, you'll get better results by using the below-mentioned software to mix the channels into just one, than simply relying on SL's viewers and servers to do it (hint: it's the same as with textures; you get far sharper images if you resize them yourself to powers-of-two width and height before uploading).
Why mono? I want stereo!
Second Life's in-world audio system is actually "more than stereo" — it's 3D, full-surround, immersive, so-called spatial sound, vaguely similar to how Dolby Atmos or Ambisonics works (but probably not so sophisticated!).
That means that sounds can come from anywhere, from any distance, and they will play appropriately on each channel of your speakers or headphones to give you clues about the origin of the sound and how far away it is. These sounds are necessarily "mono" (one channel) in nature and then mixed together with all other sounds in a scene to produce the final stereo sound that gets delivered to your speakers/headphones.
If you wish to play stereo music inside SL, your best choice is via a streaming server.
Pricing Model
The cost of uploading a sound clip is as follows:
Basic | Premium | Premium Plus |
---|---|---|
10 L$ | 10 L$ | 0 L$ |
Note that the price is fixed; it doesn't depend on sample size, length, or quality. If you make a mistake, however, you need to upload a new sample and will be charged again (just like with uploading other assets), even if the filename is the same.
Audio software
Windows | Mac | Linux |
---|---|---|
|
|
|
ffmpeg
The following section assumes some familiarity with a Linux-based operating system and bash scripting. One of the best tools for audio conversion under Linux is the tool ffmpeg. It is a command line tool that can convert both video and audio from one supported format to other supported formats. Source code for ffmpeg can be downloaded from the link but most modern Linux distributions come with a modern version already installed or ready for download in their package management system. Consult your distribution's documents on how to install packages and what package management system is supported.
The following command will use ffmpeg to convert a sound file to a Second Life compatible WAV file while cutting it just under 30 second segments for instant upload.
ffmpeg -i <filename> -f segment -segment_time 29.9 -ac 1 -ar 44100 <output filename>.%03d.wav
Command line explanation as follows.
- -i <filename> The input file to convert.
- -f segment -segment_time 29.9 Save the output file in 29.9 second segments. You can specify any time duration in the segment_time option, including 30 for 30 seconds. But experimenting using 30 as a segment size sometimes produces file sizes too large for uploading. The 29.9 entry seems to be the perfect size for uploading without issues.
- -ac 1 Converts a multi-channel, stereo, stream into a single, mono, output stream.
- -ar 44100 Makes sure the output frequency is 44100 Hz.
- <output filename>.%03d.wav Specifies the output name and format for the numbering of each segment. The %03d format will save the output stream in sequential 3-digit segments. example: mozart.000.wav, mozart.001.wav, mozart.002.wav.
Once created, the resulting WAV files should be ready to upload into Second Life.
Batch conversion
The following batch command can be used to convert an entire directory of mp3 files into segmented WAV files for direct upload.
$ for i in *.mp3; do ffmpeg -i ${i} -f segment -segment_time 29.9 -ac 1 -ar 44100 ${i/mp3/}%03d.wav ; done
Windows
The following command, similar to the prior Linux section, will convert a file to the correct WAV format using ffmpeg on Windows.
ffmpeg -i <input> -c:a pcm_s16le -ac 1 -ar 44100 <output>.wav
Online tools
An online converter which provides complete control over the conversion process can be viewed at Online-Convert.
Test scripts
Relationship to other features
List of features that need to be tested when this feature changes, and why.
Upload Assets - Upload a sound clip and make sure it still works.
User Guides
(none)
Notes
- ↑ Note that if your audio editing software has the option to choose signed vs. unsigned 16 bits, select signed.