0

I'm trying to write a music player app for Android that allows the user to take the lead vocalist out of the song.

The math involved is like so:

amount_of_removal * ((left * (balance)) - (right * (1 - balance))) + (1 - amount_of_removal)*(left + right)

Is there any possible way to apply a custom AudioEffect to an audio stream? Even if I open and decode the file myself?

Raceimaztion
  • 9,494
  • 4
  • 26
  • 41
  • 1
    In theory (I tried unsuccessfully), if you take one of the channels and reverse it "vertically", it should remove the vocals (or leave the vocals only and then you have to subtact this from the full song, I don't remember well the procedure). There are videos on this on youtube. But I really don't know how could you do this on Android. – Phantômaxx Sep 04 '14 at 07:27
  • In addition to Frank's method, it's basically removing the "center" part of the sound. Most of the times it works since vocal tends to be in the center. But it really depends on the song; if the vocal "walks around" the removal will be less efficient. Unfortunately, I also don't know how to do it in Android since I never touch this area. – Andrew T. Sep 04 '14 at 07:47
  • I've provided an answer, and noted an important drawback to being too generic. Fortunately, it simplifies things tremendously. – Raceimaztion Sep 19 '14 at 11:05

1 Answers1

2

Okay, looks like I overlooked some rather important information when I posted this question.

Chief among them is the fact that most music formats are so-called "lossy", because they don't store everything that makes up the audio waveform. MP3, for example, basically disassembles a waveform into its component frequencies, but only stores the loudest ones, discarding the quieter ones.

Couple this with the fact that, for several styles of music, the lead singer is the loudest part of it (especially when they're singing), and you have some issues with sound quality, as some of the quieter frequencies are now needed, now that the lead singer isn't there to mask it.

This means that the best format to read from is actually the lossless ones, and probably one of the easiest is the ancient WAV file.

Overall, the steps required to do what I want is probably something like this:

  1. Load audio file (using the WavFile class, as specified by this answer)
  2. Apply custom audio effect to a buffer-full of the file at a time.
  3. Pass off a buffer full of processed audio to the sound card (using something like this example)

The only drawback I can see from here (not having tested this yet) are possibly performance issues, as using straight Java might be a little slow.

Community
  • 1
  • 1
Raceimaztion
  • 9,494
  • 4
  • 26
  • 41