53
Dynamic Audio For Apps and Games slides: is.gd/dynamic_sound_android code: github.com/thillerson/dynamic-sound-android

Dynamic Sound for Android

Embed Size (px)

DESCRIPTION

Slides for my AnDevCon talk from fall 2013, covering Pure Data from an Android app or game developer's perspective

Citation preview

Page 1: Dynamic Sound for Android

Dynamic Audio For Apps and Games

slides: is.gd/dynamic_sound_android

code: github.com/thillerson/dynamic-sound-android

Page 2: Dynamic Sound for Android

Presentation tackmobile.com

is.gd/dynamic_sound_android

Page 3: Dynamic Sound for Android

Presentation tackmobile.com

is.gd/dynamic_sound_android !

github.com/thillerson/dynamic-sound-android !

Page 4: Dynamic Sound for Android

Presentation tackmobile.com

About Me

• @thillerson, +thillerson

• Developer at Tack Mobile(tackmobile.com), @tackmobile

• Android, iOS, and Mobile Web

• Rails, Node, maybe Elixir (one day)

Page 5: Dynamic Sound for Android

Presentation tackmobile.com

Rawk Star

About Me

Page 6: Dynamic Sound for Android

Presentation tackmobile.com

About Me

• Bass

• Electronic Music

• Some day I hope to play this thing --------->

Page 7: Dynamic Sound for Android

Presentation tackmobile.com

Sound Design Work: Start

• Alarm App

• Alarm Sounds

• Play Store: “tackmobile”

Page 8: Dynamic Sound for Android

Presentation tackmobile.com

Sound Design Work: Adrift

• Puzzle Game - “Adrift” in App Store

• Background Music soundcloud.com/tackmobile

• Sound Effects

Page 9: Dynamic Sound for Android

Presentation tackmobile.com

Programming Sound

• http://pragprog.com/book/thsound

• What we’re talking about today...

• ... and much more

Page 10: Dynamic Sound for Android

Presentation tackmobile.com

When We Are Done, You Will

• Understand Sound Design

• Understand Procedural Audio

• Know what Pd is, and how libpd makes it awesome

• Be excited about Dynamic Audio in your apps and games

Page 11: Dynamic Sound for Android

Presentation tackmobile.com

What is Sound Design?

Page 12: Dynamic Sound for Android

Presentation tackmobile.com

A Sound Designer

Ben Burtt

Page 13: Dynamic Sound for Android

Presentation tackmobile.com

A Sound Designer...

• Conceptualizes

• Captures or Designs

• Records

• Engineers

• Produces

• ... the sound for an experience

Page 14: Dynamic Sound for Android

Presentation tackmobile.com

Sound Designer Skills

• Understand Sound

• Intuitive vs. Theoretical

• Music vs. Sound

• Audio Engineering

Page 15: Dynamic Sound for Android

Presentation tackmobile.com

Sound Design in Mobile Apps

• Developers/Designers wear lots of hats

• Control

• Efficiency

• Asset size

Page 16: Dynamic Sound for Android

Presentation tackmobile.com

Sound Design Principles

Page 17: Dynamic Sound for Android

Presentation tackmobile.com

A Sound Designer’s Goals

• Audible Feedback

• Fulfill Expectations

• Immersion

• Emotional Response

Page 18: Dynamic Sound for Android

Presentation tackmobile.com

Sound Design and Good UX

• Your app doesn’t need sound

• Expect to be turned off

• Don’t make me listen to you

• Listen on lots of devices/environments

• Engineer for small speakers

• Make your sound mean something!

Page 19: Dynamic Sound for Android

Presentation tackmobile.com

Always

• Test with phone calls

• Test while playing music

• Have fallbacks - e.g. No music, just effects

• Provide control to the user

Page 20: Dynamic Sound for Android

Presentation tackmobile.com

A Good Example: Clear

• Realmac Software

• Josh Mobley

• Meaningful Sound

• demo

Page 21: Dynamic Sound for Android

Presentation tackmobile.com

Sound

Page 22: Dynamic Sound for Android

Presentation tackmobile.com

Longitudinal Waves

Page 23: Dynamic Sound for Android

Presentation tackmobile.com

Of Pressure

Page 24: Dynamic Sound for Android

Presentation tackmobile.com

Through A Medium

Page 25: Dynamic Sound for Android

Presentation tackmobile.com

Transverse Wave

Longitudinal Wave

Page 26: Dynamic Sound for Android

Presentation tackmobile.com

• Longitudinal Waves

• Of Pressure

• Through a Medium

Sound

Page 27: Dynamic Sound for Android

Presentation tackmobile.com

Properties of Waves

• A - Wavelength (Distance), Period (Time)

• B - Amplitude

• C - Frequency - 1/Period (measured in Hertz)

A

B

B

C 1 2 3

Page 28: Dynamic Sound for Android

Presentation tackmobile.com

Fourier Series

• Based on his work ------->

• Periodic signals composedof simple oscillatingfunctions

• Sine/Cosine waves arefundamental

Page 29: Dynamic Sound for Android

Presentation tackmobile.com

Oscillators

• Something that moves according to a periodic function

• A physical body

• An electronic device

Page 30: Dynamic Sound for Android

Presentation tackmobile.com

Basic Electronic Sound

oscillator

voltage

magnet

pressurewaves

speaker

Page 31: Dynamic Sound for Android

Presentation tackmobile.com

Digital Audio

• Stream of Numbers

• Signal

• Frequency and Amplitude

• DAC - Digital to Analog Converter

Page 32: Dynamic Sound for Android

Presentation tackmobile.com

Dynamic Audio

Page 33: Dynamic Sound for Android

Presentation tackmobile.com

Procedural Audio

• Functions

• Objects

• Controls and Components

• Produce a Signal

• “Building Sound from First Principles”

Page 34: Dynamic Sound for Android

Presentation tackmobile.com

Pure Data

• Procedural Audio

• Visual Programming Environment

• Free and Open Source

• pure-data.info

Page 35: Dynamic Sound for Android

Presentation tackmobile.com

Pure Data 101

Page 36: Dynamic Sound for Android

Presentation tackmobile.com

Signals and Values

• Signals are streams of numbers, usually audio data

• Values are numbers or symbols

Page 37: Dynamic Sound for Android

Presentation tackmobile.com

• Pd’s class

• or, kind of like a command line tool

Objects

osc~ 440

signal inlet inlet

signal outlet

class name arguments

Page 38: Dynamic Sound for Android

Presentation tackmobile.com

Hot vs Cold Inlets

• Hot inlets make objects immediately act

• Cold inlets usually store a value

• Execution order is right to left

Page 39: Dynamic Sound for Android

Presentation tackmobile.com

• Signal connections are thick

• Others are thin

Connections

osc~ 440

*~

dac~

1

Page 40: Dynamic Sound for Android

Presentation tackmobile.com

Messages

• Used for sending values without a connection

• [send] and [receive] objects

• Message boxes

Page 41: Dynamic Sound for Android

Presentation tackmobile.com

libpd

• http://libpd.cc

• Peter Brinkmann - Google Engineer

• Enables you to embed an instance of Pd in your app

• iOS and Android

Page 42: Dynamic Sound for Android

Presentation tackmobile.com

libpd for Android

• Patches should be compressed raw resources

• Utilities for dealing with patches

• Provides interfaces for audio management

• PdBase bridges to Pd

• Pass messages, floats, and lists

• Provides PdService for long running audio

Page 43: Dynamic Sound for Android

Presentation tackmobile.com

Examples

Page 44: Dynamic Sound for Android

Presentation tackmobile.com

Source Code

• github.com/thillerson/dynamic-sound-android

• Examples of capabilities, not necessarily the best architecture

• Goal: understand capabilities, have a place to start

Page 45: Dynamic Sound for Android

Presentation tackmobile.com

libpd and gradle

• At this time there’s no official support yet

• github.com/libpd/pd-for-android/pull/7 adds support.

• I have not tested this yet

Page 46: Dynamic Sound for Android

Presentation tackmobile.com

Example 1: A Simple Keyboard

• Sine wave oscillator

• Single voice

• Note on/off

Page 47: Dynamic Sound for Android

Presentation tackmobile.com

Example 1: A Simple Keyboard Patch

osc~

dac~

receive midinote

mtof receive gate

line~

*~

;

midinote 60;

gate 1;

;

gate 0$1 1

print

Page 48: Dynamic Sound for Android

Presentation tackmobile.com

Example 2: Space Rocks

• Side scroller space shooter

• Very simple implementation - not production ready game code

• With dynamic sound!

Page 49: Dynamic Sound for Android

Presentation tackmobile.com

Example 2: A Game Patchload a square waveat startup

Thruster

noise~

*~

samphold~

dac~

hip~ 200

phasor~ 800

line~

$1 200

*~ 0.1

receive thruster

BulletShip_HitAsteroid_Hit

samphold~

tabosc4~ square

dac~

line~

phasor~ 8000

tabosc4~ square

line~

unpack f f

0 $1

tabosc4~ square

line~

unpack f f

0 $1

hip~ 1000

unpack f f

0 $1

*~ 0.5

receive asteroid receive ship receive bullet

8-bit-ifythese sounds

cut low frequencies

commentcomment

Test_Messages;bullet 25 200;

;thruster 0

;thruster 1

pd wavesetup

;ship 1000 50;

;asteroid 200 100;

Page 50: Dynamic Sound for Android

Presentation tackmobile.com

Programming Sound• http://pragprog.com/

book/thsound

Page 51: Dynamic Sound for Android

Presentation tackmobile.com

Further Reading

• puredata.info && libpd.cc

• youtube.com/user/cheetomoskeeto

• http://designingsound.org

• mitpress.mit.edu/books/designing-sound

Page 52: Dynamic Sound for Android

Presentation tackmobile.com

Questions

Page 53: Dynamic Sound for Android

Thank you!Dynamic Audio • Tony Hillerson

• We’re Hiring!

[email protected]

• Excellent Team

• Awesome Projects

• Great Office