Skip to content

Aerials Audio System with miniaudio

License

Notifications You must be signed in to change notification settings

Fuxfantx/AcAudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aerials Audio System

A miniaudio binding for Defold Engine.

Only APIs used in Aerials are implemented. Refer to api/acaudio.script_api for API usages.

Note: If you want to bundle a Windows Application with this extension, you may need to put a valid MSVCRT.lib file into the lib/x86_64-win32 directory.


Example

You should implement your HitSound system with a Unit Pool like this:

local CreateUnit = AcAudio.CreateUnit
local PlayUnit = AcAudio.PlayUnit

-- Create the HitSound Unit Pool (some_src is created from AcAudio.CreateSource)
--
local HitSoundUnits, UnitCount
local FirstUnit, UnitLen = CreateUnit(some_src)
if FirstUnit then
    HitSoundUnits = {FirstUnit}
    --
    -- Choose a reasonable filter interval,
    -- And set the UnitCount according to it.
    --
    UnitCount = math.ceil(UnitLen / 50)            -- Filter Interval: 50ms
    UnitCount = (UnitCount>1) and UnitCount or 2   -- Use at least 2 Units
    for i=2, UnitCount do
        local u, l = CreateUnit(some_buf)
        if u then
            HitSoundUnits[#HitSoundUnits+1] = u
        end
    end
    UnitCount = #HitSoundUnits
end

-- Encapsule the Playing Method with the Unit Pool Created above
--
local Which = 1
local function hit()
    PlayUnit(HitSoundUnits[Which], false)           -- Play the HintSound only once
    Which = (Which==UnitCount) and 1 or (Which+1)   -- Update the counter
    StopUnit(HitSoundUnits[Which], true)            -- Let the next Unit rewind to start
end

Complying with Licenses Related

  • The extension part is under the MIT License.

  • For the miniaudio stuff included, the MIT-0 License is chosen here:

    Copyright 2023 David Reid

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    See also: miniaudio - A single file audio playback and capture library.

  • library ogg vorbis vorbisfile opus and opusfile are included in this module for OGG Vorbis and Opus support. Licenses chosen are below.

    • [BSD 3-Clause License] ogg

      Copyright (c) 2002, Xiph.org Foundation
      
      Redistribution and use in source and binary forms, with or without
      modification, are permitted provided that the following conditions
      are met:
      
      - Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
      
      - Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
      
      - Neither the name of the Xiph.org Foundation nor the names of its
      contributors may be used to endorse or promote products derived from
      this software without specific prior written permission.
      
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION
      OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      
    • [BSD 3-Clause License] vorbis & vorbisfile

      Copyright (c) 2002-2020 Xiph.org Foundation
      
      Redistribution and use in source and binary forms, with or without
      modification, are permitted provided that the following conditions
      are met:
      
      - Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
      
      - Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
      
      - Neither the name of the Xiph.org Foundation nor the names of its
      contributors may be used to endorse or promote products derived from
      this software without specific prior written permission.
      
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION
      OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      
    • [BSD 3-Clause License] opus

      Copyright 2001-2023 Xiph.Org, Skype Limited, Octasic,
                          Jean-Marc Valin, Timothy B. Terriberry,
                          CSIRO, Gregory Maxwell, Mark Borgerding,
                          Erik de Castro Lopo, Mozilla, Amazon
      
      Redistribution and use in source and binary forms, with or without
      modification, are permitted provided that the following conditions
      are met:
      
      - Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
      
      - Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
      
      - Neither the name of Internet Society, IETF or IETF Trust, nor the
      names of specific contributors, may be used to endorse or promote
      products derived from this software without specific prior written
      permission.
      
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
      OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
      EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
      PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
      LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
      NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
      SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      
      Opus is subject to the royalty-free patent licenses which are
      specified at:
      
      Xiph.Org Foundation:
      https://datatracker.ietf.org/ipr/1524/
      
      Microsoft Corporation:
      https://datatracker.ietf.org/ipr/1914/
      
      Broadcom Corporation:
      https://datatracker.ietf.org/ipr/1526/
      
    • [BSD 3-Clause License] opusfile

      Copyright (c) 1994-2013 Xiph.Org Foundation and contributors
      
      Redistribution and use in source and binary forms, with or without
      modification, are permitted provided that the following conditions
      are met:
      
      - Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
      
      - Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
      
      - Neither the name of the Xiph.Org Foundation nor the names of its
      contributors may be used to endorse or promote products derived from
      this software without specific prior written permission.
      
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION
      OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.