Recording over existing audio file in android - java

I am currently building an app in android, and I am trying to record my audio over an existing audio file (without changing the length of the file), does anyone know how is it possible to do that? Everything I tried just puts the audio files one after another in one file.

A. You should use GGmpeg for Android, for example. Here you have some questions like yours.
question with code
more detailed tutorial
Google Group
another question
B. Another approach, although limited, is Android SoundPool. Check documentation here.
The sound pool requires you to manage multiple files rather than doing
mixdowns and playback of a single file. It would be cool if the
soundpool let you grap the output as a IOStream but, alas, the SDK
doesn't seem to allow it. Further, it would be nice if the
AudioRecorder allowed you to grab a stream from the music layer...but
that doesn't look possible either. List of audio inputs:
http://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html
SOURCE: https://stackoverflow.com/a/2254086/9415337
C. Others suggest also doing it in a backend server.
D. This might also help you.

Related

JOrbis can't read ogg file from JAR

I want to play an .ogg file, so i found this piece of code.
So it downloads .ogg file from the given url and plays it. I've tried it with external files like
ExamplePlayer player = new ExamplePlayer(new File("D:\\sound.ogg").toURI().toURL().toString())
and it works. But when i try this with internal files and get it using
ExamplePlayer.class.getClassLoader().getResource("sound.ogg")
it says that "There is a hole in the first packet data.". I think maybe it doesn't work because of JAR's compression or something.
So questions are: why it doesn't work? how could i fix it? If i can't fix it, is there any other way to play .ogg files using java? Thanks.
UPD: I found a lib, but the problem still the same, it cannot read from jar file. It
I'm looking at an application I wrote several years ago that uses ogg resources, and seeing that I first import the ogg file to an InputStream object using getResourceAsStream method.
Usually with wav files, importing via the URL is preferred. Unfortunately I don't recall why I did it this way--too much new tech under the bridge. First guess is that it's a requirement from the jcraft code, otherwise I would have used my preferred method.
Even if this works in the context of an IDE, IDK if it will also work after putting the code into a JAR. getResourceAsStream is often dicey in jars.
Before I invest more time, please let us know if switching to getResourceAsStream does the trick. Maybe the fix is that simple!
+++++++++++++
EDIT: Ugh. Looking at my code, I see where I copied a class from JCraft and edited it, supplying an InputStream via wrapper code. The edit was made in order to output float PCM data from the decoder rather than having the decoder play the sound. The float PCM is then saved in a custom object similar to AudioCue, and the app I wrote this for uses that for playback. All I can remember was that it took a lot tweaking to get this to work.

How to play the audio of a SoundCloud song via URL input

I am coding a Minecraft plugin, (Just a modification to the game Minecraft but used on a Minecraft server, not a client modification)
and I want to create something that when a player inputs
"/playsong"
along with a SoundCloud URL, it will find that URL and loop it.
(being able to play a soundcloud playlist will be much appreciated)
All the other work will be done by me. (checking if the URL is null, testing if the player sends /playsong along with a valid URL, etc.)
Adding comments with // telling me what certain bits of code do will be much appreciated.
Thank you for reading.
~Matthew274
This generally is not possible. Minecraft does not have any way to play an arbitrary song that requires downloading from a remote server. There are a few ways you could still do this, but it isn't simple.
One technique would be to take the song and attempt to convert it to a series of notes for use with /playsound (or noteblocks). That isn't easy nor will it give a perfect result, but it is hypothetically doable (though I don't know any of the details).
The other technique would be to create a resource pack, send it to the client, and then have them play the song. That as well is nontrivial, but still doable. The general procedure would be:
Find and download the song from soundcloud (I don't know soundcloud's API for this, but I assume they have one).
If necessary, convert the song into a .ogg file from .mp3. There's probably also a library for this.
Create a resource pack with that sound (and the appropriate sound index) and temporarily make it for download on your server.
Send a Resource Pack Send packet linking to that resource pack.
Wait for the client to respond with Resource Pack Status of "accepted".
Play the song using the Named Sound Effect packet (or /playsound).
This process is not simple, but if you do somethings like keeping a collection of songs in the playlist and sending multiple songs in the resource pack, you should be able to implement it. You'll need ProtocolLib to send custom packets.
I'm sorry I can't give code for this, but it's a complicated task that would require several parts, none of which I know the full details on.

How do I proceed in an attempt to find audio files which play the same song but are in different compressed formats?

all i want is suppose i have same song named as song.mp3 and song.aac now i want my program to identify that they are same, i know this is non-trivail task to do.
so far i have tried fingerprinting audio using dejavu python library which produces 2 different fingerprints for our case song.mp3 and song.aac, hence it doesnt suit need of my program.
I also tried MD5 using FFMPEG but as expected it gives different hash for even same songs downloaded from different websites
Do you guys have any idea how do I proceed?
It would be even great to provide me step wise procedure and library to achieve my goal.
thank you
Audio fingerprinting is incredibly complex, and difficult to get right. You do not really want to come up with your own algorithm just like that, because it likely is much worse than established methods (being better than established methods requires doing some research ;-)).
One of the open source solutions for audio fingerprinting which I found is http://echoprint.me/codegen
You can use that in your application, either by calling directly into the libcodegen API, or by spawning subprocesses for audio analysis.

Mixing audio on android with Jmusic

I have been working on a music app for android devices for the past few months. I have written a considerable amount of code so far. However, I have been stuck for almost a month on the mixing part of the code. Since Android does not offer a way to mix audio (merge sounds into one file so that they play at the same time) I decided to add the Jmusic library to the project and use it to manipulate audio files. Unfortunately, every time I try to read an audio file from the sdcard, the app crashes. I have been looking for resource online to solve this problem, but I can't find a good one. I am thinking that maybe Android does not support the use of other libraries. Can any of you guys suggest an alternative solution if that's the case. An example code (with explanation) using Java would be greatly appreciated. What I am mainly doing is declaring a float array (data) and reading the audio file as such
data = Read.Audio("string that holds the path of the file on the sd card");
what i think is android doesn't support javaSE environment..after the compilation process
Android produces dalvik code while java has it's byte code both of them being significantly different.

1-D barcode scanner(using images from a capturing device) implementation in java

I am a student and as a project i have to implement a barcode(1-D) based attendance marking system.While surfing across the web i came to know that barcode readers are a bit costly toys to purchase,so now what I want to do is I want to capture images of barcodes through a capturing device(mostly a webcam) and then process them to get the content stored in it.
I found a few projects on the internet that do the same but they use .NET f/w and I am not so familiar with .NET technology. The only project that uses java is http://sourceforge.net/projects/javabarcoderead/ but somehow i am not able to run the jar file they are providing.
SO, I would like to know about the algorithms or methods that can be used for the same or even any project from where i can get some insight on how to move further with this...
Happy Coding...
You're right, it would be very difficult to use a library with no documentation and no source code.
I'd suggest using ZXing. It's a well-documented library with lots of examples.

Categories

Resources