rochars / wavefile

Create, read and write wav files according to the specs. :star: :notes: :heart:
MIT License
230 stars 48 forks source link

byteData_ is empty object #6

Closed diwu86 closed 6 years ago

diwu86 commented 6 years ago

Hi I use this in my react native project. When I try to load wav file from data no matter base64 or a buffer, I always got error that byteData is an empty so things like byteData.types is undefined. I had to change all other byteData to byteData in file except the definition one here. I also had to do the same thing for riffChunks. Can someone help me with this? I don't quite get why byteData without the underscore has all the information. Thanks

rochars commented 6 years ago

What version of WaveFile are you using? Also, could you give me more information about how WaveFile is being used in your React Native app?

Cheers! Rafael

diwu86 commented 6 years ago

wavefile": "^6.13.0

import WaveFile from 'wavefile'
import RNFS from 'react-native-fs'

RNFS.readFile(path, 'base64').then(data => {
let wav = new WaveFile()
wav.fromBase64(data)
}

the path is the wav file path.

I try to load data to buffer and get the same error

rochars commented 6 years ago

Could you try installing wavefile@7.0.0-alpha.9 and see if this is still an issue on your build?

Cheers! Rafael

diwu86 commented 6 years ago

Now when I do let wav = new WaveFile(), I got TypeError: _wavefile2.default is not a constructor

rochars commented 6 years ago

In version 6: WaveFile = require('wavefile');

In version 7: WaveFile = require('wavefile').WaveFile;

Sorry not to mention that earlier. Did this help?

diwu86 commented 6 years ago

Yes it's working now. Thank you very much! Are you going to release 7 with the fix?

rochars commented 6 years ago

:D

Yes, but there are more things to do before the release. I'm actually working on byte-data and riff-chunks (dependencies of WaveFile) to fix memory issues. Version 7 will be out after that.

Cheers! Rafael

rochars commented 6 years ago

Fixed in 7.0.0