K歌引擎机型问题简述(坑爹啊!!!)

底层使用ffmpeg + lamemp3 使之能编码mp3.

1.当机器有点卡,导致播放的伴奏会卡。好了,这下就完蛋了,后面所有的都不同步了。

buffer调大就好了。

2.同时播放伴奏和录音,然后合成编码,发现不同步,录音偏慢。因为播放线程即audioTrack有个buffer,如果比较大的话,导致delay很明显。因为人是听到音乐然后开始跟着唱的,呵呵。

这时要让record线程休眠一段时间,这个时间就是填满player的buffer的时间。

3.绝大部分声音和伴奏同步,偶尔不同步,录音偏快,而且有延迟越来越大的趋势。这个是因为机器有点卡,或忙于做别的事情,这时record的buffer满了,而我们还没有来及取,就导致部分数据丢失,所以就导致人声越来越快。

record的buffer调大,整个线程优先级调高,呵呵。

4.moto me86等使用 tegra 2 的系列处理器点击会crash。

我操,这个超级坑爹!因为tegra2系统处理器虽然是arme-v7但是却不支持neon浮点运算库(这个是一个非常重要的可选项,绝大部分都支持)。。。尼玛。。。目前没有好的办法。。。只能单独为他发包了。。。

坑爹的 AudioRecorder 的 setPositionMarker

from stackOverFlow

太坑了。。。

My Android Java Application needs to record audio data into the RAM and process it. This is why I use the class “AudioRecord” and not the “MediaRecorder” (records only to file).

Till now, I used a busy loop polling with “read()” for the audio data. this has been working so far, but it peggs the CPU too much. Between two polls, I put the thread to sleep to avoid 100% CPU usage. However, this is not really a clean solution, since the time of the sleep is not guaranteed and you must subtract a security time in order not to loose audio snippets. This is not CPU optimal. I need as many free CPU cycles as possible for a parallel running thread.

Now I implemented the recording using the “OnRecordPositionUpdateListener”. This looks very promising and the right way to do it according the SDK Docs. Everything seems to work (opening the audio device, read()ing the data etc.) but the Listner is never called.

Does anybody know why?

Info: I am working with a real Device, not under the Emulator. The Recording using a Busy Loop basically works (however not satifiying). Only the Callback Listener is never called.

Here is a snippet from my Sourcecode:

 

public class myApplication extends Activity {

  /* audio recording */
  private static final int AUDIO_SAMPLE_FREQ = 16000;
  private static final int AUDIO_BUFFER_BYTESIZE = AUDIO_SAMPLE_FREQ * 2 * 3; // = 3000ms
  private static final int AUDIO_BUFFER_SAMPLEREAD_SIZE = AUDIO_SAMPLE_FREQ  / 10 * 2; // = 200ms

  private short[] mAudioBuffer = null; // audio buffer
  private int mSamplesRead; // how many samples are recently read
  private AudioRecord mAudioRecorder; // Audio Recorder

  ...

  private OnRecordPositionUpdateListener mRecordListener = new OnRecordPositionUpdateListener() {

    public void onPeriodicNotification(AudioRecord recorder) {
      mSamplesRead = recorder.read(mAudioBuffer, 0, AUDIO_BUFFER_SAMPLEREAD_SIZE);
      if (mSamplesRead > 0) {

        // do something here...

      }
    }

    public void onMarkerReached(AudioRecord recorder) {
      Error("What? Hu!? Where am I?");
    }
  };

  ...

  public void onCreate(Bundle savedInstanceState) {

  try {
      mAudioRecorder = new AudioRecord(
          android.media.MediaRecorder.AudioSource.MIC,
          AUDIO_SAMPLE_FREQ,
          AudioFormat.CHANNEL_CONFIGURATION_MONO,
          AudioFormat.ENCODING_PCM_16BIT,
          AUDIO_BUFFER_BYTESIZE);
    } catch (Exception e) {
      Error("Unable to init audio recording!");
    }

    mAudioBuffer = new short[AUDIO_BUFFER_SAMPLEREAD_SIZE];
    mAudioRecorder.setPositionNotificationPeriod(AUDIO_BUFFER_SAMPLEREAD_SIZE);
    mAudioRecorder.setRecordPositionUpdateListener(mRecordListener);
    mAudioRecorder.startRecording();

    /* test if I can read anything at all... (and yes, this here works!) */
    mSamplesRead = mAudioRecorder.read(mAudioBuffer, 0, AUDIO_BUFFER_SAMPLEREAD_SIZE);

  }
}

Answer:

I believe the problem is that you still need to do the read loop. If you setup callbacks, they will fire when you’ve read the number of frames that you specify for the callbacks. But you still need to do the reads. I’ve tried this and the callbacks get called just fine. Setting up a marker causes a callback when that number of frames has been read since the start of recording. In other words, you could set the marker far into the future, after many of your reads, and it will fire then. You can set the period to some bigger number of frames and that callback will fire every time that number of frames has been read. I think they do this so you can do low-level processing of the raw data in a tight loop, then every so often your callback can do summary-level processing. You could use the marker to make it easier to decide when to stop recording (instead of counting in the read loop).

 

 

终于为开源做了点贡献

http://code.google.com/p/drum-practice/

用scala写了个android小游戏,练习架子鼓的,希望能对大家有些帮助。总算了了一桩心劫。呵呵。虽然没多少人会看到,但总归是做了,问心无愧了。呵呵。

Android 截取圆形图片核心代码

好用,呵呵(http://www.eoeandroid.com/thread-103093-1-1.html)

 

int targetWidth = 100;
int targetHeight = 100;
Bitmap targetBitmap = Bitmap.createBitmap(
targetWidth,
targetHeight,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addCircle(
((float)targetWidth - 1) / 2,
((float)targetHeight - 1) / 2,
(Math.min(((float)targetWidth), ((float)targetHeight)) / 2),
Path.Direction.CCW);
canvas.clipPath(path);
Bitmap sourceBitmap = BitmapFactory.decodeResource(
getResources(),
R.drawable.my_image);
canvas.drawBitmap(
sourceBitmap,
new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight()),
new Rect(0, 0, targetWidth, targetHeight),
null);
ImageView imageView = (ImageView)findViewById(R.id.my_image_view);
imageView.setImageBitmap(targetBitmap);

 

 

vpn销售 架构

首页

帐号 注册登陆 

冲值,在线支付

后台,查看支付信息,已卖出vpn信息

vpn流量控制

vpn带宽限制

充值后自动生成帐号并启用程式。

 

恩,目前就这些,呵呵

scala with android!!! 终于成功了!!!我fuck!!!

 

相当的激动,哈哈,能用scala开发android了!!!哈哈。搞了两天啊!!!尼码。。。都怪android,每次tools更新ant都要改动,导致网上的2010年和2011年的文章都不能用。。。我fuck。。。还好找到一篇最近的。就是用最新的android tools作的! scala还是相当给力的!哈哈

原文在这里:

http://ricky.ez2.us/2012/04/25/%E4%BD%BF%E7%94%A8-scala-%E9%96%8B%E7%99%BC-android-%E7%9A%84%E7%92%B0%E5%A2%83%E5%BB%BA%E6%A7%8B/

非常给力!

 

自己做了一个更简单的,可以看俺的,原理跟上面一样,如下:

先在eclipse中新建android项目,加入scala的nature,然后下载这个文件,把文件夹afei_ant_android_scala中的所有东西解压到project根目录中,修改local.property文件,然后 ant debug 就行了!!!编译完的文件放在bin里头,给力!!!

 

 

android下多点触摸

一开始搞的想死,相当的莫名其妙,搞清楚了发现很强大,呵呵。

 

@Override
        public boolean onTouchEvent(MotionEvent event) {
            int action = event.getActionMasked();
            if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) {
                int i = event.getActionIndex();
                Point p = new Point((int) event.getX(i), (int) event.getY(i));
                for (int j = 0; j < mRect.length; j++) {
                    if (mRect[j].contains(p.x, p.y) ) {
                        click(j);
                    }
                }
            }

最关键的是这个MotionEvent  这个东西,半猜半试的。

每当有一个action时,都会触发一个event,这个时候拿 event.getAction() 时会是 他的code,为了区分是哪个pointer发生的这个event,会加上个mask 这里第一个手指按下,第二个手指点击时getAction = 261 就是0xff00 + 5,5是 action_pointer_down ,所有就要调用一个函数 event.getActionMasked() 得到这个action,然后判断这个action是不是我们想要的,如果是,就拿到event.getActionIndex(),然后根据此index去拿这个点的相关信息就可以了。

嘿嘿,搞定,收获还是很大的,哈哈

 

如何利用gae做自己的博客系统

 

见   http://www.watch-life.net/wordpress/wordpress-2-gae.html 和  http://www.xshagua.com/221.html#more-221

俺只做两点补充:遇到了两个问题,相当的恶心。

1.我是MAC系统,python针对mac有个工具,能点击按钮发布,发布时有个错误:urllib2.URLError: urlopen error [Errno 54]

以为是python没搞定,又下了最新的python包,不行,然后使用了vpn去翻墙。翻了墙就能deploy成功了!

然后我又断开,再deploy,发现还是成功的,我fuck。。。就不敢肯定是vpn的原因了。。。我FUCK。。。总之是连了VPN后就OK了。。。

 

2.打开http://afeihehe2234.appspot.com/ 说error,说 查看LOG,看LOG后发现是

NeedIndexError: The index for this query is not ready to serve. See the Datastore Indexes page in the Admin Console

一般是数据库的索引还没有生效,有人说用了四小时才生效,我边搞边试,10分钟后就能打开了。

 

 

只可惜,在天朝,需要翻墙,呵呵