private void PlaySound()
{
if (m_atAudioTrack != null) m_atAudioTrack.release();
m_atAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
m_iSampleRate, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, m_aGeneratedSnd.length,
AudioTrack.MODE_STREAM);
m_atAudioTrack.write(m_aGeneratedSnd, 0, m_aGeneratedSnd.length);
m_atAudioTrack.setStereoVolume( AudioTrack.getMaxVolume(),
AudioTrack.getMaxVolume());
m_atAudioTrack.play();
try
{
Thread.sleep(10000);
}
catch (Exception e)
{
e.printStackTrace();
}
// Track play done. Release track.
if (m_atAudioTrack != null) m_atAudioTrack.release();
}
放入Thread.sleep(10000)会将啁啾从半秒增加到一秒或两秒。 Thread.sleep(40000)只要Thread.sleep(10000)
就会发出唧唧声 无论有没有m_atAudioTrack.setStereoVolume(AudioTrack.getMaxVolume(),AudioTrack.getMaxVolume()),音量都很大;
m_iSampleRate = 6000;与m_iSampleRate = 48000具有相同的效果; 与m_iSampleRate = 4000略有不同;
将m_aGeneratedSnd增加到内存不足错误之前的一点,不会增加声音长度
第一个问题:如何增加声音长度? 第二个问题:如何增加音量?
提前感谢您的帮助。