GithubHelp home page GithubHelp logo

neil-orzzh / craudiovisualizationview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cleveroad/waveinapp

0.0 1.0 0.0 1.63 MB

Live Audio Equalizer with wave effect

Home Page: https://www.cleveroad.com

License: MIT License

Java 100.00%

craudiovisualizationview's Introduction

Audio Visualization View

Implementation of music player concept. Welcome Live Equalizer with wave effect. As animation shows, when music plays the waves are active, and once it is paused or stopped โ€“ waves calm down.

Demo image

Setup process can be splitted into few steps.


#### Preparing AndroidManifest.xml #### * * * Audio visualization view uses OpenGL ES 2.0 for drawing waves. So you need to include this line in your manifest:
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />

All functionality built upon Visualizer object, so you also need to include this permissions in your manifest:

    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

You must be very careful with new Android M permissions flow. Make sure you have all necessary permissions before using GLAudioVisualizationView.


#### Including **GLAudioVisualizationView** into layout #### * * *

There are two ways to include GLAudioVisualizationView in your layout: directly in XML layout file or using builder in Java code.

Via XML:

    <com.cleveroad.audiovisualization.GLAudioVisualizationView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/visualizer_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:bubble_size="@dimen/bubble_size"
        app:randomize_bubble_size="true"
        app:wave_height="@dimen/wave_height"
        app:footer_height="@dimen/footer_height"
        app:waves_count="7"
        app:layers_count="4"
        app:background_color="@color/color_bg"
        />

Via Java code:

    new GLAudioVisualizationView.Builder(getContext())
        .setBubbleSize(R.dimen.bubble_size)
        .setRandomizeBubbleSize(true)
        .setWaveHeight(R.dimen.wave_height)
        .setFooterHeight(R.dimen.footer_height)
        .setWavesCount(7)
        .setLayersCount(4)
        .setBackgroundColorRes(R.color.color_bg)
        .setLayerColors(R.array.colors)
        .build();

#### Usage of **GLAudioVisualizationView** #### * * *

GLAudioVisualizationView implements AudioVisualization interface. If you don't need all GLSurfaceView's public methods, you can simply cast your view to AudioVisualization interface and use it.

    private AudioVisualization audioVisualization;
    
    ...
    
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        // you can extract AudioVisualization interface for simplifying things
        audioVisualization = (AudioVisualization) glAudioVisualizationView;
    }

...

To connect audio visualization view to audio output you can use linkTo(int) or linkTo(MediaPlayer) methods.

    // connecting to device's output mix
    audioVisualization.linkTo(0);
    ...
    MediaPlayer mp = MediaPlayer.create(...);
    audioVisualization.linkTo(mp);

You must always call onPause method to pause visualization and stop wasting CPU resources for computations in vain. As soon as your view appears in sight of user, call onResume.

    @Override
    public void onResume() {
        super.onResume();
        audioVisualization.onResume();
    }
    
    @Override
    public void onPause() {
        audioVisualization.onPause();
        super.onPause();
    }

When user leaves screen with audio visualization view, don't forget to free resources and call release() method.

    @Override
    public void onDestroyView() {
        audioVisualization.release();
        super.onDestroyView();
    }

#### Support #### * * * If you have some issues with visualization (especially on Samsung Galaxy S or HTC devices) make sure you read [this Github issue](felixpalmer/android-visualizer#5 (comment)).

If you have any other questions regarding the use of this library, please contact us for support at [email protected] (email subject: "Android visualization view. Support request.") or

Use our contacts:


#### License #### * * * The MIT License (MIT)
Copyright (c) 2016 Cleveroad Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

craudiovisualizationview's People

Contributors

iojjj avatar jekaua avatar

Watchers

 avatar

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.