add recording db buffer
This commit is contained in:
parent
bfe9464e31
commit
a8675577db
1 changed files with 10 additions and 4 deletions
|
|
@ -93,6 +93,8 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
RecordingReceiver receiver;
|
||||
Handler handler = new Handler();
|
||||
|
||||
ShortBuffer dbBuffer = null;
|
||||
|
||||
public static void startActivity(Context context, boolean pause) {
|
||||
Intent i = new Intent(context, RecordingActivity.class);
|
||||
if (pause) {
|
||||
|
|
@ -288,12 +290,18 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
|
||||
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) {
|
||||
int lenUpdate = len / samplesUpdateStereo * samplesUpdateStereo; // cut right overs (leftovers from right)
|
||||
for (int i = 0; i < lenUpdate; i += samplesUpdateStereo) {
|
||||
double dB = RawSamples.getDB(buf, i, samplesUpdateStereo);
|
||||
pitch.add(dB);
|
||||
}
|
||||
updateSamples(samplesTime);
|
||||
|
||||
int diff = len - lenUpdate;
|
||||
if (diff > 0) {
|
||||
dbBuffer = ShortBuffer.allocate(samplesUpdateStereo);
|
||||
dbBuffer.put(buf, lenUpdate, diff);
|
||||
}
|
||||
}
|
||||
|
||||
void pauseButton() {
|
||||
|
|
@ -618,8 +626,6 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
|
||||
int samplesUpdateStereo = samplesUpdate * MainApplication.getChannels(RecordingActivity.this);
|
||||
|
||||
ShortBuffer dbBuffer = null;
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
synchronized (bufferSizeLock) {
|
||||
if (buffer == null || buffer.length != bufferSize)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue