我使用Audacity创建了许多声音片段,并将它们作为.OGG文件导出到声池中。一些较长的剪辑尽早停止。音箱中的每个片段都有设定的长度吗?这是我能扩展的吗?
这是我的SoundManager:
package com.androidbook.ufgsoundboard;
import java.util.HashMap;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
public class SoundManager {
private SoundPool mSoundPool;
private HashMap<Integer, Integer> mSoundPoolMap;
private AudioManager mAudioManager;
private Context mContext;
public static final int maxSounds = 1;
public SoundManager()
{
}
public void initSounds(Context theContext) {
mContext = theContext;
mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
mSoundPoolMap = new HashMap<Integer, Integer>();
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
}
public void addSound(int Index,int SoundID)
{
mSoundPoolMap.put(Index, mSoundPool.load(mContext, SoundID, 1));
}
public void playSound(int index) {
int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), streamVolume, streamVolume, 1, 0, 1f);
}
}
答案 0 :(得分:0)
我需要将Audacity中的原始声音片段保存为11025 HZ 16位OGG文件。这允许剪辑尽可能长。