當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。