{"id":462,"date":"2014-08-25T06:21:22","date_gmt":"2014-08-25T06:21:22","guid":{"rendered":"http:\/\/charlie-roberts.com\/gibber\/?page_id=462"},"modified":"2014-08-25T22:49:01","modified_gmt":"2014-08-25T22:49:01","slug":"gibber-lib-js","status":"publish","type":"page","link":"http:\/\/charlie-roberts.com\/gibber\/gibber-lib-js\/","title":{"rendered":"Gibber.lib.js"},"content":{"rendered":"<p>Gibber.lib is a standalone JavaScript library that lets you use Gibber commands and syntax inside of any webpage. You can also use it inside of <a href=\"nodejs.org\">Node.js<\/a> via the excellent <a href=\"https:\/\/github.com\/sebpiq\/node-web-audio-api\">web-audio-api module<\/a> by Sebastien Piquemal.<\/p>\n<p>Below is a simple example using Gibber.lib in a standard HTML page to start a bass line and drum loop playing.<\/p>\n<pre>\r\n<html>\r\n\r\n<head>\r\n  <script src='build\/gibber.lib.js'><\/script>\r\n<\/head>\r\n\r\n<body><\/body>\r\n\r\n<script>\r\nGibber.init() \/\/ REQUIRED!\r\n\r\nGibber.scale.root.seq( ['c4','eb4'], 2)\r\n\r\na = Mono('bass').note.seq( [0,7], 1\/8 )\r\n\r\nb = EDrums('xoxo')\r\nb.snare.snappy = 1\r\n\r\nc = Mono('easyfx')\r\n  .note.seq( Rndi(0,12), [1\/4,1\/8,1\/2,1,2].rnd( 1\/8,4 ) )\r\n<\/script>\r\n\r\n<\/html>\r\n<\/pre>\n<p>For client-side use with HTML, Gibber.lib uses <a href=\"http:\/\/browserify.org\">browserify<\/a> to wrap everything into a single HTML file. When minimized, this file is ~166 KB in size.<\/p>\n<h3>Using with Node.js<\/h3>\n<p>You can install it for node using a <a href=\"npmjs.org\">node packaged module<\/a>. If you have node installed it only takes a few lines of code to test out the same Gibber code that&#8217;s in the the HTML code above:<\/p>\n<pre>\r\nnpm install web-audio-api\r\nnpm install gibber.lib\r\nnpm test gibber.lib\r\n<\/pre>\n<p>To use the libraries, simply place your .js file in the same directory as the node_modules folder containing the web-audio-api and gibber.lib modules. Then start the .js file with the following:<\/p>\n<pre>\r\nAudioContext = require('web-audio-api').AudioContext\r\nGibber       = require('gibber.lib')\r\n\r\nGibber.init()\r\n<\/pre>\n<p>AudioContext and Gibber currently both need to be global objects; I might try to clean this up in the future. Once you have those three lines of code you can start freely gibbering underneath.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gibber.lib is a standalone JavaScript library that lets you use Gibber commands and syntax inside of any webpage. You can also use it inside of Node.js via the excellent web-audio-api module by Sebastien Piquemal. Below is a simple example using Gibber.lib in a standard HTML page to start a bass line and drum loop playing. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/pages\/462"}],"collection":[{"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/comments?post=462"}],"version-history":[{"count":7,"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/pages\/462\/revisions"}],"predecessor-version":[{"id":473,"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/pages\/462\/revisions\/473"}],"wp:attachment":[{"href":"http:\/\/charlie-roberts.com\/gibber\/wp-json\/wp\/v2\/media?parent=462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}