Skip to content

Commit

Permalink
modify the buffer interval from 20 ms to 100 ms
Browse files Browse the repository at this point in the history
update build tools version gradle version
  • Loading branch information
ideastudios committed Oct 23, 2019
1 parent 617a990 commit ffb51ef
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 38 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "tech.oom.idealrecorderdemo"
minSdkVersion 16
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -20,14 +20,15 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.yanzhenjie:permission:1.1.0'
compile 'com.github.Jay-Goo:WaveLineView:v1.0.3'
compile 'com.github.ideastudios:IdealRecorder:2.0.4'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'junit:junit:4.12'
implementation 'com.yanzhenjie:permission:1.1.0'
implementation 'com.github.Jay-Goo:WaveLineView:v1.0.3'
implementation project(':library')
// compile 'com.github.ideastudios:IdealRecorder:2.0.4'
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import jaygoo.widget.wlv.WaveLineView;
import tech.oom.idealrecorder.IdealRecorder;
import tech.oom.idealrecorder.StatusListener;
import tech.oom.idealrecorder.utils.Log;
import tech.oom.idealrecorderdemo.widget.WaveView;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -71,12 +72,14 @@ public void onRecordData(short[] data, int length) {
for (int i = 0; i < length; i += 60) {
waveView.addData(data[i]);
}
Log.d("MainActivity", "current buffer size is " + length);
}

@Override
public void onVoiceVolume(int volume) {
double myVolume = (volume - 40) * 4;
waveLineView.setVolume((int) myVolume);
Log.d("MainActivity", "current volume is " + volume);
}

@Override
Expand Down
12 changes: 3 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -20,10 +17,7 @@ allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 06 10:56:48 CST 2017
#Wed Oct 23 14:42:54 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
14 changes: 7 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.ideastudios'
group = 'com.github.ideastudios'

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
compileSdkVersion 28
buildToolsVersion "28.0.0"

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"

Expand All @@ -25,10 +25,10 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
}
14 changes: 9 additions & 5 deletions library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.pm.PackageManager;
import android.media.AudioFormat;
import android.media.MediaRecorder;
import android.os.Environment;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static IdealRecorder getInstance() {
* @param mContext 当前应用的application context
*/
public void init(Context mContext) {
context = mContext;
context = mContext.getApplicationContext();

}

Expand Down Expand Up @@ -117,11 +116,16 @@ public IdealRecorder setVolumeInterval(long intervalMillis) {
*/
public IdealRecorder setRecordFilePath(String path) {
if (!TextUtils.isEmpty(path) && audioFileHelper != null) {
if (path.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath()) && !isWriteExternalStoragePermissionGranted()) {
Log.e(TAG, "set recorder file path failed,because no WRITE_EXTERNAL_STORAGE permission was granted");
String externalFilePath = context.getExternalFilesDir(null).getAbsolutePath();
String cacheFilePath = context.getCacheDir().getAbsolutePath();

return this;
if (!path.startsWith(externalFilePath) || !path.startsWith(cacheFilePath)) {
if (!isWriteExternalStoragePermissionGranted()) {
Log.e(TAG, "set recorder file path failed,because no WRITE_EXTERNAL_STORAGE permission was granted");
return this;
}
}

isAudioFileHelperInit = true;
audioFileHelper.setSavePath(path);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@


public class Recorder {
public static final int TIMER_INTERVAL = 20;
/**
* 每次buffer语音对应的时长为100ms
*/
public static final int TIMER_INTERVAL = 100;
private static final String TAG = "Recorder";
private IdealRecorder.RecordConfig recordConfig;
private AudioRecord mAudioRecorder = null;
Expand Down

0 comments on commit ffb51ef

Please sign in to comment.