forked from generativefm/generative.fm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpiece-loader.js
27 lines (23 loc) · 914 Bytes
/
piece-loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const DEFAULT_VISUALIZATION_TYPE = 'squareCut';
const pieceLoader = source => {
const pieceManifest = JSON.parse(source);
const output = `import image from '${pieceManifest.image}';
import makePiece from '${pieceManifest.makePiece}';
export default {
image,
makePiece,
title: '${pieceManifest.title}',
id: '${pieceManifest.artistId}-${pieceManifest.id}',
artist: '${pieceManifest.artistId}',
isRecordable: ${typeof pieceManifest.isRecordable !== 'boolean' ||
pieceManifest.isRecordable},
tags: [${pieceManifest.tags.map(tag => `"${tag}"`)}],
releaseDate: new Date('${pieceManifest.releaseDate}'),
visualizationType: '${pieceManifest.visualizationType ||
DEFAULT_VISUALIZATION_TYPE}',
sampleNames: [${pieceManifest.sampleNames.map(name => `"${name}"`)}]
}`;
return output;
};
module.exports = pieceLoader;