Skip to content

Commit

Permalink
Use the intro sound as an awesome sound check mechanism
Browse files Browse the repository at this point in the history
On (at least) Samsung Note 5, tunnel.decode property returns empty but
analysis through the java Visualizer class fails.  So use the intro
sound to see if we'll get any data in that class.

TunnelPlayer Workaround not needed, which apparently we weren't even
using (it has to be initialized), and even when used apparently doesn't
work on all devices.

The good reference I've been using:
felixpalmer/android-visualizer#5
  • Loading branch information
GuacoIV committed Jan 28, 2016
1 parent 8e04c67 commit e1ec624
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 175 deletions.
Binary file removed res/raw/workaround_1min.mp3
Binary file not shown.
7 changes: 4 additions & 3 deletions src/com/lsu/vizeq/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ public class MyApplication extends Application {
public String myName = "";
public String zipcode = null;
public String myIp;
public boolean joined = false;
public boolean hosting = false;
public boolean joined;
public boolean hosting;
public JedisPool jedisPool = new JedisPool(new JedisPoolConfig(), Redis.host, Redis.port);
String brand = Build.BRAND; // for getting BrandName
String model = Build.MODEL; // for getting Model of the device
public static boolean doFlash;
public static boolean doBackground;
public static boolean tapToFlash = false;
public static boolean tapToFlash;
public static boolean nativeAnalysis;
public static boolean foundSound;
@Override
public void onCreate()
{
Expand Down
12 changes: 5 additions & 7 deletions src/com/lsu/vizeq/RoleActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.lsu.vizeq;

import com.lsu.vizeq.util.TunnelPlayerWorkaround;

import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
Expand Down Expand Up @@ -118,18 +120,14 @@ protected void onCreate(Bundle savedInstanceState)

myapp = (MyApplication) this.getApplicationContext();

//final String useAwesome = SystemProperties.get("persist.sys.media.use-awesome");
final String usesTunnel = SystemProperties.get("tunnel.decode");

//Toast.makeText(this, "Awesome Player audio value: " + useAwesome + "\n"
//+ "Tunnel Player audio value: " + usesTunnel, Toast.LENGTH_LONG).show();

if (usesTunnel.compareTo("true") == 0)
//Note: when using native analysis, if a debugger is attached, it usually falls behind
if (usesTunnel.compareTo("true") == 0 || !MyApplication.foundSound)
{
MyApplication.nativeAnalysis = true;
LibSpotifyWrapper.nativeAnalysis = true;
}

}

findViewById(R.id.DJ).setOnTouchListener(new View.OnTouchListener()
{
Expand Down
74 changes: 54 additions & 20 deletions src/com/lsu/vizeq/VizEQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.audiofx.Visualizer;
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
Expand Down Expand Up @@ -74,29 +75,62 @@ protected void onCreate(Bundle savedInstanceState)

//load anything if necessary

final Visualizer visualizer = new Visualizer(0);
if (visualizer.getEnabled()) {
visualizer.setEnabled(false);
}
visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[0]);
Visualizer.OnDataCaptureListener captureListener = new Visualizer.OnDataCaptureListener() {

@Override
public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate)
{
for (int i = 0; i < fft.length; i++)
{
if (fft[i] != 0)
MyApplication.foundSound = true;
}
}

@Override
public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate)
{
for (int i = 0; i < waveform.length; i++)
{
if (waveform[i] != -128)
MyApplication.foundSound = true;
}
}

};
visualizer.setDataCaptureListener(captureListener, Visualizer.getMaxCaptureRate()/4, true, true);
visualizer.setEnabled(true);

Thread splashThread = new Thread()
{
public void run() {
try
{
MediaPlayer mediaPlayer = MediaPlayer.create(VizEQ.this, R.raw.vizeqintro);
AudioManager audio = (AudioManager) VizEQ.this.getSystemService(VizEQ.this.AUDIO_SERVICE);
if (audio.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) mediaPlayer.start(); // no need to call prepare(); create() does that for you
sleep(mediaPlayer.getDuration()); //length of track
mediaPlayer.release();
}
catch (Exception e)
{
// Log.d("Activity", "Login activity not started.");
}
finally
{

finish();
Intent nextIntent = new Intent(VizEQ.this, RoleActivity.class);
startActivity(nextIntent);
}
}
try
{
MediaPlayer mediaPlayer = MediaPlayer.create(VizEQ.this, R.raw.vizeqintro);

//AudioManager audio = (AudioManager) VizEQ.this.getSystemService(Context.AUDIO_SERVICE);
//if (audio.getRingerMode() == AudioManager.RINGER_MODE_NORMAL)
mediaPlayer.start();
sleep(mediaPlayer.getDuration()); //length of track
mediaPlayer.release();
visualizer.release();
}
catch (Exception e)
{

}
finally
{
finish();
Intent nextIntent = new Intent(VizEQ.this, RoleActivity.class);
startActivity(nextIntent);
}
}
};
splashThread.start();

Expand Down
73 changes: 0 additions & 73 deletions src/com/lsu/vizeq/util/SystemPropertiesProxy.java

This file was deleted.

72 changes: 0 additions & 72 deletions src/com/lsu/vizeq/util/TunnelPlayerWorkaround.java

This file was deleted.

0 comments on commit e1ec624

Please sign in to comment.