Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio Output #223

Open
wants to merge 3 commits into
base: 0.2.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/audio/ring.mp3
Binary file not shown.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"scripts": {
"coverage": "nyc npm test",
"report:coverage": "nyc report --reporter=text-lcov > reports/coverage.lcov && codecov",
"review:syntax": "semistandard types",
"start": "node scripts/cli.js",
"test": "mocha tests"
"test": "npm run review:syntax && mocha tests"
},
"keywords": [
"fabric",
Expand All @@ -26,11 +27,13 @@
"license": "MIT",
"dependencies": {
"@fabric/core": "martindale/fabric#peering-wallet",
"@suldashi/lame": "^1.2.5",
"blessed": "^0.1.81"
},
"devDependencies": {
"codecov": "^3.8.0",
"mocha": "^8.1.3",
"nyc": "^15.1.0"
"nyc": "^15.1.0",
"semistandard": "^14.2.3"
}
}
6 changes: 3 additions & 3 deletions tests/soundtrack.http.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const assert = require('assert');

describe('@fabric/soundtrack', function() {
describe('@services/http', function() {
it('should run', function() {
describe('@fabric/soundtrack', function () {
describe('@services/http', function () {
it('should run', function () {
assert('ok');
});
});
Expand Down
44 changes: 44 additions & 0 deletions tests/soundtrack.speaker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

const assert = require('assert');

const fs = require('fs');
const lame = require('@suldashi/lame');
const Speaker = require('speaker');

const settings = {
channels: 2, // 2 channels (left and right)
bitDepth: 16, // 16-bit samples
sampleRate: 44100, // 44,100 Hz sample rate
};

describe('@fabric/soundtrack', function () {
describe('@services/audio', function () {
xit('can play a sound', function (done) {
const handle = fs.createReadStream('./assets/audio/ring.mp3');
const decoder = new lame.Decoder({
// input
channels: 2,
bitDepth: 16,
sampleRate: 44100,

// output
bitRate: 128,
outSampleRate: 22050,
mode: lame.STEREO // STEREO (default), JOINTSTEREO, DUALCHANNEL or MONO
});

// Create the Speaker instance
const speaker = new Speaker(settings);

handle.pipe(decoder);
decoder.pipe(speaker);

assert('ok');

setTimeout(function () {
done();
}, 1000);
});
});
});