我尝试了一下自己拼装,倒是能播放了,就是来一个chunk 就拼起来, 格式是 wav 的,所以播放时都要在 chunk 前拼上 wav 的header 可参考代码 function combineHeaderAndChunk(header:ArrayBuffer, chunk:ArrayBuffer) { // Create a new ArrayBuffer to hold both the header and the chunk const combinedBuffer = new ArrayBuffer(header.byteLength + chunk.byteLength); // Create a Uint8Array view of the combined buffer const combinedView = new Uint8Array(combinedBuffer); // Copy the header into the combined buffer combinedView.set(new Uint8Array(header), 0); // Copy the chunk data after the header combinedView.set(new Uint8Array(chunk), header.byteLength); return combinedBuffer; } // Usage example let storedHeader = null; let isFirstChunk = true; ws.onmessage = function(event) { if (isFirstChunk) { // Assume the first 44 bytes are the header storedHeader = event.data.slice(0, 44); // const headerInfo = parseWavHeader(storedHeader); // console.log("WAV Header Info:", headerInfo); // Handle the rest of the first chunk as audio data const firstChunkData = event.data.slice(44); const combinedData = combineHeaderAndChunk(storedHeader, firstChunkData); processAudioData(combinedData); isFirstChunk = false; } else { // For subsequent chunks, combine with the stored header const combinedData = combineHeaderAndChunk(storedHeader, event.data); processAudioData(combinedData); } }; function processAudioData(audioData) { // Here you would typically send the data to the Web Audio API // For example: // audioContext.decodeAudioData(audioData) // .then(decodedData => { // // Use the decoded audio data // }) // .catch(error => console.error("Error decoding audio data:", error)); }
AudioBuffer是否支持动态添加buffer数据特性?如不支持,实时播放音频怎么解决播放卡顿?WebAudioContext.createBuffer
2024-09-18录制的时 start 方法内 format 需要传 mp3 格式, onFrameRecorded 才会被触发,手机上测试可以,我测试成功了,电脑端开发工具是不行的。 我猜你和我一样是想做音频可视化,但太卡了,换 方案吧,毕竟不是 web ,小程序内你拿到数据后需要 setData到渲染进程这通信量太卡了
decodeAudioData传入onFrameRecorded回调中的frameBuffer无效[图片] 这里是代码,下面是报错,[图片] 请问通过小程序录音获取到的分片数据ArrayBuffer可以被decodeAudioData这个方法解析成AudioBuffer吗,如果不可以的话那用何种方式可以解析?
2024-09-14实时录音,实时可视化是可以实现的,但是图像会卡成狗,毕竟是两个线程每帧都需要setData传数据, 不知道新的 skyline 渲染引擎能不能解决这种卡的问题,理论上应该可以,但是还需要等
救命,小程序到底能不能实现录音 实时 可视化?调研几天了都,目前发现几个相关的api,该怎么做? RecorderManager.onFrameRecorded();//https://developers.weixin.qq.com/miniprogram/dev/api/media/recorder/RecorderManager.onFrameRecorded.html audioCtx.decodeAudioData();// https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html myArrayBuffer.getChannelData();//https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioBuffer.getChannelData.html onFrameRecorded返回的音频片段能不能做可视化?为什么decodeAudioData解析不了,总是报传入数据不对。[图片]
2024-09-14还不支持吗?技术卡住脖子了?两套东西融合不到一起了?
小程序OffscreenCanvas还是不能用作Canvas 2d的drawImage的参数?我想将复杂的绘图先画到OffscreenCanvas进行缓存,然后再画到屏幕的canvas(2d)上, 结果drawImage报错,不支持该类型的参数
2024-07-18