Coder Social home page Coder Social logo

lincollincol / audiotool Goto Github PK

View Code? Open in Web Editor NEW
65.0 1.0 19.0 290 KB

Android library that provides audio manipulation functions like increase/decrease speed, pitch, volume, bass, etc. Library also provides cut, noise remover, and other interesting and helpfull functions

License: Apache License 2.0

Java 100.00%
android android-library audio audio-processing audio-library music cut bass noise vocal

audiotool's Introduction

AudioTool

GitHub GitHub release (latest by date) GitHub All Releases

GitHub followers GitHub stars GitHub forks

AudioTool - an android library that provides useful audio processing functions. This library based on FFMPEG and uses mobile-ffmpeg library

AudioTool provides:

  • Filters
    • filterAudio(. . .)
    • removeAudioNoise(. . .) - remove noise from audio
    • normalizeAudioVolume(. . .) - normalize audio volume
  • Equalizer
    • changeAudioBass(. . .) - reduce or increase audio bass
    • changeAudioVolume(. . .) - reduce or increase audio volume
    • changeAudioPitch(. . .) - reduce or increase audio pitch
    • changeAudioSpeed(. . .) - reduce or increase audio speed
  • Effects
    • applyShifterEffect(. . .) - apply audio pan shifter effect
    • applyReverbEffect(. . .) - apply audio reverb effect
    • applyEchoEffect(. . .) - apply audio echo effect
    • reverseAudio(. . .) - reverse audio
  • Modificators
    • cutAudio(. . .) - cut audio
    • convertVideoToAudio(. . .) - convert video to audio
    • joinAudios(. . .) - join few audio files to single
  • Other
    • generateWaveform(. . .) - generate image waveform (png)
    • getMaxLevelData(. . .) - retrive audio max level data (data can be used to draw waveform)
    • getDuration(. . .) - retrive audio duration

Example

Note: every function will modify previous audio.

Input audio -> cut -> apply effect -> filter -> output audio with all these modifications

AudioTool.getInstance(this)
  .withAudio(new File("/storage/emulated/0/Music/Linc - AudioTool.mp3"))
  .removeVocal(new OnFileComplete() {
    @Override
    public void onComplete(File output) {
      // Output file - audio without vocal
    }
  })
  .applyEchoEffect(Echo.ECHO_OPEN_AIR, new OnFileComplete() {
    @Override
    public void onComplete(File output) {
      // Output file - audio file with echo effect and without vocal 
    }
  })
                      
  /* calls */
  .release();

If you want to save current audio file state - use saveCurrentTo(path). Current audio will be saved as separate file and AudioTool continue modify input file from withAudio() parameters.

AudioTool.getInstance(this)
  .withAudio(new File("/storage/emulated/0/Music/Linc - AudioTool.mp3"))
  .removeVocal(output-> {/* do something with output */})
  .applyEchoEffect(Echo.ECHO_OPEN_AIR, output-> {/* do something with output */})
  .saveCurrentTo("/storage/emulated/0/Music/NewAudio.mp3") // Audio file with echo and without vocal
  .release();

You can save audio to new file after every function call

AudioTool.getInstance(this)
  .withAudio(new File("/storage/emulated/0/Music/Linc - AudioTool.mp3"))
  .removeVocal(output-> {/* do something with output */})
  .saveCurrentTo("/storage/emulated/0/Music/Instrumental.mp3") // Audio file without vocal
  .applyEchoEffect(Echo.ECHO_OPEN_AIR, output-> {/* do something with output */})
  .saveCurrentTo("/storage/emulated/0/Music/NewAudio.mp3") // Audio file with echo and without vocal
  .release();

If don't need result from callbacks, you can pass null as a parameter

AudioTool.getInstance(this)
  .withAudio(new File("/storage/emulated/0/Music/Linc - AudioTool.mp3"))
  .removeVocal(null) // It's ok. 
  .saveCurrentTo("/storage/emulated/0/Music/Instrumental.mp3") // Save audio without vocal to local file 
  .release();

Also, don't forget to call release() function when you finish work with AudioTool. The function remove buffer files from storage and clear other resources.

AudioTool.getInstance(this)
  .withAudio(new File("/storage/emulated/0/Music/Linc - AudioTool.mp3"))
  /* calls */
  .release(); // Always call this function 

FFmpeg

When you add AudioTool to your project, you also should implement tanersener mobile-ffmpeg library which provides you full access to ffmpeg funcitons!

Download

Gradle

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.lincollincol:AudioTool:1.2.1'
  implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1.LTS'
}

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>
<dependency>
  <groupId>com.github.lincollincol</groupId>
  <artifactId>AudioTool</artifactId>
  <version>1.2.1</version>
</dependency>

Permissions

Add permissions to Manifest.xml file in your app and grant it, before using AudioTool

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

WARNING

AudioTool process audio in the main thread ! You can run AudioTool functions with RxJava, Kotlin coroutines and Java Threads to process audio in the background therad.

AudioTool don't process audio in the background thread because of :

  • You can use your own approach to work in the background thread. It makes AudioTool library more flexible.
  • Reduce library size. Third-party library uses a lot of space and AudioTool delegates this task to user.

Feedback

[email protected]

License

   Copyright 2020 lincollincol

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

audiotool's People

Contributors

lincollincol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

audiotool's Issues

Add reverb effects

Hello, I am using your library and it is literally amazing. My workload has reduced 10x times.

When I am trying to apply reverb at any value, the output is very faint and the log is as follows:

Lavc58.65.102 libmp3lame
2021-06-08 17:35:41.128 23842-13241/com.mehoot.audiotesting I/mobile-ffmpeg: size= 41kB time=00:00:02.59 bitrate= 130.3kbits/s speed=31.9x
2021-06-08 17:35:41.128 23842-13241/com.mehoot.audiotesting I/mobile-ffmpeg: video:0kB audio:41kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
2021-06-08 17:35:41.128 23842-13241/com.mehoot.audiotesting I/mobile-ffmpeg: 0.869648%

What is the recommended way of applying reverb to using this library?

Please help!

Kindly provide access to com.arthenica:mobile-ffmpeg

Hello,

Thanks for this wonderful library which i am using in one of my apps and it works perfectly.

Currently, i would love to do some other tasks with ffmpeg and i see that your library already imports this library. com.arthenica:mobile-ffmpeg.

How do i have access to com.arthenica:mobile-ffmpeg as i ndont want to import it again to prevent my apkk size from becoming too big.

i tried this, import com.arthenica.mobileffmpeg.FFmpeg, it doesnt work

Open source

You have open source code for two libraries 'com.github.lincollincol:AudioTool:1.2.1' and
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1.LTS' ?

How to use it in realtime audio Data?

I was working on realtime audioProcessing changing pitch, speed and adding effects. I checked various libraries like ffmpeg but all of them work on a save file, instead of realtime byteArray or ShortArray. I checked examples in readme. Can this be used directly on the ByteArray audioData?

Thank you

Change the tempo and pitch using ExoPlayer PlayBackParamters

Thank you so much for your awesome lib, I'm using ExoPlayer to change the audio PlayBackParamters :

  public void setSpeed(float speed) {
        PlaybackParameters param = new PlaybackParameters(speed, (float) getCurrentPitch());
        player.setPlaybackParameters(param);
    }


    public void setPitch(float pitch) {
        PlaybackParameters param = new PlaybackParameters((float) getCurrentTempo(), pitch);
        player.setPlaybackParameters(param);
    }

Now I'm trying to save the modified audio into the storage using your library, but I'm facing an issue the output tempo and pitch is completely different from the exoplayer :

e.g. PITCH : 0.86883157 | TEMPO : 0.8699582800000001

In exoplayer those parameters should make the audio slower, when I use your lib as follows :

                try {
                        AudioTool.getInstance(this)
                                .withAudio(copiedPath)
                                .changeAudioPitch(44100, pitch, tempo, null).saveCurrentTo(outputPath);

                    } catch (IOException e) {
                        e.printStackTrace();
                    }

The output playback audio becomes faster instead of slower, I will be very thankful if you help me out with this issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.