-
Notifications
You must be signed in to change notification settings - Fork 24
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
WaveFile::Reader doesn't work with pipe IO #36
Comments
Thanks for opening this issue! Like you pointed out,
Does your original script work when using v1.0.1? As for whether analyzing an audio recording in realtime is an aim of this project, I would say the gem is agnostic. If sample data is contained in a *.wav file this gem should let you read it out, but what you do with the sample data is an outside concern. When you say realtime, do you mean for the sample data to be streamed continuously while it is being recorded, or do you mean for the entire sample data to be written all at once when recording stops? One reason I ask is that *.wav files don't seem ideal for streaming audio while it is being recorded. The problem is that the beginning of a *.wav file includes fields that indicate "chunk" sizes, which are needed to know how much sample data is in the file, and where it is located. If a program records audio and continuously appends it to a *.wav file, once recording stops it will have to go back to the beginning of the file and rewrite the correct chunk sizes. However, by this time the beginning of the file has already been streamed. This is more an issue with the *.wav file format itself, rather than this gem per se. How does (To be clear the issue isn't streaming in general, but streaming a *.wav file that is changing while it is being streamed). Regardless of whether it solves your ultimate problem, I think it makes sense to fix the bug mentioned above - thanks for pointing it out! |
After looking more closely at this, the bug mentioned above more specifically occurs when using an
However, while that should be a fix for some *.wav files, there will still probably be an issue with using |
Hello!
I was trying to use this gem to record a wav file to STDOUT and then feed it to
WaveFile::Reader
to analyze in realtime. If I recall correctly, it was something along the lines ofHowever, this results in the following exception:
which is because it's trying to seek on the IO, which is an invalid operation on a pipe.
I did also try record to a file instead of STDOUT and calling WaveFile::Reader on that, but because the file size kept increasing, that also resulted in something going wrong (I think because
WaveFile::Reader#read_until_data_chunk
tries to read until the end of the file). Also that means that the file keeps growing while the recording is ongoing, which is not ideal.I ended up calling
IO.popen("rec -c 1 -t s32 - 2>/dev/null")
which outputs the audio amplitudes as signed 32-bit integers, and analyzing that directly.The reason I'm opening this ticket is because I'm wondering whether analyzing an audio recording in realtime is an aim of this project, and if so, whether it's a planned feature or something that can be done now and I just missed something?
Thank you!
The text was updated successfully, but these errors were encountered: