Giter VIP home page Giter VIP logo

algorithmic-beat-mapping-unity's Introduction

Real-time and Preprocessed Audio Analysis for Onset Detection (Beat Mapping) Using Spectral Flux

Description

This code sample demonstrates the topics outlined in my article series "Algorithmic Beat Mapping in Unity" https://medium.com/giant-scam/algorithmic-beat-mapping-in-unity-intro-d4c2c25d2f27

This is a minimal example of the foundation for detecting beats in audio files in Unity. Audio analysis is available for real-time audio as well as preprocessing an entire audio file up front. Both analysis methods use the same spectral flux algorithm that is outlined in this article: http://www.badlogicgames.com/wordpress/?cat=18&paged=3

Usage

This code sample was tested using Unity 2017.3.0f3. It should be compatible with Unity 5 as well.

In the Hierarchy, select SongController and enable/disable Real Time Samples and Pre Process Samples. All combinations of the two are valid. Load an audio file into the SongController->AudioSource. Press Play. You should hear the audio being played and see the output of the algorithm in the two Plot objects on screen.

License

All code samples besides DSPLib.cs and Complex.cs are covered by the MIT license. See those source files for information about their external licenses. Example audio file "Chamber of Secrets for 1" by Terror Pigeon is Copyright Terror Pigeon and, while it may be distributed with this project, it may not be further distributed or used without consent.

Author

All code samples besides DSPLib.cs and Complex.cs were written by Jesse Keogh. Jesse Keogh is the Lead Developer / Co-Founder of Giant Scam Industries. https://twitter.com/giantscam

algorithmic-beat-mapping-unity's People

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

algorithmic-beat-mapping-unity's Issues

No peak detection

I have used your SpectrazlFluxAnalyser and i don't understand why I have never peak

FLIX prunedSpectralFlux | spectralFlux| threshold|Window start time | window end time | window diff time | peak \
FLUX 0.002386421 | 0.415312 | 0.4129256 | 0.1013333 | 0.912 | 0.8106667 | False |
FLUX 0.1048805 | 0.5399711 | 0.4350906 | 0.1653333 | 0.976 | 0.8106667 | False |
FLUX 0.02164552 | 0.4550485 | 0.433403 | 0.208 | 0.01866667 | -0.1893333 | False |
FLUX 0.07093194 | 0.5028276 | 0.4318956 | 0.208 | 0.04 | -0.168 | False |
FLUX 0.3509955 | 0.8292332 | 0.4782377 | 0.3146667 | 0.1253333 | -0.1893333 | False |
FLUX 0.00860393 | 0.5118882 | 0.5032843 | 0.336 | 0.168 | -0.168 | False |
FLUX 0.09828925 | 0.6198775 | 0.5215883 | 0.464 | 0.2746667 | -0.1893333 | False |
FLUX 0.00403893 | 0.5217324 | 0.5176935 | 0.4853333 | 0.3173333 | -0.168 | False |
FLUX 0.1595938 | 0.6879836 | 0.5283898 | 0.5493333 | 0.36 | -0.1893333 | False |
FLUX 0.08826494 | 0.6299612 | 0.5416963 | 0.592 | 0.4026667 | -0.1893333 | False |
FLUX 0.07798195 | 0.6537804 | 0.5757985 | 0.6133333 | 0.424 | -0.1893333 | False |

And How I convert spectrum to Frequency Hertz?

About Spectrum Sample step

Hello ,I have a questions , that is how to setting spectrum sample step , and I found in this code

int spectrumSampleSize = 1024;
int iterations = preProcessedSamples.Length / spectrumSampleSize;

why iterations = preProcessedSamples.Length / spectrumSampleSize ?
this mean if I set spectrumSampleSize to 4096 , iterations will reduce.

Shouldn't the number of iterations be determined based on the step size and time? I'm sorry, I'm not very familiar with the principles of music data processing.

Logging peak and flux points over time?

Hi thanks for the script. It works great.

This is not really an issue but a question about how I might send peak and flux points with a timestamp to a text file.

I'm hoping to use this info in a Unity timeline and kludge up a .playable file.

I've tried Debug.Log(pointInfo[i].spectralFlux); in updatePlot and I can see a logSample function in the Spectral.cs script but it is not plugged in.

Thanks for any suggestions. Cheers

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.