I confirm that the update fixed the bugs.
I just posted an update that should fix these two bugs.
I've been looking at that section of code and I think I found the bug. There's an unchecked access on a potentially null object in the method samplesAvailableToEncode(). If it happens that the number of samples added up to the point you call samplesAvailableToEncode() is a perfect multiple of the block-size used by the encoder, it should trigger the exception(or if no samples were ever added). I'll create a test case and verify this later tonight. Hopefully I will get the update posted tomorrow to...
Version is 0.3.1 , 16-bit mono. I reproduced these errors on the following sampling rates: 48 kHz, 44.1 kHz, 32 kHz, 22.05 kHz, 16 kHz. 11.025 kHz. Haven't seen it on 8 kHz till now.
I haven't seen that before but it sounds like an internal bug in the flac library. I'll check it out. In the meantime, can you tell me the conditions of the failure(which javaFlacEncoder version, encode settings used, is this still 16-bit mono as above?)
Hi, sometimes while closing the stream and finalizing using flacEncoder.encodeSamples(flacEncoder.samplesAvailableToEncode(), true); This Fatal Exception is thrown java.lang.NullPointerException: Attempt to read from field 'int javaFlacEncoder.BlockEncodeRequest.count' on a null object reference at javaFlacEncoder.FLACEncoder.samplesAvailableToEncode(FLACEncoder.java:681) This happens sometimes and not all the times. What can I do to properly finalize?
Hi, sometimes while closing the stream and finalizing using flacEncoder.encodeSamples(flacEncoder.samplesAvailableToEncode(), true); This Fatal Exception is thrown java.lang.NullPointerException: Attempt to read from field 'int javaFlacEncoder.BlockEncodeRequest.count' on a null object reference at javaFlacEncoder.FLACEncoder.samplesAvailableToEncode(FLACEncoder.java:681) This happens sometimes and not all the times. What can I do to properly finalize? Edit: Problem solved
Hi, sometimes while closing the stream and finalizing using flacEncoder.encodeSamples(flacEncoder.samplesAvailableToEncode(), true); This Fatal Exception is thrown java.lang.NullPointerException: Attempt to read from field 'int javaFlacEncoder.BlockEncodeRequest.count' on a null object reference at javaFlacEncoder.FLACEncoder.samplesAvailableToEncode(FLACEncoder.java:681) This happens sometimes and not all the times. What can I do to properly finalize?
I have fixed my problem. I had imported javaFlacEncoder source code and not the jar file. So, I deleted the source code and imported the jar file as a library. Before this, my code was failing everytime on all occassions but now it is encoding properly and producing good files that are seekable and have a known length. I will be waiting for the update though.
Interesting. The header for the #277 file is properly finalized, while the header for #388 is not. Does your code only occasionaly fail to produce a proper file now, or always fail? For example, did the run that verified the two values were equal also produce a good file, or a bad file? My point is I'm curious if something is only occasionally interrupting that code before it reaches the point of finalizing the header. I did check the library source though, and there is indeed a bug that might cause...
I just checked the value returned by '"flacEncoder.samplesAvailableToEncode()" and "flacEncoder.encodeSamples(flacEncoder.samplesAvailableToEncode(), true);" are the same. I check again the value of '"flacEncoder.samplesAvailableToEncode()" and it is equal to 0. I am using (int buffer.length) to give sample count parameter and not numRead. I have attached a recording that was recorded a while back from the same source code. I haven't changed anything in the source code that I know of. This recording...
I'm not actually certain at the moment what might be the problem. It sounds like the FLAC stream is not being finalized by the line, "flacEncoder.encodeSamples(flacEncoder.samplesAvailableToEncode(), true)" When the flac stream is finalized, various details needed for seeking(including length of stream and min/max encoded frame size) are written to the front of the stream if possible(this step will be ignored if the stream isn't seekable, but yours should be since you're writing to a file). First...
Hi, FlacEncoder worked before but now it is not working properly. Some media players are unable to play the recording and the others that play do not display duration and provide seek options. Java code and the recording is attached. Can you tell me where is the problem? boolean isRecording = false; private void startRecording() { FLACEncoder flacEncoder = new FLACEncoder(); StreamConfiguration streamConfiguration = new StreamConfiguration(); streamConfiguration.setBitsPerSample(16); streamConfiguration.setChannelCount(1);...
Unfortunately, there's not a built-in way to properly append new data directly to a previously saved file using this encoder. Information about the encoded data(md5-hash, length, number of frames, etc) is kept while encoding, and this information is written out to the header space of the FLAC stream when the stream is closed. Currently, there is no method of restoring the encoder state necessary to write a proper header to the existing stream if appending new data.
I have another question, how can I resume recording at the end of a previously saved flac file. When I try to add encoded data at the end of previously saved flac file, the recording resumes but there is an audible gap in between when the last recording was stopped and then resumed. What is the correct way to do this in javaFlacEncoder? Thanks
Hi, I did what you said and now I am able to successfully record in flac format. Thanks very much for the help!
Hi, I did what you said and now I am able to successfully record in flac format but only when the sampling rate is less than or equal to 16kHz. When the sampling rate is set to be greater than 16kHz the recording is glitchy. Below is the code I am using to record in mono but is glitchy because the sampling rate is 32kHz bufferSize = (2 * (AudioRecord.getMinBufferSize(32000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT))); FLACEncoder flacEncoder = new FLACEncoder(); StreamConfiguration...
Hi, I did what you said and now I am able to successfully record in flac format but only when the sampling rate is less than or equal to 16kHz. When the sampling rate is set to be greater than 16kHz the recording is glitchy. Below is the code I am using to record in mono but is glitchy because the sampling rate is 32kHz bufferSize = (2 * (AudioRecord.getMinBufferSize(32000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT))); FLACEncoder flacEncoder = new FLACEncoder(); StreamConfiguration...
Greetings! I can't be certain without more information on your source format and how you're reading them from the AudioRecord instance, but It looks like your problem will be with the source format conversion to int. If you're reading 16-bit PCM from the AudioRecord object, make sure you're reading those into a short[] and not a byte[] https://developer.android.com/reference/android/media/AudioRecord.html#read(short[],%20int,%20int) If you use a byte[] for 16-bit(which is deprecated but should work),...
Hi, I am using android to capture audio from phone's microphone via android's AudioRecord class. This gives me raw pcm data in an byte[] array. I then convert the byte[] array to int[] array. I am then using this code to encode the pcm data to flac but I get noise only. FLACEncoder flacEncoder = new FLACEncoder(); StreamConfiguration streamConfiguration = new StreamConfiguration(); streamConfiguration.setBitsPerSample(16); streamConfiguration.setChannelCount(1); streamConfiguration.setSampleRate(32000);...
Hi, I am using android to capture audio from phone's microphone via android's AudioRecord class. This gives me raw pcm data in an byte[] array. I then convert the byte[] array to int[] array. I am then using this code to encode the pcm data to flac but I get noise only. FLACEncoder flacEncoder = new FLACEncoder(); StreamConfiguration streamConfiguration = new StreamConfiguration(); streamConfiguration.setBitsPerSample(16); streamConfiguration.setChannelCount(1); streamConfiguration.setSampleRate(RECORDER_SAMPLERATE);...
Thank you, your suggestions worked :-)
Excellent, glad to hear it's working for you. You should be able to do the conversion...
That was it! Thank you so much! I am now getting the proper coverted speech. If you...
Greetings Check out this thread first, and see if it's the same issue with mu-law...
Hello I am using JavaFlacEncoder with JRE1.7 to encode a PCM 8bit 8KHz Mono wav file...
Hi, Hope you don't mind, but I put this project onto github to make collaboration...
Hi Preston, I guess you already knows that current implementation depends on javax.sound.sampled...
Hi Will, can you share your source code with me? Thanks
Actually, I told you a bit wrong. The sample rate and sample size will be reset to...
Hello. Does the POST response include any error details that may help? If not, the...
Hello. I am trying to do a little thing for practice. So, I'm trying to send POST...
Hello. I am trying to do a little thing for practice. So, I'm trying to send POST...