All Projects → adamwestman → debeat

adamwestman / debeat

Licence: other
Sound Library for the Defold Engine

Programming Languages

lua
6591 projects
go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to debeat

rg3d-sound
Sound library for games
Stars: ✭ 58 (+190%)
Mutual labels:  sound, sound-library
libdynamic
High performance utility library for C
Stars: ✭ 78 (+290%)
Mutual labels:  event-driven
zero-noise
A lightweight multicolor noise generator for sound masking
Stars: ✭ 23 (+15%)
Mutual labels:  sound
defold-router
whDefRouter — screen management solution for Defold Game Engine (includes demo project)
Stars: ✭ 25 (+25%)
Mutual labels:  defold-game-engine
libapenetwork
Fast cross-platform async network library
Stars: ✭ 17 (-15%)
Mutual labels:  event-driven
Mezzanine
A game engine that supports high performance 3d graphics physics and sound
Stars: ✭ 18 (-10%)
Mutual labels:  sound
glicol
(Audio) graph-oriented live coding language and music DSP library written in Rust
Stars: ✭ 853 (+4165%)
Mutual labels:  sound
jsfxr
JavaScript sound effects generator.
Stars: ✭ 120 (+500%)
Mutual labels:  sound
hfos-legacy
Hackerfleet Operating System
Stars: ✭ 28 (+40%)
Mutual labels:  event-driven
soube
Music player based on electronjs
Stars: ✭ 32 (+60%)
Mutual labels:  sound
MOE
MOE is an event-driven OS for 8/16/32-bit MCUs. MOE means "Minds Of Embedded system", It’s also the name of my lovely baby daughter 😎
Stars: ✭ 54 (+170%)
Mutual labels:  event-driven
drawpixels
Defold engine native extension for drawing pixels into texture buffer.
Stars: ✭ 46 (+130%)
Mutual labels:  defold-game-engine
deffx
A collection of useful shader effects made ready to be used with the Defold game engine
Stars: ✭ 33 (+65%)
Mutual labels:  defold-game-engine
lisp-gui-examples
GUI for generating a tone in various Lisp dialects
Stars: ✭ 28 (+40%)
Mutual labels:  sound
statechart
A rust implementation of statecharts: hierarchical, reactive state machines
Stars: ✭ 41 (+105%)
Mutual labels:  event-driven
EsperIoT
Small and simple stream-based CEP tool for IoT devices connected to an MQTT broker
Stars: ✭ 18 (-10%)
Mutual labels:  event-driven
birds
Bird Sound Synthesis based on AM+FM
Stars: ✭ 46 (+130%)
Mutual labels:  sound
roover
🐱 A lightweight audio library for React apps.
Stars: ✭ 70 (+250%)
Mutual labels:  sound
examples
Example code for the Quarkus for Spring Developers eBook
Stars: ✭ 22 (+10%)
Mutual labels:  event-driven
aura
A fast and lightweight 3D audio engine for Kha.
Stars: ✭ 31 (+55%)
Mutual labels:  sound

DeBeat

Sound Library for the Defold Engine

Try the HTML5 Demo

Usage

  1. Add latest zip URL as a dependency in your Defold project: https://github.com/adamwestman/debeat/archive/master.zip

  2. Add the mixer.go, located in debeat/go/mixer.go, to your bootstrap collection.

  3. Create a track by adding a sound component and setting it to "Loop"

  4. Create a script and require the mixer module: local mixer = require("debeat.mixer")

  5. Start the track by passing it's url to mixer.play: mixer.play(msg.url("#track")) with an optional table for gain etc.

Documentation

Mixer

Interface for controlling tracks and sound groups, enabling smooth transitions of gain values.

Requires mixer.go to be added

  • mixer.play(url, [config]) -- start playing a track.
  • mixer.stop(url, [config]) -- stop playing a track.
  • mixer.set_gain(url, gain, [config]) -- change gain on a playing track.
  • mixer.set_group_gain(hash, gain, [config]) -- change gain on a known group.
  • mixer.refresh_groups() -- refresh known sound groups, in case a collectionproxy loaded new ones.
  • local boolean = mixer.is_ready() -- verify that the mixer.go has been initalized.

url is expected to point at a sound component. msg.url("#comp")

gain is expected to be a number between 0-1.

group is expected to be a hash matching a known sound group.

play config

  • delay [number] time in seconds until the fade will begin, defaults to 0
  • attack [number] time in seconds the fade in will take, defaults to 0.1
  • easing [go.EASING_X] curve the gain value will fade in using, defaults to go.EASING_LINEAR
  • gain [number 0-1] gain value the sound will fade up to, defaults to 1

stop config

  • delay [number] time in seconds until the fade will begin, defaults to 0
  • decay [number] time in seconds the fade out will take, defaults to 0.1
  • easing [go.EASING_X] curve the gain value will fade out using, defaults to go.EASING_LINEAR

set_gain config

  • delay [number] time in seconds until the fade will begin, defaults to 0
  • duration [number] time in seconds the change will take, defaults to 0.01
  • easing [go.EASING_X] curve the gain value will fade using, defaults to go.EASING_LINEAR

Queue

Interface for controlling sfx in categories, playing them in order or disorder.

  • local instance = queue.create(hash, [config])
  • instance.add(url)
  • instance.play(url, [delay_seconds], [gain])
  • instance.stop()

url is expected to point at a sound component. msg.url("#comp")

delay_seconds [number] time in seconds until the sound will be played.

gain is expected to be a number between 0-1, defaults to 1.

create config

  • gating [number] time in seconds required between instance.play, defaults to 0.1
  • behaviour [queue.TYPE_X] constant representing the behaviour of the queue, defaults to TYPE_SEQUENCE.
  • repeat_offset [integer] value between 1 and number of added sounds, preventing repeat of a sound until that many others have played.

Script based

Queues can also be setup using a specific Game Object and script setup. The queue id will match that of the Game Object and the amount of sounds specified in the coresponding property will be expected as sound components named "sound1", "sound2" etc.

available queues Where each script matches on of the available queue behaviours

  • debeat/queues/random.script plays sound in shuffled order
  • debeat/queues/sequence.script plays sounds in order, then repeats

alt text

Event

The event system aims to separate audio controll from logic, enabling zero or multiple event handlers to react on trigger. With this approach teams can litter their code with events and later on add and tweak the audio using scripts alone.

  • event.trigger(hash|string)
  • event(hash|string) for short

available handlers

  • play_mixed.script play a sound using the mixer.
  • play_queue.script play a sound selected by a specific queue.
  • play_sound.script play a sound.
  • reset_queue.script reset the play-order for a specific queue.
  • set_group_gain.script change the gain value of a group.
  • set_mixed_gain.script change the gain value of sound currently played by the mixer.
  • stop_mixed.script stop a sound currently played by the mixer.
  • stop_queue.script stop all sounds played by a specific queue.

For all scripts the property Event Name will be compared with triggered events and if a match is found they will react.

alt text

common params

  • Event Name : The event which the listener will be attached to. Should match something triggered by events in the game.
  • Queue Name : Should match the id of a Queue. For scripts this will be the game-object ID.
  • Sound : Which sound component to invoke. Should be a url relative or absolute.
  • Gain : A value between 0-1 at which the sound will be played.
  • Gain Variation : A range of extra random variation to the gain. can be negative
  • Delay : Time in seconds to wait after the event has fired, before performing the action.
  • Attack : Time in seconds to perform fade-in of the sound.
  • Decay : Time in seconds to perform fade-out of the sound.
  • Easing : One of the Defold provided Easing values to use when fading. See debeat.util.easing for options.

Examples

collection setup

alt text

coded

	local mixer = require("debeat.mixer")
	local queue = require("debeat.queue")

	function init(self)
		msg.post(".", "acquire_input_focus")

		self.sfx_btn = queue.create(hash("btn"), {gating=0.3, behaviour=queue.TYPE_RANDOM, repeat_offset=2})
		self.sfx_btn.add(msg.url("/sounds#sfx_btn1"))
		self.sfx_btn.add(msg.url("/sounds#sfx_btn2"))
		self.sfx_btn.add(msg.url("/sounds#sfx_btn3"))
	end

	function on_input(self, action_id, action)
		if action_id == hash("sfx") and action.released then
			self.sfx_btn.play()

		elseif action_id == hash("play") and action.released then
			mixer.play(msg.url("/sounds#track_ingame"))
		elseif action_id == hash("stop") and action.released then
			mixer.stop(msg.url("/sounds#track_ingame"))
		elseif action_id == hash("drop") and action.released then
			mixer.set_gain(msg.url("/sounds#track_ingame"), 0.5)

		elseif action_id == hash("mute") and action.released then
			mixer.set_group_gain(hash("master"), 0)
		elseif action_id == hash("unmute") and action.released then
			mixer.set_group_gain(hash("master"), 1)

		end
	end

event driven

local event = require("debeat.event")

local button = require("examples.templates.button")

function init(self)
	msg.post(".", "acquire_input_focus")

	event.add_listener("block", function()
		print("Block happened")
	end)
end

function on_input(self, action_id, action)
	-- Trigger events
	if button.on_input("event_start", action_id, action) then
		event("game_start")
		return true
	elseif button.on_input("event_end", action_id, action) then
		event("game_end")
		return true
	elseif button.on_input("attack", action_id, action) then
		event("attack")
		return true
	elseif button.on_input("block", action_id, action) then
		event("block")
		return true

	end
end
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].