Jelajahi Sumber

Write a bunch of stuff about Sound for some reason;

bjorn 4 tahun lalu
induk
melakukan
fad4f2ffd1
4 mengubah file dengan 59 tambahan dan 4 penghapusan
  1. 0 1
      api/init.lua
  2. 41 2
      api/lovr/data/Sound/init.lua
  3. 18 0
      api/lovr/headset/Device.lua
  4. 0 1
      guides/Libraries.md

File diff ditekan karena terlalu besar
+ 0 - 1
api/init.lua


+ 41 - 2
api/lovr/data/Sound/init.lua

@@ -1,8 +1,47 @@
 return {
   summary = 'An object that holds raw audio samples.',
   description = [[
-    A Sound stores raw audio samples that make up a sound file.  You can use `Source` objects to
-    play them.
+    A Sound stores the data for a sound.  The supported sound formats are OGG, WAV, and MP3.  Sounds
+    cannot be played directly.  Instead, there are `Source` objects in `lovr.audio` that are used
+    for audio playback.  All Source objects are backed by one of these Sounds, and multiple Sources
+    can share a single Sound to reduce memory usage.
+
+    Metadata
+    ---
+
+    Sounds hold a fixed number of frames.  Each frame contains one audio sample for each channel.
+    The `SampleFormat` of the Sound is the data type used for each sample (floating point, integer,
+    etc.).  The Sound has a `ChannelLayout`, representing the number of audio channels and how they
+    map to speakers (mono, stereo, etc.).  The sample rate of the Sound indicates how many frames
+    should be played per second.  The duration of the sound (in seconds) is the number of frames
+    divided by the sample rate.
+
+    Compression
+    ---
+
+    Sounds can be compressed.  Compressed sounds are stored compressed in memory and are decoded as
+    they are played.  This uses a lot less memory but increases CPU usage during playback.  OGG and
+    MP3 are compressed audio formats.  When creating a sound from a compressed format, there is an
+    option to immediately decode it, storing it uncompressed in memory.  This can be a good idea for
+    short sounds, since they won't use very much memory even when they're decoded.
+
+    Streams
+    ---
+
+    Sounds can be created as a stream by passing `'stream'` as their contents when creating them.
+    Audio frames can be written to the end of the stream, and read from the beginning.  This works
+    well for situations where data is being generated in real time or streamed in from some other
+    data source.
+
+    Sources can be backed by a stream and they'll just play whatever audio is pushed to the stream.
+    The audio module also lets you use a stream as a "sink" for an audio device.  For playback
+    devices, this works like loopback, so the mixed audio from all playing Sources will get written
+    to the stream.  For capture devices, all the microphone input will get written to the stream.
+    Conversion between sample formats, channel layouts, and sample rates will happen automatically.
+
+    Keep in mind that streams can still only hold a fixed number of frames.  If too much data is
+    written before it is read, older frames will start to get overwritten.  Similary, it's possible
+    to read too much data without writing fast enough.
   ]],
   constructor = 'lovr.data.newSound'
 }

+ 18 - 0
api/lovr/headset/Device.lua

@@ -93,5 +93,23 @@ return {
       name = 'beacon/4',
       description = 'The fourth tracking device (i.e. lighthouse).'
     }
+  },
+  related = {
+    'DeviceAxis',
+    'DeviceButton',
+    'lovr.headset.getPose',
+    'lovr.headset.getPosition',
+    'lovr.headset.getOrientation',
+    'lovr.headset.getVelocity',
+    'lovr.headset.getAngularVelocity',
+    'lovr.headset.getSkeleton',
+    'lovr.headset.isTracked',
+    'lovr.headset.isDown',
+    'lovr.headset.isTouched',
+    'lovr.headset.wasPressed',
+    'lovr.headset.wasReleased',
+    'lovr.headset.getAxis',
+    'lovr.headset.vibrate',
+    'lovr.headset.animate'
   }
 }

+ 0 - 1
guides/Libraries.md

@@ -31,7 +31,6 @@ List of Libraries
 - [lovr-haxe-wrappergen](https://github.com/excessive/lovr-haxe-wrappergen) - Haxe bindings for LÖVR.
 - [lovr-icosphere](https://github.com/bjornbytes/lovr-icosphere) - A library to create icospheres.
 - [lovr-keyboard](https://github.com/bjornbytes/lovr-keyboard) - Keyboard input
-- [lovr-lighting](https://github.com/bjornbytes/lovr-lighting) - Simple lighting shaders to add to
 - [lovr-mouse](https://github.com/bjornbytes/lovr-mouse) - Mouse input
 - [lovr-joystick](https://github.com/Rabios/lovr-joystick) - Joystick input
 - [lovr-clipboard](https://github.com/Rabios/lovr-clipboard) - Clipboard module (To copy and get text from clipboard)

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini