Can I get raw PCM data from MediaPlayer or SoundPool?

前端 未结 3 884
星月不相逢
星月不相逢 2021-01-13 14:20

i use eclipse with android sdk 4.0.3 api lvl 15 to create a basic music player application.

I read and found that there are two main classes to play sounds. MediaPla

3条回答
  •  一生所求
    2021-01-13 14:43

    Hey have a look at AudioTrack for reading in bytes. You can manipulate the byte array of sound before you actually play it back. http://developer.android.com/reference/android/media/AudioTrack.html

    Audiotrack is definately more easy to control, since you get access to do the raw data, but you gotta do the work yourself, instead of just loading the class (MediaPlayer) with an asset file.

    Also look at this example for reading assets into a byte array http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/content/ReadAsset.html

    I'm not sure if you can use the byte arrays for drawing a graph?

    Hope this helps you ;-) The audiopart of Android really isn't that well-documented I'm afraid and hasn't been since day one ;\

提交回复
热议问题