All Projects → lincollincol → Amplituda

lincollincol / Amplituda

Licence: Apache-2.0 license
Amlituda - an android library that calculates amplitudes from audio and provides data in different formats. Based on this data, you can draw waveform. Android audio amplitude library.

Programming Languages

c
50402 projects - #5 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Amplituda

Awesome Web Audio
A list of resources and projects to help learn about audio
Stars: ✭ 73 (-2.67%)
Mutual labels:  audio-visualizer, audio-library, audio-processing
Waveform Playlist
Multitrack Web Audio editor and player with canvas waveform preview. Set cues, fades and shift multiple tracks in time. Record audio tracks or provide audio annotations. Export your mix to AudioBuffer or WAV! Project inspired by Audacity.
Stars: ✭ 919 (+1125.33%)
Mutual labels:  waveform, audio-visualizer
Sincnet
SincNet is a neural architecture for efficiently processing raw audio samples.
Stars: ✭ 764 (+918.67%)
Mutual labels:  waveform, audio-processing
Mpv Scripts
mpv lua scripts
Stars: ✭ 68 (-9.33%)
Mutual labels:  waveform, audio-visualizer
Spectrographic
Turn an image into sound whose spectrogram looks like the image.
Stars: ✭ 147 (+96%)
Mutual labels:  audio-visualizer, audio-processing
Img Encode
Encode an image to sound and view it as a spectrogram - turn your images into music
Stars: ✭ 157 (+109.33%)
Mutual labels:  audio-visualizer, audio-processing
Audio Oscilloscope
🎵 Waveform audio visualizer for the HTML5 canvas.
Stars: ✭ 54 (-28%)
Mutual labels:  waveform, audio-visualizer
Mwengine
Audio engine and DSP for Android, written in C++ providing low latency performance in a musical context, supporting both OpenSL and AAudio.
Stars: ✭ 190 (+153.33%)
Mutual labels:  audio-library, audio-processing
libvisual
Libvisual Audio Visualization
Stars: ✭ 67 (-10.67%)
Mutual labels:  audio-visualizer, audio-library
MusicVisualizer
A music visualizer based on the ATMEGA328P-AU
Stars: ✭ 30 (-60%)
Mutual labels:  audio-visualizer, audio-processing
drop
A LÖVE visualizer and music player
Stars: ✭ 17 (-77.33%)
Mutual labels:  waveform, waveform-visualizer
samplescope
Desktop app with the main goal to simplify audio samples search over the internet sources.
Stars: ✭ 23 (-69.33%)
Mutual labels:  samples, audio-samples
Xr3player
🎧 🎼 Advanced JavaFX Media Player
Stars: ✭ 472 (+529.33%)
Mutual labels:  audio-visualizer, audio-processing
wavebin
∿ Oscilloscope waveform capture viewer and converter.
Stars: ✭ 31 (-58.67%)
Mutual labels:  waveform, waveform-visualizer
R8brain Free Src
High-quality pro audio sample rate converter / resampler C++ library
Stars: ✭ 238 (+217.33%)
Mutual labels:  audio-library, audio-processing
Keras Sincnet
Keras (tensorflow) implementation of SincNet (Mirco Ravanelli, Yoshua Bengio - https://github.com/mravanelli/SincNet)
Stars: ✭ 47 (-37.33%)
Mutual labels:  waveform, audio-processing
Dplug
Audio plugin framework. VST2/VST3/AU/AAX/LV2 for Linux/macOS/Windows.
Stars: ✭ 341 (+354.67%)
Mutual labels:  audio-library, audio-processing
Libopenshot Audio
OpenShot Audio Library (libopenshot-audio) is a free, open-source project that enables high-quality editing and playback of audio, and is based on the amazing JUCE library.
Stars: ✭ 120 (+60%)
Mutual labels:  audio-library, audio-processing
Dswaveformimage
Generate waveform images from audio files in iOS
Stars: ✭ 228 (+204%)
Mutual labels:  waveform, audio-visualizer
songturtle
🐢 Play, slow down, and loop sections of audio files in the browser 🐢
Stars: ✭ 26 (-65.33%)
Mutual labels:  audio-visualizer, audio-processing

Amplituda

GitHub release (latest by date) GitHub

GitHub followers GitHub stars GitHub forks

What is Amplituda?

Amplituda - an android library based on FFMPEG which process audio file and provide an array of samples. Based on the processed data, you can easily draw custom waveform using the value of the processed data array as the height of the single column.
Average processing time is equal to 1 second for audio with duration 3 min 20 seconds and 1 hour audio will be processed in approximately 20 seconds.

You can also use WaveformSeekBar library which is fully compatible with Amplituda

⠀ ⠀

⠀ ⠀

⠀ ⠀

How to use Amplituda?

Example

/* Step 1: create Amplituda */
Amplituda amplituda = new Amplituda(context);

/* Step 2: process audio and handle result */
amplituda.processAudio("/storage/emulated/0/Music/Linc - Amplituda.mp3")
        .get(result -> {
            List<Integer> amplitudesData = result.amplitudesAsList();
            List<Integer> amplitudesForFirstSecond = result.amplitudesForSecond(1);
            long duration = result.getAudioDuration(AmplitudaResult.DurationUnit.SECONDS);
            String source = result.getAudioSource();
            InputAudio.Type sourceType = result.getInputAudioType();
            // etc
        }, exception -> {
            if(exception instanceof AmplitudaIOException) {
                System.out.println("IO Exception!");
            }
        });

/* And that's all! You can read full documentation below for more information about Amplituda features */

Download

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.lincollincol:amplituda:2.1.4'
}

Full documentation

• Process audio

Amplituda amplituda = new Amplituda(context);

/**
 * AmplitudaProcessingOutput<T> - wrapper class for Amplituda processing result.
 * This class stores the output audio processing data
 * and provides functions to obtain the result
 * Generic type T - audio source type: File, String (URL or path), Integer (res/raw) 
 */
AmplitudaProcessingOutput<T> processingOutput;

/* Process audio */

// Local audio file
processingOutput = amplituda.processAudio(new File("/storage/emulated/0/Music/Linc - Amplituda.mp3"));

// Path to local audio file
processingOutput = amplituda.processAudio("/storage/emulated/0/Music/Linc - Amplituda.mp3");

// URL audio
processingOutput = amplituda.processAudio("https://audio-url-example.com/amplituda.mp3");

// Resource audio
processingOutput = amplituda.processAudio(R.raw.amplituda);

• Compress output data

/** 
 * Compress result data (optional)
 * The output data can contain a lot of samples. 
 * For example: 
 *  - 5-second audio can contain 100+ samples
 *  - 3-minute audio can contain 7000+ samples
 * You can pass `Compress` params with the number of 
 * preferred samples per second and compress type as a parameter.
 * Compress types:
 * - Compress.SKIP    - take first number of `preferredSamplesPerSecond` and skip others 
 * - Compress.PEEK    - take peek number of `preferredSamplesPerSecond` and skip others
 * - Compress.AVERAGE - merge all samples to number of `preferredSamplesPerSecond`
 */ 
 
// Example: input audio duration - 10 seconds
 
amplituda.processAudio(<audio>, Compress.withParams(Compress.AVERAGE, 1));
// Output: data with 1 sample per 1 second. 
// Approximate output data size - 60 [duration] * 1 [preferredSamplePerSecond] = 60 [samples]

amplituda.processAudio(<audio>, Compress.withParams(Compress.AVERAGE, 5));
// Output: data with 5 sample per 1 second
// Approximate output data size - 60 [duration] * 5 [preferredSamplePerSecond] = 300 [samples]

• Handle progress

/**
 * AmplitudaProgressListener - progress listener class.
 * This class has 3 methods that describe current progress:
 *  - void onStartProgress() - amplituda start processing (optional)
 *  - void onStopProgress()  - amplituda stop processing (optional)
 *  - void onProgress(ProgressOperation operation, int progress) -
 *       amplituda process audio and share current operation and progress in percent (0-100)
 * onProgress() also inform about current operation:
 *  - PROCESSING  - amplituda start process audio
 *  - DECODING    - amplituda decode raw/res audio 
 *  - DOWNLOADING - amplituda download audio from url 
 */
amplituda.processAudio(
    <audio>,
    new AmplitudaProgressListener() {
        @Override
        public void onStartProgress() {
            super.onStartProgress();
            System.out.println("Start Progress");
        }

        @Override
        public void onStopProgress() {
            super.onStopProgress();
            System.out.println("Stop Progress");
        }

        @Override
        public void onProgress(ProgressOperation operation, int progress) {
            String currentOperation = "";
            switch (operation) {
                case PROCESSING: currentOperation = "Process audio"; break;
                case DECODING: currentOperation = "Decode resource"; break;
                case DOWNLOADING: currentOperation = "Download audio from url"; break;
            }
            System.out.printf("%s: %d%% %n", currentOperation, progress);
        }
    }
)

• Handle result and errors

AmplitudaProcessingOutput<T> processingOutput;
// . . . process audio . . .

/**
 * AmplitudaResult<T> - wrapper class for the final result
 * This class also provides many functions to format result: List<Integer>, String etc
 * and info about input audio: 
 *  - Input audio source: path to audio/resource or url. 
 *  - Source type according to input audio: FILE, PATH, URL or RESOURCE 
 *  - Audio duration
 * Generic type T - audio source type: File, String (URL or path), Integer (res/raw)
 */
 AmplitudaResult<T> result;
 
 /**
  * After processing you can get the result by calling the function get() 
  * This function has multiple overloads:
  *  - void get(successListener, errorListener)
  *  - void get(successListener)
  *  - AmplitudaResult<T> get(errorListener)
  *  - AmplitudaResult<T> get(successListener)
  */
 
// Overload #1: result as a callback with error listener
processingOutput.get(result -> { 
        /* handle result here */ 
    }, exception -> { 
        /* handle errors here */ 
    });

// Overload #2: result as a callback without error listener
processingOutput.get((AmplitudaSuccessListener<T>) result -> { 
    /* handle result here */ 
});

// Overload #3: result as a returned object with error listener
result = processingOutput.get((AmplitudaException exception) -> { 
    /* handle errors here */ 
});

// Overload #4: result as a returned object without error listener
result = processingOutput.get();

/**
 * Exceptions. More info about exceptions here:
 * https://github.com/lincollincol/Amplituda/tree/master/app/src/main/java/linc/com/amplituda/exceptions
 */
processingOutput.get((AmplitudaException exception) -> {
    if(exception instanceof AmplitudaIOException) {
        // Handle io exceptions
    } else if(exception instanceof AmplitudaProcessingException) {
        // Handle processing exceptions
    } else {
        exception.printStackTrace();
    }
});

• Format result

/**
 * Format result. As written earlier, AmplitudaResult
 * has many functions for formatting the result
 */
 AmplitudaResult<T> result;
 
 // Get result as list:
 List<Integer> samples = result.amplitudesAsList(); 
 System.out.println(Arrays.toString(samples.toArray()));
 // Output: [0, 0, 0, 0, 0, 5, 3, 6, . . . , 6, 4, 7, 1, 0, 0, 0]
 
 // Get result as list only for second `1`
 List<Integer> samplesForFirstSecond = result.amplitudesForSecond(1);
 System.out.println(Arrays.toString(samples.toArray()));
 // Output: [0, 0, 5, . . . 6, 4, 0]

// Get result as json format String
System.out.println(result.amplitudesAsJson());
// Output: [0, 0, 0, 0, 0, 5, 3, 6, . . . , 6, 4, 7, 1, 0, 0, 0]

// Get result as single line sequence format String (horizontal String)
System.out.println(result.amplitudesAsSequence(
        AmplitudaResult.SequenceFormat.SINGLE_LINE)
);
// Output: 0 0 0 0 0 5 3 6 . . . 6 4 7 1 0 0 0

// Get result as single line sequence format String with custom delimiter `*` (horizontal String)
System.out.println(result.amplitudesAsSequence(
        AmplitudaResult.SequenceFormat.SINGLE_LINE, " * ")
);
// Output: 0 * 0 * 0 * 0 * 0 * 5 * 3 * 6 * . . . 6 * 4 * 7 * 1 * 0 * 0 * 0

// Get result as new line sequence format String  
System.out.println(result.amplitudesAsSequence(
        AmplitudaResult.SequenceFormat.NEW_LINE)
);
/* Output: 
    0 
    0 
    5 
    3 
    . . . 
    6 
    1 
    0 
    0
    */

• Enable Amplituda logs (optional)

Amplituda amplituda = new Amplituda(context);

// Use default android Log constants to set priority. The second parameter - enable or disable logs. 
// Amplituda logs are disabled by default
amplituda.setLogConfig(Log.DEBUG, true);

Permissions

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

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

Reduce size

Add android:extractNativeLibs="false" to application in the Manifest.xml

<application
      . . .
    android:extractNativeLibs="false"
      . . . >
    <activity . . ./>
</application>

Feedback

[email protected]

License

   Copyright 2020-present 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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].