Web Audio API by Boris Smus

update 11/20/2014

re-cloned local copy of repository to tkzic/webaudioapi.com

  • copied the static folder from template/ to posts/
  • copied all of the index.html versions of the index.txt files in the topics from my previous version.
  • copied main index.html to posts
  • Actually, I should have just forked this…

Also have copied the updates to my online server http://zerokidz.com/webaudioapi/content/posts

original post

http://www.amazon.com/Web-Audio-API-Boris-Smus/dp/1449332684/ref=sr_1_1?ie=UTF8&qid=1363231741&sr=8-1&keywords=web+audio+api

http://webaudioapi.com/samples

Some notes on using the examples from the github repository… https://github.com/borismus/webaudioapi.com

Each example is contained in a post/ folder, but… a few things were missing – like the html wrappers for each example. They can be copied from http://webaudioapi.com/samples, using ‘view source’ and making these changes:

  • remove Google analytics code
  • change file refs for static/ folder to ../static

Then copy style.css and js/shared.js and place them in a static/ folder at the same level as posts. This way the examples will look right and have all shared refs.

My version of source is in: tkzic/web-audio-api/webaudioapi

Also try this link (not updated since 3/14/2013) http://zerokidz.com/webaudioapi/content/posts

I have kept the original zip, but it appears the archive is under active development and its probably worth cloning it and keeping it up to date…

Btw, this code and the book is amazing.

 

 

Getting started with Web Audio API

With full source code examples.

By Boris Smus at HTML5 Rocks

http://www.html5rocks.com/en/tutorials/webaudio/intro/

update 5/2014

To get full source with comments, make a URL in this format – (the buttons on the tutorial page only gives minified JS)

http://www.html5rocks.com/en/tutorials/webaudio/intro/js/rhythm-sample.js?ModPagespeed=off

Here’s a note about it: https://github.com/html5rocks/www.html5rocks.com/issues/367

To get the source for the UI – ie., buttons and sliders – just view the page source for the tutorial

Scheduling Web Audio

http://www.html5rocks.com/en/tutorials/audio/scheduling/

JAM with chrome case study

http://www.html5rocks.com/en/tutorials/casestudies/jamwithchrome-audio/

Case Study: Building Technitone.com

http://www.html5rocks.com/en/tutorials/casestudies/technitone/

 

 

 

 

 

iOS core midi

A few references:

Classic PGmidi (Pete Goodliffe)

http://goodliffe.blogspot.com/2010/10/using-coremidi-in-ios-example.html

The synthetic bits coreMidi braindump is now password protected… sigh

http://syntheticbits.com/blog

A helpful diagram showing terminology

http://xmidi.com/blog/how-to-access-midi-devices-with-coremidi/

Useful core Audio and core Midi links for iOS

http://www.deluge.co/?q=core-midi-core-audio-useful-links

an older ios midi project

https://github.com/JohnGoodstadt/MidiNotes

 

xcode 4.6 subversion Assembla error

notes

This is obscure, but happened with Loup and was fixed by using the answer from the following SO post

http://stackoverflow.com/questions/13133883/having-difficulty-pulling-repository-from-assembla

<code>Error validating server certificate for 'https://subversion.assembla.com:443': - The certificate is not issued by a trusted authority. Use the fingerprint to validate the certificate manually! Certificate information: - Hostname: *.assembla.com - Valid: from Thu, 24 Mar 2011 19:30:40 GMT until Sun, 24 Mar 2013 19:30:40 GMT - Issuer: 07969287, http://certificates.godaddy.com/repository, GoDaddy.com, Inc., Scottsdale, Arizona, US - Fingerprint: ae:b0:b6:94:14:5f:4b:28:d2:82:68:ae:e9:18:85:b3:ea:36:ee:f2 (R)eject, accept (t)emporarily or accept (p)ermanently?</code>

Zombie processes in Max

Shell object artifacts.

Today I set up a subpatcher in Max to launch a ruby server, using [aka.shell]. I didn’t realize it was running, so I ran it again – then Max froze, so I force-quit out of it. This left a zombie process in control of the UDP port.

Later I found this command, which identifies all processes on the machine:

# ps -xo pid,ppid,stat,command

Anyway, its probably not a good idea to run servers from shell commands without a way to kill them.

Here’s a screenshot of the sub-patcher which figures out how to run a shell command in the same folder as the patch:

 file

in tkzic/max teaching examples/

ruby-shell-server-trick.maxpat

 

The sound of a new machine

Using internet ping data to control a synthesizer in Max

This project uses ‘ping’ times to about 40 Google domains, like google.ca, google.de, etc., to control pitch and amplitude of a 20 voice droning synthesizer.

Imagine working in a Google control center. A soothing low pitched drone fills the room. Then Suddenly you hear a slowly rising pitch. You check the monitors – Google Paraguay is experiencing network failure. You light a cigarette and wait for things to calm down.

update 2/6/2021

Not using ruby to ping – due to API shutting down. The new version uses the Max [shell] external to ping from the command line.

download

https://github.com/tkzic/internet-sensors

folder: ping

files

main Max patch
  • sound-of-a-new-machine3.maxpat
abstractions and other files

instructions

  • Open the Max patch: sound-of-a-new-machine3.maxpat
  • Turn on audio. Turn up the gain.
  • In the Max patch, click the toggle box to start polling. It may take a minute to hear any sounds, while the oscillators are loading. Increase polling speed to 400 or so if you can’t wait.
  • Another reason you might not hear anything interesting is if the clip threshold is too low. Watch the incoming ping times and set the clip threshold above the average level.
  • Adjust the pitch multiplier to your desired pitch range. It will take some time for all of the oscillators to adjust after a pitch change.
  • If you hear clicks or pops, try reducing the sample rate to 44.1 KHz, or increasing the IO vector size (in Options | Audio Status).

note: Occasionally the server program will time-out when its launched. Try launching again, or edit it and increase the timeout value in [p shellping].


deprecated information for previous version using ruby

The server is a ruby script which handles the http: requests using the Mashape ping-uin API and sends messages to Max using OSC

The synth has a weird clustering drone like effect like some kind of alien life force.

The patch design is kind of embarrassing. Its obvious I forgot how to use [poly~]. Maybe by the time you read this, we’ll have addressed this.  Hey billions of patch cords look cool.

Here’s an example of the Mashape API in curl

curl --include --request GET 'https://igor-zachetly-ping-uin.p.mashape.com/pinguin.php?address=google.ca' \
  --header 'X-Mashape-Authorization: YOUR-MASHAPE-API-KEY'

Here’s a list of Google domains

http://en.wikipedia.org/wiki/List_of_Google_domains

download

https://github.com/tkzic/internet-sensors

folder: ping

files

main Max patch
  • sound-of-a-new-machine2.maxpat
abstractions and other files
  • google.txt (list of domains for [coll] object
ruby
  • domain-ping.rb

ruby gems

install the following ruby gems using: sudo xcrun gem install <gem-name>

  • require ‘osc-ruby’
  • require ‘patron’
  • require ‘json’

authorization

  • Register with mashape http://mashape.com to get an API-key for ping-uin
  • Then edit domain-ping.rb to enter your mashape API-key.

instructions

  • Open the Max patch: sound-of-a-new-machine2.maxpat
  • Turn on audio. Turn up the gain.
  • From a terminal window type the following command
# ./domain-ping.rb


  •  In the Max patch, click the toggle box to start polling. It may take a minute to hear any sounds, while the oscillators are loading. Increase polling speed to 400 or so if you can’t wait.
  • Another reason you might not hear anything interesting is if the clip threshold is too low. Watch the incoming ping times and set the clip threshold above the average level.
  • Adjust the pitch multiplier to your desired pitch range.
  • When you’ve had enough, type <ctrl-c> in the terminal window to stop the server.

note: Occasionally the server program will time-out when its launched. Try launching again, or edit it and increase the timeout value.