Skip to content

Commit

Permalink
Fill in audio module tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Mar 1, 2016
1 parent 043d147 commit 1849d64
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions modules/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,38 @@

## <img class="constrain-sm" src="https://s3.amazonaws.com/technicalmachine-assets/technical-io/modules/usb.png"> Audio

[<i class="fa fa-github"> View source on Github</i>](https://github.com/tcr/node-audiovideo)
[<i class="fa fa-github">View source on Github</i>](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:

`wget https://dl.dropboxusercontent.com/u/3531958/yoda-mudhole.mp3`

Create a file called ".tesselinclude" with the mp3 file name in it:

```
touch .tesselinclude;
echo "yoda-mudhole.mp3" > .tesselinclude
```

### Step 2
</div>
</div>

<div class="row">
<div class="large-6 columns">

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.

</div>
<div class="large-6 columns">

![](http://i.imgur.com/uifn1p7.jpg)
![](http://i.imgur.com/zbRKAVx.jpg)

</div>
</div>
Expand All @@ -35,7 +46,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

Expand All @@ -46,10 +57,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 %}

Expand All @@ -71,16 +93,15 @@ 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.

</div>
<div class="large-6 columns">

![](AUDIO OUTPUT GIF)

</div>
</div>
Expand All @@ -90,7 +111,10 @@ 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 else can you do with an audio module?

- 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.

What are you making? [Share your invention!](//tessel.io/projects)

Expand Down

0 comments on commit 1849d64

Please sign in to comment.