Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  javax.sound.sampled API - Real - Time Panning  (Read 1594 times)
0 Members and 1 Guest are viewing this topic.
Offline snk_kid

Senior Newbie

Java games rock!

« Posted 2003-11-13 06:44:02 »

Hi i'm trying to map a mono sound of a character to stero by panning. I have a class that filters a stream of bytes, i can get the sample of the mono sound but i'm having problems in creating the stereo samples. Its hard for me to explain so ill paste some code here its from the class Soundfilter.
This is the method i use to get the sample from bytes and works fine.

public static short getSample(byte[] buffer, int position) {
       return (short)(
           ((buffer[position+1] & 0xff) << Cool |
           (buffer[position] & 0xff));

But if i want to put it back with a new left and right sample in new byte array of samples i have this method:

public static void setSample(byte[] buffer, int pos, short leftSample, short rightSample) {

  buffer[pos]= (byte)(leftSample & 0xff);
  buffer[pos + 1]      = (byte)((leftSample >> Cool & 0xff);
  buffer[pos + 2] = (byte)(rightSample & 0xff);
  buffer[pos + 3]      = (byte)((rightSample >> Cool & 0xff);

Is the left and right sample in the correct position?  In a 16bit sample of stereo sound does the first 2 bytes represent left sample and the next 2 bytes represent right sample?
Offline swpalmer

JGO Coder

Exp: 12 years

Where's the Kaboom?

« Reply #1 - Posted 2003-11-13 12:17:44 »

I'm not that familiar with java sound APIs, but can't you just do this by controlling the mixer instead of manipulating the audio sample data directly?

Offline snk_kid

Senior Newbie

Java games rock!

« Reply #2 - Posted 2003-11-13 14:25:37 »

The Control classes are not good at it in real time, it produces alot of hishes and clicks because its not gradually changing the samples overtime. I would use joal and jogl for my project but the requirements of my project are to get the game running on my uni's computers which 1) i doubt OpenAL will be installed on them and i wont be allowed to do it myself. 2) i did some tests and jogl doesn't display correctly. So i'm pretty much stuck with using almost pure java libs which isn't 2 bad not doing some mad 3D game here lol.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder

Exp: 12 years

Where's the Kaboom?

« Reply #3 - Posted 2003-11-15 01:02:08 »

Can you get around it by doing the gradual changes with your java code? Set a target for the value and move toward it in steps each frame.  Adjust the max step size to avoid pops.

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Coldstream24 (16 views)
2015-09-03 00:41:28

Andrew_3ds (26 views)
2015-09-01 19:08:10

afikri (17 views)
2015-08-31 09:30:22

afikri (25 views)
2015-08-31 09:30:07

afikri (13 views)
2015-08-31 09:27:24

afikri (16 views)
2015-08-31 09:26:40

Roquen (30 views)
2015-08-29 11:30:54

GamerC4 (36 views)
2015-08-22 20:38:50

GamerC4 (33 views)
2015-08-22 20:37:18

GamerC4 (40 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!