Merge branch 'audiorecorder-1.5.3'
This commit is contained in:
commit
10ff5e6d84
2 changed files with 9 additions and 52 deletions
|
|
@ -8,8 +8,8 @@ android {
|
|||
applicationId "com.github.axet.audiorecorder"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23
|
||||
versionCode 131
|
||||
versionName "1.5.2"
|
||||
versionCode 132
|
||||
versionName "1.5.3"
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
|
|
@ -43,5 +43,5 @@ android {
|
|||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.github.axet:android-audio-library:0.0.36' // compile project(':android-audio-library')
|
||||
compile 'com.github.axet:android-audio-library:0.0.38' // compile project(':android-audio-library')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioRecord;
|
||||
import android.media.AudioTrack;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -35,6 +34,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.github.axet.androidlibrary.animations.MarginBottomAnimation;
|
||||
import com.github.axet.androidlibrary.app.AudioTrack;
|
||||
import com.github.axet.audiolibrary.app.RawSamples;
|
||||
import com.github.axet.audiolibrary.app.Sound;
|
||||
import com.github.axet.audiolibrary.app.Storage;
|
||||
|
|
@ -48,7 +48,6 @@ import com.github.axet.audiorecorder.app.MainApplication;
|
|||
import com.github.axet.audiorecorder.services.RecordingService;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class RecordingActivity extends AppCompatActivity {
|
||||
public static final String TAG = RecordingActivity.class.getSimpleName();
|
||||
|
|
@ -82,8 +81,6 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
// current play sound track
|
||||
AudioTrack play;
|
||||
|
||||
Runnable playInterval;
|
||||
|
||||
TextView title;
|
||||
TextView time;
|
||||
TextView state;
|
||||
|
|
@ -448,31 +445,17 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
RawSamples rs = new RawSamples(storage.getTempRecording());
|
||||
int len = (int) (rs.getSamples() - editSample);
|
||||
|
||||
final long playStart = System.currentTimeMillis();
|
||||
final long playEnd;
|
||||
|
||||
switch (MainApplication.getChannels(this)) {
|
||||
case 1:
|
||||
playEnd = playStart + len * 1000 / sampleRate;
|
||||
break;
|
||||
case 2:
|
||||
playEnd = playStart + len * 1000 / 2 / sampleRate;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("unknown mode");
|
||||
}
|
||||
|
||||
final AudioTrack.OnPlaybackPositionUpdateListener listener = new AudioTrack.OnPlaybackPositionUpdateListener() {
|
||||
@Override
|
||||
public void onMarkerReached(AudioTrack track) {
|
||||
public void onMarkerReached(android.media.AudioTrack track) {
|
||||
editPlay(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPeriodicNotification(AudioTrack track) {
|
||||
public void onPeriodicNotification(android.media.AudioTrack track) {
|
||||
if (play != null) {
|
||||
long now = System.currentTimeMillis();
|
||||
long playIndex = editSample / MainApplication.getChannels(RecordingActivity.this) + (now - playStart) * sampleRate / 1000;
|
||||
long playIndex = editSample / MainApplication.getChannels(RecordingActivity.this) + (now - play.playStart) * sampleRate / 1000;
|
||||
pitch.play(playIndex / (float) samplesUpdate);
|
||||
}
|
||||
}
|
||||
|
|
@ -482,36 +465,10 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
rs.open(editSample, buf.length);
|
||||
int r = rs.read(buf);
|
||||
play = sound.generateTrack(sampleRate, buf, r);
|
||||
play.setPositionNotificationPeriod(playUpdate);
|
||||
play.setPlaybackPositionUpdateListener(listener, handler);
|
||||
play.play();
|
||||
|
||||
int mark = 0;
|
||||
try {
|
||||
mark = play.getNotificationMarkerPosition();
|
||||
} catch (IllegalStateException ignore) { // Unable to retrieve AudioTrack pointer for getMarkerPosition()
|
||||
}
|
||||
if (mark <= 0) { // some old bugged phones unable to set markers
|
||||
handler.removeCallbacks(playInterval);
|
||||
playInterval = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (System.currentTimeMillis() >= playEnd) {
|
||||
listener.onMarkerReached(play);
|
||||
return;
|
||||
}
|
||||
listener.onPeriodicNotification(play);
|
||||
handler.postDelayed(playInterval, PitchView.UPDATE_SPEED);
|
||||
}
|
||||
};
|
||||
playInterval.run();
|
||||
} else {
|
||||
play.setPositionNotificationPeriod(playUpdate);
|
||||
play.setPlaybackPositionUpdateListener(listener, handler);
|
||||
}
|
||||
} else {
|
||||
if (playInterval != null) {
|
||||
handler.removeCallbacks(playInterval);
|
||||
playInterval = null;
|
||||
}
|
||||
if (play != null) {
|
||||
play.release();
|
||||
play = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue