fix registration
This commit is contained in:
parent
bba4a3c52f
commit
a583caa53c
4 changed files with 16 additions and 17 deletions
|
|
@ -634,7 +634,7 @@ public class MainActivity extends AppCompatActivity implements AbsListView.OnScr
|
|||
// Otherwise, set the URL to null.
|
||||
Uri.parse("http://host/path"),
|
||||
// TODO: Make sure this auto-generated app deep link URI is correct.
|
||||
Uri.parse("android-app://com.github.axet.android-audio-recorder/http/host/path")
|
||||
Uri.parse("android-app://com.github.axet.audiorecorder/http/host/path")
|
||||
);
|
||||
AppIndex.AppIndexApi.start(client, viewAction);
|
||||
}
|
||||
|
|
@ -654,7 +654,7 @@ public class MainActivity extends AppCompatActivity implements AbsListView.OnScr
|
|||
// Otherwise, set the URL to null.
|
||||
Uri.parse("http://host/path"),
|
||||
// TODO: Make sure this auto-generated app deep link URI is correct.
|
||||
Uri.parse("android-app://com.github.axet.android-audio-recorder/http/host/path")
|
||||
Uri.parse("android-app://com.github.axet.audiorecorder/http/host/path")
|
||||
);
|
||||
AppIndex.AppIndexApi.end(client, viewAction);
|
||||
client.disconnect();
|
||||
|
|
|
|||
|
|
@ -598,13 +598,11 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
if (cur > goTime || pitch.stableRefresh()) {
|
||||
rs.write(buffer);
|
||||
|
||||
int pa = getPa(buffer, 0, readSize);
|
||||
|
||||
int s = CHANNEL_CONFIG == AudioFormat.CHANNEL_IN_MONO ? readSize : readSize / 2;
|
||||
|
||||
samplesUpdateCount += s;
|
||||
if (samplesUpdateCount >= samplesUpdate) {
|
||||
pitch.add(pa);
|
||||
pitch.add(getPa(buffer, 0, readSize));
|
||||
samplesUpdateCount -= samplesUpdate;
|
||||
}
|
||||
|
||||
|
|
@ -665,14 +663,14 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
time.setText(MainApplication.formatDuration(ms));
|
||||
}
|
||||
|
||||
int getPa(short[] buffer, int offset, int len) {
|
||||
float getPa(short[] buffer, int offset, int len) {
|
||||
double sum = 0;
|
||||
for (int i = offset; i < offset + len; i++) {
|
||||
sum += buffer[i] * buffer[i];
|
||||
}
|
||||
|
||||
int amplitude = (int) (Math.sqrt(sum / len));
|
||||
int pa = (int) (amplitude / (float) MAXIMUM_ALTITUDE * 100) + 1;
|
||||
float pa = amplitude / (float) MAXIMUM_ALTITUDE + 0.01f;
|
||||
|
||||
return pa;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package com.github.axet.audiorecorder.app;
|
||||
|
||||
import android.media.AudioFormat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.github.axet.audiorecorder.activities.RecordingActivity;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
|
@ -15,7 +13,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
public class RawSamples {
|
||||
|
|
@ -42,10 +39,10 @@ public class RawSamples {
|
|||
|
||||
// open for reading
|
||||
//
|
||||
// bufReadSize - samples size
|
||||
// bufReadSize - samples count
|
||||
public void open(int bufReadSize) {
|
||||
try {
|
||||
readBuffer = new byte[(RecordingActivity.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1) * bufReadSize];
|
||||
readBuffer = new byte[getBufferLen(bufReadSize)];
|
||||
is = new FileInputStream(in);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
@ -58,7 +55,7 @@ public class RawSamples {
|
|||
// bufReadSize - samples size
|
||||
public void open(long offset, int bufReadSize) {
|
||||
try {
|
||||
readBuffer = new byte[(RecordingActivity.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1) * bufReadSize];
|
||||
readBuffer = new byte[getBufferLen(bufReadSize)];
|
||||
is = new FileInputStream(in);
|
||||
is.skip(offset * (RecordingActivity.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1));
|
||||
} catch (IOException e) {
|
||||
|
|
@ -99,8 +96,12 @@ public class RawSamples {
|
|||
return getSamples(in.length());
|
||||
}
|
||||
|
||||
public long getSamples(long samples) {
|
||||
return samples / (RecordingActivity.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1);
|
||||
public long getSamples(long len) {
|
||||
return len / (RecordingActivity.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1);
|
||||
}
|
||||
|
||||
public int getBufferLen(int samples) {
|
||||
return samples * (RecordingActivity.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1);
|
||||
}
|
||||
|
||||
public void trunk(long pos) {
|
||||
|
|
|
|||
|
|
@ -381,8 +381,8 @@ public class PitchView extends ViewGroup {
|
|||
}
|
||||
}
|
||||
|
||||
public void add(int a) {
|
||||
data.add(a / 100.0f);
|
||||
public void add(float a) {
|
||||
data.add(a);
|
||||
|
||||
// after pause, we still may get one last sample. force view redraw.
|
||||
if (thread == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue