Created
September 13, 2020 14:22
-
-
Save globau/bf7a8c27a95e4e15de6ae9546d5678ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gulp/package.json b/gulp/package.json | |
index 9c3d018..02cc854 100644 | |
--- a/gulp/package.json | |
+++ b/gulp/package.json | |
@@ -34,6 +34,7 @@ | |
"flatted": "^2.0.1", | |
"fs-extra": "^8.1.0", | |
"gulp-audiosprite": "^1.1.0", | |
+ "gulp-newy": "^2.0.4", | |
"howler": "^2.1.2", | |
"html-loader": "^0.5.5", | |
"ignore-loader": "^0.1.2", | |
diff --git a/gulp/sounds.js b/gulp/sounds.js | |
index c38e7a6..2173980 100644 | |
--- a/gulp/sounds.js | |
+++ b/gulp/sounds.js | |
@@ -1,14 +1,21 @@ | |
const path = require("path"); | |
const audiosprite = require("gulp-audiosprite"); | |
+const fs = require("fs"); | |
+const newy = require("gulp-newy"); | |
function gulptasksSounds($, gulp, buildFolder) { | |
// Gather some basic infos | |
const soundsDir = path.join(__dirname, "..", "res_raw", "sounds"); | |
const builtSoundsDir = path.join(__dirname, "..", "res_built", "sounds"); | |
- gulp.task("sounds.clear", () => { | |
- return gulp.src(builtSoundsDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true })); | |
- }); | |
+ function musicOutputFile(projectDir, srcFile, absSrcFile) { | |
+ // Returns the full path to the res_built mp3 for the src file | |
+ const outputFile = path.parse(absSrcFile); | |
+ outputFile.dir = path.join(builtSoundsDir, "music"); | |
+ outputFile.ext = ".mp3"; | |
+ fs.mkdirSync(outputFile.dir, { recursive: true }); | |
+ return path.format(outputFile); | |
+ } | |
const filters = ["volume=0.2"]; | |
@@ -21,21 +28,16 @@ function gulptasksSounds($, gulp, buildFolder) { | |
return gulp | |
.src([path.join(soundsDir, "music", "**", "*.wav"), path.join(soundsDir, "music", "**", "*.mp3")]) | |
.pipe($.plumber()) | |
+ .pipe(newy(musicOutputFile)) | |
.pipe( | |
- $.cache( | |
- $.fluentFfmpeg("mp3", function (cmd) { | |
- return cmd | |
- .audioBitrate(48) | |
- .audioChannels(1) | |
- .audioFrequency(22050) | |
- .audioCodec("libmp3lame") | |
- .audioFilters(["volume=0.15"]); | |
- }), | |
- { | |
- name: "music", | |
- fileCache, | |
- } | |
- ) | |
+ $.fluentFfmpeg("mp3", function (cmd) { | |
+ return cmd | |
+ .audioBitrate(48) | |
+ .audioChannels(1) | |
+ .audioFrequency(22050) | |
+ .audioCodec("libmp3lame") | |
+ .audioFilters(["volume=0.15"]); | |
+ }) | |
) | |
.pipe(gulp.dest(path.join(builtSoundsDir, "music"))); | |
}); | |
@@ -45,21 +47,16 @@ function gulptasksSounds($, gulp, buildFolder) { | |
return gulp | |
.src([path.join(soundsDir, "music", "**", "*.wav"), path.join(soundsDir, "music", "**", "*.mp3")]) | |
.pipe($.plumber()) | |
+ .pipe(newy(musicOutputFile)) | |
.pipe( | |
- $.cache( | |
- $.fluentFfmpeg("mp3", function (cmd) { | |
- return cmd | |
- .audioBitrate(256) | |
- .audioChannels(2) | |
- .audioFrequency(44100) | |
- .audioCodec("libmp3lame") | |
- .audioFilters(["volume=0.15"]); | |
- }), | |
- { | |
- name: "music-high-quality", | |
- fileCache, | |
- } | |
- ) | |
+ $.fluentFfmpeg("mp3", function (cmd) { | |
+ return cmd | |
+ .audioBitrate(256) | |
+ .audioChannels(2) | |
+ .audioFrequency(44100) | |
+ .audioCodec("libmp3lame") | |
+ .audioFilters(["volume=0.15"]); | |
+ }), | |
) | |
.pipe(gulp.dest(path.join(builtSoundsDir, "music"))); | |
}); | |
@@ -117,8 +114,8 @@ function gulptasksSounds($, gulp, buildFolder) { | |
gulp.task("sounds.buildall", gulp.parallel("sounds.music", "sounds.sfx")); | |
gulp.task("sounds.buildallHQ", gulp.parallel("sounds.musicHQ", "sounds.sfx")); | |
- gulp.task("sounds.fullbuild", gulp.series("sounds.clear", "sounds.buildall", "sounds.copy")); | |
- gulp.task("sounds.fullbuildHQ", gulp.series("sounds.clear", "sounds.buildallHQ", "sounds.copy")); | |
+ gulp.task("sounds.fullbuild", gulp.series("sounds.buildall", "sounds.copy")); | |
+ gulp.task("sounds.fullbuildHQ", gulp.series("sounds.buildallHQ", "sounds.copy")); | |
gulp.task("sounds.dev", gulp.series("sounds.buildall", "sounds.copy")); | |
} | |
diff --git a/gulp/yarn.lock b/gulp/yarn.lock | |
index d0628aa..0ba7d1d 100644 | |
--- a/gulp/yarn.lock | |
+++ b/gulp/yarn.lock | |
@@ -2970,6 +2970,11 @@ colors@1.0.x: | |
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" | |
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs= | |
+colors@^1.0.3: | |
+ version "1.4.0" | |
+ resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" | |
+ integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== | |
+ | |
colors@^1.3.3: | |
version "1.3.3" | |
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d" | |
@@ -5909,6 +5914,16 @@ gulp-match@^1.1.0: | |
dependencies: | |
minimatch "^3.0.3" | |
+gulp-newy@^2.0.4: | |
+ version "2.0.4" | |
+ resolved "https://registry.yarnpkg.com/gulp-newy/-/gulp-newy-2.0.4.tgz#98dddafe411f30d0a0379e16655806c2f7474242" | |
+ integrity sha1-mN3a/kEfMNCgN54WZVgGwvdHQkI= | |
+ dependencies: | |
+ colors "^1.0.3" | |
+ gulp-util "^3.0.4" | |
+ through2 "^0.6.3" | |
+ vinyl "^0.4.6" | |
+ | |
gulp-phonegap-build@^0.1.5: | |
version "0.1.5" | |
resolved "https://registry.yarnpkg.com/gulp-phonegap-build/-/gulp-phonegap-build-0.1.5.tgz#36c145e63cd204702be0f3b99be19e096712bcaf" | |
@@ -6019,7 +6034,7 @@ gulp-util@^2.2.19: | |
through2 "^0.5.0" | |
vinyl "^0.2.1" | |
-gulp-util@^3.0.0, gulp-util@~3.0.0: | |
+gulp-util@^3.0.0, gulp-util@^3.0.4, gulp-util@~3.0.0: | |
version "3.0.8" | |
resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" | |
integrity sha1-AFTh50RQLifATBh8PsxQXdVLu08= | |
@@ -12250,7 +12265,7 @@ through2@^0.5.0, through2@^0.5.1: | |
readable-stream "~1.0.17" | |
xtend "~3.0.0" | |
-through2@^0.6.1, through2@~0.6.1: | |
+through2@^0.6.1, through2@^0.6.3, through2@~0.6.1: | |
version "0.6.5" | |
resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" | |
integrity sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg= | |
@@ -12964,7 +12979,7 @@ vinyl@^0.2.1, vinyl@~0.2.2: | |
dependencies: | |
clone-stats "~0.0.1" | |
-vinyl@^0.4.0: | |
+vinyl@^0.4.0, vinyl@^0.4.6: | |
version "0.4.6" | |
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" | |
integrity sha1-LzVsh6VQolVGHza76ypbqL94SEc= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment