If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-08-17
Hey,
I wanted to say this project is awesome! Thanks so much for creating this- I was worried I would have to do an implementation of a FLAC encoder in Java myself. You are a total Boss.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for the feedback :) Glad to hear it's getting some use.
I just posted an update. There's several important bug fixes, as well as some minor performance improvements. Be sure to post any bugs you may find to the help forum.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I didn't need the javax sound SPI for what I was doing, so didn't really consider it. I may at some point wrap the encoder in a AudioFileWriter implementation, and read directly from an AudioInputStream, which could simplify the encode process(is this what you're referring to?)
I do plan to improve error reporting, but not sure when(probably not "near future"). I'm able to work on this project a bit in spare time only. Be sure to let me know if there's any specific cases you find that need improved, I'll try to target those first.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes, that's exactly what I refer to. If your FLAC encoder can be plugged to javax sound SPI too, it has next + (we plan to use jFLAC stable library, which is plugged to javax sound SPI, but FLAC encoder implementation is "to be done")
As for error reporting, I have no concrete issues, but I've read ToDo file, that errors can be ignored and encoder tells nothing about it. For our project it is enough error reporting of type "encoding not sucessfull" in some form in order to inform users there was FLAC encoding problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I recall correctly, the only potential errors I know of that may not be handled/reported properly would occur when using the threaded methods(handling of an IOException in a child thread). I do intend to fix this issue at some point. Non-threaded mode should avoid this issue though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to integrate FLACEncoder into javax sound SPI and I've found first problem - encoder needs as input FLACOutputStream (wrapper for FileOutputStream), but in javax sound SPI I have this stream already in hand and there is no possibility just to set such stream (also extension of FLACOutputStream is not possible, because members are package protected)
Can you please enhance implementation?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is probably just a mistype, but FLACOutputStream only is used for output, not input(input is in the form of int arrays);
The methods in FLACOutputStream are supposed to be public, I'll fix that and post an update in a few minutes. You should then be able to wrap the OutputStream or File that the SPI provides, into a FLACOutputStream.
Let me know of any other issues you find, and I'll try to fix them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
it was misunderstanding - "input" in context input parameter to encoder
Is it possible to add third constructor into FLACFileOutputStream.
public FLACFileOutputStream(FileOutputStream fos) { this.fos = fos; isValid=true; position=0;}
OR
pass-through exceptions produced in existing two constructors?
Creating FileOutputStream can produce IOException, which can be directly thrown through implemented AudioFileWriter.write(…) method
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sounds fair enough, I'll do both actually(both options have their place). I also am altering the method seek(int), to throw an IOException(though you probably won't need that), and deprecating isValid() since it would no longer be necessary.
I should add, that this is still fairly new code(not used by many but myself yet), so there's obviously some bugs to work out. Make sure you test it with your expected audio format, as it won't likely work yet for everything the FLAC reference encoder supports. I've tested it with various configurations using 16 bit sample size(the most common), and it seems to be stable for that format.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have prepared integration (prototype) of FLACEncoder with javax sound SPI AudioFileWriter. Somehow it is working, can you please look at it? Where may I send sources to you? If you like it, you can add it to your library. (some parts were reused from FLAC_FileEncoder.java)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Great! I enabled the Tracker module. I think the "Feature Request" or "Support Request" tracker would be a good spot for this; there is an option to upload files when making the tracker entry.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for sharing this :) I've looked through the file and integrated it with the library. I changed a couple IOExceptions to IllegalArgumentException(which better matches what the SPI library expects, according to the documentation). I moved some of the code that was common between FLACFileWriter and FLAC_FileEncoder into a new class, and improved the detection of format-support(testing more than just the sample-size now, as well as moving the test into the getAudioFileTypes(AudioInputStream) method ). I also finished out the implementation by adding support for OutputStream. You can check out the result so far in the file attached to the Feature-Request tracker item, which has the sources and spi-enabled jar file(there are other, unrelated changes in this file as well, but they shouldn't affect anything if you're depending only on SPI support). This release should be more stable(including fixed 24 bit encoding), but I want to do more testing and finish the documentation before I post it as a normal file-release.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
oops, I thought you would get an auto-response from the tracker since you created the entry. I'll be sure to post a comment as well from now on when I post files. Please let me know if the updated file works right for you or not.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've tested and it looks fine. I have only one problem and I dont know if it is a problem in sound player or FLAC encoder.
Following use case: I 've downloaded test FLAC file, then converted it to WAV and back to FLAC.
jFLAC sound player (version 1.3) plays downloaded FLAC, but throws exception, when wants to play converted FLAC (exception see tracker)
I've played all these files in Amarok, everything is OK. I'm not expert, it looks like jFLAC player has some limited support to FLAC files. Can you please have a look at it and say, what differences can be between original and converted FLAC streamed by FLAC encoder? If you have more place somewhere I can post to you all three test files.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if it'll fit in email, you can email it to me at plwwwJavaFlacEncoder@gmail.com. Otherwise, perhaps you can upload it to a site like megaupload.com or sendspace.com, and email me the link.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using the JFlac-1.3 SndPlayer class, I'm not able to play any flac files. I Just get UnsupportedAudioFileException. It appears the JFlac SPI services aren't being properly registered(this is different from the error you're asking about, of course). Can you confirm, is this the player you're using? If so, what is your command to start it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I remade the jflac jar file, with the appropriate services files. I'm now recreating your error(the original plays, the converted does not).
Using the flac reference decoder, the converted file tests as good. I'm also able to decode both files into the exact same wav file using the reference decoder(exact same, md5 hashes match). I've tried this with another test file encoded by my library, and I ended up with it playing, but it skipped the first half the audio. The exception given by JFlac on your converted file is an EOFException, which makes me think it is skipping over something that it doesn't understand. I've also tested with mplayer, and all files play just fine. Since it is only failing on files made by my code, I must be doing something unexpected(but not necessarily wrong, as it works in other players).
I'll mess with this again later and see if I can find what's going on.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Welcome to Open Discussion
Hey,
I wanted to say this project is awesome! Thanks so much for creating this- I was worried I would have to do an implementation of a FLAC encoder in Java myself. You are a total Boss.
thanks for the feedback :) Glad to hear it's getting some use.
I just posted an update. There's several important bug fixes, as well as some minor performance improvements. Be sure to post any bugs you may find to the help forum.
Hi,
I evaluate this encoder for use in one project. I have following questions:
1. Do you plan to implement integration with javax sound SPI?
2. Do you plan to improve error reporting in near future?
Thanks
Hi Krutelp,
I didn't need the javax sound SPI for what I was doing, so didn't really consider it. I may at some point wrap the encoder in a AudioFileWriter implementation, and read directly from an AudioInputStream, which could simplify the encode process(is this what you're referring to?)
I do plan to improve error reporting, but not sure when(probably not "near future"). I'm able to work on this project a bit in spare time only. Be sure to let me know if there's any specific cases you find that need improved, I'll try to target those first.
Hi plwww,
yes, that's exactly what I refer to. If your FLAC encoder can be plugged to javax sound SPI too, it has next + (we plan to use jFLAC stable library, which is plugged to javax sound SPI, but FLAC encoder implementation is "to be done")
As for error reporting, I have no concrete issues, but I've read ToDo file, that errors can be ignored and encoder tells nothing about it. For our project it is enough error reporting of type "encoding not sucessfull" in some form in order to inform users there was FLAC encoding problem.
If I recall correctly, the only potential errors I know of that may not be handled/reported properly would occur when using the threaded methods(handling of an IOException in a child thread). I do intend to fix this issue at some point. Non-threaded mode should avoid this issue though.
Hi plwww,
I tried to integrate FLACEncoder into javax sound SPI and I've found first problem - encoder needs as input FLACOutputStream (wrapper for FileOutputStream), but in javax sound SPI I have this stream already in hand and there is no possibility just to set such stream (also extension of FLACOutputStream is not possible, because members are package protected)
Can you please enhance implementation?
This is probably just a mistype, but FLACOutputStream only is used for output, not input(input is in the form of int arrays);
The methods in FLACOutputStream are supposed to be public, I'll fix that and post an update in a few minutes. You should then be able to wrap the OutputStream or File that the SPI provides, into a FLACOutputStream.
Let me know of any other issues you find, and I'll try to fix them.
Hi plwww,
it was misunderstanding - "input" in context input parameter to encoder
Is it possible to add third constructor into FLACFileOutputStream.
public FLACFileOutputStream(FileOutputStream fos) { this.fos = fos; isValid=true; position=0;}
OR
pass-through exceptions produced in existing two constructors?
Creating FileOutputStream can produce IOException, which can be directly thrown through implemented AudioFileWriter.write(…) method
Sounds fair enough, I'll do both actually(both options have their place). I also am altering the method seek(int), to throw an IOException(though you probably won't need that), and deprecating isValid() since it would no longer be necessary.
I should add, that this is still fairly new code(not used by many but myself yet), so there's obviously some bugs to work out. Make sure you test it with your expected audio format, as it won't likely work yet for everything the FLAC reference encoder supports. I've tested it with various configurations using 16 bit sample size(the most common), and it seems to be stable for that format.
Hi plwww,
I have prepared integration (prototype) of FLACEncoder with javax sound SPI AudioFileWriter. Somehow it is working, can you please look at it? Where may I send sources to you? If you like it, you can add it to your library. (some parts were reused from FLAC_FileEncoder.java)
Great! I enabled the Tracker module. I think the "Feature Request" or "Support Request" tracker would be a good spot for this; there is an option to upload files when making the tracker entry.
Added to tracker, feature requests section.
Thanks for sharing this :) I've looked through the file and integrated it with the library. I changed a couple IOExceptions to IllegalArgumentException(which better matches what the SPI library expects, according to the documentation). I moved some of the code that was common between FLACFileWriter and FLAC_FileEncoder into a new class, and improved the detection of format-support(testing more than just the sample-size now, as well as moving the test into the getAudioFileTypes(AudioInputStream) method ). I also finished out the implementation by adding support for OutputStream. You can check out the result so far in the file attached to the Feature-Request tracker item, which has the sources and spi-enabled jar file(there are other, unrelated changes in this file as well, but they shouldn't affect anything if you're depending only on SPI support). This release should be more stable(including fixed 24 bit encoding), but I want to do more testing and finish the documentation before I post it as a normal file-release.
Hi plwww,
Great! :-) Looks good - I've added some comments to integration.
Looks like there is bug in new implementation - see attached ZIP and comments in tracker.
Hi plwww,
can you please fix bug in FLACFileWriter.java and add all-zip to tracker? I want to test the encoder library "as is".
Sorry, now I see it is already done :-)
oops, I thought you would get an auto-response from the tracker since you created the entry. I'll be sure to post a comment as well from now on when I post files. Please let me know if the updated file works right for you or not.
I've tested and it looks fine. I have only one problem and I dont know if it is a problem in sound player or FLAC encoder.
Following use case: I 've downloaded test FLAC file, then converted it to WAV and back to FLAC.
jFLAC sound player (version 1.3) plays downloaded FLAC, but throws exception, when wants to play converted FLAC (exception see tracker)
I've played all these files in Amarok, everything is OK. I'm not expert, it looks like jFLAC player has some limited support to FLAC files. Can you please have a look at it and say, what differences can be between original and converted FLAC streamed by FLAC encoder? If you have more place somewhere I can post to you all three test files.
if it'll fit in email, you can email it to me at plwwwJavaFlacEncoder@gmail.com. Otherwise, perhaps you can upload it to a site like megaupload.com or sendspace.com, and email me the link.
Mail with test data sent.
Using the JFlac-1.3 SndPlayer class, I'm not able to play any flac files. I Just get UnsupportedAudioFileException. It appears the JFlac SPI services aren't being properly registered(this is different from the error you're asking about, of course). Can you confirm, is this the player you're using? If so, what is your command to start it?
Yes … I forgot. jFLAC JAR is not build correctly, you must add services directory in META-INF
Ok, I remade the jflac jar file, with the appropriate services files. I'm now recreating your error(the original plays, the converted does not).
Using the flac reference decoder, the converted file tests as good. I'm also able to decode both files into the exact same wav file using the reference decoder(exact same, md5 hashes match). I've tried this with another test file encoded by my library, and I ended up with it playing, but it skipped the first half the audio. The exception given by JFlac on your converted file is an EOFException, which makes me think it is skipping over something that it doesn't understand. I've also tested with mplayer, and all files play just fine. Since it is only failing on files made by my code, I must be doing something unexpected(but not necessarily wrong, as it works in other players).
I'll mess with this again later and see if I can find what's going on.