黑莓录音示例代码

Sam*_*Sam 3 audio blackberry mmapi java-me

有没有人知道一个好的存储库来获取BlackBerry的示例代码?具体来说,这些样本将帮助我学习录制音频的机制,甚至可能对其进行采样并对其进行一些动态信号处理?

我想读取传入的音频,如果需要的话,逐个样本,然后处理它以产生所需的结果,在这种情况下是可视化器.

Mak*_*tar 11

RIM API包含用于处理音频和视频内容的JSR 135 Java Mobile Media API.
你纠正了BB知识库中的混乱.唯一的方法是浏览它,希望他们不会再次更改站点地图.
它是开发人员 - >资源 - > 知识库 - > Java API和样本 - > 音频和视频

录音

基本上录制音频很简单:

  • 使用正确的音频编码创建播放器
  • 获取RecordControl
  • 开始录音
  • 停止录音

链接:
RIM 4.6.0 API参考:包javax.microedition.media
如何 - 在BlackBerry智能手机上录制音频
如何 - 在应用程序中播放音频
如何 - 支持流式音频到媒体应用程序
如何 - 指定音频路​​径路由
如何收件人 - 从媒体应用程序获取媒体播放时间内容是
什么 - 支持的音频格式
什么是 - 媒体应用程序错误代码

录音样本

声明了与Player,RecordControl和资源的线程:

final class VoiceNotesRecorderThread extends Thread{
   private Player _player;
   private RecordControl _rcontrol;
   private ByteArrayOutputStream _output;
   private byte _data[];

   VoiceNotesRecorderThread() {}

   private int getSize(){
       return (_output != null ? _output.size() : 0);
   }

   private byte[] getVoiceNote(){
      return _data;
   }
}
Run Code Online (Sandbox Code Playgroud)

在Thread.run()上开始录音:

   public void run() {
      try {
          // Create a Player that captures live audio.
          _player = Manager.createPlayer("capture://audio");
          _player.realize();    
          // Get the RecordControl, set the record stream,
          _rcontrol = (RecordControl)_player.getControl("RecordControl");    
          //Create a ByteArrayOutputStream to capture the audio stream.
          _output = new ByteArrayOutputStream();
          _rcontrol.setRecordStream(_output);
          _rcontrol.startRecord();
          _player.start();    
      } catch (final Exception e) {
         UiApplication.getUiApplication().invokeAndWait(new Runnable() {
            public void run() {
               Dialog.inform(e.toString());
            }
         });
      }
   }
Run Code Online (Sandbox Code Playgroud)

并且在thread.stop()上停止录制:

   public void stop() {
      try {
           //Stop recording, capture data from the OutputStream,
           //close the OutputStream and player.
           _rcontrol.commit();
           _data = _output.toByteArray();
           _output.close();
           _player.close();    
      } catch (Exception e) {
         synchronized (UiApplication.getEventLock()) {
            Dialog.inform(e.toString());
         }
      }
   }
Run Code Online (Sandbox Code Playgroud)

处理和采样音频流

在录制结束时,您将使用特定音频格式的数据填充输出流.因此,要处理或采样它,您必须解码此音频流.

谈论飞行处理,这将更复杂.您必须在录制期间读取输出流而不记录提交.因此需要解决几个问题:

  • 同步访问记录器和采样器的输出流 - 线程问题
  • 读取正确数量的音频数据 - 深入了解音频格式解码以找出标记规则

也可能有用:
java.net:Vikram Goyal在Java ME中的流内容实验