Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

audio-vs1053b

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-vs1053b - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

examples/enya.mp3

60

index.js

@@ -45,6 +45,5 @@ // Copyright 2014 Technical Machine, Inc. See the COPYRIGHT

var _audioCallbacks = {};
var _fillBuff = new Buffer(15000);
var _fillBuff = new Buffer(25000);
_fillBuff.fill(0);
function use (hardware, next) {

@@ -154,3 +153,6 @@ return new Audio(hardware, next);

Audio.prototype._handleRecordedData = function(length) {
this.emit('data', _fillBuff.slice(0, length));
// Copy the recorded data into a new buff for consumption
var cp = new Buffer(length);
_fillBuff.copy(cp, 0, 0, length);
this.emit('data', cp);
}

@@ -180,3 +182,3 @@

// Check if this chunk is too small to be played solo
if (this.bufferedLen >= 10000) {
if (this.bufferedLen >= 5000) {
var audioData = Buffer.concat(this.bufs);

@@ -187,2 +189,3 @@ this.bufs = []; this.bufferedLen = 0;

if (ret < 0) {
err = new Error("Unable to queue the streamed buffer.");

@@ -214,8 +217,19 @@ }

var pusher = recordStream.push.bind(recordStream);
var bufQueue = [];
audio.on('data', pusher);
audio.on('data', function(data) {
bufQueue = bufQueue.concat(data);
});
process.once('audio_recording_complete', recordStream.push.bind(recordStream));
recordStream._read = function(size) {
var toSend = size > bufQueue.length ? bufQueue.length : size;
for (var i = 0; i < toSend; i++) {
recordStream.push(bufQueue[i]);
}
}
process.once('audio_recording_complete', function() {
recordStream.push(null)
});
recordStream._write = function() {};

@@ -483,2 +497,9 @@

if (buff.length === 0) {
if (callback) {
callback();
}
return;
}
self.spi.lock(function(err, lock) {

@@ -551,6 +572,20 @@ if (err) {

if (buff.length === 0) {
if (callback) {
callback();
}
return;
}
// Initialize SPI to the correct settings
self.spi.initialize();
// If there was a lock in place, wait until it's released
self.spi.lock(function(err, lock) {
// Release the lock so that we don't wait until complete for next queue
lock.release();
self.lock = null;
if (err) {

@@ -564,3 +599,2 @@ if (callback) {

else {
self.lock = lock;

@@ -697,2 +731,3 @@ var streamID = hw.audio_queue_buffer(self.MP3_XCS.pin, self.MP3_DCS.pin, self.MP3_DREQ.pin, buff, buff.length);

}
}

@@ -705,2 +740,5 @@

process.once('audio_recording_complete', function recStopped(length) {
process.unref();
// If a callback was provided, return it

@@ -715,3 +753,2 @@ if (callback) {

var ret = hw.audio_stop_recording();
if (ret < 0) {

@@ -725,7 +762,8 @@ var err = new Error("Not in valid state to stop recording.");

this.emit('error', err);
return;
}
else {
process.ref();
}
}
exports.use = use;

2

package.json
{
"name": "audio-vs1053b",
"version": "0.1.3",
"version": "0.1.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc