[android-developers] MediaFormat.getByteBuffer(“csd-0”) returning null on some devices

2016-12-07 Thread Swapnil Gupta
H guys,

Please have a look at this 
post: http://stackoverflow.com/q/41014730/2606411.

Best Regards.
Swapnil Gupta.
Music Technology Group/ MusicMuni Labs.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/ebf7b410-fa28-48c3-99fe-859120812bdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Character animation on Android

2016-10-11 Thread Swapnil Gupta
Hello guys,

I am developing an android application where my activity contains a 
character which is animated. The requirement is such that there are various 
stages in the activity and there is an animation sequence for each stage 
which I loop till the application is in a particular state. I have tried 
the following ways to animate but still not clear what is the best way to 
approach this:

1) Tried with the class AnimationDrawable and adding all the frames of the 
animation sequence. I have a sequence of frames at 25 fps and the sequence 
is around 5 seconds long. When I loaded all the frames (around 125) into 
AnimationDrawable, I get out of memory error.
2) I next tried using the ValueAnimator and setting it to animate over 
integer values equal to the number of frames that I have. I put all the 
resource ids for the frames in an array and refer to them from inside the 
ValueAnimator.AnimationUpdateListener. I set the animation for run 
infinitely. The problem here is that I clearly see a lot of frames being 
skipped. I have other UI components on my application which also utilise a 
lot of UI thread (for instance, plotting of pitch in real time).

Reading about this, I now have these options to go ahead:

1) Instead of animating frames, I just put a video for the given animation 
on a transparent background (no sure how easy is it to have a transparent 
background).
2) I use SurfaceView for animating the sequence of frames. (e.g. 
http://gamecodeschool.com/android/coding-android-sprite-sheet-animations/)
3) I dive into OpenGL and learn how to use it (would it be an overkill)?

Let me know what do you guys think about this. Meanwhile, I will quickly 
try to look into all these methods.

Regards.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6723fda7-c69d-41d5-8d8b-c5772101d3c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] How to synchronise frame animation with a clock/metronome in Android?

2016-08-31 Thread Swapnil Gupta
I have added this specific question on stackoverflow. Please throw some 
light on this :)

http://stackoverflow.com/q/39253884/2606411?sem=2


Regards.

Swapnil.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/2025e560-c38c-42b6-bbb7-a28f8218e69e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: echo cancellation

2016-08-17 Thread Swapnil Gupta
Hi Neha,

Did you find a solution to the feedback cancellation problem for android?

Thanks.
Swapnil.

On Thursday, May 26, 2011 at 11:28:29 AM UTC+2, neha wrote:
>
> Is there any way to synchronize the capturing and playback of audio 
> data in Android? 
>
> I am using audioRecord/track to achieve this.But its producing echo. 
> Is there any way to cancel echo. 
> My code is- 
> { 
> isRecording=true; 
>
>   bufferSize = 
> AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_CONFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT);
>  
>
> audioRecord = new 
> AudioRecord(MediaRecorder.AudioSource.MIC, 
> 8000, 
> AudioFormat.CHANNEL_CONFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT, 
> bufferSize); 
>
> audioRecord.startRecording(); 
>
> int BUFFER_SIZE_IN_BYTES 
> =AudioTrack.getMinBufferSize(RECORDER_SAMPLERATE,AudioFormat.CHANNEL_CONFIGURATION_MONO,RECORDER_AUDIO_ENCODING);
>  
>
> AudioTrack audioTrack = new 
> AudioTrack(AudioManager.STREAM_SYSTEM, 
>
>  
> 8000,AudioFormat.CHANNEL_CONFIGURATION_MONO, 
>
>
>  AudioFormat.ENCODING_PCM_16BIT, 
> BUFFER_SIZE_IN_BYTES, 
>
>  AudioTrack.MODE_STREAM); 
> byte[] buffer=new byte[400]; 
> audioTrack.play(); 
> while (isRecording) { int bytesRead = 
> audioRecord.read(buffer, 
> 0, 
> 400); 
> int bytesWritten = 
> audioTrack.write(buffer, 0, 400); 
>
> }

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/a000cfbe-a512-4f12-848e-8247c5751281%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] TextureView canvas drawing problems

2015-12-29 Thread Swapnil Gupta
I am trying to write a real time pitch visualization using TextureView. The 
flow of the code I have implemented seems to be okay but I am unable to see 
the pitch contour I am trying to plot.

So, I have created a custom view as ...

public class PitchSurfaceView extends TextureView implements 
TextureView.SurfaceTextureListener { ...}

In the constructor of the view I have set the listener ...

public PitchSurfaceView(Context context, AttributeSet attrs) {
  ...

setOpaque(false); 
setSurfaceTextureListener(this);
}

Inside my onSurfaceTextureAvailable(), I am doing the following
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int 
width, int height) {
Log.i(TAG, "Width of the texture view: " + width);
Log.i(TAG, "Height of the texture view: " + height);

// creating the bitmaps to draw them 
if (!isBitmapsCreated) {
Log.i(TAG, "Drawing bitmaps for the first time.");
createBitmaps();
drawMyBitmaps();
isBitmapsCreated = true;
}
   * drawOnView();*
}

The important method here is drawOnView which actually uses the canvas to 
draw on the View bitmap. As for other methods above, I have already tested 
them using a custom View by just extending the View class. They work fine 
there. Here is my implementation of drawOnView()

protected void drawOnView() {
if(null == mPitchContourGT) {
Log.e(TAG, "mPitchContourGT is null", new 
NullPointerException());
return;
}

final Canvas canvas = lockCanvas();

try {
// clearing the canvas ...
Log.d("drawOnView", "Before!!");
canvas.drawColor(0x, PorterDuff.Mode.CLEAR);
// Drawing the front padding ...
canvas.drawBitmap(mBitmaps[0], 0, 0, mPainter);
int pos = mBitmaps[0].getWidth();

for (int i = 0; i < (mBitmaps.length - 1) * mNumberLoops; i++) {
// mBitmaps.length - 1 because we have an extra bitmap at 
the beginning ..
final int index = i % (mBitmaps.length - 1) + 1;
canvas.drawBitmap(mBitmaps[index], pos, 0, mPainter);
pos += mBitmaps[index].getWidth();
}
} finally {
unlockCanvasAndPost(canvas);
}
Log.d("drawOnView", "After!!");
}

Here I am first getting lock at the canvas and drawing my earlier created 
bitmaps on the canvas. I see the debug logs that I have put but I cannot 
see the brawn bitmaps on my view. Anything wrong that I am doing?


On Tuesday, October 16, 2012 at 5:31:33 PM UTC+2, Conrad Chapman wrote:
>
> I looked at this more and Romain Guy unsurprisingly got it 100% right.
> My code pasted here is wrong.
> DO NOT add 
> setWillNotDraw(true); in the TextureView and
>  mSurface.updateTexImage(); in the drawing thread.
> They will mess it up!
>
>
> On Thursday, 4 October 2012 17:17:33 UTC+2, Conrad Chapman wrote:
>>
>> Thank you so much Romain for your reply and example. I might be the only 
>> real canvas textureview example on the net. It worked but not quite as you 
>> said. It might be something to do with my class structure as this part of 
>> the program does not have internal classes..
>> I will explain and show a little. Maybe my approach is bad or wrong I 
>> don't know.
>> CLASSES
>> Main Activity
>> spawns
>> - CustomTextureView class extending TextureView
>>   -this spawns the worker thread (it does not extend thread 
>> but just a worker class)
>>
>> the TextureView constructor
>>
>> public CustomTextureView (Context context, AttributeSet attrs) {
>> super(context, attrs);
>> mContext = context;
>> setWillNotDraw(true);
>> setFocusableInTouchMode(true);
>> setFocusable(true);
>> setSurfaceTextureListener(this);
>>
>> }
>> and the listener callback within this class
>> @Override
>> public void onSurfaceTextureAvailable(SurfaceTexture surface, int width,
>> int height) {
>> // TODO Auto-generated method stub
>> isRunning = true;
>> mSurface = surface;
>> mChart.setTextureSurface(surface);//mChart is the worker class/thread
>> mChart.setSurfaceSize(width, height);
>> mChart.Redraw(true);//this does all the canvas drawing on a bitmap for 
>> buffering.
>> invalidate();//this is essential to make it display on 1st run..why?
>> }
>>
>> The worker class spawned from the CustomTextureView and the critical void
>> protected void RenderCanvas(){
>> final Canvas canvas = CustomTextureView .lockCanvas(null);
>> try {
>>canvas.drawBitmap(buffBitmap, 0, 0, null);
>> } finally {
>> CustomTextureView .unlockCanvasAndPost(canvas);
>> mSurface.updateTexImage();
>> }
>> }
>>
>> So I do not work from the main activity and don't understand why I need 
>> to call invalidate() in onSurfaceTextureAvailable for the 1st run to 
>> display properly.
>>
>> Romain Guy you said NOT to call updateTexImage