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

baptism

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baptism - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

11

asset.js

@@ -19,5 +19,10 @@ const debug = require('debug')('baptism:track')

if (this.type.includes('image') || this.hint === 'image') {
this.binary = Buffer.from(fs.readFileSync(this.filename))
.toString('base64')
try {
if (this.type.includes('image') || this.hint === 'image') {
this.binary = Buffer.from(fs.readFileSync(this.filename))
.toString('base64')
}
} catch (err) {
console.error('Binary generation failed! This should not happen.')
throw new Error(err)
}

@@ -24,0 +29,0 @@ }

const Album = require('./album')
const { Asset, CoverArt } = require('./asset')
const { Master, Premaster } = require('./master')
const Release = require('./release')
const { CD, Digital, Download, Release, Stream, Vinyl } = require('./release')
const Track = require('./track')

@@ -15,3 +15,4 @@ const flags = require('./flags.json')

module.exports = {
Album, Asset, CoverArt, Master, Premaster, Release, Track, flags, soxi, stats, spectrogram
Album, Asset, CD, CoverArt, Digital, Download, Master, Premaster, Release,
Stream, Track, Vinyl, flags, soxi, stats, spectrogram
}

@@ -7,2 +7,5 @@ const Track = require('./track')

super(source, opts)
if (opts.version) {
this.version = opts.version
}
}

@@ -15,2 +18,4 @@ }

this.revision = null
this.parent = null

@@ -25,2 +30,6 @@

}
if (this.revision) {
this.revision = revision
}
}

@@ -30,2 +39,6 @@

if (!this.parent) cb(new Error(`No parent, add one to the Master first.`))
return {
peak: this.stats.peak.db - this.parent.stats.peak.db,
rms: this.stats.rms.db - this.parent.stats.rms.db,
}
}

@@ -32,0 +45,0 @@ }

{
"name": "baptism",
"version": "0.0.5",
"version": "0.0.6",
"description": "",

@@ -14,2 +14,3 @@ "main": "index.js",

"debug": "^4.1.1",
"disconnect": "^1.2.1",
"fluent-ffmpeg": "^2.1.2",

@@ -16,0 +17,0 @@ "little-process-box": "^0.2.3",

@@ -54,2 +54,36 @@ # SACRED1: Baptism

## Usage
### Audio Files
`Baptism` only works on WAV audio files and its extension formats, such as
broadcast wave (BWF).
A WAV file is objectified by instantiating a `new Baptism.Track`, or its
extension classes, `Premaster` and `Master`. However, it is recommended to use
the `Album` or `Release` classes to create `Track` objects. A `Premaster` is
meant to be added to an `Album`, while a `Master` is meant to be added to a
`Release`.
### Releases
An `Album` is instantiated by passing it a directory of WAV files. In order to
guarantee proper track ordering, ensure WAV file path basenames begin with a
[leading zero](https://en.wikipedia.org/wiki/Leading_zero), then the track number,
followed by the track title, i.e., `03 - This Is A Song Title.wav`. Other files
present in the directory lacking the `.wav` file extension will be ignored.
A `Release` is an objectified version of a physical or digital music release,
and it can be instantiated by calling `new Baptism.Release`. However, it is
recommended to call one of its class extensions, `Vinyl`, `Stream`, `Download`,
and `CD`. An `Album` can be added to a `Release` via its `Release.add()` method.
### Assets
An ancillary file asset such as a cover art image, a cue sheet, credits, etc.,
may be objectified by the `Asset` class. It can be instantiated via
`new Baptism.Asset`. Certain class extensions exist for specific asset features
, including `CoverArt`. Additional class extensions are in development and
forthcoming in a future release.
## API

@@ -129,10 +163,14 @@ > WIP

Compare the `Master` audio file's dynamics and formatting properties with its
parent `Track`. Performs necessary analyses on the `Master` and `Track` objects
if the information is not already available. Callback returns an object which
provides comparison results and validations validations.
parent `Track` or `Premaster`. Performs necessary analyses on the `Master` and
`Track` objects if the information is not already available. Callback returns an
object which provides comparison results and value deltas.
### `const premaster = bap.Premaster(filename, [opts])`
> WIP
An object representing a `Track` which has been prepared as a *premaster*. This
is a common form of audio asset that is delivered to a mastering engineer.
Same as declaring a `Track` except for the extra properties that limit its data
scope.
### `const Release = bap.Release`

@@ -139,0 +177,0 @@

@@ -5,2 +5,4 @@ const Album = require('./album')

const Discogs = require('disconnect').Client
class Release {

@@ -30,5 +32,35 @@ constructor(opts={}) {

if (this.minutesPerSide) {
this.sides = Number((this.duration / (this.minutesPerSide * 60 * 2)).toFixed(0.1)) + 1
this.sides = Number((this.duration / (this.minutesPerSide * 60 * 2))
.toFixed(0.1)) + 1
}
}
fromDiscogs(id) {
const db = new Discogs().database()
db.getRelease(id, (err, data) => {
if (err) return cb(err)
if (this instanceof Vinyl) {
const releaseFormat = data.formats.filter(df => df.name === 'Vinyl')
if (releaseFormat.length > 0) {
this.dbData = data
if (this.dbData.formats) { // auto-fill vinyl format data if avail
const formatDesc = this.dbData.formats[0].descriptions
for (const desc of formatDesc) {
if (desc.includes('"')) {
this.size = Number(desc.replace('"', ''))
} else if (desc.includes('RPM')) {
this.speed = Number(desc.replace('RPM', '').replace(' ', ''))
}
}
}
}
} else if (this instanceof CD) {
const releaseFormat = data.formats.filter(df => df.name === 'CD')
if (releaseFormat.length > 0) {
this.dbData = data
}
}
})
}
}

@@ -35,0 +67,0 @@

@@ -6,7 +6,12 @@ const debug = require('debug')('baptism:soxi')

function parseSoxi(soxiStr) {
const soxiStats = soxiStr.split('\n').filter(f => f !== '').map(m => m.split(': ')[1])
return {
channels: Number(soxiStats[1]),
sampleRate: Number(soxiStats[2]),
bitDepth: Number(soxiStats[3].split('-bit')[0])
try {
const soxiStats = soxiStr.split('\n').filter(f => f !== '').map(m => m.split(': ')[1])
return {
channels: Number(soxiStats[1]),
sampleRate: Number(soxiStats[2]),
bitDepth: Number(soxiStats[3].split('-bit')[0])
}
} catch (err) {
console.error('Could not parse soxi output. How did that happen???')
throw new Error(err)
}

@@ -13,0 +18,0 @@ }

@@ -6,15 +6,19 @@ const debug = require('debug')('baptism:stats')

function parseStats(st) {
const stats = `${st}`.split('\n').map(stat => { return Number(stat.split(':')[1]) })
const statsObj = {
duration: stats[1],
peak: {
db: 20 * Math.log10( stats[3] ),
value: stats[3]
},
rms: {
db: 20 * Math.log10( stats[8] ),
value: stats[8]
try {
const stats = `${st}`.split('\n').map(stat => { return Number(stat.split(':')[1]) })
const statsObj = {
duration: stats[1],
peak: {
db: 20 * Math.log10( stats[3] ),
value: stats[3]
},
rms: {
db: 20 * Math.log10( stats[8] ),
value: stats[8]
}
}
return statsObj
} catch (err) {
throw new Error(err)
}
return statsObj
}

@@ -21,0 +25,0 @@

@@ -29,14 +29,20 @@ const { Asset } = require('./asset')

if (this.type === 'audio/wav') {
this.wav = new WaveFile()
try {
if (this.type === 'audio/wav') {
this.wav = new WaveFile()
this.wav.fromBase64(Buffer.from(fs.readFileSync(this.filename))
.toString('base64'))
this.wav.fromBuffer(Buffer.from(fs.readFileSync(this.filename)))
if (this.tags) {
for (const tag of this.tags) {
this.wav.setTag(...tag)
if (this.tags) {
for (const tag of this.tags) {
this.wav.setTag(...tag)
}
}
}
} catch (err) {
console.error('Error occurred during Track instantiation! This should ' +
'not happen. Something is very wrong.')
throw new Error(err)
}
}

@@ -43,0 +49,0 @@

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