当前位置: 首页>>代码示例>>Java>>正文


Java Visualizer类代码示例

本文整理汇总了Java中android.media.audiofx.Visualizer的典型用法代码示例。如果您正苦于以下问题:Java Visualizer类的具体用法?Java Visualizer怎么用?Java Visualizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Visualizer类属于android.media.audiofx包,在下文中一共展示了Visualizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: VisualizerController

import android.media.audiofx.Visualizer; //导入依赖的package包/类
public VisualizerController(MediaPlayer mediaPlayer)
{
	try
	{
		if (mediaPlayer == null)
		{
			return;
		}

		audioSessionId = mediaPlayer.getAudioSessionId();
		visualizer = new Visualizer(audioSessionId);
	}
	catch (Throwable x)
	{
		Log.w(TAG, "Failed to create visualizer.", x);
	}

	if (visualizer != null)
	{
		int[] captureSizeRange = Visualizer.getCaptureSizeRange();
		int captureSize = Math.max(PREFERRED_CAPTURE_SIZE, captureSizeRange[0]);
		captureSize = Math.min(captureSize, captureSizeRange[1]);
		visualizer.setCaptureSize(captureSize);
	}
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:26,代码来源:VisualizerController.java

示例2: getVisualizer

import android.media.audiofx.Visualizer; //导入依赖的package包/类
public Visualizer getVisualizer()
{
	if (released)
	{
		released = false;

		try
		{
			visualizer = new Visualizer(audioSessionId);
		}
		catch (Throwable x)
		{
			visualizer = null;
			Log.w(TAG, "Failed to create visualizer.", x);
		}
	}

	return visualizer;
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:20,代码来源:VisualizerController.java

示例3: onFftDataCapture

import android.media.audiofx.Visualizer; //导入依赖的package包/类
@Override
public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
    int dataSize = fft.length / 2 - 1;
    for (int i = 0; i < SOUND_INDEX_COEFFICIENTS.length; i++) {
        int index = (int) (SOUND_INDEX_COEFFICIENTS[i] * dataSize);
        byte real = fft[2 * index];
        byte imag = fft[2 * index + 1];
        long magnitudeSquare = real * real + imag * imag;
        magnitudeSquare = (long) Math.sqrt(magnitudeSquare);
        float dbs = magnitudeToDb(magnitudeSquare);
        float dbPercentage = dbs / MAX_DB_VALUE;
        if (dbPercentage > 1.0f) {
            dbPercentage = 1.0f;
        }
        mDbsPercentagesConcrete[i] = mDbsPercentagesConcrete[i] * FILTRATION_ALPHA + dbPercentage * FILTRATION_BETA;
    }

    changeShadow(mDbsPercentagesConcrete[0], mDbsPercentagesConcrete[1], mDbsPercentagesConcrete[2]);

}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:21,代码来源:VisualizerShadowChanger.java

示例4: onFftDataCapture

import android.media.audiofx.Visualizer; //导入依赖的package包/类
@Override
public void onFftDataCapture(Visualizer visualizer, byte[] fft,
                             int samplingRate) {
    for (int i = 0; i < 32; i++) {
        mValueAnimators[i].cancel();
        rfk = fft[i * 2 + 2];
        ifk = fft[i * 2 + 3];
        magnitude = rfk * rfk + ifk * ifk;
        dbValue = magnitude > 0 ? (int) (10 * Math.log10(magnitude)) : 0;

        mValueAnimators[i].setFloatValues(mFFTPoints[i * 4 + 1],
                mFFTPoints[3] - (dbValue * 16f));
        //mValueAnimators[i]
        // .setInterpolator(new AccelerateDecelerateInterpolator());
        mValueAnimators[i].start();
    }
}
 
开发者ID:Lawiusz,项目名称:xposed_lockscreen_visualizer,代码行数:18,代码来源:VisualizerView.java

示例5: init

import android.media.audiofx.Visualizer; //导入依赖的package包/类
private void init() {
    mBytes = null;
    mFFTBytes = null;

    //mFlashPaint.setColor(Color.argb(122, 255, 255, 255));
    mFadePaint.setColor(Color.argb(100, 255, 255, 255)); // Adjust alpha to

    mRenderers = new HashSet<>();


    mVisualizer = new Visualizer(0);
    Log.w(Constants.TAG, "SetCapture Size (FFT MINRANGE):" + mVisualizer.getCaptureSize());
    recordingSampler = new RecordingSampler();

    // transPainter = new Paint();
    // transPainter.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
}
 
开发者ID:souliss,项目名称:soulissapp,代码行数:18,代码来源:VisualizerView.java

示例6: onDestroy

import android.media.audiofx.Visualizer; //导入依赖的package包/类
@Override
protected void onDestroy() {
    super.onDestroy();
    // disable loudness
    if (mLoudness != null) {
        mLoudness.setEnabled(false);
        mLoudness.release();
        mLoudness = null;
    }
    // disable visualizer
    if (mVisualizer != null) {
        mVisualizer.setEnabled(false);
        mVisualizer.setMeasurementMode(Visualizer.MEASUREMENT_MODE_NONE);
        mVisualizer.release();
    }
    // release mediaplayer
    if (mMediaPlayer != null) {
        mMediaPlayer.release();
    }
}
 
开发者ID:TechBooster,项目名称:C85-Android-4.4-Sample,代码行数:21,代码来源:MainActivity.java

示例7: start

import android.media.audiofx.Visualizer; //导入依赖的package包/类
/**
 * Starts capturing and retrieving audio data, forwarding it to the provided
 * {@link RawDataListener}, or does nothing if recording is already started.
 * Returns immediately once retrieval is set up.
 *
 * @throws IllegalStateException if audio capture couldn't be enabled
 */
@Override
public void start(RawDataListener out) {
    if (audioSource.getEnabled()) {
        return;
    }
    int largestSize = getOutputSize();
    Log.d(TAG, "Using captureSize " + largestSize);
    if (audioSource.setCaptureSize(largestSize) != Visualizer.SUCCESS) {
        throw new IllegalStateException("Bad capture size: " + largestSize);
    }
    int maxMilliHz = getDataRefreshRateHz();
    Log.d(TAG, "Starting viz with hz=" + maxMilliHz);
    audioSource.setDataCaptureListener(new PassthruListener(out), maxMilliHz * 1000, false, true);
    audioSource.setEnabled(true);
}
 
开发者ID:nickbp,项目名称:musicviz,代码行数:23,代码来源:PlayerAudioSource.java

示例8: getOutputSize

import android.media.audiofx.Visualizer; //导入依赖的package包/类
/**
 * Returns the largest available data width for system audio capture, suitable for passing to
 * {@link Visualizer#setCaptureSize(int)}.
 */
public int getOutputSize() {
    int[] range = Visualizer.getCaptureSizeRange();
    if (range.length != 2) {
        throw new IllegalStateException(
            "Expected 2 elements in capture size range, got " + range.length);
    }
    if (range[0] > range[1]) {
        Log.w(TAG, "Capture size range is backwards: [" + range[0] + ", " + range[1] + "]");
        int tmp = range[0];
        range[0] = range[1];
        range[1] = tmp;
    }
    Log.v(TAG, "Capture size range: [" + range[0] + ", " + range[1] + "]");
    return findLargestBaseTwoInInclusiveRange(range[0], range[1]);
}
 
开发者ID:nickbp,项目名称:musicviz,代码行数:20,代码来源:PlayerAudioSource.java

示例9: VisualizerWrapper

import android.media.audiofx.Visualizer; //导入依赖的package包/类
public VisualizerWrapper(@NonNull Context context, int audioSessionId, @NonNull final OnFftDataCaptureListener onFftDataCaptureListener) {
       mediaPlayer = MediaPlayer.create(context, R.raw.av_workaround_1min);
	visualizer = new Visualizer(audioSessionId);
       visualizer.setEnabled(false);
	visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
       captureRate = Visualizer.getMaxCaptureRate();
       captureListener = new Visualizer.OnDataCaptureListener() {
           @Override
           public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {

           }

           @Override
           public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
               boolean allZero = Utils.allElementsAreZero(fft);
               if (lastZeroArrayTimestamp  == 0) {
                   if (allZero) {
                       lastZeroArrayTimestamp = System.currentTimeMillis();
                   }
               } else  {
                   if (!allZero) {
                       lastZeroArrayTimestamp = 0;
                   } else if (System.currentTimeMillis() - lastZeroArrayTimestamp >= WAIT_UNTIL_HACK) {
                       setEnabled(true);
                       lastZeroArrayTimestamp = 0;
                   }
               }
               onFftDataCaptureListener.onFftDataCapture(fft);
           }
       };
       visualizer.setEnabled(true);
}
 
开发者ID:Cleveroad,项目名称:WaveInApp,代码行数:33,代码来源:VisualizerWrapper.java

示例10: run

import android.media.audiofx.Visualizer; //导入依赖的package包/类
@Override
public void run()  {
    try {
        mVisualizer = new Visualizer(0);
        mVisualizer.setEnabled(false);
        mVisualizer.setCaptureSize(66);
        mVisualizer.setDataCaptureListener(mVisualizerListener,
                Visualizer.getMaxCaptureRate(), false, true);
        mVisualizer.setEnabled(true);
    } catch (Throwable e){
            if (areWeInsideSystemUI){
                LLog.e(e);
            } else e.printStackTrace();
    }
}
 
开发者ID:Lawiusz,项目名称:xposed_lockscreen_visualizer,代码行数:16,代码来源:VisualizerView.java

示例11: linkPlayer

import android.media.audiofx.Visualizer; //导入依赖的package包/类
public void linkPlayer(int sessionId){
    Timber.d("linkPlayer, session id: %d", sessionId);
    visualizer = new Visualizer(sessionId);
    if(!visualizer.getEnabled()){
        visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
    }
    visualizer.setDataCaptureListener(dataCaptureListener, Visualizer.getMaxCaptureRate() / 2, true, true);
    visualizer.setEnabled(true);
}
 
开发者ID:linroid,项目名称:Sky31Radio,代码行数:10,代码来源:EqualizerView.java

示例12: VisualizerController

import android.media.audiofx.Visualizer; //导入依赖的package包/类
public VisualizerController(Context context, MediaPlayer mediaPlayer) {
     try {
audioSessionId = mediaPlayer.getAudioSessionId();
         visualizer = new Visualizer(audioSessionId);
     } catch (Throwable x) {
         LOG.warn("Failed to create visualizer.", x);
     }

     if (visualizer != null) {
         int[] captureSizeRange = Visualizer.getCaptureSizeRange();
         int captureSize = Math.max(PREFERRED_CAPTURE_SIZE, captureSizeRange[0]);
         captureSize = Math.min(captureSize, captureSizeRange[1]);
         visualizer.setCaptureSize(captureSize);
     }
 }
 
开发者ID:MadMarty,项目名称:madsonic-5.5,代码行数:16,代码来源:VisualizerController.java

示例13: getVisualizer

import android.media.audiofx.Visualizer; //导入依赖的package包/类
public Visualizer getVisualizer() {
if(released) {
	released = false;
	try {
		visualizer = new Visualizer(audioSessionId);
	} catch (Throwable x) {
		visualizer = null;
		LOG.warn("Failed to create visualizer.", x);
	}
}

      return visualizer;
  }
 
开发者ID:MadMarty,项目名称:madsonic-5.5,代码行数:14,代码来源:VisualizerController.java

示例14: updateStatus

import android.media.audiofx.Visualizer; //导入依赖的package包/类
private void updateStatus() {
    // Capture the sample
    Visualizer.MeasurementPeakRms measurementPeakRms = new Visualizer.MeasurementPeakRms();
    visualizer.getMeasurementPeakRms(measurementPeakRms);
    // Notify our updateable
    updateable.setPeakValue(measurementPeakRms.mPeak);
    updateable.setRmsValue(measurementPeakRms.mRms);
}
 
开发者ID:shinobicontrols,项目名称:bitesize-kitkat,代码行数:9,代码来源:SamplingSoundMeter.java

示例15: startMusic

import android.media.audiofx.Visualizer; //导入依赖的package包/类
private Bitmap startMusic() {
	mMediaPlayer = MediaPlayer.create(this, R.raw.hyperfun);
	mMediaPlayer.setLooping(true);
	mAudioSession = mMediaPlayer.getAudioSessionId();
	mMediaPlayer.start();
	mVisualizer = new Visualizer(mAudioSession);
	mVisualizer.setDataCaptureListener(this, Visualizer.getMaxCaptureRate() / 2, true, true);
	mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1] / 2);
	Bitmap visualizerBitmap = Bitmap.createBitmap(Visualizer.getCaptureSizeRange()[1] / 2, 2, Bitmap.Config.RGB_565)
			.copy(Bitmap.Config.RGB_565, true);
	visualizerBitmap.eraseColor(Color.BLACK);
	mVisualizer.setScalingMode(Visualizer.SCALING_MODE_AS_PLAYED);
	mVisualizer.setEnabled(true);
	return visualizerBitmap;
}
 
开发者ID:ErikHellman,项目名称:ShaderDroid,代码行数:16,代码来源:ShaderDroidMain.java


注:本文中的android.media.audiofx.Visualizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。