@magenta/core
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -31,10 +31,6 @@ "use strict"; | ||
return new Promise(function (resolve, reject) { | ||
_this.loadManifest().then(function () { | ||
resolve(_this.checkpointManifest); | ||
}); | ||
_this.loadManifest().then(function () { resolve(_this.checkpointManifest); }); | ||
}); | ||
} | ||
return new Promise(function (resolve, reject) { | ||
resolve(_this.checkpointManifest); | ||
}); | ||
return new Promise(function (resolve, reject) { resolve(_this.checkpointManifest); }); | ||
}; | ||
@@ -44,5 +40,3 @@ CheckpointLoader.prototype.getAllVariables = function () { | ||
if (this.variables != null) { | ||
return new Promise(function (resolve, reject) { | ||
resolve(_this.variables); | ||
}); | ||
return new Promise(function (resolve, reject) { resolve(_this.variables); }); | ||
} | ||
@@ -96,4 +90,5 @@ return new Promise(function (resolve, reject) { | ||
if (quantInfo.max !== quantInfo.min) { | ||
quantConstant_1 = ((quantInfo.max - quantInfo.min) / | ||
(Math.pow(2, quantInfo.bytes * 8) - 1)); | ||
quantConstant_1 = | ||
((quantInfo.max - quantInfo.min) / | ||
(Math.pow(2, quantInfo.bytes * 8) - 1)); | ||
} | ||
@@ -100,0 +95,0 @@ values = quantValues.map(function (v) { return v * quantConstant_1 + quantInfo.min; }); |
@@ -0,1 +1,2 @@ | ||
import * as tf from '@tensorflow/tfjs'; | ||
export declare enum ChordQuality { | ||
@@ -11,2 +12,5 @@ Major = 0, | ||
} | ||
export declare class ChordEncodingException extends Error { | ||
constructor(message?: string); | ||
} | ||
export declare class ChordSymbols { | ||
@@ -17,1 +21,19 @@ static pitches(chord: string): number[]; | ||
} | ||
export declare abstract class ChordEncoder { | ||
abstract depth: number; | ||
abstract encode(chord: string): tf.Tensor1D; | ||
} | ||
export declare class MajorMinorChordEncoder extends ChordEncoder { | ||
depth: number; | ||
private index(chord); | ||
encode(chord: string): tf.Tensor<tf.Rank.R1>; | ||
} | ||
export declare class TriadChordEncoder extends ChordEncoder { | ||
depth: number; | ||
private index(chord); | ||
encode(chord: string): tf.Tensor<tf.Rank.R1>; | ||
} | ||
export declare class PitchChordEncoder extends ChordEncoder { | ||
depth: number; | ||
encode(chord: string): tf.Tensor<tf.Rank.R1>; | ||
} |
@@ -13,3 +13,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tf = require("@tensorflow/tfjs"); | ||
var tonal_1 = require("tonal"); | ||
var constants = require("./constants"); | ||
var CHORD_QUALITY_INTERVALS = [ | ||
@@ -40,2 +42,13 @@ ['1P', '3M', '5P'], | ||
exports.ChordSymbolException = ChordSymbolException; | ||
var ChordEncodingException = (function (_super) { | ||
__extends(ChordEncodingException, _super); | ||
function ChordEncodingException(message) { | ||
var _newTarget = this.constructor; | ||
var _this = _super.call(this, message) || this; | ||
Object.setPrototypeOf(_this, _newTarget.prototype); | ||
return _this; | ||
} | ||
return ChordEncodingException; | ||
}(Error)); | ||
exports.ChordEncodingException = ChordEncodingException; | ||
var ChordSymbols = (function () { | ||
@@ -46,3 +59,3 @@ function ChordSymbols() { | ||
if (!tonal_1.Chord.exists(chord)) { | ||
throw new ChordSymbolException('Unrecognized chord symbol: ' + ("" + chord)); | ||
throw new ChordSymbolException("Unrecognized chord symbol: " + chord); | ||
} | ||
@@ -55,3 +68,3 @@ var notes = tonal_1.Chord.notes(chord); | ||
if (!root) { | ||
throw new ChordSymbolException('Chord symbol has unknown root: ' + ("" + chord)); | ||
throw new ChordSymbolException("Chord symbol has unknown root: " + chord); | ||
} | ||
@@ -62,3 +75,3 @@ return tonal_1.Note.chroma(root); | ||
if (!tonal_1.Chord.exists(chord)) { | ||
throw new ChordSymbolException('Unrecognized chord symbol: ' + ("" + chord)); | ||
throw new ChordSymbolException("Unrecognized chord symbol: " + chord); | ||
} | ||
@@ -79,2 +92,80 @@ var intervals = tonal_1.Chord.intervals(chord); | ||
exports.ChordSymbols = ChordSymbols; | ||
var ChordEncoder = (function () { | ||
function ChordEncoder() { | ||
} | ||
return ChordEncoder; | ||
}()); | ||
exports.ChordEncoder = ChordEncoder; | ||
var MajorMinorChordEncoder = (function (_super) { | ||
__extends(MajorMinorChordEncoder, _super); | ||
function MajorMinorChordEncoder() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.depth = 1 + 2 * constants.NUM_PITCH_CLASSES; | ||
return _this; | ||
} | ||
MajorMinorChordEncoder.prototype.index = function (chord) { | ||
if (chord === constants.NO_CHORD) { | ||
return 0; | ||
} | ||
var root = ChordSymbols.root(chord); | ||
var quality = ChordSymbols.quality(chord); | ||
var index = 1 + quality * constants.NUM_PITCH_CLASSES + root; | ||
if (index >= this.depth) { | ||
throw new ChordEncodingException("Chord is neither major nor minor: " + chord); | ||
} | ||
return index; | ||
}; | ||
MajorMinorChordEncoder.prototype.encode = function (chord) { | ||
return tf.oneHot(tf.tensor1d([this.index(chord)]), this.depth).as1D(); | ||
}; | ||
return MajorMinorChordEncoder; | ||
}(ChordEncoder)); | ||
exports.MajorMinorChordEncoder = MajorMinorChordEncoder; | ||
var TriadChordEncoder = (function (_super) { | ||
__extends(TriadChordEncoder, _super); | ||
function TriadChordEncoder() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.depth = 1 + 4 * constants.NUM_PITCH_CLASSES; | ||
return _this; | ||
} | ||
TriadChordEncoder.prototype.index = function (chord) { | ||
if (chord === constants.NO_CHORD) { | ||
return 0; | ||
} | ||
var root = ChordSymbols.root(chord); | ||
var quality = ChordSymbols.quality(chord); | ||
var index = 1 + quality * constants.NUM_PITCH_CLASSES + root; | ||
if (index >= this.depth) { | ||
throw new ChordEncodingException("Chord is not a standard triad: " + chord); | ||
} | ||
return index; | ||
}; | ||
TriadChordEncoder.prototype.encode = function (chord) { | ||
return tf.oneHot(tf.tensor1d([this.index(chord)]), this.depth).as1D(); | ||
}; | ||
return TriadChordEncoder; | ||
}(ChordEncoder)); | ||
exports.TriadChordEncoder = TriadChordEncoder; | ||
var PitchChordEncoder = (function (_super) { | ||
__extends(PitchChordEncoder, _super); | ||
function PitchChordEncoder() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.depth = 1 + 3 * constants.NUM_PITCH_CLASSES; | ||
return _this; | ||
} | ||
PitchChordEncoder.prototype.encode = function (chord) { | ||
if (chord === constants.NO_CHORD) { | ||
return tf.oneHot(tf.tensor1d([0]), this.depth).as1D(); | ||
} | ||
var root = ChordSymbols.root(chord); | ||
var rootEncoding = tf.oneHot(tf.tensor1d([root]), constants.NUM_PITCH_CLASSES).as1D(); | ||
var pitchBuffer = tf.buffer([constants.NUM_PITCH_CLASSES]); | ||
ChordSymbols.pitches(chord).forEach(function (pitch) { return pitchBuffer.set(1.0, pitch); }); | ||
var pitchEncoding = pitchBuffer.toTensor().as1D(); | ||
var bassEncoding = rootEncoding; | ||
return tf.concat1d([tf.tensor1d([0.0]), rootEncoding, pitchEncoding, bassEncoding]); | ||
}; | ||
return PitchChordEncoder; | ||
}(ChordEncoder)); | ||
exports.PitchChordEncoder = PitchChordEncoder; | ||
//# sourceMappingURL=chords.js.map |
@@ -6,1 +6,3 @@ export declare const DEFAULT_QUARTERS_PER_MINUTE = 120; | ||
export declare const MIDI_VELOCITIES = 128; | ||
export declare const NO_CHORD = "N.C."; | ||
export declare const NUM_PITCH_CLASSES = 12; |
@@ -8,2 +8,4 @@ "use strict"; | ||
exports.MIDI_VELOCITIES = 128; | ||
exports.NO_CHORD = 'N.C.'; | ||
exports.NUM_PITCH_CLASSES = 12; | ||
//# sourceMappingURL=constants.js.map |
@@ -0,3 +1,3 @@ | ||
import { tensorflow } from '@magenta/protobuf'; | ||
import * as tf from '@tensorflow/tfjs'; | ||
import { tensorflow } from '@magenta/protobuf'; | ||
import NoteSequence = tensorflow.magenta.NoteSequence; | ||
@@ -7,8 +7,12 @@ import INoteSequence = tensorflow.magenta.INoteSequence; | ||
type: string; | ||
args: DrumsConverterArgs | MelodyConverterArgs | TrioConverterArgs; | ||
args: BaseConverterArgs; | ||
} | ||
export interface BaseConverterArgs { | ||
numSteps?: number; | ||
numSegments?: number; | ||
} | ||
export declare function converterFromSpec(spec: ConverterSpec): MelodyConverter | DrumsConverter | TrioConverter; | ||
export declare abstract class DataConverter { | ||
readonly abstract numSteps: number; | ||
readonly abstract numSegments: number; | ||
readonly numSteps: number; | ||
readonly numSegments: number; | ||
readonly abstract depth: number; | ||
@@ -18,17 +22,12 @@ readonly abstract NUM_SPLITS: number; | ||
abstract toNoteSequence(tensor: tf.Tensor2D): Promise<INoteSequence>; | ||
constructor(args: BaseConverterArgs); | ||
} | ||
export interface DrumsConverterArgs { | ||
numSteps: number; | ||
numSegments?: number; | ||
export interface DrumsConverterArgs extends BaseConverterArgs { | ||
pitchClasses?: number[][]; | ||
} | ||
export declare class DrumsConverter extends DataConverter { | ||
readonly numSteps: number; | ||
readonly numSegments: number; | ||
readonly depth: number; | ||
readonly pitchClasses: number[][]; | ||
readonly pitchToClass: { | ||
[pitch: number]: number; | ||
}; | ||
readonly pitchToClass: Map<number, number>; | ||
readonly NUM_SPLITS: number; | ||
depth: number; | ||
constructor(args: DrumsConverterArgs); | ||
@@ -41,11 +40,12 @@ toTensor(noteSequence: INoteSequence): tf.Tensor<tf.Rank.R2>; | ||
} | ||
export interface MelodyConverterArgs { | ||
numSteps: number; | ||
export declare class DrumsOneHotConverter extends DrumsConverter { | ||
readonly depth: number; | ||
constructor(args: DrumsConverterArgs); | ||
toTensor(noteSequence: INoteSequence): tf.Tensor<tf.Rank.R2>; | ||
} | ||
export interface MelodyConverterArgs extends BaseConverterArgs { | ||
minPitch: number; | ||
maxPitch: number; | ||
numSegments?: number; | ||
} | ||
export declare class MelodyConverter extends DataConverter { | ||
readonly numSteps: number; | ||
readonly numSegments: number; | ||
readonly minPitch: number; | ||
@@ -61,8 +61,6 @@ readonly maxPitch: number; | ||
} | ||
export interface TrioConverterArgs { | ||
export interface TrioConverterArgs extends BaseConverterArgs { | ||
melArgs: MelodyConverterArgs; | ||
bassArgs: MelodyConverterArgs; | ||
drumsArgs: DrumsConverterArgs; | ||
numSteps: number; | ||
numSegments?: number; | ||
} | ||
@@ -73,4 +71,2 @@ export declare class TrioConverter extends DataConverter { | ||
drumsConverter: DrumsConverter; | ||
readonly numSteps: number; | ||
readonly numSegments: number; | ||
readonly depth: number; | ||
@@ -77,0 +73,0 @@ readonly NUM_SPLITS: number; |
109
es5/data.js
@@ -48,7 +48,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var protobuf_1 = require("@magenta/protobuf"); | ||
var tf = require("@tensorflow/tfjs"); | ||
var protobuf_1 = require("@magenta/protobuf"); | ||
var sequences_1 = require("./sequences"); | ||
var tflib = require("./tf_lib"); | ||
var NoteSequence = protobuf_1.tensorflow.magenta.NoteSequence; | ||
var util_1 = require("util"); | ||
var DEFAULT_DRUM_PITCH_CLASSES = [ | ||
@@ -78,2 +78,5 @@ [36, 35], | ||
} | ||
else if (spec.type === 'DrumsOneHotConverter') { | ||
return new DrumsOneHotConverter(spec.args); | ||
} | ||
else { | ||
@@ -85,3 +88,5 @@ throw new Error('Unknown DataConverter type in spec: ' + spec.type); | ||
var DataConverter = (function () { | ||
function DataConverter() { | ||
function DataConverter(args) { | ||
this.numSteps = args.numSteps; | ||
this.numSegments = args.numSegments; | ||
} | ||
@@ -94,11 +99,10 @@ return DataConverter; | ||
function DrumsConverter(args) { | ||
var _this = _super.call(this) || this; | ||
var _this = _super.call(this, args) || this; | ||
_this.NUM_SPLITS = 0; | ||
_this.pitchClasses = (args.pitchClasses) ? | ||
args.pitchClasses : DEFAULT_DRUM_PITCH_CLASSES; | ||
_this.numSteps = args.numSteps; | ||
_this.numSegments = args.numSegments; | ||
_this.pitchToClass = {}; | ||
_this.pitchClasses = util_1.isNullOrUndefined(args.pitchClasses) ? | ||
DEFAULT_DRUM_PITCH_CLASSES : | ||
args.pitchClasses; | ||
_this.pitchToClass = new Map(); | ||
var _loop_1 = function (c) { | ||
this_1.pitchClasses[c].forEach(function (p) { _this.pitchToClass[p] = c; }); | ||
this_1.pitchClasses[c].forEach(function (p) { _this.pitchToClass.set(p, c); }); | ||
}; | ||
@@ -120,3 +124,3 @@ var this_1 = this; | ||
noteSequence.notes.forEach(function (note) { | ||
drumRoll.set(1, note.quantizedStartStep, _this.pitchToClass[note.pitch]); | ||
drumRoll.set(1, note.quantizedStartStep, _this.pitchToClass.get(note.pitch)); | ||
drumRoll.set(0, note.quantizedStartStep, -1); | ||
@@ -165,3 +169,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var noteSequence, s, rollSlice, pitches, p; | ||
var noteSequence, rollSplit, s, pitches, p; | ||
return __generator(this, function (_a) { | ||
@@ -171,2 +175,3 @@ switch (_a.label) { | ||
noteSequence = NoteSequence.create(); | ||
rollSplit = tf.split(roll, roll.shape[0]); | ||
s = 0; | ||
@@ -176,7 +181,6 @@ _a.label = 1; | ||
if (!(s < roll.shape[0])) return [3, 4]; | ||
rollSlice = roll.slice([s, 0], [1, roll.shape[1]]); | ||
return [4, rollSlice.data()]; | ||
return [4, rollSplit[s].data()]; | ||
case 2: | ||
pitches = _a.sent(); | ||
rollSlice.dispose(); | ||
rollSplit[s].dispose(); | ||
for (p = 0; p < pitches.length; ++p) { | ||
@@ -204,11 +208,29 @@ if (pitches[p]) { | ||
exports.DrumRollConverter = DrumRollConverter; | ||
var DrumsOneHotConverter = (function (_super) { | ||
__extends(DrumsOneHotConverter, _super); | ||
function DrumsOneHotConverter(args) { | ||
var _this = _super.call(this, args) || this; | ||
_this.depth = Math.pow(2, _this.pitchClasses.length); | ||
return _this; | ||
} | ||
DrumsOneHotConverter.prototype.toTensor = function (noteSequence) { | ||
var _this = this; | ||
var numSteps = this.numSteps || noteSequence.totalQuantizedSteps; | ||
var labels = Array(numSteps).fill(0); | ||
for (var _i = 0, _a = noteSequence.notes; _i < _a.length; _i++) { | ||
var _b = _a[_i], pitch = _b.pitch, quantizedStartStep = _b.quantizedStartStep; | ||
labels[quantizedStartStep] += Math.pow(2, this.pitchToClass.get(pitch)); | ||
} | ||
return tf.tidy(function () { return tf.oneHot(tf.tensor1d(labels), _this.depth); }); | ||
}; | ||
return DrumsOneHotConverter; | ||
}(DrumsConverter)); | ||
exports.DrumsOneHotConverter = DrumsOneHotConverter; | ||
var MelodyConverter = (function (_super) { | ||
__extends(MelodyConverter, _super); | ||
function MelodyConverter(args) { | ||
var _this = _super.call(this) || this; | ||
var _this = _super.call(this, args) || this; | ||
_this.NUM_SPLITS = 0; | ||
_this.NOTE_OFF = 1; | ||
_this.FIRST_PITCH = 2; | ||
_this.numSteps = args.numSteps; | ||
_this.numSegments = args.numSegments; | ||
_this.minPitch = args.minPitch; | ||
@@ -230,3 +252,4 @@ _this.maxPitch = args.maxPitch; | ||
if (n.pitch < _this.minPitch || n.pitch > _this.maxPitch) { | ||
throw Error("`NoteSequence` has a pitch outside of the valid range: " + n.pitch); | ||
throw Error('`NoteSequence` has a pitch outside of the valid range: ' + | ||
("" + n.pitch)); | ||
} | ||
@@ -237,3 +260,3 @@ mel.set(n.pitch - _this.minPitch + _this.FIRST_PITCH, n.quantizedStartStep); | ||
}); | ||
return tf.oneHot(mel.toTensor(), this.depth); | ||
return tf.tidy(function () { return tf.oneHot(mel.toTensor(), _this.depth); }); | ||
}; | ||
@@ -291,3 +314,3 @@ MelodyConverter.prototype.toNoteSequence = function (oh) { | ||
function TrioConverter(args) { | ||
var _this = _super.call(this) || this; | ||
var _this = _super.call(this, args) || this; | ||
_this.NUM_SPLITS = 3; | ||
@@ -301,7 +324,6 @@ _this.MEL_PROG_RANGE = [0, 31]; | ||
_this.bassConverter = new MelodyConverter(args.bassArgs); | ||
_this.drumsConverter = new DrumsConverter(args.drumsArgs); | ||
_this.numSteps = args.numSteps; | ||
_this.numSegments = args.numSegments; | ||
_this.depth = (_this.melConverter.depth + _this.bassConverter.depth + | ||
_this.drumsConverter.depth); | ||
_this.drumsConverter = new DrumsOneHotConverter(args.drumsArgs); | ||
_this.depth = | ||
(_this.melConverter.depth + _this.bassConverter.depth + | ||
_this.drumsConverter.depth); | ||
return _this; | ||
@@ -314,10 +336,16 @@ } | ||
var drumsSeq = sequences_1.Sequences.clone(noteSequence); | ||
melSeq.notes = noteSequence.notes.filter(function (n) { return (!n.isDrum && n.program >= _this.MEL_PROG_RANGE[0] && | ||
n.program <= _this.MEL_PROG_RANGE[1]); }); | ||
bassSeq.notes = noteSequence.notes.filter(function (n) { return (!n.isDrum && n.program >= _this.BASS_PROG_RANGE[0] && | ||
n.program <= _this.BASS_PROG_RANGE[1]); }); | ||
melSeq.notes = noteSequence.notes.filter(function (n) { | ||
return (!n.isDrum && n.program >= _this.MEL_PROG_RANGE[0] && | ||
n.program <= _this.MEL_PROG_RANGE[1]); | ||
}); | ||
bassSeq.notes = noteSequence.notes.filter(function (n) { | ||
return (!n.isDrum && n.program >= _this.BASS_PROG_RANGE[0] && | ||
n.program <= _this.BASS_PROG_RANGE[1]); | ||
}); | ||
drumsSeq.notes = noteSequence.notes.filter(function (n) { return n.isDrum; }); | ||
return tf.concat([this.melConverter.toTensor(melSeq), | ||
this.bassConverter.toTensor(bassSeq), | ||
this.drumsConverter.toTensor(drumsSeq)], -1); | ||
return tf.tidy(function () { return tf.concat([ | ||
_this.melConverter.toTensor(melSeq), | ||
_this.bassConverter.toTensor(bassSeq), | ||
_this.drumsConverter.toTensor(drumsSeq) | ||
], -1); }); | ||
}; | ||
@@ -331,7 +359,13 @@ TrioConverter.prototype.toNoteSequence = function (th) { | ||
case 0: | ||
ohs = tflib.split(th, [this.melConverter.depth, this.bassConverter.depth, | ||
this.drumsConverter.depth], -1); | ||
ohs = tf.split(th, [ | ||
this.melConverter.depth, this.bassConverter.depth, | ||
this.drumsConverter.depth | ||
], -1); | ||
return [4, this.melConverter.toNoteSequence(ohs[0])]; | ||
case 1: | ||
ns = _c.sent(); | ||
ns.notes.forEach(function (n) { | ||
n.instrument = 0; | ||
n.program = 0; | ||
}); | ||
return [4, this.bassConverter.toNoteSequence(ohs[1])]; | ||
@@ -342,6 +376,6 @@ case 2: | ||
n.instrument = 1; | ||
n.pitch = _this.BASS_PROG_RANGE[0] + 1; | ||
n.program = _this.BASS_PROG_RANGE[0]; | ||
return n; | ||
})); | ||
return [4, this.drumsConverter.toNoteSequence(ohs[1])]; | ||
return [4, this.drumsConverter.toNoteSequence(ohs[2])]; | ||
case 3: | ||
@@ -353,2 +387,3 @@ drumsNs = _c.sent(); | ||
})); | ||
ohs.forEach(function (oh) { return oh.dispose(); }); | ||
return [2, ns]; | ||
@@ -355,0 +390,0 @@ } |
@@ -11,5 +11,3 @@ import { tensorflow } from '@magenta/protobuf'; | ||
export { data }; | ||
import * as tflib from './tf_lib'; | ||
export { tflib }; | ||
export * from './midi_io'; | ||
export * from './sequences'; |
@@ -15,6 +15,4 @@ "use strict"; | ||
exports.data = data; | ||
var tflib = require("./tf_lib"); | ||
exports.tflib = tflib; | ||
__export(require("./midi_io")); | ||
__export(require("./sequences")); | ||
//# sourceMappingURL=index.js.map |
@@ -53,6 +53,3 @@ "use strict"; | ||
} | ||
ns.tempos.push(NoteSequence.Tempo.create({ | ||
time: 0, | ||
qpm: parsedMidi.header.bpm | ||
})); | ||
ns.tempos.push(NoteSequence.Tempo.create({ time: 0, qpm: parsedMidi.header.bpm })); | ||
var instrumentNumber = -1; | ||
@@ -71,5 +68,3 @@ for (var _i = 0, _a = parsedMidi.tracks; _i < _a.length; _i++) { | ||
instrument: instrumentNumber, | ||
program: track.instrumentNumber, | ||
startTime: startTime, | ||
endTime: endTime, | ||
program: track.instrumentNumber, startTime: startTime, endTime: endTime, | ||
pitch: note.midi, | ||
@@ -98,5 +93,3 @@ velocity: Math.floor(note.velocity * constants.MIDI_VELOCITIES), | ||
PPQ: ns.ticksPerQuarter, | ||
timeSignature: [ | ||
ns.timeSignatures[0].numerator, ns.timeSignatures[0].denominator | ||
] | ||
timeSignature: [ns.timeSignatures[0].numerator, ns.timeSignatures[0].denominator] | ||
}, | ||
@@ -103,0 +96,0 @@ tracks: [] |
@@ -92,3 +92,4 @@ "use strict"; | ||
var note = _a[_i]; | ||
note.quantizedStartStep = this.quantizeToStep(note.startTime, stepsPerSecond); | ||
note.quantizedStartStep = | ||
this.quantizeToStep(note.startTime, stepsPerSecond); | ||
note.quantizedEndStep = this.quantizeToStep(note.endTime, stepsPerSecond); | ||
@@ -117,11 +118,9 @@ if (note.quantizedEndStep === note.quantizedStartStep) { | ||
var qns = this.clone(noteSequence); | ||
qns.quantizationInfo = NoteSequence.QuantizationInfo.create({ | ||
stepsPerQuarter: stepsPerQuarter | ||
}); | ||
qns.quantizationInfo = | ||
NoteSequence.QuantizationInfo.create({ stepsPerQuarter: stepsPerQuarter }); | ||
if (qns.timeSignatures.length > 0) { | ||
qns.timeSignatures.sort(function (a, b) { | ||
return a.time - b.time; | ||
}); | ||
if (qns.timeSignatures[0].time !== 0 && !(qns.timeSignatures[0].numerator === 4 && | ||
qns.timeSignatures[0].denominator === 4)) { | ||
qns.timeSignatures.sort(function (a, b) { return a.time - b.time; }); | ||
if (qns.timeSignatures[0].time !== 0 && | ||
!(qns.timeSignatures[0].numerator === 4 && | ||
qns.timeSignatures[0].denominator === 4)) { | ||
throw new MultipleTimeSignatureException('NoteSequence has an implicit change from initial 4/4 time ' + | ||
@@ -147,7 +146,3 @@ ("signature to " + qns.timeSignatures[0].numerator + "/") + | ||
else { | ||
var timeSignature = NoteSequence.TimeSignature.create({ | ||
numerator: 4, | ||
denominator: 4, | ||
time: 0 | ||
}); | ||
var timeSignature = NoteSequence.TimeSignature.create({ numerator: 4, denominator: 4, time: 0 }); | ||
qns.timeSignatures.push(timeSignature); | ||
@@ -165,5 +160,3 @@ } | ||
if (qns.tempos.length > 0) { | ||
qns.tempos.sort(function (a, b) { | ||
return a.time - b.time; | ||
}); | ||
qns.tempos.sort(function (a, b) { return a.time - b.time; }); | ||
if (qns.tempos[0].time !== 0 && | ||
@@ -186,10 +179,8 @@ qns.tempos[0].qpm !== constants.DEFAULT_QUARTERS_PER_MINUTE) { | ||
else { | ||
var tempo = NoteSequence.Tempo.create({ | ||
qpm: constants.DEFAULT_QUARTERS_PER_MINUTE, | ||
time: 0 | ||
}); | ||
var tempo = NoteSequence.Tempo.create({ qpm: constants.DEFAULT_QUARTERS_PER_MINUTE, time: 0 }); | ||
qns.tempos.push(tempo); | ||
} | ||
var stepsPerSecond = this.stepsPerQuarterToStepsPerSecond(stepsPerQuarter, qns.tempos[0].qpm); | ||
qns.totalQuantizedSteps = this.quantizeToStep(qns.totalTime, stepsPerSecond); | ||
qns.totalQuantizedSteps = | ||
this.quantizeToStep(qns.totalTime, stepsPerSecond); | ||
this.quantizeNotes(qns, stepsPerSecond); | ||
@@ -196,0 +187,0 @@ return qns; |
@@ -8,3 +8,3 @@ "use strict"; | ||
var splitSizes; | ||
if (typeof (numOrSizeSplits) === "number") { | ||
if (typeof (numOrSizeSplits) === 'number') { | ||
splitSizes = Array(numOrSizeSplits).fill(t.shape[axis] / numOrSizeSplits); | ||
@@ -11,0 +11,0 @@ } |
{ | ||
"name": "@magenta/core", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "", | ||
@@ -11,3 +11,3 @@ "main": "es5/index.js", | ||
"@magenta/protobuf": "^0.0.4", | ||
"@tensorflow/tfjs": "^0.6.1", | ||
"@tensorflow/tfjs": "^0.9.0", | ||
"midiconvert": "^0.4.4", | ||
@@ -20,3 +20,4 @@ "tonal": "^1.1.3", | ||
"browserify": "~14.4.0", | ||
"clang-format": "^1.2.2", | ||
"clang-format": "^1.0.41-c", | ||
"fs": "^0.0.1-security", | ||
"tape": "^4.9.0", | ||
@@ -23,0 +24,0 @@ "ts-node": "^5.0.1", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1690552
34
36070
9
+ Added@tensorflow/tfjs@0.9.1(transitive)
+ Added@tensorflow/tfjs-core@0.7.1(transitive)
+ Added@tensorflow/tfjs-layers@0.4.1(transitive)
- Removed@tensorflow/tfjs@0.6.1(transitive)
- Removed@tensorflow/tfjs-core@0.6.0(transitive)
- Removed@tensorflow/tfjs-layers@0.1.2(transitive)
Updated@tensorflow/tfjs@^0.9.0