maxl0rd / standingwave3

Flash ActionScript3 dynamic audio library
http://www.noteflight.com
162 stars 28 forks source link

creating a sample from recorder mic audio #8

Closed PieterNijs closed 14 years ago

PieterNijs commented 14 years ago

I'm trying to get recorded audio data into a sample using the WaveFile.createSample method (passing the recorder.output) as argument. This results in the following error:

Error: Error #2030: End of file was encountered. at flash.utils::ByteArray/readUTFBytes() at com.noteflight.standingwave3.formats::WaveFile$/createSample()

I'm thinking that the byteArray that my mic recorder outputs is raw audio instead of wav audio, so I alternitavely tried to first convert my raw audio to wav audio using:

var wavData:ByteArray = new ByteArray(); WaveFile.writeBytesToWavFile(wavData, recorder.output, 44, 2, 16);
WaveFile.createSample(wavData);

but the same error occurs... I've been breaking my head on this for the past day, and there's no info online about this... what am I doing wrong? How can I get raw audio (byteArray) into a sample, and add filters to this (echo)?

maxl0rd commented 14 years ago

Recorder output is not wave format. It is raw audio data in floating point, and compatible with Sample's internal format.

I suggest modifying Sample. All you need to do is make a writeBytes() call to write the recorder output into the alchemy byte array at the proper position.

PieterNijs commented 14 years ago

Thanks for the quick reply... I tried what you said, but I'm clearly doing something wrong. What do you exactly mean? I tried adding a writeBytesRaw method to the Sample class that sets the recorded bytes to the _awaveMemory byteAray. Is this the alchemy byteArray you meant? Or is it a part of the _awave object I have to set?

It's pretty frustrating that there are almost no examples to be found online. I found one other example of someone who used your engine in combination with the micrecorder classes (bytearray.org) but he didn't share his code, and I'm not even sure what he uses your engine for (he exports an mp3 from recorded mic input).

Any pointers would be highly appreciated. I'm trying to create a tool that lets you record your voice, add echo to it, change the pitch, and mix it with a prerecorded sample. Your engine seems a perfect fit to do this...

Thanks in advance.

maxl0rd commented 14 years ago

Pieter

I thought about this, and it's not trivial. You will have to understand the framework well to make something useful.

There will have to be some kind of source that can manage the recording. That source will have to have a Sample that can hold the audio data. You will have to manage the memory in the Sample by hand (ie, know how much time can be recorded, resize it, etc.). Then you will have to figure out how to write each record buffer into that Sample. If you are playing this back at the same time, or effecting in real-time, then it will be more complex.

This is something we've thought about adding for a long time, but no one's had time to work on the lib much lately, sorry. This is a very small project, and there are not very many people using it.