My question is simple: what is the default number of the bands provided by the built-in android equalizer? Also, what is the guaranteed minimum number of bands?
As far as I researched, the answer appears to be 5, but it is not very well documented. However, testing it on my devices, which is currently available, I got the following result:
HTC Desire S running android 2.3.5: 5 bands
Sony Xperia Tipo running android 4.0.x: 5 bands
however, Nexus 4 running Android 4.3.1: 6 bands
The way I get theese numbers is the following:
MediaPlayer mp=new MediaPlayer(this);
/* some initialization */
Equalizer eq=new Equalizer(0, mp.getAudioSessionId());
short bands=eq.getNumberOfBands();
So, on some devices, I may be able to get more bands, but the minimum number is 5?
Also, is that a good approach that I render the UI part of the equalizer dynamically, depending on how much bands the current device has, and then let the user set his own preferences?
Thanks in advance!
I can't tell the number of bands of device. It is hardware dependent. Samsung galaxy have 13 equalizer bands and some devices have greater than it.
You can simply create any number of bands programamtically.
Equalizer eq=new Equalizer(0, mp.getAudioSessionId());
short bands=eq.getNumberOfBands();
LinearLayout parentViewToAllEqualizerSeekBars = findViewById...
for(int i=0;i<(int)bands.length;i++)
{
//create seekbar programmatically and set it min max and add to the view
Seekbar seek = new SeekBar(this);
seek.min(equalizerMinLevel....)
seek.max(equalizerMaxLevel..)
parentViewToAllEqualizerSeekBars .addView(seek);
}
Now it will work on all devices.Whether it has band less than 5 or greater than 13.
Note:
Also check whether equalizer!=null must
I do not think there is a default number of bands, and you should not build your application assuming there is a default/fixed number of bands.
Definitely you will have to render your UI equalizer dynamically, based on device number of bands.
Because of low reputation i have to tell it to you here
Maximum number of bands are 8, I have created 8 seekbar and only show seekbar ==numberOfBands
How to implement Equalizer in android
Related
It is possible to change the frequency of the bands of an equalizer, or is only possible to use 60Hz 230 Hz 910 Hz 3600 Hz 14000 Hz?
I suppose you're talking about android.media.audiofx.Equalizer.
Different Android devices have different number of frequency bands, and you can set it freely between the supported ones, as the docs says:
setBandLevel(short band, short level)
Sets the given equalizer band to
the given gain value.
Parameters
band - short: frequency band that will have the new gain. The numbering of the bands starts from 0 and ends at (number of bands - 1).
level - short: new gain in millibels that will be set to the given band. getBandLevelRange() will define the maximum and minimum values.
This answer from WoodyDev gives us some example code to get range supported for the device:
// New instance of equalizer (add it as a member of your class rather than a scoped instance like this)
Equalizer mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());
// Get the number of bands available on your device
short bands = mEqualizer.getNumberOfBands();
// Get the gain level available for the bands
final short minEQLevel = mEqualizer.getBandLevelRange()[0];
final short maxEQLevel = mEqualizer.getBandLevelRange()[1];
You can find more opinions and help here: Number of bands in Android Equalizer
I upgraded my Samsung Galaxy S4 from latest KitKat to Lollipop (5.0.1) yesterday and my IR remote control app that I have used for months stopped working.
Since I was using a late copy of KitKat ConsumerIrManager, the transmit( ) function was sending the number of pulses using the code below. It worked very nicely.
private void irSend(int freqHz, int[] pulseTrainInMicroS) {
int [] pulseCounts = new int [pulseTrainInMicroS.length];
for (int i=0; i<pulseTrainInMicroS.length; i++) {
long iValue = pulseTrainInMicroS[i] * freqHz / 1000000;
pulseCounts[i] = (int) iValue;
}
m_IRService.transmit(freqHz, pulseCounts);
}
when it stopped working yesterday, I began looking closely at it.
I noticed that the transmitted waveform is not having any relationship with the requested pulse train. even the code below doesn't work correctly! there is
private void TestSend() {
int [] pulseCounts = {100, 100, 100};
m_IRService.transmit(38000, pulseCounts);
}
the resulting waveforms had many problems and so are entirely useless.
the waveforms were entirely wrong
the frequency was wrong and the pulse spacing was not regular
they were not repeatable
looking at the demodulated waveform:
if my 100, 100, 100 were correctly rendered, I should have seen two pulses 2.6ms (before 4.4.3(?) 100 us) long. instead I received (see attached) "[demodulated] not repeatable 1.BMP" and "[demodulated] not repeatable 2.BMP". note that the waveform isn't 2 pulses...in fact, it's not even repeatable.
as for the captures below, the signal goes low when the IR is detected.
we should have seen two pulses going low for 2.6 ms and 2.6 ms between them (see green line below).
I had also tried shorter pulses using 50, 50, 50 and have observed that the first pulse isn't correct either (see below).
looking at the modulated waveform:
the frequency was not correct; instead, it was about 18kHz and irregular.
I'm quite experienced with this and have formal education in electronics.
It seems to me there's a bug in ConsumerIrManager.transmit( )...
curiously, the "WatchOn" application that comes with the phone still works.
thank you for any insights you can give.
Test equipment:
Tektronix TDS-2014B, 100 MHz, used in peak-detect mode.
As #IvanTellez says, a change was made in Android in respect to this functionality. Strangely, when I had it outputting simple IR signals (for troubleshooting purposes), the function behaves as shown above (erratically, wrong carrier frequency, etc). When I eventually returned to normal types of IR signals, it worked correctly.
I'm trying to implements presets on an android equalizer, to do so I'm using getNumberOfPresets():
mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());
mEqualizer.setEnabled(true);
short presetNumber = mEqualizer.getNumberOfPresets();
On my nexus 4 (4.2.2) I'm getting presetNumber=10 but using an other device running android 4.0.4 I get presetNumber=0. With this last value I am not able to use:
mEqualizer.usePreset(short);
How can I force the equalizer to use presets?
thx
All the audio effects are hardware-dependent and not guaranteed on all devices.
Because of this, you should always check if the device supports the AudioEffect.
You can query available effects using AudioEffect.queryEffects();
http://developer.android.com/reference/android/media/audiofx/AudioEffect.html#queryEffects()
I want to make a Seek Bar that controls DTMF volume(e.g 0 to 100). I have searched a lot but could not find any thing. I am doing this but its not working..
int seekbarValue=seekBar.getProgress();
AudioManager audioManager=(AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_DTMF, seekbarValue, 0);
Please any one tell me a solution to control DTMF volume.
None of the (AudioManager.STREAM_*) volumes go to 100 (int).
A valid stream volume for setStreamVolume(...) is between 0 and getStreamMaxVolume(int streamType).
Each stream can have a different max volume int, like 8, 10, or 16 from what I remember. Might even be different on different devices.
I hope that is enough to point you and future visitors in the right direction.
I wanted to add a little more information to the answer of #Anonsage.
As #Anonsage mentioned, each stream has a different max volume. As per Kitkat 4.4.2 implementation, these are the max values.
STREAM.DTMF: 15
STREAM.MUSIC: 15
STREAM.VOICECALL: 5
STREAM.RINGTONE: 7
If you actually get into the lower levels and look into the AudioService.java of AOSP code, there is a rescaling operation that helps to show similar UI and update the actual values of the stream.
I use SurfaceView for play video. I use Samsung Galaxy Tab to test. I set size:
LinearLayout.LayoutParams videoViewParams = new LinearLayout.LayoutParams(m_mainView.getPictureWidth(), m_mainView.getPictureHeight());
mPreview = (SurfaceView) videoView.findViewById(R.id.surface);
mPreview.setLayoutParams(videoViewParams);
When mainView.getPictureWidth() or mainView.getPictureHeight() is higer then 1024 - i get message in logcat:
01-12 11:49:15.839: ERROR/SurfaceFlinger(2491): LayerBuffer init temp buff failed with w=1210, h=922, exp max=1024x1024 on 0
and i see only black screen.
Why?
In my application I use video scaling, and sometimes I need to get a video of a size greater than 1024.
It is suspected that this restriction only on Samsung. Checked on emulators - all ok!Found a single theme -
a similar problemt where people asked him to test the media player (and he says that for all its devices, the application works correctly). One user is the same problem on Samsung Galaxy S. Only he exp max = 800x800. Ie obtained here is taken the maximum value of screen sizes and forms the limit.
Any ideas?
I still have 2 ideas:
1)Make a zoom limit for all devices (Set the maximum size of video as a maximum size of one side of the screen). But in this case sometimes zoom in general will not or he will be very small.
2)Catch this log about error and show the user a dialogue that in such a zoom video to play will not work. But how to catch this log?
What do you think about this?