mirror of
https://github.com/FMS-Cat/condition.git
synced 2025-08-09 15:36:34 +02:00
dev: MusicWrite, best for outputting a wav
This commit is contained in:
@@ -18,9 +18,11 @@
|
||||
"@fms-cat/automaton-with-gui": "^4.1.1",
|
||||
"@fms-cat/experimental": "^0.5.0",
|
||||
"@fms-cat/glcat-ts": "^0.14.2",
|
||||
"@types/audiobuffer-to-wav": "^1.0.0",
|
||||
"@types/webpack-env": "^1.16.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
||||
"@typescript-eslint/parser": "^4.17.0",
|
||||
"audiobuffer-to-wav": "^1.0.0",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
|
||||
"glslify-loader": "^2.0.0",
|
||||
|
@@ -8,7 +8,7 @@ let music: Music;
|
||||
|
||||
if ( process.env.DEV ) {
|
||||
music = new MusicRealtime();
|
||||
// music = new MusicOffline();
|
||||
// music = new MusicWrite();
|
||||
} else {
|
||||
music = new MusicOffline();
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import { gl } from '../globals/canvas';
|
||||
const BUFFER_LENGTH = 16384;
|
||||
|
||||
export class MusicOffline extends Music {
|
||||
private __buffer: AudioBuffer;
|
||||
protected __buffer: AudioBuffer;
|
||||
private __currentBufferSource?: AudioBufferSourceNode | null;
|
||||
|
||||
public constructor() {
|
||||
|
15
src/music/MusicWrite.ts
Normal file
15
src/music/MusicWrite.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { MusicOffline } from './MusicOffline';
|
||||
import toWav from 'audiobuffer-to-wav';
|
||||
|
||||
export class MusicWrite extends MusicOffline {
|
||||
public async prepare(): Promise<void> {
|
||||
await super.prepare();
|
||||
|
||||
const b = toWav( this.__buffer );
|
||||
const blob = new Blob( [ b ] );
|
||||
const anchor = document.createElement( 'a' );
|
||||
anchor.href = URL.createObjectURL( blob );
|
||||
anchor.download = 'wenis.wav';
|
||||
anchor.click();
|
||||
}
|
||||
}
|
10
yarn.lock
10
yarn.lock
@@ -100,6 +100,11 @@
|
||||
"@nodelib/fs.scandir" "2.1.4"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@types/audiobuffer-to-wav@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/audiobuffer-to-wav/-/audiobuffer-to-wav-1.0.0.tgz#4b974f50b96f3f760231b11b2e22dac33b2d2fbf"
|
||||
integrity sha512-SbhLEr/BOWStZ0w9mPJLjUc6REGl+lUsf8M/opXy1jvAFfm+Ontt/8c0KZEvNY+TWy9NO1j/V+32uPCBNExpRg==
|
||||
|
||||
"@types/eslint-scope@^3.7.0":
|
||||
version "3.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.0.tgz#4792816e31119ebd506902a482caec4951fabd86"
|
||||
@@ -571,6 +576,11 @@ atob@^2.1.2:
|
||||
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
||||
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
||||
|
||||
audiobuffer-to-wav@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/audiobuffer-to-wav/-/audiobuffer-to-wav-1.0.0.tgz#d5b432271455e7fee56b111cd0f8d620d7f9e105"
|
||||
integrity sha1-1bQyJxRV5/7laxEc0PjWINf54QU=
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
|
Reference in New Issue
Block a user