initial commit
This commit is contained in:
commit
237b7a617d
91
.gitignore
vendored
Normal file
91
.gitignore
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
# Audio Files
|
||||
audio
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
31
command-line/main.js
Normal file
31
command-line/main.js
Normal file
@ -0,0 +1,31 @@
|
||||
const child_process = require('child_process');
|
||||
|
||||
// Requirements:
|
||||
// gstreamer: gst-launch-1.0
|
||||
// ffmpeg: ffmpeg
|
||||
|
||||
// gstreamer = audio recording
|
||||
// see `pacmd list` for audio sources
|
||||
// -v for verbose output
|
||||
// $ gst-launch-1.0 -v pulsesrc device = "alsa_output.pci-0000_00_1f.3.analog-stereo.monitor" ! wavenc ! filesink location="output.wav"
|
||||
function start_recording() {
|
||||
let device = 'alsa_output.pci-0000_00_1f.3.analog-stereo.monitor';
|
||||
let output = 'output.wav';
|
||||
let recording_process = child_process.spawn(
|
||||
'gst-launch-1.0', [ '-v', 'pulsesrc', 'device', '=', device, '!', 'wavenc', '!', 'filesink', 'location', '=', output ]
|
||||
);
|
||||
return recording_process;
|
||||
}
|
||||
|
||||
async function stop_recording() {
|
||||
|
||||
}
|
||||
|
||||
// ffmpeg = file conversion (wav -> mp3)
|
||||
// $ ffmpeg -i output.wav -b:a 192k output.mp3
|
||||
// metadata can be added as follows
|
||||
// $ ffmpeg -i output.wav \
|
||||
// -metadata title="Song Name" \
|
||||
// -metadata author="Song Artist" \
|
||||
// -metadata album="Song Album" \
|
||||
// -b:a 192k output.mp3
|
81
logger/logger.js
Executable file
81
logger/logger.js
Executable file
@ -0,0 +1,81 @@
|
||||
const moment = require('moment');
|
||||
const colors = require('colors/safe');
|
||||
const util = require('util');
|
||||
|
||||
function padCenter(x, p, n) {
|
||||
x = '' + x;
|
||||
let z = false;
|
||||
while (x.length < n) {
|
||||
if (z) {
|
||||
z = false;
|
||||
x = p + x;
|
||||
} else {
|
||||
z = true;
|
||||
x = x + p;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
function createLogger(name) {
|
||||
let logger = {};
|
||||
function colorize(level, text) {
|
||||
let map = {
|
||||
'error': colors.red,
|
||||
'warn': colors.yellow,
|
||||
'info': colors.green,
|
||||
'debug': colors.blue,
|
||||
'silly': colors.magenta,
|
||||
};
|
||||
if (level in map) {
|
||||
return map[level](text);
|
||||
} else {
|
||||
return colors.bgWhite(text);
|
||||
}
|
||||
}
|
||||
logger.log = function(level, message, data) {
|
||||
let prefix = `[ ${colorize(level, padCenter(level, ' ', 5))} | ${padCenter(name, ' ', 6)} | ${moment().format('HH:mm:ss.SSS')} ]`;
|
||||
let out = '';
|
||||
if (message !== undefined && typeof message !== 'string') {
|
||||
data = message;
|
||||
message = null;
|
||||
}
|
||||
if (message) {
|
||||
out += `${prefix}: ${message}`;
|
||||
}
|
||||
function handleData(data) {
|
||||
if (data) {
|
||||
if (typeof message === 'string') {
|
||||
out += '\n';
|
||||
}
|
||||
if (data instanceof Error) {
|
||||
if (data.stack) {
|
||||
out += `${prefix}# ${data.stack.split('\n').join(`\n${prefix}# `)}`;
|
||||
} else {
|
||||
out += `${prefix}# ${data.name}: ${data.message}`;
|
||||
}
|
||||
} else {
|
||||
let s = util.inspect(data, { colors: true });
|
||||
s = s.split('\n').map(o => `${prefix}$ ${o}`).join('\n');
|
||||
out += s;
|
||||
//let s = `{${prettyjson.render(data).split('\n').map(o => ' ' + o).join('\n').substring(1)} }`;
|
||||
//out += `${prefix}$ ${s.split('\n').map(o => colors.italic(o)).join(`\n${prefix}$ `)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(data)) {
|
||||
data.forEach(handleData);
|
||||
} else {
|
||||
handleData(data);
|
||||
}
|
||||
console.log(out);
|
||||
}
|
||||
logger.error = (message, data) => { logger.log('error', message, data); };
|
||||
logger.warn = (message, data) => { logger.log('warn', message, data); };
|
||||
logger.info = (message, data) => { logger.log('info', message, data); };
|
||||
logger.debug = (message, data) => { logger.log('debug', message, data); };
|
||||
logger.silly = (message, data) => { logger.log('silly', message, data); };
|
||||
return logger;
|
||||
}
|
||||
|
||||
module.exports = createLogger;
|
18
logger/package-lock.json
generated
Normal file
18
logger/package-lock.json
generated
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "logger",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"colors": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz",
|
||||
"integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg=="
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
|
||||
}
|
||||
}
|
||||
}
|
15
logger/package.json
Executable file
15
logger/package.json
Executable file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "logger",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "logger.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"colors": "^1.3.3",
|
||||
"moment": "^2.24.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user