Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  OpenAL question  (Read 741 times)
0 Members and 1 Guest are viewing this topic.
Offline Middy

Junior Member




Java games rock!


« Posted 2004-08-28 19:02:30 »

Hey I have some trouble with my selfmade soundmanager.

I hear an echo of a previous played sound after running a few other sounds. I have checked the Java side and that particular sound is not being played when I hear it. So I am thinking its some buffer I havent cleared, or I am removing the sound in a wrong way. I have included som of  the code, since othervise the post became too long. The poll method handles starting and stopping sounds


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
      
     
      public void poll(float dt) {
           
                 
            System.out.println(_sourcesBeingPlayed.size());
            //remove sounds that are done
           Iterator I = _sourcesBeingPlayed.listIterator();
            while(I.hasNext()){
                  SoundSource ss = (SoundSource)I.next();
                 
                  //update play time for all sounds playing
                 ss._s._timeBeingPlayed+=dt;
                 
                  //Update velocity and position
                 updateSourcePosition(ss);
                  updateSourceVelocity(ss);
                 
                  if(_debug)
                        System.out.println("checking if sound with source idx "+ss._soundBufferidx+" is done" );
                  //is sound still playing?, if not KILL it
                 if(!(AL10.alGetSourcei(_soundSources.get(ss._soundBufferidx), AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING)){
                        if(_debug)
                              System.out.println("Releasing Source"+ss._soundBufferidx );      
                        //add source back to pool
                       _sourcePool.add(ss);
                       
                        //set sound to not playing
                       ss._s._playing=false;
                        //remove reference
                       ss._s=null;
                        _soundSources.position(ss._soundBufferidx);
                          AL10.alDeleteSources(_soundSources);
                        //kill sound
                       I.remove();
                  }
            }
           
     
           
      //Update listener
   createListener(_soundListener);
           
      //Are there new sounds added? Simple FIFO que
   
      if(_soundQue.size()>0 && _sourcePool.size()>0){
                        boolean done=false;
                       
                        while(!done){
                              //sound Que is empty
                             if(_soundQue.size()==0)
                                    done=true;
                             
                              if(_sourcePool.size()>0 && !done){
                                    if(_debug){
                                          System.out.println("There are "+_sourcePool.size()+" sources left" );
                                          System.out.println("There are "+_soundQue.size()+" sounds in QUE " );
                                    }
                                    Sound s = (Sound)_soundQue.get(0);
                                   
                                    if(_debug)
                                          System.out.println("working with sound " +s);
                                   
                                    SoundSource ss =(SoundSource) _sourcePool.get(0);
                                   
                                    int sourceBufidx = ss.get_soundBufferidx();
                                   
                                    //assign sound to source
                                   ss.assignSound(s);
                                   
                                    //create a new sound buffer
                                   createNewBuffer(ss,sourceBufidx);

                                    //Start playing source
                                   AL10.alSourcePlay(_soundSources.get(sourceBufidx));
                             
                                    //add source to sources being played
                                   _sourcesBeingPlayed.add(ss);
                                   
                                   
                                    //set sound to playing
                                   ss._s._playing=true;
                                   
                                    _soundQue.remove(0);
                                    _sourcePool.remove(0);
                                    if(_debug){
                                          System.out.println("There are now "+_sourcePool.size()+" sources left" );
                                          System.out.println("There are "+_sourcesBeingPlayed.size()+" sounds being played " );
                                          printSoundsBeingPlayed();
                                    }
                                   
                              }else{ //no more sources
                                   done=true;
                                   
                              }
                             
                              //if there are sounds left to be played update their delay times
                             for(int i=0;i<_soundQue.size();i++){
                                    Sound s = (Sound)_soundQue.get(i);
                                    s._timeDelayed +=dt;
                              }
                       

                                   
                  }
     
            }
           
      }
           
      public void printSoundsBeingPlayed(){
           
            //if there are sounds left to be played update their delay times
           for(int i=0;i<_sourcesBeingPlayed.size();i++){
                  SoundSource s = (SoundSource)_sourcesBeingPlayed.get(i);
           
            }
      }

      /**
       * @param sound
       */

      public void stopSound(Sound sound) {


            Iterator I = _sourcesBeingPlayed.listIterator();
            while(I.hasNext()){
                  SoundSource ss = (SoundSource)I.next();
                        if(ss._s==sound){            
                              AL10.alSourceStop(_soundSources.get(ss._soundBufferidx));
                              ss._s=null;      
                              _sourcePool.add(ss);
                              I.remove();
                  }
            }
           
           
      }
}

When do I get my makeMyGameAsILike() extension?
Offline aNt

Senior Member




AFK


« Reply #1 - Posted 2004-08-31 15:33:25 »

sod it use FMOD- it kicks ass! the 3d is second to none
Offline Middy

Junior Member




Java games rock!


« Reply #2 - Posted 2004-08-31 15:34:37 »

I have no problem with that, when its released by the LWJGL guys I might do that

When do I get my makeMyGameAsILike() extension?
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.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!