fix restore samples crash

This commit is contained in:
Alexey Kuznetsov 2017-06-18 17:28:25 +03:00
commit b506bc265e
2 changed files with 6 additions and 8 deletions

View file

@ -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.55' // compile project(':android-audio-library')
compile 'com.github.axet:android-audio-library:0.0.56' // compile project(':android-audio-library')
}

View file

@ -282,13 +282,11 @@ public class RecordingActivity extends AppCompatActivity {
int len = rs.read(buf);
rs.close();
pitch.clear(cut / samplesUpdate);
for (int i = 0; i < len; i += samplesUpdate * MainApplication.getChannels(this)) {
double dB = 0;
for (int c = 0; c < MainApplication.getChannels(this); c++) {
dB += RawSamples.getDB(buf, i + samplesUpdate * c, samplesUpdate);
}
dB = dB / MainApplication.getChannels(this);
int samplesUpdateStereo = samplesUpdate * MainApplication.getChannels(this);
pitch.clear(cut / samplesUpdateStereo);
len = len / samplesUpdateStereo * samplesUpdateStereo; // cut right overs (leftovers from right)
for (int i = 0; i < len; i += samplesUpdateStereo) {
double dB = RawSamples.getDB(buf, i, samplesUpdateStereo);
pitch.add(dB);
}
updateSamples(samplesTime);