bpm js

37
js bpm onset detection in the Browser Janessa Det - WEB eng @TWITTERNYC

Upload: janessa-det

Post on 05-Dec-2014

1.794 views

Category:

Technology


0 download

DESCRIPTION

Onset Detection in the Browser JSConf 2013

TRANSCRIPT

Page 1: BPM JS

jsbpm

onset detection in the BrowserJanessa Det - WEB eng @TWITTERNYC

Page 2: BPM JS

hello.bpmjs

janessa det (@jandet)

twitter nycSoftware engineerWeb Team

columbia universityM.S. Computer scienceGraphics & Vision

duke universityB.S.E. biomedical engineering

Page 3: BPM JS

IRON MAN

onset detectionbpm. what?

bpmjsjanessa det (@jandet)

onset detectionfundamental to:sonar, speech, EKG's,movement detection

thisthing

IRON MAN

Page 4: BPM JS

IRON MAN

onset detectionbpm. what?

bpmjsjanessa det (@jandet)

onset detectionfundamental to:sonar, speech, EKG's,movement detection

thisthing

IRON MAN

Page 5: BPM JS

AUTOMATICTRANSCRIPTIONOF MUSIC

onset detectionbpm. what?

bpmjsjanessa det (@jandet)

AUTOMATICTRANSCRIPTIONOF MUSIC

thisthing

1. instrument identification

2. instrument isolation

3. pitch detection

4. dynamics

Page 6: BPM JS

accessibleapplicable

sharablecross-platform

fast

digital signals processing

in the browser. why?bpmjs

janessa det (@jandet)

accessibleapplicable

sharablecross-platform

fast

digital signals processing

Page 7: BPM JS

javascript

in the browser. why?bpmjs

janessa det (@jandet)

because

javascript

and it would be cool

is fun

to play with

Page 8: BPM JS

diverse

diversity is powerful.bpmjs

janessa det (@jandet)

the browser is

diversethe community is

Page 9: BPM JS

diverse

diversity is powerful.bpmjs

janessa det (@jandet)

the browser is

diversethe community is

Page 10: BPM JS

diversity is powerful.bpmjs

janessa det (@jandet)

yeah,that’s me

reality

the dream

"finding ways to breedengineering research, music, and artwith the trusty steed of javascriptto make the magical unicorns of my imagination a reality"

Page 11: BPM JS

diversity is powerful.bpmjs

janessa det (@jandet)

yeah,that’s me

reality

the dream

"finding ways to breedengineering research, music, and artwith the trusty steed of javascriptto make the magical unicorns of my imagination a reality"

ok, let’sbreed some

unicorns

Page 12: BPM JS

onset detection?how do we doonset detection?

Page 13: BPM JS

GENRES

tempos

beats

onsets

what is bpm?bpmjs

janessa det (@jandet)

1. pitch

2. notes

3. percussive beats

DRUM AND BASS 160-180 BPM

House 118-135 BPM

hip-hop 115 BPM

Concert marches 120 BPM

Screamers 130-150 BPM

beatsGENRES

what is a beat?

1. pitched non-percussive

2. pitched percussive

3. non-pitched percussive

4. complex mixed

onsetstempos

Largo 40-60 BPM

Larghetto 60-66 BPM

Adagio 66-76 BPM

Andante 76-108 BPM

Moderato 108-120 BPM

Allegro 120-168 BPM

Presto 168-200 BPM

Prestissimo 200+ BPM

Page 14: BPM JS

bpmjsjanessa det (@jandet)detection method.

DETECTIONFUNCTIONstft

DETECTIONFUNCTIONSTFT PEAK PICKINGPEAK PICKING BPMBPM

Prep the signalfor Detection

Functions

Selectively maximize for onset properties

Pick out peak times from Detection Function

CalculateBPM

ಠ_ಠ

Page 15: BPM JS

bpmjsjanessa det (@jandet)detection method.

DETECTIONFUNCTIONstft

DETECTIONFUNCTIONSTFT PEAK PICKINGPEAK PICKING BPMBPM

Prep the signalfor Detection

Functions

Selectively maximize for onset properties

Pick out peak times from Detection Function

CalculateBPM

Page 16: BPM JS

stft. short-time fourier transform.

bpmjsjanessa det (@jandet)

4. zero paddingZero pad to nearest power of 2

2. hamming windowApply windowing function -- Hamming

3. normalizationNormalize magnitude

5. fast fourier transformConvert to frequency domain

1. window slicingSlice signal into overlapping windows

Page 17: BPM JS

detection functions.bpmjs

janessa det (@jandet)

frequency based methods

3. phase deviation

1. High frequency content

2. spectral difference

4. euclidian distance

Page 18: BPM JS

peak pickingbuild threshold

peak picking.bpmjs

janessa det (@jandet)

build threshold1. median filterSmooth out the signal for thresholding

2. adaptive thresholdingThreshold by median-filtered signal

3. initial peak findingIdentify local maxima

4. thresholding peaksApply adaptive threshold to peak findings

5. refractory periodApply minimum time between peaks as threshold

peak picking

Page 19: BPM JS

120 BPM

bpm calculation.bpmjs

janessa det (@jandet)

0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0peak times (in seconds)

0.5

1 beat / 0.5 sec * 60 sec / 1 min

= 120 BPM

Page 20: BPM JS

in javascript?how do we do itin javascript?

Page 21: BPM JS

color profile of

music characterization.bpmjs

janessa det (@jandet)

color profile ofso insane by discovery

average ~ 115 bpm

0:30 1:000:15 0:45 1:15 1:45 2:151:30 2:000:00 2:30 3:002:45 3:15

Page 22: BPM JS

dsp.jsweb audio

complex arithmetic

a lot of loops & mathbrowserify

tools used.bpmjs

janessa det (@jandet)

dsp.jsweb audio

complex arithmetic

a lot of loops & mathbrowserify

i

Page 23: BPM JS

modules.bpmjs

janessa det (@jandet)

peak picking

detection

bpmweb audioAudioBuffer node

hfc sd pd e. dist.

dsp.js

fft windowing

complexstft

Page 24: BPM JS

how to not break chrome

js challenges.bpmjs

janessa det (@jandet)

float32array

how to not break chrome

compatibility

complex arithmeticmatrices

Page 25: BPM JS

how to not break chrome

js challenges.bpmjs

janessa det (@jandet)

float32array

how to not break chrome

compatibility

complex arithmeticmatrices

NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN... NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN NaNNaNNaNNaNNaNNaNNaNNaN

Page 26: BPM JS

0. signal winndow

stft. short-time fourier transform.

bpmjsjanessa det (@jandet)

3. ZERO PADDING

1. HAMMING WINDOW

2. NORMALIZATION

4. FFT -> Complex objects

Page 27: BPM JS

bpmjsjanessa det (@jandet)

detection functions.hfc

sd

pd

e. dist.

not bad...

Page 28: BPM JS

bpmjsjanessa det (@jandet)

peak picking.detectionfunction (ed)

median filtered

thresholdedetc

Page 29: BPM JS

THE DREAM:

matlab!!benchmarks

optimizations& performance

bpmjsjanessa det (@jandet)

1. web workers for stft2. SLICE WELL-SELECTED WINDOWS

benchmarksvs. matlab!!

THE DREAM: “REAL-TIME”

3. asm.js, enscripten, LLjs

Page 30: BPM JS

weaknesses.

future work.

weaknesses.bpmjs

janessa det (@jandet)

1. sensitive tuning parameters

2. a priori knowledge helpful to select detection functions

3. median filtering or aggressive thresholding can cripple

the detection function

future work.1. only scratching the surface of research

2. many detection functions

3. onset detection for different applications

Page 31: BPM JS

is the unicorn beautiful?ok so how did i do?is the unicorn beautiful?

Page 32: BPM JS

bpmjsjanessa det (@jandet)

ok, it feels alittle forced

but we’re getting there!!

Page 33: BPM JS

the web is changing.bpmjs

janessa det (@jandet)

web audio api

dsp.jsGod Bless npm

Page 34: BPM JS

rethinkingweb engineering.

bpmjsjanessa det (@jandet)

what does it mean to be aweb engineer?how about more engineering?

this is not the final frontier

Page 35: BPM JS

bpmjsjanessa det (@jandet)

embrace diversityopen community of learning

knowledge builds upon itselfcombining fields is very powerful

think outside the boxbreed those unicorns

rethinkingweb engineering.

Page 36: BPM JS

bpmjsjanessa det (@jandet)

thanks.

go forth and breed unicorns

Page 37: BPM JS

main referencesBeat Detection for Automated Music Transcription:An exploration of Onset Detection Algorithms.http://bingweb.binghamton.edu/~ahess2/Onset_Detection_Nov302011.pdf

The Scientist and Engineer's Guide toDigital Signal ProcessingBy Steven W. Smith, Ph.D.http://www.dspguide.com/pdfbook.htm

additional resources:Gamedev: beat detection algorithmshttp://archive.gamedev.net/archive/reference/programming/features/beatdetection/index.html

BPM Databasehttp://www.bpmdatabase.com/