Giter VIP home page Giter VIP logo

klaklasp's Introduction

KlakLASP

KlakLASP is an extension for Klak to create audio reactive behaviors with using the Klak Wiring system.

Screenshot

KlakLASP integrates the LASP plugin to analyze audio signals. Thanks to the low-latency nature of LASP, it doesn't introduce noticeable delays between audio input and actions.

GIF Demo

System Requirements

  • Unity 2017.1 or later

At the moment, KlakLASP only supports Windows (64 bit) and macOS (64 bit).

Installation

Before installing KlakLASP to a project, all its dependent plugins (Klak and LASP) should be installed to the project. Follow the installation instructions in each page.

Then, download one of the unitypackage files from the Releases page and import it to the project.

How It Works

The Audio Input node has a VU meter in the inspector, and it shows how the node analyzes input audio signals and determines output.

GIF

The node tracks the recent peak amplitude of the input audio signals, and determine the output based on the difference between the current amplitude and the peak amplitude.

When the current amplitude is equal or larger than the peak amplitude, it outputs a value of 1. The VU meter indicates over-peak input with a red band (see the image below).

Meter

When the current amplitude is smaller than the peak amplitude and larger than the value of (peak amplitude - dynamic range), it outputs a value between 0 and 1 that varies based on the position in the dynamic range. This range is indicated with a gray band in the VU meter (see the image below).

Meter

When the current amplitude is equal or smaller than the value of (peak amplitude - dynamic range), it outputs a value of 0.

Meter

The peak amplitude value slowly decreases by time to adapt itself to the recent amplitude level. The GIF above shows this behavior that the peak amplitude and the dynamic range are slightly slid to the left while the input doesn't hit the peak.

Note that the peak amplitude doesn't exactly match with the actual peak of the input signals -- there is a small margin between them, so that it increases the chance of hitting the peak.

Audio Input Properties

Filter Type

Four types of filters are available -- Bypass, Low-Pass, Band-Pass and High-Pass. These filter are useful to detect rhythmic accents. For instance, the Low-Pass filter can be used to make a behavior that reacts to kick drums or a bassline.

Dynamic Range (dB)

Specifies the difference between the lowest amplitude and the highest amplitude in decibel.

Auto Gain Control

When enabled, it automatically adjust the amount of the gain based on recent peak of amplitude (as explained in the How It Works section). When disabled, the peak amplitude is fixed to 0dB, and the amount of the gain is manually controlled by the Gain property.

Hold And Fall Down

Enables the "peak-hold and fall down" behavior that is commonly used in VU meters. This is useful to make animation smoother. The GIF below shows the difference between with/without this option.

GIF

TIPS

Dynamic Range = Clickiness of Behavior

Although having a wide dynamic range is important for expressiveness, it tends to make behavior slower and unclear. It's recommended reducing the dynamic range when "clicky" behavior is preferred.

GIF

Use internal audio sources

LASP Loopback can be used as a substitute of the LASP plugin. It analyzes audio output from Unity instead of external audio sources. This is useful to create audio reactive behaviors with internal audio sources.

Current Limitations

  • LASP always tries to use the system default device for recording. There is no way to use a device that is not assigned as default.
  • LASP only supports monophonic input. Only the first channel (the left channel in case of stereo input) will be enabled when using a multi-channel audio device.

License

MIT

klaklasp's People

Contributors

keijiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

klaklasp's Issues

Issue with 'AudioInput' namespace

Issue:
Console error appears on import of KlakLasp.unitypackage

Error Message:

Assets/Klak/Audio/AudioInput.cs(82,26): error CS0234: The type or namespace name 'AudioInput' does not exist in the namespace 'Lasp' (are you missing an assembly reference?)

Fix:
Change line 82 of AudioInput.cs

get { return Lasp.AudioInput.CalculateRMSDecibel(_filterType); }

to ->

get { return Lasp.MasterInput.CalculateRMSDecibel(_filterType); }

version: Unity 2019.2.9f1

Patcher UI doesn't work with .Net 4.x runtime

Steps to reproduce:

  1. switch to .Net 4.x scripting runtime in the player settings, restart when necessary
  2. open Particles scene under Test folder
  3. select "Patch" game object
  4. in the inspector, click "Open Patcher"
  5. Errors appear in the console and no UI is displayed.

error msg:

ArgumentException: Value does not fall within the expected range.
UnityEditor.Graphs.Property.ConvertFromSingleValue (System.Object o) (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Property.cs:339)
...
Klak.Wiring.Patcher.Node.PopulateSlots () (at Assets/Klak Imported/Wiring/Editor/Patcher/Node.cs:135)
...
ArgumentException: Getting control 2's position in a group with only 2 controls when doing repaint
Aborting

version: Unity 2018.2.2f1

Crash when no audio interface is available

Hi Keijiro, I've attempted to run some of the samples and build something from scratch using the Klak and Lasp Libraries and Unity is Crashing on me consistently.

Machine:
Model: MacPro6,1, BootROM MP61.0116.B17, 6 processors, 6-Core Intel Xeon E5, 3.5 GHz, 64 GB, SMC 2.20f18
Graphics: AMD FirePro D500, AMD FirePro D500, PCIe, 3072 MB

errlog.txt

Audio input works in editor but not on build

Hey and thanks for the package.
The audio input works really good for me in the editor but after build it doesn't seem to work.
I am using apple mac silicon architecture, any ideas what might be missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.