Skip to content

Commit

Permalink
Merge pull request #205 from bemusic/bmson2
Browse files Browse the repository at this point in the history
Parallel Loading and Extracted bmson parser
  • Loading branch information
dtinth committed Sep 8, 2015
2 parents 7bf0d9b + 24e4c19 commit a127b6a
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 356 deletions.
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"homepage": "https://github.com/spacetme/bemuse",
"devDependencies": {
"artstep": "^5555.0.0",
"autoprefixer-loader": "^2.0.0",
"autoprefixer-loader": "^3.0.0",
"babel-core": "^5.8.20",
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
Expand All @@ -41,7 +41,7 @@
"codeclimate-test-reporter": "^0.1.0",
"connect": "^3.3.3",
"coveralls": "^2.11.2",
"css-loader": "^0.15.6",
"css-loader": "^0.17.0",
"dotenv": "^1.2.0",
"eslint": "^1.0.0",
"eslint-plugin-react": "^3.2.0",
Expand All @@ -62,21 +62,21 @@
"jasmine": "^2.1.1",
"js-yaml": "^3.2.5",
"json-loader": "^0.5.2",
"merge-stream": "^0.1.6",
"merge-stream": "^1.0.0",
"mocha": "^2.1.0",
"node-env": "^0.1.6",
"node-notifier": "^4.0.3",
"node-sass": "^3.2.0",
"node-ssi": "^0.3.0",
"pegjs-loader": "^0.1.1",
"sass-loader": "^1.0.4",
"sass-loader": "^2.0.1",
"script-loader": "^0.6.1",
"selenium-webdriver": "^2.45.1",
"serviceworker-loader": "^0.1.0",
"sinon": "git://github.com/cjohansen/Sinon.JS#sinon-2.0",
"sinon-chai": "^2.7.0",
"style-loader": "^0.9.0",
"through2": "^0.6.3",
"style-loader": "^0.12.3",
"through2": "^2.0.0",
"transform-loader": "^0.2.2",
"url-loader": "^0.5.5",
"val-loader": "^0.5.0",
Expand All @@ -88,20 +88,19 @@
"dependencies": {
"audio-context": "^0.1.0",
"baconjs": "^0.7.53",
"bemuse-indexer": "^1.6.0",
"bemuse-indexer": "^2.0.1",
"bluebird": "^2.9.10",
"bms": "^2.0.0-beta.2",
"bms": "^2.0.0",
"bytes": "^2.1.0",
"chance": "^0.7.3",
"classnames": "^2.1.3",
"co": "^4.3.1",
"data-structure": "^1.2.0",
"debug": "^2.1.1",
"fastclick": "^1.0.6",
"gulp-cucumber": "0.0.8",
"invariant": "^2.1.0",
"isparta": "^2.2.0",
"isparta-instrumenter-loader": "^0.1.1",
"isparta": "^3.0.4",
"isparta-instrumenter-loader": "^0.2.1",
"jquery": "^2.1.3",
"keycode": "^2.0.0",
"keytime": "^0.1.0",
Expand Down
148 changes: 0 additions & 148 deletions spec/bmson/bmson_spec.js

This file was deleted.

24 changes: 24 additions & 0 deletions spec/progress/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,28 @@ describe('ProgressUtils', function() {
})
})

describe('.simultaneous', function () {
it('should report in fifo manner', function () {
let out = new Progress()
let simultaneous = ProgressUtils.simultaneous(out)
let a = new Progress()
let b = new Progress()
simultaneous.add(a)
a.report(10, 20)
expect(out.current).to.equal(10)
simultaneous.add(b)
b.report(11, 30)
expect(out.current).to.equal(10)
a.report(15, 20)
expect(out.current).to.equal(15)
a.report(20, 20)
expect(out.current).to.equal(11)
b.report(21, 30)
expect(out.current).to.equal(21)
b.report(30, 30)
expect(out.current).to.equal(30)
expect(out.total).to.equal(30)
})
})

})
2 changes: 1 addition & 1 deletion src/app/query-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import query from 'bemuse/utils/query'

export function getMusicServer() {
return query.BEMUSE_MUSIC_SERVER
return query.BEMUSE_MUSIC_SERVER || query.server
}

export function getTimeSynchroServer() {
Expand Down
12 changes: 1 addition & 11 deletions src/app/song-loader/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import 'bemuse/polyfill'
import indexer from 'bemuse-indexer'
import Promise from 'bluebird'

import * as bmson from 'bemuse/bmson'

/*global FileReaderSync*/
if (typeof FileReader === 'undefined' &&
typeof FileReaderSync !== 'undefined') {
Expand All @@ -25,22 +23,14 @@ if (typeof FileReader === 'undefined' &&
}
}

function getFileInfo(buffer, metadata) {
if (metadata.name.match(/\.bmson$/i)) {
return bmson.getInfo(buffer, metadata)
} else {
return indexer.getFileInfo(buffer, metadata)
}
}

addEventListener('message', function({ data }) {
let files = data.files.map(convertBuffer)
postMessage({ type: 'started' })
function onProgress(current, total, file) {
postMessage({ type: 'progress', current, total, file })
}
Promise.try(function () {
return indexer.getSongInfo(files, { onProgress, getFileInfo })
return indexer.getSongInfo(files, { onProgress })
})
.then(function(song) {
song.warnings.forEach(function(warning) {
Expand Down
Loading

0 comments on commit a127b6a

Please sign in to comment.