Click here to Skip to main content
15,170,741 members
Home / Discussions / Android
   

Android

 
AnswerRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:52
MemberDavidw196924-Feb-17 17:52 
AnswerRe: Method not returning expected value Pin
Richard MacCutchan23-Feb-17 4:58
mveRichard MacCutchan23-Feb-17 4:58 
GeneralRe: Method not returning expected value Pin
Davidw196924-Feb-17 17:53
MemberDavidw196924-Feb-17 17:53 
QuestionAndroid and C# Web Services Pin
Member 1155786814-Feb-17 23:41
MemberMember 1155786814-Feb-17 23:41 
SuggestionRe: Android and C# Web Services Pin
Richard Deeming15-Feb-17 3:39
mveRichard Deeming15-Feb-17 3:39 
QuestionAndroid: High Pass filter Pin
Himanshu Bhutani13-Feb-17 2:36
MemberHimanshu Bhutani13-Feb-17 2:36 
QuestionRe: Android: High Pass filter Pin
David Crow13-Feb-17 3:41
MemberDavid Crow13-Feb-17 3:41 
AnswerRe: Android: High Pass filter Pin
Nick_314159265415-Apr-17 4:55
MemberNick_314159265415-Apr-17 4:55 
I suggest that you add logging to your application using the default android log utility. This will make your investigation much easier. Using a debugger - as somebody else suggested - is a very valid approach, but where you are looking at real-time effects (which may or may not be relevant) there's no substitute for logging. You can do this as follows:

Add this import to your MainActivity and Filter classes:
Java
import android.util.Log;

Then add this static variable as a class variable to each:
Java
private static final String TAG = "Himanshu";


Now add some logging like this:

Java
while ((read = in.read(buff)) > 0) {
    Log.i(TAG, "Raw audio: " + read);    // *** Nick's suggested log point. ***               
    out.write(buff, 0, read);
}
out.flush();
byte[] audioBytes = out.toByteArray();
final FloatBuffer fb = ByteBuffer.wrap(audioBytes).asFloatBuffer();
final float[] dst = new float[fb.capacity()];
fb.get(dst);

Filter filter = new Filter(15000,44100, Filter.PassType.Highpass,1);
for (int i = 0; i <dst.length; i++) {
    filter.Update(dst[i]);
    dst[i] = filter.getValue();
    Log.i(TAG, "Filtered audio: " + dst[i]);   // *** Nick's suggested log point. ***
}

etc etc..

In order to view your log you need to use adb. If you work in a windows environment you'd do this in a DOS command shell:
adb logcat Himanshu:* *:s -v time

Issue the above logcat command BEFORE starting your app and triggering the audio record & playback. This command is saying: Capture all log messages (.i, .d, .v, .w, .e etc.. i.e. of category: Information, Debug, Verbose, Warning and Error) and do NOT capture any other log messages, show log timestamps.

I didn't check all of the places in your code where that would also shed light on the problem. It's your code and I'm sure that you can quickly identify these places.

Actually I would have done a couple of other things also before going quite so far as you have:

1. Confirm that you can play audio samples, do this by creating a simple square wave, storing it in memory and squirting it out. You can use PCM at 16 kSamples/sec and a ~200 Hz waveform.

2. Capture recorded audio to a file and check that this is valid audio.

One other thing to mention is that you are using the AMR Narrow Band voice codec. This is not a generic audio encoding algorithm. AMR (NB) has been highly optimised for voice telephony, and as is the case for such codecs. This may be important because these codecs do not handle tones at all well and music isn't very well supported. I'm not sure what kind of audio you are dealing with. You may want to consider an alternative audio encoding format such as MP3 or plain/differential PCM.
QuestionAndroid Day of Week Calculator Pin
Pavlex49-Feb-17 10:50
MemberPavlex49-Feb-17 10:50 
AnswerRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:02
MemberDavid Crow9-Feb-17 11:02 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:09
MemberPavlex49-Feb-17 11:09 
GeneralRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:12
MemberDavid Crow9-Feb-17 11:12 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:15
MemberPavlex49-Feb-17 11:15 
SuggestionRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:23
MemberDavid Crow9-Feb-17 11:23 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:32
MemberPavlex49-Feb-17 11:32 
GeneralRe: Android Day of Week Calculator Pin
David Crow9-Feb-17 11:36
MemberDavid Crow9-Feb-17 11:36 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 11:38
MemberPavlex49-Feb-17 11:38 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan9-Feb-17 22:07
mveRichard MacCutchan9-Feb-17 22:07 
GeneralRe: Android Day of Week Calculator Pin
Pavlex49-Feb-17 22:39
MemberPavlex49-Feb-17 22:39 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan9-Feb-17 23:20
mveRichard MacCutchan9-Feb-17 23:20 
GeneralRe: Android Day of Week Calculator Pin
David Crow10-Feb-17 3:08
MemberDavid Crow10-Feb-17 3:08 
GeneralRe: Android Day of Week Calculator Pin
Richard MacCutchan10-Feb-17 3:46
mveRichard MacCutchan10-Feb-17 3:46 
GeneralMobile and o/s application development Pin
JimmiJames337-Feb-17 6:42
professionalJimmiJames337-Feb-17 6:42 
QuestionRe: Mobile and o/s application development Pin
David Crow7-Feb-17 7:15
MemberDavid Crow7-Feb-17 7:15 
QuestionAndroid Popup Window Pin
Pavlex42-Feb-17 9:09
MemberPavlex42-Feb-17 9:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.