Currently, I am working on an application that is taking a stream of audio (RAW encoded bytes) and is applying some transformations to it (resampling, converting stereo to mono etc..). I have implemented encoding raw bytes using opus codec thanks to JNI but I have a little problem:
Is there a way to listen to opus encoded stream saved to a file? I am aware that if I add some file headers and do some additional operations I should be able to save it as OGG file, but I do not want to waste time implementing functionality just to listen audio in the test.
Ideally, I would like to find a tool that would be able to play such stream, like audacity is playing RAW (after adding encoding parameters of course).
Thank you.
Did you try the opusdec utility from the OPUS tools package?
This utility should allow you to take opus stream and play it out as PCM encoded wav file which you should be able to pipe to a command-line .wav player and listen to it.
No need for any implementation, just a shell command executed via Runtime.Exec(),
Should do it
e.g. For a system with pulseaudio installed
yourstream.opus | padsp opusdec -
if no pulseaudio any wav player can use the wav stream output and play it.
For e.g.
opusdec --force-wav yourinput.opus - | <YOUR WAV Stream Accepting Player>
Related
I'm currently working on a project to encrypt MP3 audio using JAVA and produce garbled sound from that encrypted MP3 file. So far, I can encrypt the whole MP3 file using DES encryption method. However, this encrypted file is not playable using MP3 player. I know that MP3 file has some structure (header and data, etc), but I have no idea to implement encryption on this file without breaking the whole MP3 structure.
How to make this encrypted MP3 file playable?
Some more info about parsing and mp3 stream in java: JavaLayer is an mp3 decoder that naturally implements stream processing mostly with javazoom.jl.decoder.Bitstream class. It will skip all tag data and give you raw bytes for each frame.
Another library that does some mp3 stream parsing is jaudiotagger, maybe you can scavenge some code from there too.
Both of these libraries are distributed under LGPL, so just be aware of licensing issues.
How can I erase the silence (lower then the threshold) part of a wav file using Java?
Some say "pull samples out of the PCM data". How can I do that?
This should be straight forward. A wav is uncompressed so you can simply open it and process it using standard (binary) input streams.
For the actual audio processing, the Java Sound API will do the trick. Check out http://www.oracle.com/technetwork/java/index-139508.html for full details. Nice to play with.
I would like to perform a FFT on frames of an MP3 file using Java (think spectrum analyzer). I found JLayer which seems to fit the requirement of MP3 Decoding, but I'm not sure how to use it (Most examples are simply players that use the higher level helper, but that's not what I am looking for). FFT seems easy compared to decoding MP3 files ;)
My question is basically this: How would I take an MP3 file in java, and decode it to raw audio data for analysis in Java using JLayer
I am on the same Boat - trying to decode and analyze MP3 files using Java. You may want to check out MP3 SPI from the same author. There is a good example of getting the raw decoded PCM data from an MP3 file in his page:
http://www.javazoom.net/mp3spi/documents.html
Good luck,
Uri
I need to make a simple app in java, that capture some audio from microphone, and save it in file, using FLAC. I found tutorial :
http://www.developer.com/java/other/article.php/2105421/Java-Sound-Capturing-Microphone-Data-into-an-Audio-File.htm ,
but I need save file in flac audio, so I added jFLAC library, and I'm simply doing:
AudioSystem.write(new AudioInputStream(targetDataLine), FlacFileFormatType.FLAC, new File("junk.flac"));
but I get an exception :
java.lang.IllegalArgumentException: could not write audio file: file type not supported: FLAC
at javax.sound.sampled.AudioSystem.write(AudioSystem.java:1346)
at pl.com.stream.snippet.concurentmap_test.AudioRecorder02$CaptureThread.run(AudioRecorder02.java:211)
Is there any example or tutorial, that shows, how to save audio file in flac format in Java?
From the info. page on JavaSound:
Service Provider Interface
The Java Sound API uses a Service Provider Interface to identify encoders & decoders for sound formats and sequence types. This way, adding support for a new format or type is as simple as providing a decoder and/or encoder for it, adding an SPI file to the manifest of the Jar it is in, then adding the Jar to the run-time class-path of the application. ...
Further quote from that page:
Java Sound Capabilities
The capabilities of the sampled sound API can be obtained using such methods as AudioSystem.getAudioFileTypes() ...
I think if you iterate the array returned by that method, you will find that FLAC is not listed. The solution is to add a FLAC encoder using the SPI.
We have a requirement where we need to convert from .wav file to .mp3 and we are currently using "Tritonus" library to do that . The concern with that library is that requires "installation" of some "dll" files to the class path.
I am wondering are there any API's those allow better processing without local installation.
And other question is ,having mp3 format files will make it easier to join the files into a single file than having .wav files ?
As a former contributor to the JLayer MP3 Library, I'm fairly sure that it doesn't do WAV to MP3 - just MP3 playback and conversion to WAV. (I spent some time optimizing the decoder :-)
Regarding appending files (and possibly other operations), it is generally better to perform edit operations using the uncompressed format, and compress at the end.
I think the spec allows mp3 files to be concatenated, since they are a series of frames, but behaviour may vary from player to player.
So, to be safe, and maintain quality, I'd concat using WAVs and then compress the final result to MP3. Concating files is not so straightforward - you have to at least make sure they are at the same percieved volume, or you will get a noticible shift in volume from one file to the next. Such operations are definitely best performed on the uncompressed data.
The JLayer MP3 Library appears to support several operations on MP3 and WAV files including conversion, with no native libraries to install.
You can use MP3SPI to do this. This is a java sound plugin, just include the jar into the classpath, and you can use java sound api to convert between wav and mp3.