@magenta/music
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -43,5 +43,5 @@ "use strict"; | ||
} | ||
function addControlChangesToSequence(ns, instrument, chords) { | ||
for (var _i = 0, chords_2 = chords; _i < chords_2.length; _i++) { | ||
var ccParams = chords_2[_i]; | ||
function addControlChangesToSequence(ns, instrument, controlChanges) { | ||
for (var _i = 0, controlChanges_1 = controlChanges; _i < controlChanges_1.length; _i++) { | ||
var ccParams = controlChanges_1[_i]; | ||
var cc = index_1.NoteSequence.ControlChange.create({ | ||
@@ -298,2 +298,19 @@ time: ccParams[0], | ||
}); | ||
test('Merge Instruments', function (t) { | ||
var ns = createTestNS(); | ||
ns.notes.push({ pitch: 60, program: 0, isDrum: false }); | ||
ns.notes.push({ pitch: 64, program: 0, isDrum: false }); | ||
ns.notes.push({ pitch: 36, program: 0, isDrum: true }); | ||
ns.notes.push({ pitch: 48, program: 32, isDrum: false }); | ||
ns.notes.push({ pitch: 42, program: 1, isDrum: true }); | ||
var expected = sequences.clone(ns); | ||
expected.notes[0].instrument = 0; | ||
expected.notes[1].instrument = 0; | ||
expected.notes[2].instrument = 9; | ||
expected.notes[3].instrument = 1; | ||
expected.notes[4].instrument = 9; | ||
expected.notes[4].program = 0; | ||
t.deepEqual(index_1.NoteSequence.toObject(sequences.mergeInstruments(ns)), index_1.NoteSequence.toObject(expected)); | ||
t.end(); | ||
}); | ||
//# sourceMappingURL=sequences_test.js.map |
@@ -28,1 +28,2 @@ import { INoteSequence, NoteSequence } from '../protobuf/index'; | ||
export declare function unquantizeSequence(qns: INoteSequence, qpm?: number): NoteSequence; | ||
export declare function mergeInstruments(ns: INoteSequence): NoteSequence; |
@@ -254,2 +254,19 @@ "use strict"; | ||
exports.unquantizeSequence = unquantizeSequence; | ||
function mergeInstruments(ns) { | ||
var result = clone(ns); | ||
var events = result.notes.concat(result.pitchBends).concat(result.controlChanges); | ||
var programs = Array.from(new Set(events.filter(function (e) { return !e.isDrum; }).map(function (e) { return e.program; }))); | ||
events.forEach(function (e) { | ||
if (e.isDrum) { | ||
e.program = 0; | ||
e.instrument = 9; | ||
} | ||
else { | ||
var index = programs.indexOf(e.program); | ||
e.instrument = (index >= 9) ? index + 1 : index; | ||
} | ||
}); | ||
return result; | ||
} | ||
exports.mergeInstruments = mergeInstruments; | ||
//# sourceMappingURL=sequences.js.map |
@@ -0,1 +1,3 @@ | ||
import * as tf from '@tensorflow/tfjs-core'; | ||
export { tf }; | ||
export * from './core/index'; | ||
@@ -2,0 +4,0 @@ export * from './music_rnn/index'; |
@@ -6,2 +6,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tf = require("@tensorflow/tfjs-core"); | ||
exports.tf = tf; | ||
__export(require("./core/index")); | ||
@@ -8,0 +10,0 @@ __export(require("./music_rnn/index")); |
{ | ||
"name": "@magenta/music", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Make music in the browser with machine learning.", | ||
@@ -35,3 +35,3 @@ "main": "es5/index.js", | ||
"prepublish": "yarn lint && yarn test && yarn build && yarn doc && yarn bundle", | ||
"build": "tsc", | ||
"build": "tsc && cp src/protobuf/proto.* es5/protobuf", | ||
"bundle": "browserify --standalone mm src/index.ts -p [tsify] > dist/magentamusic.js", | ||
@@ -38,0 +38,0 @@ "lint": "tslint -c ../tslint.json -p . -t verbose", |
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
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
2776905
61668
73