Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
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 1416 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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (35 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!