Zwei Sounds zusammen fügen + gleichzeitig abspielen

  • Antworten:2
Dark Blood Studios
  • Forum-Beiträge: 203

20.12.2011, 16:47:29 via Website

Hi, kann man irgendwie zwei Sounds z.B. ogg zu einem zusammenfügen? Also ich will sie nicht hintereinnander machen sonder gleichzeitig.
Und wie kann ich mehrere Sounds gleichzeitig abspielen? Mit Soundpool hört sich dass irgendwie seltsam an. Hier mal mein Code wie ich es bis jetzt versucht habe:

1private float volume;
2private SoundPool soundPool;
3private HashMap<Integer, Integer> soundPoolMap;
4private Thread thread = new Thread(this);
5
6public init() {
7 Context context = getApplicationContext();
8
9 soundPool = new SoundPool(200, AudioManager.STREAM_MUSIC, 100);
10 soundPoolMap = new HashMap<Integer, Integer>();
11 soundPoolMap.put(1, soundPool.load(context, R.raw.sound_1, 100));
12 soundPoolMap.put(2, soundPool.load(context, R.raw.sound_2, 100));
13 soundPoolMap.put(3, soundPool.load(context, R.raw.sound_3, 100));
14 soundPoolMap.put(4, soundPool.load(context, R.raw.sound_4, 100));
15 soundPoolMap.put(5, soundPool.load(context, R.raw.sound_5, 100));
16 soundPoolMap.put(6, soundPool.load(context, R.raw.sound_6, 100));
17 soundPoolMap.put(7, soundPool.load(context, R.raw.sound_7, 100));
18 soundPoolMap.put(8, soundPool.load(context, R.raw.sound_8, 100));
19 soundPoolMap.put(9, soundPool.load(context, R.raw.sound_9, 100));
20 soundPoolMap.put(10, soundPool.load(context, R.raw.sound_10, 100));
21 soundPoolMap.put(11, soundPool.load(context, R.raw.sound_11, 100));
22
23 AudioManager mgr = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
24 float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
25 float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
26 volume = streamVolumeCurrent / streamVolumeMax;
27
28 thread.start();
29}
30
31public void run() {
32 soundPool.play(soundPoolMap.get(1), volume, volume, 1, 0, 1f);
33 soundPool.play(soundPoolMap.get(2), volume, volume, 1, 0, 1f);
34 soundPool.play(soundPoolMap.get(3), volume, volume, 1, 0, 1f);
35 soundPool.play(soundPoolMap.get(4), volume, volume, 1, 0, 1f);
36}

Antworten
Dark Blood Studios
  • Forum-Beiträge: 203

12.02.2012, 22:41:21 via Website

Hat in zwischenzeit jemand eine Idee?

Antworten
Dr Danger
  • Forum-Beiträge: 3

13.02.2012, 08:38:24 via Website

Also Soundpool ist an sich schonmal die richtige Wahl, allerdings spielst du die sounds ja einfach nacheinander ab.
Wie man jetzt 2 Sounds gleichzeit startet weiss ich ehrlich gesagt auch nicht. Vielleicht kannst du pro sound einen Thread starten?

Antworten