Giter Site home page Giter Site logo

bullheadandplato / androidequalizer Goto Github PK

View Code? Open in Web Editor NEW
227.0 8.0 70.0 6.33 MB

Android Equalizer View that can also manage the audio track frequencies

License: Apache License 2.0

Java 100.00%
android android-equalizer audio-track-frequencies android-library music

androidequalizer's Introduction

AndroidEqualizer

Android Equalizer View that can also manage the audio track frequencies

Add Equalizer in your Android app

How To Use

STEP 1

In settings.gradle you can add the repositories you want to add to the project:

repositories {
        google()
        jcenter() // Warning: this repository is going to shut down soon
        mavenCentral()
        maven { url 'https://www.jitpack.io' } // this is the line to be added
    }

and:

dependencies {
      implementation 'com.github.bullheadandplato:AndroidEqualizer:2.2'
}

if not using AndroidX. it will not have DialogEqualizerFragment or any other improvements

dependencies {
     implementation 'com.github.bullheadandplato:AndroidEqualizer:1.0'
}

STEP 2

For Equalizer in dialog

 DialogEqualizerFragment fragment = DialogEqualizerFragment.newBuilder()
                    .setAudioSessionId(sessionId)
                    .themeColor(ContextCompat.getColor(this, R.color.primaryColor))
                    .textColor(ContextCompat.getColor(this, R.color.textColor))
                    .accentAlpha(ContextCompat.getColor(this, R.color.playingCardColor))
                    .darkColor(ContextCompat.getColor(this, R.color.primaryDarkColor))
                    .setAccentColor(ContextCompat.getColor(this, R.color.secondaryColor))
                    .build();
            fragment.show(getSupportFragmentManager(), "eq");

For Equalizer in your view

Create a frame in your layout file.

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        android:id="@+id/eqFrame"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
        

In your Activity class

 int sessionId = mediaPlayer.getAudioSessionId();
        mediaPlayer.setLooping(true);
        EqualizerFragment equalizerFragment = EqualizerFragment.newBuilder()
                .setAccentColor(Color.parseColor("#4caf50"))
                .setAudioSessionId(sessionId)
                .build();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.eqFrame, equalizerFragment)
                .commit();

This work is mostly borrowed from https://github.com/harjot-oberai/MusicDNA

androidequalizer's People

Contributors

bullheadandplato avatar kl3jvi 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidequalizer's Issues

Does this library work with soundPool object ?

i want to use this library with soundPool but it not work
`int streamId = soundPool.play(soundID, volume, volume, 2, -1, rate);
DialogEqualizerFragment fragment = DialogEqualizerFragment.newBuilder()
.setAudioSessionId(sessionId)
...
.build();

fragment.show(getSupportFragmentManager(), "eq");`

App crashing

Fatal Exception: java.lang.IllegalArgumentException
AudioEffect: bad parameter value
in onCreate method

Not working on Android 12

Hi. Sometimes it works, sometimes it doesn't. I couldn't figure out what caused the problem. I didn't get any logs about this problem

Compile Please

Hello,

Compiling fails with a gradle build error:

Welcome to Gradle 5.4.1!

Here are the highlights of this release:

  • Run builds with JDK12

  • New API for Incremental Tasks

  • Updates to native projects, including Swift 5 support

For more details see https://docs.gradle.org/5.4.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

  • What went wrong:

Task 'compile' is ambiguous in root project 'AndroidEqualizer-master'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTestJavaWithJavac', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestShaders', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugRenderscript', 'compileDebugShaders', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources', 'compileLint', 'compileReleaseAidl', 'compileReleaseJavaWithJavac', 'compileReleaseRenderscript', 'compileReleaseShaders', 'compileReleaseSources', 'compileReleaseUnitTestJavaWithJavac', 'compileReleaseUnitTestSources'.

  • Try:

Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

BUILD FAILED in 33s

Im very new to gradle and I just dont know what to do - can you please compile this?
Thank you!

adding enable and disable equalizer.

Am trying to add enable and disable in my app so i tried below but unable to save setting in shared preference. So kindly help me to add this function. below is what i tried.

private void loadEqualizerSettings(){
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

        Gson gson = new Gson();
        EqualizerSettings settings = gson.fromJson(preferences.getString(PREF_KEY, "{}"), EqualizerSettings.class);
        EqualizerModel model = new EqualizerModel();
        model.setEqualizerEnabled(settings.isEqualizerEnabled);
        model.setBassStrength(settings.bassStrength);
        model.setPresetPos(settings.presetPos);
        model.setReverbPreset(settings.reverbPreset);
        model.setSeekbarpos(settings.seekbarpos);

        Settings.isEqualizerEnabled = settings.isEqualizerEnabled;
        Settings.isEqualizerReloaded = true;
        Settings.bassStrength = settings.bassStrength;
        Settings.presetPos = settings.presetPos;
        Settings.reverbPreset = settings.reverbPreset;
        Settings.seekbarpos = settings.seekbarpos;
        Settings.equalizerModel = model;
    }

    private void saveEqualizerSettings(){
        if (Settings.equalizerModel != null){
            EqualizerSettings settings = new EqualizerSettings();
            settings.isEqualizerEnabled = Settings.equalizerModel.isEqualizerEnabled();
            settings.bassStrength = Settings.equalizerModel.getBassStrength();
            settings.presetPos = Settings.equalizerModel.getPresetPos();
            settings.reverbPreset = Settings.equalizerModel.getReverbPreset();
            settings.seekbarpos = Settings.equalizerModel.getSeekbarpos();

            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

            Gson gson = new Gson();
            preferences.edit()
                    .putString(PREF_KEY, gson.toJson(settings))
                    .apply();
        }
    }

from above code you could notice i have added this line settings.isEqualizerEnabled = Settings.equalizerModel.isEqualizerEnabled(); instead of settings.isEqualizerEnabled = true; so that we have a extra function of enable and disable.

settings.java

public class EqualizerSettings {
    public boolean isEqualizerEnabled;
    public int[] seekbarpos = new int[5];
    public int presetPos;
    public short reverbPreset;
    public short bassStrength;
}

Screenshot_1569785199

Features

  1. Set the state of Switch before showing the Fragment
  2. Remember Custom Settings
  3. Enable Equalizer without displaying the Fragment

Is any of these supported, if yes please let me know the "How To"

Also, there is no Title on the dialog.

App appears after confusion AudioEffect: Bad parameter value

java.lang.RuntimeException: Unable to create service com.yfoo.listenx.service.PlayService: java.lang.IllegalArgumentException: AudioEffect: bad parameter value
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4823)
at android.app.ActivityThread.access$3000(ActivityThread.java:260)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by: java.lang.IllegalArgumentException: AudioEffect: bad parameter value
at android.media.audiofx.AudioEffect.checkStatus(AudioEffect.java:1346)
at android.media.audiofx.Equalizer.usePreset(Equalizer.java:335)
at com.bullhead.equalizer.EqualizerFragment.initEq(EqualizerFragment.java:22)
at e.p.c.i.k.(PlayerPresenter.java:56)
at com.yfoo.listenx.service.PlayService.onCreate(PlayService.java:17)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4809)
at android.app.ActivityThread.access$3000(ActivityThread.java:260) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2470) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:219) 
at android.app.ActivityThread.main(ActivityThread.java:8668) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109) 
2022-04-26 10:00:36.075 23057-23057/? E/AndroidRuntime: FATAL EXCEPTION: main

not support rtl orientation

When I change the language of the phone to arabic, the seekBars does not appear
can you fix in your library the orientation by adding this attribut

<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
  android:layoutDirection="ltr"
 ...
>

Licence

If you build / used some code from https://github.com/harjot-oberai/MusicDNA as per your README:

This work is mostly borrowed from https://github.com/harjot-oberai/MusicDNA

then you should publish it under the same licence, as the MusicDNA is publish under BY NC SA licence (BY - attribution, NC - non-commercial, SA - share alike). You only fulfilled the BY part. SA means you should not publish your work under different license if it's based on MusicDNA's code.

Why it matters: I am building a commercial app and was looking for open source equalizer. I can use code under Apache/MIT licence and add link to the repo in my app, but I am (obviously) not allowed to use code under NC licence.

issue with scrollview

When I use analog controller inside scroll view getting issue in click. Analog controller click not getting

How do i add Dialog Equalizer with ExoPlayer.

As per your documentation i was able to add in equalizer in activity but i was not able to open in Dialog. And also i want to add with ExoPlayer

is there any brief documentation, to add equalizer with exoplayer and open in dialog.

Or how can we do that ?

Library error

ERROR: Configuration with name 'testImplementation' not found.

That's how he's making mistakes.

My App crashes while trying to show dialog

`package me.arvin.audiofy.audioplayer;

import me.arvin.audiofy.R;

import android.app.Activity;
import android.app.ActivityManager;
import android.os.Handler;
import android.os.Build;
import android.content.Context;
import android.content.ComponentName;
import android.util.Log;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.PluginRegistry.Registrar;

import com.bullhead.equalizer.DialogEqualizerFragment;

public class EqualizerPlugin implements MethodCallHandler {
private static final Logger LOGGER = Logger.getLogger(EqualizerPlugin.class.getCanonicalName());

private final MethodChannel channel;
private final Handler handler = new Handler();

private Context context;
private FragmentActivity activity;

public static void registerWith(final Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "arvinciu/equalizer");
    channel.setMethodCallHandler(new EqualizerPlugin(channel, ((FragmentActivity)registrar.activity())));
}

private EqualizerPlugin(final MethodChannel channel, FragmentActivity activity) {
    this.channel = channel;
    this.activity = activity;
    this.context = activity.getApplicationContext();
    this.channel.setMethodCallHandler(this);
}

@Override
public void onMethodCall(final MethodCall call, final MethodChannel.Result response) {
    try {
    handleMethodCall(call, response);
    } catch (Exception e) {
    dispose();
    LOGGER.log(Level.SEVERE, "Unexpected error!", e);
    response.success(0); // error
    }
}

@SuppressWarnings("unchecked")
private void handleMethodCall(final MethodCall call, final MethodChannel.Result response) {
    final int sessionId = call.argument("sessionId");
    handleSendMessage("id: " + sessionId);
    switch (call.method) {
        case "show": {
            DialogEqualizerFragment fragment = DialogEqualizerFragment.newBuilder()
                .setAudioSessionId(sessionId)
                .themeColor(ContextCompat.getColor(this.context, R.color.EqprimaryColor))
                .textColor(ContextCompat.getColor(this.context, R.color.EqtextColor))
                .accentAlpha(ContextCompat.getColor(this.context, R.color.EqplayingCardColor))
                .darkColor(ContextCompat.getColor(this.context, R.color.EqprimaryDarkColor))
                .setAccentColor(ContextCompat.getColor(this.context, R.color.EqsecondaryColor))
                .build();

            try{
                if(!activity.isFinishing())fragment.show(activity.getSupportFragmentManager(), "equalizer");
            } catch (Exception e){
                handleSendMessage(e.toString());
            }
        }
    }
    response.success(2);
}

public void handleSendMessage(String text) {
    channel.invokeMethod("audio.sendMessage", buildArguments(text));
}

private static Map<String, Object> buildArguments(Object value) {
    Map<String, Object> result = new HashMap<>();
    result.put("value", value);
    return result;
}
  
private void dispose() {

}

}`

Can you help me what's wrong with my code?
There is a difference with the code, because i'm connecting Flutter with Java so the code must like that.
Thank you!

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.