Author Topic: [java] Mix stereo to mono  (Read 2931 times)

Offline ziliss

  • bit
  • Posts: 2
    • View Profile
[java] Mix stereo to mono
« on: April 06, 2012, 07:27:51 PM »
Hello,

I have a question related to your 3D Sound System.
How can I mix the 2 channels of a stereo sound, to get a mono sound ?

I ask this question because stereo sounds don't work well in the 3D sound system. Only the volume of the sound is modified, there is no spatialization for stereo sounds. But I want the sound to be played stereo in some cases (when the player is making the sound), and in mono in others (when other players are making the sounds).

I don't want to provide 2 files for every sound: 1 mono and 1 stereo, because it would almost double the bandwidth and download size.

If there is a way to mix the 2 channels in the sound system, it would be the easiest way. I looked at your javadoc, but I didn't find anything.

I could also generate the mono on the client. I don't know if there is a function to do that in the default java packages.

I am new to sound in java, so if I could just have a hint or a link to start my researches, it would be very helpful.

ziliss

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: [java] Mix stereo to mono
« Reply #1 on: April 07, 2012, 07:26:19 AM »
I'm not sure, but I'll do a little research to see if Java has a good way to do this.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline ziliss

  • bit
  • Posts: 2
    • View Profile
Re: [java] Mix stereo to mono
« Reply #2 on: April 09, 2012, 07:20:22 AM »
Ok, thanks for the reply.

I am digging in the java sound system and architecture when I have some spare time. If I find an easy way, I will try to post something here. Might be useful to others.

I had another idea: create 2 sources, one for right, one for left, and play them at the same location. It would require twice as much channels, and make the number of needed channels less predicatable.