Skip to content

Commit ce0a5fc

Browse files
committed
1.1
1 parent dc6a0da commit ce0a5fc

File tree

98 files changed

+50
-5481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+50
-5481
lines changed

.idea/misc.xml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
35.6 KB
Binary file not shown.
35.6 KB
Binary file not shown.
39.2 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package mrcheng.myapplication;
2+
3+
/**
4+
* Created by mr.cheng on 2016/11/30.
5+
*/
6+
public class MyThread {
7+
8+
static {
9+
System.loadLibrary("myNativeLib");
10+
}
11+
public native void getStringFromNative(short[] shorts, double[] doubles);
12+
}

myapplication/src/main/java/util/ReadFileThread.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,16 @@
2727
import cn.bmob.v3.listener.SaveListener;
2828
import mrcheng.myapplication.BaseActivity;
2929
import mrcheng.myapplication.Bmob_ChatActivity;
30+
import mrcheng.myapplication.MyThread;
3031
import mrcheng.myapplication.R;
3132

3233
/**
3334
* Created by mr.cheng on 2016/9/28.
3435
*/
3536
public class ReadFileThread extends Thread {
36-
static {
37-
38-
System.loadLibrary("myNativeLib");
39-
40-
}
41-
4237
private ObjectInputStream objectInputStream;
4338
private ServerSocket serverSocket;
4439

45-
public native void getStringFromNative(short[] shorts, double[] doubles);
46-
4740
private Context mContext;
4841
private List<Float> mDatas = new ArrayList<>();
4942
private boolean flag = true;
@@ -60,10 +53,6 @@ public ReadFileThread(Context context, String ip) {
6053
ReadFile();
6154
}
6255

63-
public void MyNativeMethod(short[] shorts, double[] doubles) {
64-
getStringFromNative(shorts, doubles);
65-
}
66-
6756
@Override
6857
public void run() {
6958
super.run();
@@ -116,14 +105,15 @@ public void run() {
116105

117106
private void ReadFile() {
118107
try {
108+
MyThread my=new MyThread();
119109
int length;
120110
InputStream is = mContext.getResources().openRawResource(R.raw.fmsignal);
121111
BufferedInputStream inputStream = new BufferedInputStream(is);
122112
byte[] buf = new byte[64000 * 2];
123113
double[] doubles = new double[65536];
124114
while ((length = inputStream.read(buf, 0, buf.length)) != -1) {
125115
short[] shorts = byteArray2ShortArray(buf, buf.length / 2);
126-
getStringFromNative(shorts, doubles);
116+
my.getStringFromNative(shorts, doubles);
127117
}
128118
inputStream.close();
129119
is.close();

myapplication/src/main/java/util/RecordFileThread.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@
1111
import java.io.FileWriter;
1212
import java.io.IOException;
1313

14+
import mrcheng.myapplication.MyThread;
15+
1416
/**
1517
* Created by mr.cheng on 2016/10/11.
1618
*/
1719
public class RecordFileThread extends Thread {
1820
private AudioRecord recorder;
1921
private Handler mHandler;
20-
21-
static {
22-
System.loadLibrary("myNativeLib");
23-
}
24-
25-
public native void getStringFromNative(short[] shorts, double[] doubles);
26-
22+
private MyThread mMyThread=new MyThread();
2723
public RecordFileThread(Handler handler) {
2824
mHandler = handler;
2925
}
@@ -41,7 +37,7 @@ public void run() {
4137
recorder.stop();
4238
recorder.release();
4339
double[] doubles = new double[65536];
44-
getStringFromNative(myRecoed, doubles);
40+
mMyThread.getStringFromNative(myRecoed, doubles);
4541
MyWriteFileMethod(doubles);
4642
}
4743

myapplication/src/main/java/util/UpFileActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import butterknife.OnClick;
3333
import cn.bmob.v3.BmobUser;
3434
import mrcheng.myapplication.BaseActivity;
35+
import mrcheng.myapplication.MyThread;
3536
import mrcheng.myapplication.R;
3637

3738
/**
@@ -135,10 +136,10 @@ private void MyWriteFileMethod(final short[][] mydatas) {
135136
file.createNewFile();
136137

137138
writer = new BufferedWriter(new FileWriter(file));
138-
ReadFileThread readFileThread = new ReadFileThread(UpFileActivity.this, "");
139+
MyThread myThread=new MyThread();
139140
double[] doubles = new double[65536];
140141
for (int j = 0; j < mydatas.length; j++) {
141-
readFileThread.getStringFromNative(mydatas[j], doubles);
142+
myThread.getStringFromNative(mydatas[j], doubles);
142143
for (int i = 0; i < 8192; i++) {
143144
writer.write(doubles[i] + "\r\n");
144145
writer.flush();

myapplication/src/main/jni/Decimate.cpp

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)