Browse Source

newSoundData;

bjorn 7 years ago
parent
commit
618b8bb570
2 changed files with 135 additions and 0 deletions
  1. 77 0
      api/init.lua
  2. 58 0
      api/lovr/data/newSoundData.lua

+ 77 - 0
api/init.lua

@@ -2102,6 +2102,83 @@ return {
             }
           }
         },
+        {
+          name = "newSoundData",
+          summary = "Create a new SoundData.",
+          description = "Creates a new SoundData.  You can pass a filename or Blob to decode, an existing AudioStream to decode audio samples from, or you can create an empty SoundData that is able to hold a certain number of samples.",
+          key = "lovr.data.newSoundData",
+          module = "lovr.data",
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "filename",
+                  type = "string",
+                  description = "The filename of the sound to decode."
+                }
+              },
+              returns = {
+                {
+                  name = "soundData",
+                  type = "TextureData",
+                  description = "The new TextureData."
+                }
+              }
+            },
+            {
+              arguments = {
+                {
+                  name = "samples",
+                  type = "number",
+                  description = "The total number of samples in each channel."
+                },
+                {
+                  name = "sampleRate",
+                  type = "number",
+                  description = "The number of samples per second."
+                },
+                {
+                  name = "bitDepth",
+                  type = "number",
+                  description = "The number of bits stored for each sample."
+                }
+              },
+              returns = {
+                {
+                  name = "soundData",
+                  type = "TextureData",
+                  description = "The new TextureData."
+                }
+              }
+            },
+            {
+              arguments = {},
+              returns = {
+                {
+                  name = "soundData",
+                  type = "TextureData",
+                  description = "The new TextureData."
+                }
+              }
+            },
+            {
+              arguments = {
+                {
+                  name = "blob",
+                  type = "string",
+                  description = "The Blob containing sound data to decode."
+                }
+              },
+              returns = {
+                {
+                  name = "soundData",
+                  type = "TextureData",
+                  description = "The new TextureData."
+                }
+              }
+            }
+          }
+        },
         {
           name = "newTextureData",
           summary = "Create a new TextureData.",

+ 58 - 0
api/lovr/data/newSoundData.lua

@@ -0,0 +1,58 @@
+return {
+  summary = 'Create a new SoundData.',
+  description = [[
+    Creates a new SoundData.  You can pass a filename or Blob to decode, an existing AudioStream to
+    decode audio samples from, or you can create an empty SoundData that is able to hold a certain
+    number of samples.
+  ]],
+  arguments = {
+    samples = {
+      type = 'number',
+      description = 'The total number of samples in each channel.'
+    },
+    sampleRate = {
+      type = 'number',
+      description = 'The number of samples per second.'
+    },
+    bitDepth = {
+      type = 'number',
+      description = 'The number of bits stored for each sample.'
+    },
+    channels = {
+      type = 'number',
+      description = 'The number of channels in the sound (1 for mono, 2 for stereo).'
+    },
+    filename = {
+      type = 'string',
+      description = 'The filename of the sound to decode.'
+    },
+    blob = {
+      type = 'string',
+      description = 'The Blob containing sound data to decode.'
+    }
+  },
+  returns = {
+    soundData = {
+      type = 'TextureData',
+      description = 'The new TextureData.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'filename' },
+      returns = { 'soundData' }
+    },
+    {
+      arguments = { 'samples', 'sampleRate', 'bitDepth', 'channelCount' },
+      returns = { 'soundData' }
+    },
+    {
+      arguments = { 'audioStream' },
+      returns = { 'soundData' }
+    },
+    {
+      arguments = { 'blob' },
+      returns = { 'soundData' }
+    }
+  }
+}