feat:暂存
This commit is contained in:
1 parent
272536d740
commit
23ed602434
3 files changed
+64
-2
No files matched your search
Generated
+5
@@ -12975,6 +12975,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"soundtouchjs": {
|
||||||
|
"version": "0.1.27",
|
||||||
|
"resolved": "https://registry.npmjs.org/soundtouchjs/-/soundtouchjs-0.1.27.tgz",
|
||||||
|
"integrity": "sha512-Ok/1U16sGDsOMD3ZOiXfojPzqYA/TO3ocNZyXQvTm8tIAQJaN4y0Tig4NlrvOVz8sMuIvp1dMH5xvGjXzNygww=="
|
||||||
|
},
|
||||||
"source-list-map": {
|
"source-list-map": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/source-list-map/download/source-list-map-2.0.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/source-list-map/download/source-list-map-2.0.1.tgz",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ant-design-vue": "^1.7.4",
|
"ant-design-vue": "^1.7.4",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
|
"soundtouchjs": "^0.1.27",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-router": "^3.2.0",
|
"vue-router": "^3.2.0",
|
||||||
"vuex": "^3.4.0"
|
"vuex": "^3.4.0"
|
||||||
|
|||||||
+58
-2
@@ -19,16 +19,72 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { PitchShifter } from "soundtouchjs";
|
||||||
export default {
|
export default {
|
||||||
name: "About",
|
name: "About",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
shifter: null,
|
||||||
|
audioCtx: null,
|
||||||
|
gainNode: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// this.init();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleChange(info) {
|
handleChange(info) {
|
||||||
console.log(info);
|
console.log(info);
|
||||||
|
const fileReader = new FileReader();
|
||||||
|
fileReader.onload = onLoad;
|
||||||
|
try {
|
||||||
|
fileReader.readAsArrayBuffer(file);
|
||||||
|
} catch (err) {
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
beforeUpload(event) {
|
beforeUpload() {
|
||||||
console.log(event);
|
// console.log(event);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
init() {
|
||||||
|
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
this.gainNode = this.audioCtx.createGain();
|
||||||
|
if (this.shifter) {
|
||||||
|
this.shifter.off();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fileReaderOnLoad({ target: { result: buffer } }) {
|
||||||
|
if (this.shifter) {
|
||||||
|
this.shifter.off();
|
||||||
|
}
|
||||||
|
if (buffer) {
|
||||||
|
this.audioCtx.decodeAudioData(buffer).then((audioBuffer) => {
|
||||||
|
this.newShifter(audioBuffer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
decodeAudioData() {
|
||||||
|
this.audioCtx.decodeAudioData(buffer, (audioBuffer) => {
|
||||||
|
this.shifter = new PitchShifter(this.audioCtx, audioBuffer, 1024);
|
||||||
|
this.shifter.on("play", (detail) => {
|
||||||
|
// do something with detail.timePlayed;
|
||||||
|
// do something with detail.formattedTimePlayed;
|
||||||
|
// do something with detail.percentagePlayed
|
||||||
|
console.log(detail);
|
||||||
|
});
|
||||||
|
this.shifter.tempo = 1;
|
||||||
|
this.shifter.pitch = 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
newShifter(buffer) {
|
||||||
|
const myShifter = new PitchShifter(this.audioCtx, buffer, 16384);
|
||||||
|
myShifter.tempo = tempo;
|
||||||
|
myShifter.pitch = pitch;
|
||||||
|
myShifter.on("play", onPlay);
|
||||||
|
setDuration(myShifter.formattedDuration);
|
||||||
|
setShifter(myShifter);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Reference in new issue
Block a user