GithubHelp home page GithubHelp logo

cartergames / audiomanager Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 1.0 140.13 MB

A free audio/sound management system for Unity with automatic library management & more!

Home Page: https://carter.games/audiomanager

License: MIT License

C# 100.00%
audio audiomanager audiomanager-script audiomanager-api musicplayer music sound soundmanager unity unitypackage

audiomanager's Introduction

AM Banner 1200x630

Audio Manager is a FREE audio/sound management library for Unity with options to play clips & background music for any game.

Badges

CodeFactor GitHub all releases GitHub release (latest by date) GitHub repo size Unity

Legacy Version

You can still acces the legacy 2.x version in the 2.x branch of this repo.

Key Features

  • Automatic scanning of audio clips in the project.
  • Dynamic start time for each clip to start where it starts playing audable audio, cutting out deadspace.
  • Flexiable API for playing audio clips or groups of clips.
  • Editor to manage the library, assign groups of clips together and music track lists.
  • No setup needed, just import and go.
  • Entirely static API, no scene references needed.
  • Music playing setup.
  • Inspector players for quick prototyping without needing to write any code.
  • Regularly updated and maintained with ❤️

How To Install

Either download and import the package from the releases section or the Unity Asset Store and use the package manager. Alternatively, download this repo and copy all files into your project.

Setup

Unlike the 2.x version of the asset. 3.x doesn't have any user setup needed for it to actually function. Once you import the asset into your project, you'll be prompted to scan for audio, do the scan and you'll be all set for use.

Basic Scripting To Play A Clip

You can play audio either through the inspector clip player which lets you setup a clip or a group through an editor or through code.

Inspector

Untitled

A inspector class to allow users to play audio from the audio library like you can with the normal API but just from the inspector. The editor has options to apply some of the edit modules, play a single track/defined group and listen to events the setup would normally trigger.

To play a clip from the inspector player, just reference it to another class or use a button unity event etc. to call Play() on the class. Example:

[SerializeField] private InspectorAudioClipPlayer player;

private void OnEnable()
{
    player.Play();
}

Code

Like 2.x the API is mostly the same but with a few edits. The same Play(), PlayFromTime(), PlayWithDelay() etc are present, but you can apply Edit Modules to any method which let you make these edits as needed. There are the common volume & pitch edits for all method variations, but for other edits the modules are used instead to save needing 1000s of lines of method overrides.

private void OnEnable()
{
    // Plays the clip with no user edits.
    AudioManager.Play("MyClip");

    // Plays the clip with edits to volume.
    AudioManager.Play("MyClip", .5f);

    // Plays the clip with edits to volume via edit modules.
    AudioManager.Play("MyClip", new VolumeEdit(.5f));
}

You can play from a collection of clips with the group play methods, which work the exact same as the standard ones, but with groups. These can be defined in the library editor or in code should you wish. Example:

private void OnEnable()
{
    // Plays the group with no user edits.
    AudioManager.PlayGroup(Group.MyGroup);

    // Plays the group with edits to volume.
    AudioManager.PlayGroup(Group.MyGroup, .5f);

    // Plays the group with edits to volume via edit modules.
    AudioManager.PlayGroup(Group.MyGroup, new VolumeEdit(.5f));

    // Plays a group from an array of clip names.
    string[] clips = new string[3] { "Click_01", "Click_02", "Click_03" };
    AudioManger.PlayGroup(clips, GroupPlayMode.Random);
}

For more information on all of this, please consult the documentation: https://carter.games/docs/audiomanager/3x

Example Scene

Please see the example project .zip for an example of the asset usage. It couldn't be provided in the package due to how the asset handles the audio library automation.

Documentation

You can access a online of the documentation here: Online Documentation. A offline copy if provided with the package and asset if needed.

Authors

Additional Contributors

  • Yousef Al-Hadhrami - (Legacy - V:2.6.1) - Hotfix to AudioPool.cs class throwing a null reference exception error.

Licence

MIT Licence

audiomanager's People

Contributors

jonathanmcarter avatar yemeni avatar

Stargazers

 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

Forkers

yemeni

audiomanager's Issues

Script can not scan audio files at path contain "Assets" string

Hi,

I encountered a minor issue with the script that I wanted to bring to your attention.
In my folder structure, I have organized my files in the following way:

Assets/PingPong/Script/*
Assets/PingPong/Assets/Prefabs/*
Assets/PingPong/Assets/Audio/*
Assets/PingPong/Assets/Dialog/*

I noticed that in the source code, the linefileDirs.GetArrayElementAtIndex(i).stringValue.Replace("Assets", "")) could work incorrectly in this case, script can not scan audio clip.

Thank you for creating such a useful asset

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.