| @@ -0,0 +1,37 @@ | |||||
| <!doctype html> | |||||
| <html lang="en"> | |||||
| <head> | |||||
| <meta charset="utf-8"> | |||||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |||||
| <title>Audio Test</title> | |||||
| <!-- <link rel="stylesheet" type="text/css" href="css/styles.css"> --> | |||||
| </head> | |||||
| <body> | |||||
| <p></p> | |||||
| <script type="text/javascript" src="jamming.js"></script> | |||||
| <script type="text/javascript"> | |||||
| runPage() | |||||
| /* parameters */ | |||||
| var params = { | |||||
| sampleRate: 8000, | |||||
| frameSize: 100, /* in ms */ | |||||
| }; | |||||
| window.AudioContext = window.AudioContext || window.webkitAudioContext; | |||||
| var audioContext = new AudioContext(); | |||||
| recconf = { | |||||
| samplerRate: 8000, | |||||
| numChannels: 1, | |||||
| } | |||||
| </script> | |||||
| </body> | |||||
| </html> | |||||
| @@ -6,8 +6,8 @@ | |||||
| "private": true, | "private": true, | ||||
| "scripts": { | "scripts": { | ||||
| "build": "yarn run build:lib && yarn run build:webpack", | "build": "yarn run build:lib && yarn run build:webpack", | ||||
| "build:lib": "babel src/ -d lib/", | |||||
| "build:webpack": "webpack lib/index.js -o dist/jamming.js", | |||||
| "build:lib": "rm -rf lib && babel src/ -d lib/", | |||||
| "build:webpack": "webpack --mode='development' lib/index.js -o dist/jamming.js", | |||||
| "test": "yarn run build:lib && nyc mocha lib/**/**.spec.js" | "test": "yarn run build:lib && nyc mocha lib/**/**.spec.js" | ||||
| }, | }, | ||||
| "author": "John-Mark Gurney <jmg@funkthat.com>", | "author": "John-Mark Gurney <jmg@funkthat.com>", | ||||
| @@ -1 +1,17 @@ | |||||
| module.exports = require("./jamming").Jamming; | |||||
| const jamming = require("./jamming"); | |||||
| async function runPage() { | |||||
| var constraints = { audio: true }; | |||||
| let stream = null; | |||||
| try { | |||||
| stream = await navigator.mediaDevices.getUserMedia(constraints); | |||||
| console.log('got stream'); | |||||
| } catch(err) { | |||||
| console.log('got error'); | |||||
| } | |||||
| } | |||||
| // #4 of https://stackoverflow.com/questions/37656592/define-global-variable-with-webpack | |||||
| global.runPage = runPage; | |||||
| @@ -0,0 +1,12 @@ | |||||
| 'use strict' | |||||
| const index = require('../index') | |||||
| const expect = require('chai').expect | |||||
| describe('index module', () => { | |||||
| describe('"members"', () => { | |||||
| it('should be have the following members', () => { | |||||
| expect(global.runPage).to.be.a('function'); | |||||
| }) | |||||
| }) | |||||
| }) | |||||
| @@ -1,6 +1,6 @@ | |||||
| 'use strict' | 'use strict' | ||||
| const Jamming = require('../index') | |||||
| const Jamming = require('../jamming').Jamming | |||||
| const expect = require('chai').expect | const expect = require('chai').expect | ||||
| describe('Jamming class', () => { | describe('Jamming class', () => { | ||||