Skip to content

Commit

Permalink
extend PacketCallbak with peak() function
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Oct 16, 2012
1 parent 6e337ef commit 49c3c58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/com/jazzido/PacketDroid/AudioBufferProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void stopRecording() {

void decode(short[] s) {
// Log.d(LOG_TAG, "CALLBACK!: " + s.length);
short max = 0;
for (int i = 0; i < s.length; i++) {
if (writeAudioBuffer) {
try {
Expand All @@ -112,8 +113,13 @@ void decode(short[] s) {
}
}
fbuf[fbuf_cnt++] = s[i] * (1.0f/32768.0f);
if (max < s[i])
max = s[i];
else if (max < -s[i])
max = (short)-s[i];
}

callback.peak(max);

if (fbuf_cnt > overlap) {
processBuffer(fbuf, fbuf_cnt - overlap);
Expand Down
1 change: 1 addition & 0 deletions src/com/jazzido/PacketDroid/PacketCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

public interface PacketCallback {
public void received(byte[] packet);
public void peak(short peak_value);
}

0 comments on commit 49c3c58

Please sign in to comment.