Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
Cómo descargar una matriz de archivos de audio en un solo archivo

Estoy tratando de crear una aplicación web de caja de resonancia en la que pueda agregar archivos de audio al sitio web y se almacenarán dentro de la base de datos indexada para luego recuperarlos y reproducirlos.

También estaba pensando en agregar una función que le permitiera descargar el paquete completo de archivos de audio como un solo archivo para que otras personas pudieran importar su paquete. Los datos se verían así:

 const data = [ { title: 'audio1', description: 'blabla' audio: AudioBuffer //or some other buffer },{ title: 'audio2', description: 'blablabla' audio: AudioBuffer } ]

La pregunta es, ¿cómo haría para descargar esto como un solo archivo? Probablemente haya una manera con blobs, etc., pero no tengo idea de dónde buscar. Obviamente, también tendría que decodificar esto para usarlo.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Vale la pena evitar las bibliotecas externas y mantener tu aplicación optimizada. Considere crear un archivo binario descargable estructurado como:

 ************************************************* | MARKER | META | AUDIO | AUDIO | ... | *************************************************
 // Example 32 MiB audio buffers const audio1 = new Uint8Array(32 * 1024**2 / Uint8Array.BYTES_PER_ELEMENT) const audio2 = new Float32Array(32 * 1024**2 / Float32Array.BYTES_PER_ELEMENT)​ // Metadata for your file const meta = new TextEncoder().encode(JSON.stringify([ { title: 'audio1', length: audio1.byteLength }, { title: 'audio2', length: audio2.byteLength }, ]))​ // use 32-bit integer to store byte index where audio begins (metadata ends) const marker = new Uint32Array([ meta.byteLength + 4 // include 4 bytes for this 32-bit integer ])​ function initDownload() { const a = document.createElement('a') a.href = URL.createObjectURL(new Blob([ marker, meta, audio1, audio2, ], { type: 'application/octet-stream' })) a.download = 'saved-audio-project.bin' a.click() } function parseFile(buffer) { // ArrayBuffer of file const metaLength = new DataView(buffer).getUint32(0, true) let readOffset = 4 // 4-byte marker length const audioFiles = JSON.parse( new TextDecoder().decode( buffer.slice(readOffset, readOffset += metaLength) ) ) audioFiles.forEach(audio => audio.data = new Float32Array( buffer.slice(readOffset, readOffset += audio.length) )) return audioFiles }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!