Ember as Song

A presentation at EmberConf 2020 in March 2020 in by James C Davis

Slide 1

Slide 1

Ember as Song James C. Davis

Slide 2

Slide 2

An Idea • Brainstorming session • Melanie Sumner • Compose a song alongside building an Ember app

Slide 3

Slide 3

The Idea Grows • How to best compare building an app with composing a song • Map elements of song to concepts in Ember • An Ember app that IS a song

Slide 4

Slide 4

Programming and Songwriting • Both creative endeavors • Both are complex • Share many fundamental concepts • Patterns • Loops • Conditionals • Problem solving • Bugfixing

Slide 5

Slide 5

What’s in a song? • Sections • Intro • Verse • Chorus • Bridge

Slide 6

Slide 6

What are sections composed of? • Instruments • Parts • Notes • Measures • Phrases

Slide 7

Slide 7

Mapping to Ember • Sections -> Routes • Instruments -> Services • Parts -> Components • Notes -> Contextual Components

Slide 8

Slide 8

Section -> Route • A location in the song • Composed of instruments playing parts together • The musical equivalent of a “page”

Slide 9

Slide 9

Instrument -> Service • Instruments are global • Maintain state when moving through sections • Keep playing • Volume • Effects

Slide 10

Slide 10

Part -> Component • Made up of notes for one instrument • Often a pattern that repeats within a section • Often re-used across multiple sections

Slide 11

Slide 11

Note -> Contextual Component • Belongs to a part • Needs context • Which instrument • When to play relative to other notes

Slide 12

Slide 12

Other Globals • Tempo • Master Volume • Playing state (start, pause, stop) • Where we are in the timeline • Could be handled by a single or multiple services

Slide 13

Slide 13

Concept -> Implementation • Web Audio API - https://www.w3.org/TR/webaudio/ • • Extremely powerful, but very low level Tone.js - https://tonejs.github.io • Built on top of Web Audio API • Primitives for making music (not just sounds)

Slide 14

Slide 14

Hello World • Create one instrument: piano • Play a single note: middle C

Slide 15

Slide 15

Service: piano ember g service piano

Slide 16

Slide 16

Instrument Component

Slide 17

Slide 17

Part Component • Responsible for • Connecting notes to an instrument • Scheduling notes to play • Scheduling draws • Looping

Slide 18

Slide 18

Part Component

Slide 19

Slide 19

Note Component

Slide 20

Slide 20

Play it!

Slide 21

Slide 21

Slide 22

Slide 22

Scale • String of notes, one after another • Ascending (or descending) in pitch • Hitting all the white keys (for a C scale)

Slide 23

Slide 23

Scale

Slide 24

Slide 24

Slide 25

Slide 25

How does this work?

Slide 26

Slide 26

Visualization

Slide 27

Slide 27

Two Instruments

Slide 28

Slide 28

Slide 29

Slide 29

Multi-part

Slide 30

Slide 30

Slide 31

Slide 31

Loops

Slide 32

Slide 32

Slide 33

Slide 33

Drum Kit

Slide 34

Slide 34

Drum Kit

Slide 35

Slide 35

Slide 36

Slide 36

Drum Loop

Slide 37

Slide 37

Slide 38

Slide 38

Putting it all Together • Composed a song with Ember! • Routes and controllers for: intro, verse, chorus • Auto-advances among the sections • Routes handle timing and advancing • Controllers inject instruments (services) • Parent route for drums

Slide 39

Slide 39

Slide 40

Slide 40

Future Plans • Write more songs! • Turn this into an add-on • Continue to add features • Collaboratively write songs using GitHub!

Slide 41

Slide 41

Thank You! jamescdavis.github.io/ember-as-song twitter: @jamscdavis everywhere else: @jamescdavis