From c10afe660fd02b43a585f52d78e6c860d8b50988 Mon Sep 17 00:00:00 2001 From: Kelsey Breseman Date: Mon, 15 Feb 2016 17:08:53 -0800 Subject: [PATCH 1/4] scaffolding for audio module tutorial --- _layouts/default.html | 4 ++ modules.md | 1 + modules/_module_footer.html | 4 ++ modules/audio.html | 10 ++++ modules/audio.md | 100 ++++++++++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+) create mode 100644 modules/audio.html create mode 100644 modules/audio.md diff --git a/_layouts/default.html b/_layouts/default.html index 8c114b1..deb6599 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 8690738..59f48d9 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) * [Climate](modules/climate.html) * [GPS](modules/gps.html) diff --git a/modules/_module_footer.html b/modules/_module_footer.html index 322fb61..b3b3909 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..19c7639 --- /dev/null +++ b/modules/audio.md @@ -0,0 +1,100 @@ +{::options parse_block_html="true" /} + +
    +
    + +## Audio + +[ View source on Github](https://github.com/tcr/node-audiovideo) + +### 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` + +### Step 2 +
    +
    + +
    +
    + +Plug Tessel into your computer via USB, then plug the audio module into either of Tessel's USB ports. + +
    +
    + +![](http://i.imgur.com/uifn1p7.jpg) + +
    +
    + +
    +
    + +### Step 3 + +Install by typing `npm install audiovideo` 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/ + +/********************************************* +DESC of EXAMPLE +*********************************************/ + +// EXAMPLE GOES HERE + +{% endhighlight %} + +Save the file. + +
    +
    + +
    +
    + +### Step 6 + +
    +
    + +
    +
    + +In your command line, `t2 run audio.js` + +Hooray! You should see WHATEVER YOU SHOULD SEE FROM THE EXAMPLE + +**Bonus:** EXTRA CHALLENGE FOR AUDIO + +To see what else you can do with the USB audio module, read the [audiovideo](https://github.com/tcr/node-audiovideo) documentation. + +
    +
    + +![](AUDIO OUTPUT GIF) + +
    +
    + +
    +
    + +### Step 7 + +What else can you do with an audio module? Get inspired by a [community-created project.](http://tessel.io/projects) + +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). + +
    +
    From 043d147ef045123d3d337fe18c652fd711455b07 Mon Sep 17 00:00:00 2001 From: Kelsey Breseman Date: Mon, 15 Feb 2016 17:14:27 -0800 Subject: [PATCH 2/4] fixes step numbering --- modules/audio.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/audio.md b/modules/audio.md index 19c7639..a00086d 100644 --- a/modules/audio.md +++ b/modules/audio.md @@ -61,7 +61,7 @@ Save the file.
    -### Step 6 +### Step 5
    @@ -88,7 +88,7 @@ To see what else you can do with the USB audio module, read the [audiovideo](htt
    -### Step 7 +### Step 6 What else can you do with an audio module? Get inspired by a [community-created project.](http://tessel.io/projects) From 4429362098f3846d8c673513f7121744cb5431f9 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 1 Mar 2016 12:55:20 -0500 Subject: [PATCH 3/4] Fill in audio module tutorial --- modules/audio.md | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/modules/audio.md b/modules/audio.md index a00086d..4630cba 100644 --- a/modules/audio.md +++ b/modules/audio.md @@ -5,7 +5,7 @@ ## Audio -[ View source on Github](https://github.com/tcr/node-audiovideo) +[View source on Github](https://github.com/tessel/tessel-av) ### Step 1 @@ -13,6 +13,14 @@ Make a directory inside your "tessel-code" folder called "audio", change directo `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
    @@ -20,12 +28,12 @@ Make a directory inside your "tessel-code" folder called "audio", change directo
    -Plug Tessel into your computer via USB, then plug the audio module into either of Tessel's USB ports. +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/uifn1p7.jpg) +![](http://i.imgur.com/zbRKAVx.jpg)
    @@ -35,7 +43,7 @@ Plug Tessel into your computer via USB, then plug the audio module into either o ### Step 3 -Install by typing `npm install audiovideo` into the command line. +Install by typing `npm install tessel-av` into the command line. ### Step 4 @@ -46,10 +54,21 @@ Rename "index.js" to "audio.js" and replace the file's contents with the followi // http://creativecommons.org/publicdomain/zero/1.0/ /********************************************* -DESC of EXAMPLE +- 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. *********************************************/ -// EXAMPLE GOES HERE +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 %} @@ -71,16 +90,18 @@ Save the file. In your command line, `t2 run audio.js` -Hooray! You should see WHATEVER YOU SHOULD SEE FROM THE EXAMPLE +Hooray! You should hear the mp3 playing in a loop! **Bonus:** EXTRA CHALLENGE FOR AUDIO -To see what else you can do with the USB audio module, read the [audiovideo](https://github.com/tcr/node-audiovideo) documentation. +To see what else you can do with the USB audio module, read the [tessel-av](https://github.com/tessel/tessel-av) documentation. + +- Try connecting buttons to your Tessel 2 and use them to control playback. +- Load many mp3s onto a USB storage drive and playback from that source.
    -![](AUDIO OUTPUT GIF)
    @@ -90,9 +111,7 @@ To see what else you can do with the USB audio module, read the [audiovideo](htt ### Step 6 -What else can you do with an audio module? Get inspired by a [community-created project.](http://tessel.io/projects) - -What are you making? [Share your invention!](//tessel.io/projects) +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). From 245f39feb1ebc5b3f659d6981f6c49bb55f29723 Mon Sep 17 00:00:00 2001 From: Kelsey Breseman Date: Sun, 10 Apr 2016 10:41:46 +0200 Subject: [PATCH 4/4] modified for immediate deployment without result video --- modules/audio.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/audio.md b/modules/audio.md index 4630cba..a41a19a 100644 --- a/modules/audio.md +++ b/modules/audio.md @@ -13,9 +13,9 @@ Make a directory inside your "tessel-code" folder called "audio", change directo `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. +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: +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` @@ -55,7 +55,7 @@ Rename "index.js" to "audio.js" and replace the file's contents with the followi /********************************************* - 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. +- When the audio reaches the end, play it again from the beginning. *********************************************/ var path = require('path'); @@ -86,22 +86,17 @@ Save the file.
    -
    +
    In your command line, `t2 run audio.js` Hooray! You should hear the mp3 playing in a loop! -**Bonus:** EXTRA CHALLENGE FOR AUDIO - -To see what else you can do with the USB audio module, read the [tessel-av](https://github.com/tessel/tessel-av) documentation. - -- Try connecting buttons to your Tessel 2 and use them to control playback. -- Load many mp3s onto a USB storage drive and playback from that source. +**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.