2011-07-31 52 views
1

我使用Audacity創建了多個聲音剪輯,並將它們作爲.OGG文件導出到soundpool中。儘管如此,一些較長的剪輯會盡早停止。 Soundpool中每個剪輯的設置長度是多少?這是我可以延伸的東西嗎?Android延長聲音剪輯

這裏是我的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

我需要在Audacity中保存我原來的聲音片段爲11025 HZ 16位的OGG文件。這允許剪輯只要我想要的時間。