Library to run the Tessel Audio Module. Plays and records sound.
Last updated 5 years ago by technicalmachine .
MIT/APACHE · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install audio-vs1053b 
SYNC missed versions from official npm registry.

#Audio Driver for the audio-vs1053b Tessel audio module. The hardware documentation for this module can be found here.

If you run into any issues you can ask for support on the Audio Module Forums.


npm install audio-vs1053b

###Limitations The current version of the Tessel runtime is too slow to play audio files smoothly. That means we wrote a custom C shim that handles most of the playback and recording of data. There are several consequences of the C shim:

  • Any other modules that use SPI for communication will be blocked while the Audio Module is playing a buffer.
  • You can only have one Audio Module attached to Tessel at a time.
  • Updates to the Audio Module driver must be released in both firmware and this npm repo.

It sucks but we're expecting major runtime speed improvements to render the C shim unnecessary within the next couple of months.

###Development Status Playback and recording to/from the local file system works well. Streams work less well. Interacting with the SDCard, Ambient, and IR doesn't work yet (issues with the SPI bus). This module is currently undergoing heavy development to fix those issues. Please file any bugs you find with this module.


This Audio Module demo sets volume, then plays
an audio file out over Headphones/Line out

var tessel = require('tessel');
var fs = require('fs');
var audio = require('audio-vs1053b').use(tessel.port['A']);

var audioFile = 'sample.mp3';

// Wait for the module to connect
audio.on('ready', function() {
  console.log("Audio module connected! Setting volume...");
  // Set the volume in decibels. Around .8 is good; 80% max volume or -25db
  audio.setVolume(.8, function(err) {
    if (err) {
      return console.log(err);
    // Get the song
    console.log('Retrieving file...');
    var song = fs.readFileSync(audioFile);
    // Play the song
    console.log('Playing ' + audioFile + '...');, function(err) {
      if (err) {
      } else {
        console.log('Done playing', audioFile);

// If there is an error, report it
audio.on('error', function(err) {


# audio.setVolume( leftChannelDb, [rightChannelDb,] callback(err) )
Set the output volume. Level is a Number from 0.0 to 1.0 (-127dB to 0dB)

# audio.setInput( input, callback(err) )
Set the input to either 'lineIn' or 'mic'. Defaults to 'lineIn'.

# audio.setOutput( output, callback(err) )
Set the output to either 'lineOut' or 'headphones'. Defaults to 'lineOut'.

# audio.startRecording( [profile] callback(err) )
Start recording sound from the input. (Receive data in the 'data' event) Callback called after recording initialized (not stopped ) .quality is an optional argument that can be 'voice', 'wideband-voice', 'wideband-stereo', 'hifi-voice', or 'stereo-music'. Default is 'hifi-voice'.

# audio.stopRecording( callback(err) )
Stop recording sound (note that may receive one more 'data' event before this completes when the buffer is flushed. )

# [audioBuff], callback(err) )
Play a buffer. If no buffer is passed in, the module will attempt to resume a buffer that was paused.

# audio.pause( callback(err) )
Pause the buffer.

# audio.stop( callback(err) )
Stop playing and flush the buffer.

# audio.createPlayStream()
Returns a stream that a buffer can be piped into to play audio.

# audio.createRecordStream()
Returns a readable stream of mic data.

# audio.availableRecordingProfiles()
Returns an array of available profiles.


# audio.on( 'ready', callback() )
The audio module is ready to use.

# audio.on( 'error', callback(err) )
The audio module had an error on connection.

# audio.on( 'volume', callback(volume) )
Volume was set.

# audio.on( 'input', callback(input) )
The input mode was set.

# audio.on( 'output', callback(output) )
The output mode was set.

# audio.on( 'startRecording', callback() )
Started recording from the input.

# audio.on( 'data', callback(audioBuff) )
Received recorded data.

# audio.on( 'stopRecording', callback() )
Stopped recording on the input.

# audio.on( play', callback() )
A buffer is beginning to be played.

# audio.on( 'pause', callback() )
Playback was paused.

# audio.on( 'stop', callback() )
Playback was stopped.

# audio.on( 'end', callback(err) )
The buffer finished playing.

###Further Examples

  • Audio Out No Streams. This Audio Module demo sends audio from a file to Headphones/Line out without using streams..
  • Record Sound. This Audio Module demo sends audio from the microphone to a file without using streams.
  • Stream Audio Out. This Audio Module demo sends audio from a file to Headphones/Line out using streams.
  • Stream Sound to File. This Audio Module demo takes line-in and writes it to a file using streams.

###License MIT or Apache 2.0, at your option

Current Tags

  • 0.2.0                                ...           latest (5 years ago)

12 Versions

  • 0.2.0                                ...           5 years ago
  • 0.1.91                                ...           6 years ago
  • 0.1.9                                ...           6 years ago
  • 0.1.6                                ...           6 years ago
  • 0.1.5                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.5.1                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2016 © |