Does anyone know of a library for either python, c(++), or java , or even an external app, that I can use to check for a specific audio distortion in an mp3? My problem is this:
I have a very robust Django app that automatically does podcasting for a radio station for all the different shows, but about once a week the computer that does the actual recording records corrupted audio, that has a specific interence pattern, it's a chopping sound almost like a helicopter where the audio drops several times a second. I'm not hoping to fix those audio files(as I've tried manually with good editing software and it's just a lost cause) but rather detect weither or not that type of corruption is present so I can switch to the back-up version of the recording automatically. external tools should ideally run on linux, but windows is acceptable as long as it is headless(no forced gui).
Thanks.
I think all you will need to do is do an fft on the mp3 and you should see a really low frequency spike which corresponds to the big drops. I'm no dsp guru though so not sure that this will work, but its easy to try.
You can use the numpy library for python for this. Link
just read in the mp3 file into an array and then do an fft, for a test I would recommend just plotting it first (using maptlotlib for example), with both versions, corrupt and good and see if you can easily detect the corrupt version. Then hopefully you can write a simple algorithm to detect corrupted files from there fft's.
For reading in the mp3 into a data buffer you can use PyMedia http://pymedia.org/
I haven't used PyMedia so i'm not sure on reading the mp3 into a buffer (it shouldn't be too complicated I imagine), but after that plotting the fft is as simple as:
from numpy import *
from numpy.fft import *
import pylab
# place code to read the mp3 file into buf[] here.
buf_fft = fft(buf, 1024)
pylab.plot(fftfreq(1024, 0.1), abs(buf_fft))
pylab.show()
Try BASS Library and see if it has what you are looking for.
Related
I was able to follow the examples of how to encode video with io.humble easily enough. But, the only example of including audio that I can find simply encodes audio at the beginning of the video. I can't figure out how to encode samples at arbitrary locations. Using setTimestamp doesn't do anything.
Here is the example I found:
https://www.javatips.net/api/myLib-master/myLib.AGPLv3/myLib.humble.test/src/test/java/com/ttProject/humble/test/BeepSoundTest.java
If I modify the beepSamples() method to increase the "sampleNum" value, I can create a longer tone. But calling the method multiple times or setting samples.setTimestamp() to other values or calling setTimestamp() on the packets, all do nothing.
No matter what I do, the audio always shows up at the beginning of the video.
Ultimately, I want to be able to load arbitrary mp3 files of various audioclips and then merge them into the audio stream of the video at specific timestamps. But I can't even get this example to encode at different points in the video stream.
The author of this tool unfortunately is not interested in maintaining it or providing examples. Luckily, I found JavaCV which is an alternative that turned out to be really easy to use.
So to anyone else having this problem, I recommend switching to JavaCV. Other options are also JCodec and Xuggler, but Xuggler is deprecated (same author as io.humble) and JCodec apparently is slow and produces much larger files.
If you need support with these kind of projects. I maintain a fork of Xuggler (https://github.com/olivierayache/xuggle-xuggler)..I can provide help on these topics.
I need to be able trim wav audio files for an application I'm building.. but I have several problems.
I tried using FFmpeg-android, but if you target the latest SDK, and in the future, android no longer allows using "FFmpeg.execute". I also tried with the newer mobile-FFmpeg, but the developer stopped maintaining it a few months ago... I also would like to avoid heavy frameworks to also work with video, since I only need to work with audio. I can't find answers anywhere, what am I supposed to do?
You can use AudioTrack to write PCM.
I don't know how one translates input files into PCM data. But once it is in that form, you can edit it to suit your needs and then use AudioTrack to play back the result.
Maybe the MediaExtractor.readSampleData method can be used to read the audio data into an array where you can get to it and do your trimming. I've not done enough with Android to know if this is a viable plan or not.
I need a function that I can call, that plays a sound. It needs to have a parameter where I can give it the name of the file I'm trying to play. I've tried searching on the internet, but it's all mostly based around the sun library. And that gives me a warning. Thanks in advance.
You can use Java media framework to play media. As for the method :)
that you have to customize as per your need.
Or if you just want beep sounds, you can use bell character or create beep using awt toolkit
//Bell character
System.out.println("\007");
//Toolkit
java.awt.Toolkit.getDefaultToolkit().beep();
The Java Tutorials, for some reason, doesn't have a simple example of playing a sound in the fire-and-forget manner that you are asking about. But there are other tutorials online that do so.
The search term that will be of most help is "Clip" from the library javax.sound.sampled. This is a core library, so there is no need to import anything. The Clip class loads audio files in RAM, and allows you to play them back from RAM on demand. It is mostly used for short sounds. You should be able to find some code examples if you include "java clip" in a search.
Also in that library is SourceDataLine. This is often used for sounds that are too large to hold in memory. The class plays back data that you provide to its write() method. Thus it is common to pair the class with an AudioInputStream that was set up to read data from a file location. Again, there should be code examples if you search on the class name.
I made use of SourceDataLine to write a small audio library which can be found on GitHub, called AudioCue. The syntax is simpler than with Clip, assuming your source file is a wav file with 16-bit encoding, 44100 fps, stereo, low-endian (also known as "CD Quality"). To make use of it, there are six classes to load. You can just cut and paste. It is kind of a "super Clip" in that it allows extra capabilities like real time volume, panning and variable speed playback, as well as concurrent playback. There is a simple "fire-and-forget" example posted in the README.MD
The library is free to use. (BSD-type license.)
I am trying to convert a mp3 file into WAVE format in my Android application. This operation should take little time, as the application is social, and it is not acceptable for the user to wait for too long.
So here is where I am :
I have already tried to use JLayer (proposed in a similar question Convert mp3 to wav on Android), but the conversion is too slow: it takes about 40 seconds for a 2 minutes mp3 file.
Concerning the library LAME (as in Lame4Android), I also tried it (with Android NDK) but the result is still too slow (15s to 10s).
I came across another library: JUCE, but it is too vast, and including the entire library in the project in order to do that simple conversion seems a bit... excessive. And I am also afraid it will slow the application.
So what I am currently looking for is a C/C++ library to use in order to do that.
Do you know any fast libraries?
Thank you.
Not sure if the license will work for you (GPLv2), but have you considered libmad?
As I understand it, there's not a NDK build available for download, but here is a page describing how to make one yourself...
Another option is libmpg123, which is LGPLv2.1. The same blog has an article describing how to use it in Android.
I am looking for a 100% Java solution for encoding software generated images into an AVI stream together with an uncompressed audio track.
At the moment I am using JMF, but its size and installation problems make it a bad solution for my purpose.
While it does not support audio, I created an MJPEG AVI Java class some years ago. You basically just tell it the resolution of your output video, along with the frame rate, then you just keep adding images to it. When you are done, you tell it to finish and it'll close out the AVI. It is based off of the Microsoft documentation on AVI, RIFF, and BITMAP file formats.
Other than not supporting audio, the only real problem is it implements the version of the AVI format limited to 2GB per file. While the class will write out a much larger file, I am uncertain that any players or video editors would be able to read it.
The way I've used this code in the past, is to generate an MJPEG AVI for processing in a video editor (adding audio, etc. in the editor). It helped me with automating some tedious slide show generation. Not sure if this code will help you, as is, but it might help if you are trying to roll your own solution. MJPEGGenerator.java is available if you are interested!
You can use JMF, see this nice example.
There is a nice blog entry here:
http://www.randelshofer.ch/blog/2008/08/writing-avi-videos-in-pure-java/
By Werner Randelshofer