Stereo audio playback in android

Related topics on this subject include only mono reproduction, where the left and right frequencies are the same.

My question is: how to generate a stereo tone so that the left channel has a different frequency than the right channel?

I thought about pre-writing .wav files, but writing a lot of .wav files and putting them in the res folder is not a good idea.

I come across classes SoundPooland AudioTrack, but I need a fragment showing the different frequencies of the left and right channels stored as a buffer before playing the tone.

Or are there other ways? Indicate the desired fragment.

+5
source share
4 answers

:


  • //playback rate (1.0 = normal playback, range 0.5 to 2.0)
    float lFrequency = 1.0;
    float rFrequency = 1.0;

  • SoundPool
    SoundPool sp = SoundPool(2, AudioManager.STREAM_MUSIC, 0);

  • ( )
    int sLeft = sp.load(mContext, R.raw.yourAudioFileId, 1);
    int sRight = sp.load(mContext, R.raw.yourAudioFileId, 1);

  • 2 ( ) ( )
    sp.play (sLeft, 1.0, 0.0, 0, 0, lFrequency);
    sp.play (sRight, 0.0, 1.0, 0, 0, rFrequency);

+4

, SoundPool, - . : " SoundPool MediaPlayer 16- PCM" , , , Stereo , .

+3

WAV WAV- , WAV , SoundPool, AudioTrack ( ).

() 2- . , ( [0] L, [1] R, [2] L ..). , , , ( CD, 88200 ), , AudioTrack .

WAV SoundPool ( ). WAV ( ): 44- , .

, , , .

, WAV java:

http://computermusicblog.com/blog/2008/08/29/reading-and-writing-wav-files-in-java

+1

.ogg( WAV , ), , Android. , , . , . , . . tone.ogg. Tone

0

All Articles