Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release of Bemuse v47.2.0 #654

Merged
merged 30 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bd389ba
Updates usage of co to async/await is src/audio.js
Oct 2, 2019
ffbea8c
Updates usage of `co` to async function in pre-deploy.js
mslourens Oct 2, 2019
caa541b
Updates usage of `co` to async function in scene-manager/index.js
mslourens Oct 2, 2019
a4e2efa
Updates usage of `co` to async function in scintillator/loader.js
mslourens Oct 2, 2019
036a9a2
Updates usage of `co` to async function in game/index.js
mslourens Oct 2, 2019
931bc56
Move getKeyMode to bemuse-notechart
mslourens Oct 2, 2019
8e8b24e
Updates usage of `co` to async function in bemuse-packer.js
mslourens Oct 2, 2019
df0e85a
Updates usage of `co` to async function in src/scintillator/index.spe…
Oct 3, 2019
1164089
Fix some code to pass codeclimate
Oct 3, 2019
8e659cd
Updates usage of to async function in src/devtools/playgrounds/skin.js
SorielV Oct 3, 2019
d382b7a
up `load` fn to async in src/auto-synchro/music.js
setheal Oct 2, 2019
5ca0279
🐙 Merge commit 'bd389ba2c6fc1ac768e5a302570c389bd81fe2b4'; commit 'ff…
dtinth Oct 4, 2019
9338d2a
Convert the `packIntoBemuse` fn to async fn
aboudicheng Oct 6, 2019
1ca2ea8
Converting usage of co to async functions src/coming-soon/demo/index
pnkapadia64 Oct 12, 2019
4d68212
fixing code smells
pnkapadia64 Oct 12, 2019
1b6beed
Merge remote-tracking branch 'pnkapadia64/627-co-to-async' into co-merge
resir014 Feb 3, 2020
bd2cb9e
Merge branch 'master' into co-merge
resir014 Feb 3, 2020
7fea403
Merge branch 'master' into co-merge
resir014 Feb 3, 2020
4ea1adf
Merge branch 'master' into co-merge
resir014 Feb 3, 2020
aa4a012
:wrench: update webpack-dev-server
resir014 Feb 3, 2020
78ec654
Merge remote-tracking branch 'aboudicheng/master' into co-merge
resir014 Feb 3, 2020
d6d28de
:white_check_mark: fixed test to remove code smell
resir014 Feb 3, 2020
4a69458
Merge remote-tracking branch 'mslourens/622-convert-co-to-async' into…
resir014 Mar 1, 2020
439df15
Merge remote-tracking branch 'SorielV/master' into co-merge
resir014 Mar 1, 2020
0b90513
:rotating_light: rebuild yarn.lock + remove unused import
resir014 Mar 1, 2020
7616fe8
Merge branch 'master' into co-merge
resir014 Mar 1, 2020
5f5707f
Add gitpod config
dtinth May 3, 2020
36a10db
Merge pull request #655 from co-merge
release-train[bot] May 3, 2020
0a95b88
Prepare changelog for v47.2.0-pre.202005030946
release-train[bot] May 3, 2020
d2099f0
Update package.json to version v47.2.0-pre.202005030946
release-train[bot] May 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks:
- init: yarn
command: yarn start
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
[@thakkaryash94]: https://github.com/thakkaryash94
[@hajimehoshi]: https://github.com/hajimehoshi
[@nekokan]: https://github.com/Nekokan
[@tayhobbs]: https://github.com/TayHobbs
[@mslourens]: https://github.com/mslourens
[@setheal]: https://github.com/setheal
[@511v41]: https://github.com/511V41
[@aboudicheng]: https://github.com/aboudicheng
[@pnkapadia64]: https://github.com/pnkapadia64

## v47.2.0-pre.202005030946

### Internals

- Migrate part of the code from `co` to `async function`s. (#639, by
[@TayHobbs]; #641, #642, #643, #645, #649, by [@mslourens]; #646, by
[@setheal]; #652, by [@511V41]; #656, by [@aboudicheng]; #657, by
[@pnkapadia64]). [#655], by [@dtinth]

[#655]: https://github.com/bemusic/bemuse/pull/655

## v47.1 (2019-10-04)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bemuse",
"version": "47.1.0",
"version": "47.2.0-pre.202005030946",
"description": "BEAT☆MUSIC☆SEQUENCE, a web-based music game of the future",
"main": "index.js",
"private": true,
Expand Down Expand Up @@ -144,7 +144,7 @@
"web-audio-test-api": "^0.5.2",
"webpack": "4.20.2",
"webpack-dev-middleware": "^3.4.0",
"webpack-dev-server": "3.1.11",
"webpack-dev-server": "3.10.2",
"worker-loader": "^2.0.0",
"yn": "^1.3.0"
},
Expand Down
20 changes: 19 additions & 1 deletion packages/bemuse-notechart/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,32 @@ export class Notechart {
return this._spacing.factor(beat)
}

/**
* Gets the keyMode from scratch
* @param scratch
* @returns {string}
*/
getKeyMode(scratch: string): string {
const usedColumns: { [column: string]: boolean } = {}
for (const note of this.notes) {
usedColumns[note.column] = true
}
if (scratch === 'off' && !usedColumns['1'] && !usedColumns['7']) return '5K'
if (scratch === 'left' && !usedColumns['6'] && !usedColumns['7'])
return '5K'
if (scratch === 'right' && !usedColumns['1'] && !usedColumns['2'])
return '5K'
return '7K'
}

_preTransform(
bmsNotes: BMS.BMSNote[],
playerOptions: Partial<PlayerOptions>
) {
let chain = _.chain(bmsNotes)
let keys = getKeys(bmsNotes)
if (playerOptions.scratch === 'off') {
chain = chain.map(note => {
chain = chain.map((note: BMS.BMSNote) => {
if (note.column && note.column === 'SC') {
return Object.assign({}, note, { column: null })
} else {
Expand Down
71 changes: 29 additions & 42 deletions packages/bemuse-tools/src/audio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Promise from 'bluebird'
import co from 'co'
import fs from 'fs'
import Throat from 'throat'
import { cpus } from 'os'
Expand Down Expand Up @@ -28,47 +27,35 @@ export class AudioConvertor {
_doConvert(path, type) {
return this._SoX(path, type)
}
// TODO [#621]: Convert the `_SoX` method to async function (instead of using `co`) in [bemuse-tools] src/audio.js
// See issue #575 for more details.
_SoX(path, type) {
return co(
function*() {
let typeArgs = []
try {
let fd = yield Promise.promisify(fs.open, fs)(path, 'r')
let buffer = Buffer.alloc(4)
let read = yield Promise.promisify(fs.read, fs)(
fd,
buffer,
0,
4,
null
)
yield Promise.promisify(fs.close, fs)(fd)
if (read === 0) {
console.error('[WARN] Empty keysound file.')
} else if (
buffer[0] === 0x49 &&
buffer[1] === 0x44 &&
buffer[2] === 0x33
) {
typeArgs = ['-t', 'mp3']
} else if (buffer[0] === 0xff && buffer[1] === 0xfb) {
typeArgs = ['-t', 'mp3']
} else if (
buffer[0] === 0x4f &&
buffer[1] === 0x67 &&
buffer[2] === 0x67 &&
buffer[3] === 0x53
) {
typeArgs = ['-t', 'ogg']
}
} catch (e) {
console.error('[WARN] Unable to detect file type!')
}
return yield this._doSoX(path, type, typeArgs)
}.bind(this)
)
async _SoX(path, type) {
let typeArgs = []
try {
let fd = await Promise.promisify(fs.open)(path, 'r')
let buffer = Buffer.alloc(4)
let read = await Promise.promisify(fs.read)(fd, buffer, 0, 4, null)
await Promise.promisify(fs.close)(fd)
if (read === 0) {
console.error('[WARN] Empty keysound file.')
} else if (
buffer[0] === 0x49 &&
buffer[1] === 0x44 &&
buffer[2] === 0x33
) {
typeArgs = ['-t', 'mp3']
} else if (buffer[0] === 0xff && buffer[1] === 0xfb) {
typeArgs = ['-t', 'mp3']
} else if (
buffer[0] === 0x4f &&
buffer[1] === 0x67 &&
buffer[2] === 0x67 &&
buffer[3] === 0x53
) {
typeArgs = ['-t', 'ogg']
}
} catch (e) {
console.error('[WARN] Unable to detect file type!')
}
return this._doSoX(path, type, typeArgs)
}
_doSoX(path, type, inputTypeArgs) {
return throat(
Expand Down
54 changes: 24 additions & 30 deletions packages/bemuse-tools/src/bemuse-packer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Promise from 'bluebird'
import co from 'co'
import path from 'path'
import fs from 'fs'
import Payload from './payload'
Expand Down Expand Up @@ -27,37 +26,32 @@ export class BemusePacker {
this._refs.push(ref)
return ref
}
// TODO [#622]: Convert the `write` method to async function (instead of using `co`) in [bemuse-tools] src/bemuse-packer.js
// See issue #575 for more details.
write(folder) {
return co(
function*() {
let files = []
let refs = []
let nums = {}
for (let ref of this._refs) {
let payload = new Payload()
for (let file of ref.files) {
let [start, end] = payload.add(file.buffer)
files.push({ name: file.name, ref: [ref.index, start, end] })
}
let hash = payload.hash
let num = (nums[ref.name] || 0) + 1
nums[ref.name] = num
let out = ref.name + '.' + num + '.' + hash.substr(0, 8) + '.bemuse'
refs.push({ path: out, hash: hash })
yield this._writeBin(path.join(folder, out), Buffer.alloc(0), payload)
console.log(`Written ${out}`)
}
let metadata = { files, refs }
yield writeFile(
path.join(folder, 'metadata.json'),
JSON.stringify(metadata)
)
console.log(`Written metadata.json`)
}.bind(this)
async write(folder) {
let files = []
let refs = []
let nums = {}
for (let ref of this._refs) {
let payload = new Payload()
for (let file of ref.files) {
let [start, end] = payload.add(file.buffer)
files.push({ name: file.name, ref: [ref.index, start, end] })
}
let hash = payload.hash
let num = (nums[ref.name] || 0) + 1
nums[ref.name] = num
let out = ref.name + '.' + num + '.' + hash.substr(0, 8) + '.bemuse'
refs.push({ path: out, hash: hash })
await this._writeBin(path.join(folder, out), Buffer.alloc(0), payload)
console.log(`Written ${out}`)
}
let metadata = { files, refs }
await writeFile(
path.join(folder, 'metadata.json'),
JSON.stringify(metadata)
)
console.log(`Written metadata.json`)
}

_writeBin(path, metadataBuffer, payload) {
let file = fs.createWriteStream(path)
let size = Buffer.alloc(4)
Expand Down
45 changes: 20 additions & 25 deletions packages/bemuse-tools/src/packer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Promise from 'bluebird'
import co from 'co'
import fs from 'fs'
import _ from 'lodash'

Expand All @@ -12,30 +11,26 @@ import BemusePacker from './bemuse-packer'
let mkdirp = Promise.promisify(require('mkdirp'))
let fileStat = Promise.promisify(fs.stat, fs)

// TODO [#624]: Convert the `packIntoBemuse` function to async function (instead of using `co`) in [bemuse-tools] src/packer.js
// See issue #575 for more details.
export function packIntoBemuse(path) {
return co(function*() {
let stat = yield fileStat(path)
if (!stat.isDirectory()) throw new Error('Not a directory: ' + path)

let directory = new Directory(path)
let packer = new BemusePacker(directory)

console.log('-> Loading audios')
let audio = yield directory.files('*.{mp3,wav,ogg}')

console.log('-> Converting audio to ogg [better audio performance]')
let oggc = new AudioConvertor('ogg', '-C', '3')
oggc.force = true
let oggs = yield dotMap(audio, file => oggc.convert(file))
packer.pack('ogg', oggs)

console.log('-> Writing...')
let out = join(path, 'assets')
yield mkdirp(out)
yield packer.write(out)
})
export async function packIntoBemuse(path) {
let stat = await fileStat(path)
if (!stat.isDirectory()) throw new Error('Not a directory: ' + path)

let directory = new Directory(path)
let packer = new BemusePacker(directory)

console.log('-> Loading audios')
let audio = await directory.files('*.{mp3,wav,ogg}')

console.log('-> Converting audio to ogg [better audio performance]')
let oggc = new AudioConvertor('ogg', '-C', '3')
oggc.force = true
let oggs = await dotMap(audio, file => oggc.convert(file))
packer.pack('ogg', oggs)

console.log('-> Writing...')
let out = join(path, 'assets')
await mkdirp(out)
await packer.write(out)
}

function dotMap(array, map) {
Expand Down
30 changes: 13 additions & 17 deletions src/auto-synchro/music/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash'
import co from 'co'
import context from 'bemuse/audio-context'
import download from 'bemuse/utils/download'
import SamplingMaster from 'bemuse/sampling-master'
Expand All @@ -17,24 +16,21 @@ let ASSET_URLS = {
/**
* Loads the files and create a music instance.
*/
export function load() {
// TODO [#626]: Convert the `load` function to async function (instead of using `co`) in src/auto-synchro/music.js
// See issue #575 for more details.
return co(function*() {
let master = new SamplingMaster(context)
let sample = name =>
download(ASSET_URLS[`${name}.ogg`])
.as('arraybuffer')
.then(buf => master.sample(buf))
let samples = _.fromPairs(
yield Promise.all(
['bgm', 'intro', 'kick', 'snare'].map(name =>
sample(name).then(sampleObj => [name, sampleObj])
)
export async function load() {
let master = new SamplingMaster(context)

let sample = name =>
download(ASSET_URLS[`${name}.ogg`])
.as('arraybuffer')
.then(buf => master.sample(buf))
let samples = _.fromPairs(
await Promise.all(
['bgm', 'intro', 'kick', 'snare'].map(name =>
sample(name).then(sampleObj => [name, sampleObj])
)
)
return music(master, samples)
})
)
return music(master, samples)
}

/**
Expand Down
Loading