Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saved as [object ArrayBuffer] #64

Open
hamptonmoore opened this issue Apr 10, 2019 · 1 comment
Open

Saved as [object ArrayBuffer] #64

hamptonmoore opened this issue Apr 10, 2019 · 1 comment

Comments

@hamptonmoore
Copy link

My code is simply

const Audio = require('audio');

Audio.load('./test.mp3', (err, audio) => {
	//repeat slowed down fragment
	//audio.remove(3, 4.1)

	audio.save('edited-record.mp3')
})

and it causes the edited-record.mp3 to be just a text file with [object ArrayBuffer] as the contents. Node version is v10.15.3 on windows 10

@redraskal
Copy link

redraskal commented Jun 18, 2019

I've had little success with mp3 files on Windows at least and end up with the same result as you.

In case you're still wondering on how to fix this issue, I would first only load wav files and convert the mp3 files to wav beforehand. You'll want to save them as wav files since loading them as mp3's will result in really messed up files that are slowed down in speed. I found my answer from looking at the save function in the code and from the answer on this Stack Overflow page: https://stackoverflow.com/questions/46623517/write-a-wav-file-in-node-js-from-an-audiobuffer.

const Audio = require('audio')
const toWav = require('audiobuffer-to-wav')
const fs = require('fs')

Audio.load('./test.wav').then(audio => {
  audio.normalize()

  let buffer = audio.read({
    format: 'audiobuffer'
  })
  let wav = toWav(buffer)

  fs.appendFileSync('test2.wav', new Buffer(wav))
})

Hopefully this helps you and anyone else experiencing this problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants