The more it hears a pitch, the more plays that pitch.
By Yago De Quay
The more it hears a pitch, the more plays that pitch.
By Yago De Quay
The Echonest API provides sample level audio analysis.
http://developer.echonest.com/docs/v4/_static/AnalyzeDocumentation.pdf
What if you used that data to reconstruct music by driving a sequencer in Max? The analysis is a series of time based quanta called segments. Each segment provides information about timing, timbre, and pitch – roughly corresponding to rhythm, harmony, and melody.
https://github.com/tkzic/internet-sensors
folder: echo-nest
You will need to sign up for a developer account at The Echo Nest, and get an API key. https://developer.echonest.com
Edit the ruby server file: echonest-synth2.rb replacing the API with your new API from echonest
Install the following ruby gems (from the terminal):
gem install patron
gem install osc-ruby
gem install json
gem install uri
1. In Terminal run the ruby server:
./echonest-synth2.rb
2. Open the Max patch: echonest-synth4.maxpat and turn on the audio.
3. Enter an Artist and Song title for analysis, in the text boxes. Then press the greet buttons for title and artist. Then press the /analyze button. If it works you will get prompts from the terminal window, the Max window, and you should see the time in seconds in upper right corner of the patch.
If there are problems with the analysis, its most likely due to one of the following:
3. Press one of the preset buttons to turn on the tracks.
4. Now you can play the track by pressing the /play button.
The Mixer channels from Left to right are:
Best results happen with slow abstract material, like the Miles (Wayne Shorter) piece above. The bass is not really happening. Lines all sound pretty much the same. I’m thinking it might be possible to derive a bass line from the pitch data by doing a chordal analysis of the analysis.
Here are screenshots of the Max sub-patches (the main screen is in the video above)
Timbre (percussion synth) – plays filtered noise:
Random octave synth:
Here’s a Coltrane piece, using roughly the same configuration but with sine oscillators for everything:
There are issues with clicks on the envelopes and the patch is kind of a mess but it plays!
Several modules respond to the API data:
Since the key/mode data is global for the track, bass notes are probable guesses. This method doesn’t work for material with strong root motion or a variety of harmonic content. Its essentially the same approach I use when asked to play bass at an open mic night.
The envelopes click at times – it may be due to the relaxed method of timing, i.e.., none at all. If they don’t go away when timing is corrected, this might get cleaned up by adding a few milliseconds to the release time – or looking ahead to make sure the edges of segments are lining up.
[update] Using the Max [poly~] object cleared up the clicking and distortion issues.
Timbre data drives a random noise filter machine. I just patched something together and it sounded responsive – but its kind of hissy – an LPF might make it less interesting.
Haven’t used any of the beat, tatum, or section data yet. The section data should be useful for quashing monotony.
another update – 4/2013
tried to write this into a Max4Live device – so that the pitch data would be played my a Midi (software) instrument. No go. The velocity data gets interpreted in mysterious ways – plus each instrument has its own envelope which interferes with the segment envelopes. Need to think this through. One idea would be to write a device which uses EN analysis data for beats to set warp markers in Live. It would be an amazing auto-warp function for any song. Analysis wars: Berlin vs. Somerville.
Echonest anaylsis in Max.
By Michael Dewberrry
I downloaded the fork version from ‘dewb’ as it has been converted to run in Max6. It looks like the object retrieves all of the analysis data. It would actually be instructive to read the source code to see how they implemented libcurl and JSON for the http: requests.
A ‘mini’ version of the Google domain ping synthesizer from the internet-sensors collection (Using the Mashape API). This one runs in Web Audio, using the Web Audio Playground with OSC.
Looks like a card game. Anyway it sounds cool. Doesn’t have the panning of the original, but it has an organic sound due to portamento in frequency changes, and more ‘beating’. Here’s a short excerpt.
Another example of Max controlling WAP https://reactivemusic.net/?p=6193
https://github.com/tkzic/WebAudio
folder is: WebAudio/osctest/
update: you can run an online version of WAP Web client at http://zerokidz.com/wap/index.html – If you load this page, skip to step 3.
1. run the node webserver in WebAudio
node nodeserver.js
(it will run on localhost port 8081 – for example http://127.0.0.1:8081)
2. In Chrome web browser, run: 127.0.0.1:8081/index.html
3. From a terminal window, go to the osctest/ folder and start the server by typing:
./wapOSCserver-ping.rb
4. Load the Max patch:
wapPingTest.maxpat
5. In Chrome, click the OSC button – the ruby server should open a socket connection
6. Also in Chrome, load the patch: ping2 (note that there is a json copy of this patch ping2.json that can be pasted in, if it doesn’t show up in the menu)
6.5 In WAP, Click the square buttons on the 5 Oscillators to start them playing. You should hear sounds at this point.
7. Now back in Max patch – click green toggle to start polling and you probably want to increase the polling rate to about 50 ms instead of 1000 ms
update: here’s how to produce a sine wave: https://reactivemusic.net/?p=6574
General consensus: scriptProcessing is not robust enough to process multiple signal chains.
updated 5/17/2014
This fork adds the following features to Chris Wilson’s Web Audio Playground:
Try it out at: http:zerokidz.com/wap/index.html
For optimum results try Chrome on Mac OS. But it does work in other browsers.
Patch file format is JSON. Patches are reloaded by firing gesture events which created them.
Source code: https://github.com/tkzic/WebAudio
sub-folder: osctest
Note: You can either run a local web server, using nodeserver.js and index.html – in the WebAudio folder – or use the online version of WAP as described here.
1. Load WAP in a Google Chrome browser using the following URL: http:zerokidz.com/wap/index.html
2. In WAP, load a patch called: delay-thing.
Note: If the patch doesn’t exist you can paste it in by opening the file osctest/delay-thing.json in a text editor and copying the text. Then click paste in WAP and paste in the text. Then make sure to save it in WAP by typing in the name “delay-thing” and clicking the save-as: button
3. In a terminal window, go to the osctest/ folder and start the server by typing:
ruby ./wapOSCserver.rb
4. In WAP, Press the OSC button – the ruby server should acknowledge with the message: “WebSocket connection open”
5. Open the Max patch: wapOSCtester.maxpat
6. In WAP press the play button on the Oscillator module (you should hear sounds)
7. In the Max patch drag the slider on the left to control the oscillator pitch. You should hear the sound change and see the sliders move in WAP.
The html side of the connection is done in js/socketsOSC.js
look at the function: connectOSC() – which gets triggered by the OSC button in index.html
Incoming messages from Max (via Ruby server) are parsed in parseOSCMessage() which figures out how to set appropriate values for the audio objects in the DOM.
There are currently no acknowledgement or error messages being returned (at least I don’t remember doing this)
Stuff without purpose.
by Daniel Pettersson
Includes: webAudioToy which is visual programming language, with patch cords, for the web audio API. – Note you may need “Chrome” to run these…
local source code: tkzic/uglyhack
This is a tweak of a demo program by Boris Smus from http://webaudioapi.com
The audio is generated in the web browser using the webaudio API. Oscillator frequency is being controlled by an iPod touch running touchOSC.
A ruby program is running in the background. It starts 2 servers, one to handle Osc messages from the iPod. and a websockets server which passes Osc messages to the web client in the browser, which parses the data and sets oscillator frequency.
local source files in tkzic/web-audio-api/webaudioapi/content/posts/oscillator-ws
(these are for my local files – source has not been published yet) Please contact me directly for more information about this code. Or have a look at a very similar example at: https://github.com/tkzic/WebAudio
1. run the node webserver in tkzic/
node nodeserver.js
(it will run on localhost port 8081 – for example http://127.0.0.1:8081)
2. In Chrome web browser, run: http://192.168.1.104:8081/web-audio-api/webaudioapi/content/posts/oscillator-ws/index.html
The following screen will appear:
3. From a terminal prompt run this ruby script (in tkzic/web-audio-api/webaudioapi/content/posts/oscillator-ws)
./wapOSCserver.rb
4. In webpage in Chrome, click the sockets button – the ruby server should open a socket connection, also click the play/pause button to start the oscillator
5. In touchOSC point the host to the ip address of the laptop (ie., 192.168.1.104) running on default ports, (out 8000, in 9000)
6. In touchOSC run the ‘simple’ layout and move fader1 to change the pitch of the oscillator
Note: You will probably also want to open the developer javascript console in Chrome to see what is going on.
Need to clean up the ruby server code to handle error conditions, ie., network interruptions, missing files, browser incompatibility, etc.,