diff --git a/_layouts/default.html b/_layouts/default.html index 7d3c677..f23e169 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -129,6 +129,10 @@

ambient +
  • + audio +
  • ble diff --git a/modules.md b/modules.md index 9565971..fcbc439 100644 --- a/modules.md +++ b/modules.md @@ -56,6 +56,7 @@ If you've already tried out your modules, move on to [Tweet.](tweet.html) * [Accelerometer](modules/accelerometer.html) * [Ambient (Light + Sound)](modules/ambient.html) +* [Audio](modules/audio.html) * [BLE](modules/ble.html) * [Camera](modules/camera.html) * [Climate](modules/climate.html) diff --git a/modules/_module_footer.html b/modules/_module_footer.html index cb5601b..19867dc 100644 --- a/modules/_module_footer.html +++ b/modules/_module_footer.html @@ -14,6 +14,10 @@

    Choose another module

    "moduleLink">Ambient Light + Sound
  • +
  • + Audio +
  • BLE diff --git a/modules/audio.html b/modules/audio.html new file mode 100644 index 0000000..79efbfc --- /dev/null +++ b/modules/audio.html @@ -0,0 +1,10 @@ +--- +layout: default +--- + +{% capture include_install %} +{% include_relative audio.md %} +{% endcapture %} +{{ include_install | markdownify }} + +{% include_relative _module_footer.html %} diff --git a/modules/audio.md b/modules/audio.md new file mode 100644 index 0000000..a41a19a --- /dev/null +++ b/modules/audio.md @@ -0,0 +1,114 @@ +{::options parse_block_html="true" /} + +
    +
    + +## Audio + +[View source on Github](https://github.com/tessel/tessel-av) + +### Step 1 + +Make a directory inside your "tessel-code" folder called "audio", change directory into that folder, and initialize a tessel project: + +`mkdir audio; cd audio; t2 init` + +Download [this mp3](https://dl.dropboxusercontent.com/u/3531958/yoda-mudhole.mp3) into the "audio" directory, this will be the audio file we manipulate. + +In order to include static, non-require-dependency resources in your deployment, you'll need to explicitly inform Tessel's CLI. To do this, create a `.tesselinclude` file in your `audio` directory. In that file, type the name of the static asset that should be deployed with the project. For this project, your `.tesselinclude` will have at least the following in it: + +`yoda-mudhole.mp3` + +(Learn more about Tessel CLI deployment [tips and tricks in the docs](https://tessel.io/docs/cli#usage)) + +### Step 2 +
    +
    + +
    +
    + +Plug Tessel into your computer via USB, then plug the audio module into either of Tessel's USB ports. You will also need some kind of speaker output, headphones or [desk speakers](http://www.amazon.com/AmazonBasics-Powered-Computer-Speakers-A100/dp/B00GHY5F3K/) will do the trick. + +
    +
    + +![](http://i.imgur.com/zbRKAVx.jpg) + +
    +
    + +
    +
    + +### Step 3 + +Install by typing `npm install tessel-av` into the command line. + +### Step 4 + +Rename "index.js" to "audio.js" and replace the file's contents with the following: + +{% highlight js %} +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/publicdomain/zero/1.0/ + +/********************************************* +- Play audio from an amusing scene between Luke Skywalker, R2-D2 and Yoda +- When the audio reaches the end, play it again from the beginning. +*********************************************/ + +var path = require('path'); +var av = require('tessel-av'); +var mp3 = path.join(__dirname, 'yoda-mudhole.mp3'); +var sound = new av.Speaker(mp3); + +sound.play(); + +sound.on('end', function(seconds) { + sound.play(); +}); + + +{% endhighlight %} + +Save the file. + +
    +
    + +
    +
    + +### Step 5 + +
    +
    + +
    +
    + +In your command line, `t2 run audio.js` + +Hooray! You should hear the mp3 playing in a loop! + +**Bonus:** Try connecting buttons to your Tessel 2 and use them to control playback. Hint: it may help to look for the NPM module `tessel-gpio-button`. + +**Extra bonus:** Load many mp3s onto a USB storage drive and playback from that source. Hint: check out the "storage" tutorial on the left sidebar. + +To see what else you can do with the USB audio module, read the [tessel-av](https://github.com/tessel/tessel-av) documentation. + +
    +
    + +
    +
    + +### Step 6 + +What else can you do with an audio module? What are you making? [Share your invention!](//tessel.io/projects) + +If you run into any issues you can check out the [module forums](http://forums.tessel.io/c/modules). + +
    +